tags:

views:

111

answers:

1

I'm currently debugging a project that uses an external library (LibFirm). When i call library functions, I can't really see what's going on there with gdb (i.e. I can't inspect local variables and such).

The library is open source and I compiled it myself, so I think it should be possible to let gdb look into it too. How?

What I am currently seeing is

(gdb) bt
#0  0x00994422 in __kernel_vsyscall ()
#1  0x002704d1 in *__GI_raise (sig=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0x00273932 in *__GI_abort () at abort.c:92
#3  0x00269648 in *__GI___assert_fail (
    assertion=0xd238f4 "_get_type_state(ctx.frame_tp) == layout_fixed", 
    file=0xd23458 "be/beabi.c", line=1879, function=0xd23d0d "modify_irg")
    at assert.c:81
#4  0x00b219e3 in ?? () from /usr/local/lib/libfirm.so.0
#5  0x00b21df0 in be_abi_introduce () from /usr/local/lib/libfirm.so.0
#6  0x00b59b77 in ?? () from /usr/local/lib/libfirm.so.0
#7  0x00b5b4a5 in be_main () from /usr/local/lib/libfirm.so.0
#8  0x0807daa0 in main (argc=3, argv=0xbffff914) at main.cc:243
(gdb) frame 8
#8  0x0807daa0 in main (argc=3, argv=0xbffff914) at main.cc:243
243                 be_main(output, "a.s");
(gdb) frame 4
#4  0x00b219e3 in ?? () from /usr/local/lib/libfirm.so.

frame 8 looks nice while frame 4 doesn't tell me anything. I added

dir /usr/local/include/libfirm
dir /home/thomas/Dev/foreign/libfirm

to my .gdbinit, so gdb should find header and source files of the lib.

A: 

I had to use ./configure --enable-debug (CFLAGS="-g" was on by default, but it may not be in other projects, so remind this one). Furthermore, you may want to use CFLAGS="-g -O0" (instead of only -g) to keep the code readable.

Larry_Croft