I have a list of breakpoints which I want to add each time I debug a particular program. I created a file that contain the breakpoints and used gdb -x "file" commend, but all the breakpoints that are pending on future shared library load wasn't added. Is there a way to fix this problem?
Asked
Active
Viewed 2,384 times
1 Answers
4
In your script set breakpoints in shared libraries as pending and when the shared libraries are loaded your breakpoints will be correctly set.
(gdb) help set breakpoint pending
Set debugger's 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 of a script (suppose print_in_lib
in in a shared library that will be loaded with dlopen
):
file main
set breakpoint pending on
b print_in_lib
r
And this is its output:
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)