[LLVMdev] problems with dwarf/gdb

Ken McMillan kenmcmil at yahoo.com
Mon Apr 13 23:00:25 PDT 2009

I'm having trouble debugging x86 code generated by LLVM.
GDB does work with the code, but not correctly, for example,
the "next" command does not skip over a function call.

Here's an example.

Source program gdb1.c:

int x;

void foo(){

void bar(){

int main(){
  return 0;


$ llvm-gcc -g -emit-llvm  -c gdb1.c -o gdb1.bc
$ llc gdb1.bc
$ gcc -m32 gdb1.s -o gdb1
$ gdb ./gdb1
GNU gdb Red Hat Linux (6.6-16.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) b main
Breakpoint 1 at 0x80483a0: file
/home/mcmillan/projects/impact2/test//gdb1.c, line 11.
(gdb) run
Starting program: /home/mcmillan/projects/impact2/test/gdb1 

Breakpoint 1, main () at /home/mcmillan/projects/impact2/test//gdb1.c:11
11	int main(){
(gdb) next
main () at /home/mcmillan/projects/impact2/test//gdb1.c:12
12	  foo();
foo () at /home/mcmillan/projects/impact2/test//gdb1.c:4
4	  x++;
5	}
main () at /home/mcmillan/projects/impact2/test//gdb1.c:13
13	  bar();
bar () at /home/mcmillan/projects/impact2/test//gdb1.c:8
8	  x--;
9	}

Notice the "next" causes gdb to step into "foo" instead of stepping
over it. 

Also, notice that I used -m32 on the gcc command line to assemble
the LLVM-generated source file. This seems to be needed, though
I don't know why LLVM would be generating 32-bit code on my
64-bit machine.

Versions: LLVM 2.5 (though got same result with 2.2), gcc 4.1.2,
gdb 6.6, running on x86 Linux (Fedora 7).

Has anyone had similar issues with gdb? Is debugging with gdb
known to work properly on other platforms?

Thanks for any help --

Ken McMillan

View this message in context: http://www.nabble.com/problems-with-dwarf-gdb-tp23033690p23033690.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.

More information about the llvm-dev mailing list