In my Linux system I'm writing a program that dynamically loads some .so libraries when running. It's like this: The executable program will search under a particular directory when it starts to run and then load all the .so files in that directory. Please note that the executable and the .so are built independently, and the build of the executable does NOT link to the .so files.
My problem is: After I run the program(thus all the .so libraries have been loaded) with GDB attached, I seem to be able to set a breakpoint on the code in the .so file(the GDB prompts me that this breakpoint is set in a shared library), but this breakpoint never actually breaks.
How should I make these breakpoints really work? During the debug session I have all the source code available at the right places, and the -g option is on. I also removed the -O2 optimization when compiling.
Check that debugging information was properly loaded for .so file. Look at the output of command (gdb) info sharedlibrary
. If your library appears with asterisk (*) symbol in loaded libraries table then debug symbols were not loaded and gdb unable to stop at breakpoints in this .so.
Perhaps your function is never called. Place a breakpoint at your shared library's entry point (a function that your main program fetches with dlsym
). I have just verified that my gdb
(7.1) does stop at such a breakpoint.
If you absolutely sure that your function is called (say, it produces some unique output that you can see) but the breakpoint you set on it is not fired, then it's a bug in gdb
and it should be reported to the gdb
maintainers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With