[LLVMdev] Connecting JITted code to gdb

Jeffrey Yasskin jyasskin at google.com
Thu Mar 26 23:35:37 PDT 2009


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?

Thanks,
Jeffrey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a_module.ll
Type: application/octet-stream
Size: 16971 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090327/34e782e3/attachment.obj>


More information about the llvm-dev mailing list