[LLVMdev] Connecting JITted code to gdb

Evan Cheng evan.cheng at apple.com
Fri Mar 27 13:48:27 PDT 2009


Run with -debug-only=jit.

Break on line 1148 of JITEmitter.cpp. The debugging message will tell  
you the address and size of the function that was jitted. You can then  
tell gdb to disassemble the code.

On Mar 26, 2009, at 11:35 PM, Jeffrey Yasskin wrote:

> Hi all. I'm working on the recently-announced unladen-swallow project,
> and I'm having a bit of trouble getting gdb to step into functions
> I've compiled with LLVM's JIT compiler. The attached a_module.ll is
> the module I produce from compiling
>
> def foo(r):
>  for i in r:
>    pass
>
> I'm JIT-compiling and running foo() with:
>
> 	typedef PyObject *(*NativeFunction)(PyFrameObject *);
> 	llvm::ExecutionEngine *engine = ...->getExecutionEngine();
> 	NativeFunction native =
> 		(NativeFunction)engine->getPointerToFunction(function);
> 	return native(frame);
>
> However, when I try to step into the call with gdb, I get:
>
> Breakpoint 1, eval_llvm_function (function_obj=0x142f6e0,
> frame=0x1350b98) at ../src/Python/ceval.cc:2549
> 2549			(NativeFunction)engine->getPointerToFunction(function);
> (gdb) n
> Current language:  auto; currently c++
> 2550		return native(frame);
> (gdb) p native
> $1 = (NativeFunction) 0x2080010
> (gdb) b *0x2080010
> Breakpoint 2 at 0x2080010
> (gdb) s
> Breakpoint 2, 0x02080010 in ?? ()
>
>
> If I don't set the second breakpoint, that last step totally skips the
> call. To see if I'm just emitting totally wrong debugging information,
> I compiled the module into a binary with a stub main, and gdb'ed into
> that. Trying to set a breakpoint on "foo" from there crashed Apple's
> gdb, which isn't ideal but at least indicates that something's
> happening with the dwarf information.
>
> Do I need to do anything extra to get the debug information the JIT
> produces hooked into gdb?


That isn't available. Currently the JIT does not produce dwarf  
information.

Evan

>
>
> Thanks,
> Jeffrey
> <a_module.ll>_______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list