NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Debugging with gdb under netbsd-6



Hello,

   I have had some trouble debugging shared libraries for a while. I
used to be able to step into shared objects during debug, but for some
reason I am no longer able to do so. When running the attached program
in gdb, I get this behavior:

---------------------------------------------
gauss$ gdb ./testprog
GNU gdb (GDB) 7.3.1
[---]
This GDB was configured as "x86_64--netbsd".
[---]
Reading symbols from /home/jan/tmp/dbgtest/testprog...done.
(gdb) break 9
Breakpoint 1 at 0x400a40: file testprog.c, line 9.
(gdb) run
Starting program: /home/jan/tmp/dbgtest/testprog

Breakpoint 1, main (argc=1, argv=0x7f7fffffdb68) at testprog.c:9
9               bar = foo(42, 72);
(gdb) step
11              printf("bar=%d\n", bar);
(gdb)
---------------------------------------------

   .. I would have expected to be able to step into foo() in the shared
library.

   And I used to be able to set breakpoints in functions in shared
libraries as well, but now I get:

---------------------------------------------
gauss$ gdb ./testprog
[---]
Reading symbols from /home/jan/tmp/dbgtest/testprog...done.
(gdb) break foo
Breakpoint 1 at 0x400790
(gdb) run
Starting program: /home/jan/tmp/dbgtest/testprog

Breakpoint 1, 0x0000000000400790 in foo@plt ()
---------------------------------------------

   Another thing I used to do, but which no longer works:

---------------------------------------------
gauss$ gdb ./testprog
[---]
Reading symbols from /home/jan/tmp/dbgtest/testprog...done.
(gdb) break testlib.c:8
No source file named testlib.c.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (testlib.c:8) pending.
(gdb) run
Starting program: /home/jan/tmp/dbgtest/testprog
bar=114
[Inferior 1 (process 3178) exited normally]
---------------------------------------------

   And when programs crash in shared libraries, the backtrace shows
nothing but "?? (??)".

   I'm almost afraid to ask, as I assume there's something brutally
obvious I'm missing..

-- 
Kind regards,
Jan Danielsson

all: testprog libtest.so

testprog: testprog.c testlib.h libtest.so
        $(CC) -g -o testprog testprog.c -Wl,-L,$(PWD),-rpath,$(PWD) -ltest

libtest.so: testlib.c testlib.h
        $(CC) -shared -g -o libtest.so -fPIC testlib.c

clean: .PHONY
        rm testprog libtest.so

int foo(int a, int b)
{
        int c;

        c = a + b;

        return c;
}
int foo(int a, int b);
#include <stdio.h>

#include "testlib.h"

int main(int argc, const char *argv[])
{
        int bar;

        bar = foo(42, 72);

        printf("bar=%d\n", bar);

        return 0;
}


Home | Main Index | Thread Index | Old Index