[LLVMdev] Why -jit-emit-debug doesn't work with gdb-7.1 ?

Reid Kleckner reid.kleckner at gmail.com
Mon Jun 21 11:14:49 PDT 2010


On Sat, Jun 19, 2010 at 8:53 PM, Yuri <yuri at rawbw.com> wrote:
> I have followed http://llvm.org/docs/DebuggingJITedCode.html, used the
> latest release gdb-7.1 (from March 18, 2010) and got this stack:
>
> (gdb) bt
> #0  0x35532156 in ?? ()
> #1  0x355320f8 in ?? ()
> #2  0x35532098 in ?? ()
> #3  0x3553202e in ?? ()
> #4  0x34a5661a in ?? ()
> #5  0x349d9bd9 in ?? ()
> #6  0x08052cd9 in main (argc=4, argv=0xbfbfe264, envp=0xbfbfe278) at
> /tmp/llvm-svn/llvm/tools/lli/lli.cpp:234
>
> Did they not include llvm interface into 7.1 release?

Yes, I have some version of 7.1 installed on my workstation and it works for me.

With this source file t.c:

#include <stdio.h>
#include <stdlib.h>
void baz() {
  printf("Hello, World!\n");
  abort();
}
void bar() {
  baz();
}
void foo() {
  bar();
}
int main(int argc, char **argv) {
  foo();
  return 0;
}

Compiled like so:

[rnk at tamalpais llvm]$ Debug/bin/clang -fexceptions t.c -c -emit-llvm -o t.bc

-fexceptions is important when compiling C code, because otherwise the
functions are annotated nounwind, which avoids generating .eh_frame
dwarf.  gdb uses the exception handling dwarf to unwind the stack.  So
long as your frontend doesn't add nounwind it's not a problem.

[rnk at tamalpais llvm]$ gdb --args Debug/bin/lli t.bc
GNU gdb (GDB) 7.1-gg5
...
Reading symbols from /home/rnk/llvm/Debug/bin/lli...done.
(gdb) run
Starting program: /home/rnk/llvm/Debug/bin/lli t.bc
warning: no loadable sections found in added symbol-file
/usr/lib/debug/lib/ld-2.7.so
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Hello, World!

Program received signal SIGABRT, Aborted.
0x00007ffff4e7d095 in raise () from /lib/libc.so.6
(gdb) bt
#0  0x00007ffff4e7d095 in raise () from /lib/libc.so.6
#1  0x00007ffff4e7eaf0 in abort () from /lib/libc.so.6
#2  0x00007ffff7f5e198 in baz ()
#3  0x00007ffff7f5e110 in bar ()
#4  0x00007ffff7f5e0a0 in foo ()
#5  0x00007ffff7f5e031 in main ()
#6  0x00007ffff6d79a89 in llvm::JIT::runFunction (this=0x647c10, F=0x643040,
    ArgValues=std::vector of length 2, capacity 2 = {...}) at JIT.cpp:439
#7  0x00007ffff6d03b1b in llvm::ExecutionEngine::runFunctionAsMain
(this=0x647c10, Fn=0x643040,
    argv=std::vector of length 1, capacity 1 = {...},
envp=0x7fffffffe520) at ExecutionEngine.cpp:423
#8  0x000000000040d42b in main (argc=2, argv=0x7fffffffe508,
envp=0x7fffffffe520) at lli.cpp:234
(gdb)

In a debug build, you shouldn't have to pass -jit-emit-debug, since
it's on by default.  I would have tested with a release build, but I
won't have one until ~15min from now.  :)

> On the side note: is option -disable-fp-elim also required for gdb? I am
> getting different stack depths in gdb with and without it.

No, it shouldn't be.


Are you giving your functions names?

Reid




More information about the llvm-dev mailing list