[LLVMdev] Connecting JITted code to gdb

Chris Lattner clattner at apple.com
Wed Apr 1 12:56:08 PDT 2009


On Mar 31, 2009, at 12:33 PM, Jeffrey Yasskin wrote:
> There appear to be two techniques in common use to debug
> dynamically-generated code despite this. First, as Evan suggests
> below, we can have the JIT print the address range that it's written a
> function into, have gdb disassemble that, set breakpoints at
> particular addresses, and print variables by knowing what register
> they live in. Second, as described at
> http://www.mono-project.com/Debugging#Debugging_with_GDB_in_XDEBUG_mode 
> ,
> we can write out a full object file with dwarf tables, and use
> add-symbol-file to get gdb to load that on demand.

Hi Jeffrey,

Adding support for this would be a great thing, and is somewhere on my  
long-term todo list (which is probably farther out than you'd like  
it ;-).

Note that the LLVM JIT does have hooks to build a runtime symbol table  
for generated code, see the ENABLE_JIT_SYMBOL_TABLE ifdef in  
JITEmitter.cpp.  This is used for performance tools that want to  
dynamically sample code that may or may not be generated by the JIT  
and need a way to attribute it back to the LLVM function name.  My  
intention is for the simple data structure that is built by this  
(which hangs off the public symbol "__jitSymbolTable") to eventually  
include a pointer to GDB data.  It would be really nice someday if GDB  
could walk this structure to find its debug symbols.

-Chris




More information about the llvm-dev mailing list