Gdb -x library breakpoint

I have a list of breakpoints that I want to add each time I debug a particular program. I created a file containing breakpoints and the gdb -x "file" used, but all breakpoints waiting to load the future shared library were not added. Is there any way to solve this problem?

0
source share
1 answer

In a script, set breakpoints in shared libraries as pending, and when shared libraries load, your breakpoints will be set correctly.

(gdb) help set breakpoint pending Set debugger behavior regarding pending breakpoints. If on, an unrecognized breakpoint location will cause gdb to create a pending breakpoint. If off, an unrecognized breakpoint location results in an error. If auto, an unrecognized breakpoint location results in a user-query to see if a pending breakpoint should be created. 

And this is an example script (suppose print_in_lib in in a shared library to be loaded using dlopen ):

 file main set breakpoint pending on b print_in_lib r 

And this is his conclusion:

 host: srv2-x64rh5-01, OS: Linux 2.6.18-238.el5>gdb -q Function "print_in_lib" not defined. Breakpoint 1 (print_in_lib) pending. warning: no loadable sections found in added symbol-file system-supplied DSO at 0x2aaaaaaab000 thousands: 1 print_debug: 0 Breakpoint 1, print_in_lib (print_debug=0) at my_lib.cpp:7 7 if (print_debug) { (gdb) bt #0 print_in_lib (print_debug=0) at my_lib.cpp:7 #1 0x00000000004008ab in main (argc=<value optimized out>, argv=<value optimized out>) at main.cpp:37 (gdb) 
+4
source

All Articles