Git Product home page Git Product logo

gallium.jl's Introduction

Gallium

Build Status

For now, the easiest way to use Gallium is through the examples/call.jl script.

julia> ARGS = ["1234"]
julia> include("call.jl")

This will add several REPL modes:

  • Global target julia mode (activated via \ ). Evaluate julia code at global scope in the inferior
  • Host C++ mode (activated via <). Evaluate C++ code in the host. Useful to interact with LLDB's C++ API
  • Target C++ mode (activated via >). Evaluate C++ code in the target
  • LLDB mode (activated via `). Run an lldb command

The LLDB command prompt supports all your usual debugger commands (b, bt, s, n, finish), as well as the following custom commands:

  • js - Step through julia code. Including stepping through indirect dispatch
  • jbt - Obtain a julia backtrace
  • jp - Run a julia expression, with current local variables in scope (to be integrated into the target julia REPL mode)
  • jobj - Retrieve a handle to the current frame's JIT object file

Debugging missing local variable and line number coverage

Local variable coverage can be missing at several level: julia, llvm or DWARF. To debug at the julia level, just use code_typed, etc. To debug at the llvm level, the following command sequence may be helpful:

julia> using DIDebug
julia> first(current_thread(Gallium.ctx(dbg))) |> Gallium.getASTForFrame
Target C++> $ans->functionObject
Target C++> GetBitcodeForFunction($ans)
julia> data = Gallium.retrieve(dbg,ans)
julia> DIDebug.parseBitcode(data)
C++> $ans->dump()

To debug at the DWARF, level the following may be helpful:

LLDB> jobj
julia> oh = ans
julia> collect(DWARF.DIETrees(ObjFileBase.debugsections(oh)))

Building Gallium

Gallium requires custom versions of julia, LLVM, Clang, LLDB and libuv. The easiest way to obtain these is to checkout the kf/gallium branch of julia, which will attempt to check out the correct branches and build everything from scratch. Note that this only works on a fresh install. If you already have a version of llvm-svn checked out you will manually needs to go in and check out the kf/gallium branch on from JuliaLang/{llvm, clang, lldb}. After the julia build succeeds, you may need to apply the following patch to Cxx.jl:

diff --git a/src/bootstrap.cpp b/src/bootstrap.cpp
index 01ff792..8dca780 100644
--- a/src/bootstrap.cpp
+++ b/src/bootstrap.cpp
@@ -846,8 +846,8 @@ DLLEXPORT void init_clang_instance(C, const char *Triple) {
     Cxx->CI->getLangOpts().Bool = 1;
     Cxx->CI->getLangOpts().WChar = 1;
     Cxx->CI->getLangOpts().C99 = 1;
-    Cxx->CI->getLangOpts().RTTI = 1;
-    Cxx->CI->getLangOpts().RTTIData = 1;
+    Cxx->CI->getLangOpts().RTTI = 0;
+    Cxx->CI->getLangOpts().RTTIData = 0;
     Cxx->CI->getLangOpts().ImplicitInt = 0;
     Cxx->CI->getLangOpts().PICLevel = 2;
     Cxx->CI->getLangOpts().Exceptions = 1;          // exception handling

Finally, you'll need to run the following series of commands at the julia prompt:

Pkg.clone("https://github.com/Keno/Cxx.jl.git")
Pkg.build("Cxx")
Pkg.add("Reactive")
Pkg.clone("[email protected]:Keno/JITTools.jl.git")
Pkg.clone("[email protected]:Keno/DIDebug.jl.git")
Pkg.clone("[email protected]:Keno/TerminalUI.jl.git")
Pkg.clone("[email protected]:Keno/Gallium.jl.git")
Pkg.clone("[email protected]:Keno/ObjFileBase.jl.git")
Pkg.clone("[email protected]:Keno/MachO.jl.git")
Pkg.clone("[email protected]:Keno/ELF.jl.git")
Pkg.clone("[email protected]:Keno/AbstractTrees.jl.git")
Pkg.clone("[email protected]:Keno/VT100.jl.git")

Common Troubles

  • unable to connect on Linux: Make sure ptrace protection is disabled. You can do this manually by running echo 0 > /proc/sys/kernel/yama/ptrace_scope

gallium.jl's People

Contributors

keno avatar

Watchers

Isaiah Norton avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.