0

Afternoon,everbody. I have an application 'test' compiled by main.c . A dynamic liabrary 'libtest.so' which is compiled by test.cpp with '-g'. In main.c I invoke the 'libtest.so' with 'dlopen' . And now I want to set a breakpoint in test.cpp ,but the gdb never hit it. I do as follow:

gdb ./test -d /home/lcl/test

break test.cpp:35

run

can anybody give me some tips ,thanks!

Wayne.liu
  • 141
  • 2
  • 9

1 Answers1

3

You should first verify that dlopen is actually succeeding (it's likely that it's not).

To do so:

  • set a breakpoint in main.c after dlopen.
  • confirm that returned handle is not NULL

At that point, GDB should have loaded symbols for libtest.so, and libtest.so should show up in info shared GDB output.

If everything looks good, info break should show an active breakpoint in test.cpp:35 at some address. If that breakpoint is never hit, it's likely that you never actually exercise that line of code.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362