问题
I added two breakpoints in functions of one shared library (.so) and ran gdb 7.4
and attached it to a process.
Gdb hit the breakpoint and I ran n
for several steps, and gdb reported the following errors(with bold text):
(gdb) b [function name]
Breakpoint 1 at 0xf1f28a49: file ../../../../../[file name].cpp, line 167.
Breakpoint 2 at 0xf1f2dae5: file ../../../../../[file name].cpp, line 60.
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.
(gdb) c
Continuing.
[New Thread 0xcaafab90 (LWP 28480)]
[Thread 0xcaafab90 (LWP 28480) exited]
[New Thread 0xcaafab90 (LWP 29558)]
[New Thread 0xc8cb6b90 (LWP 29980)]
[Switching to Thread 0xc8cb6b90 (LWP 29980)]
Breakpoint 2, [function name] (ostr=..., clientResponse=..., httpProtocol=..., >reqType=...) at ../../../../../[file name].cpp:60
60 ../../../../../[file name].cpp: No such file or directory.
in ../../../../../[file name].cpp
(gdb) ni
0xf1f2daed 60 in ../../../../../[file name].cpp
(gdb) n
Breakpoint 1, [function name] (ostr=..., clientResponse=..., httpProtocol=..., >closeConn=..., asynchResponse=..., reqType=...)
at ../../../../../[file name].cpp:167
167 in ../../../../../[file name].cpp
(gdb) n
Warning:
Cannot insert breakpoint 0.
Error accessing memory address 0x36cc6dde: Input/output error.
0xf7082771 in siglongjmp () from /lib/libc.so.6
(gdb)
This is the output from /proc/[PID]/maps
:
08048000-08146000 r-xp 00000000 08:03 293876
08146000-08150000 rw-p 000fe000 08:03 293876
08150000-099c8000 rw-p 08150000 00:00 0
[heap]
c21f9000-c21fa000 ---p c21f9000 00:00 0
c21fa000-c29fa000 rwxp c21fa000 00:00 0
c29fa000-c29fb000 ---p c29fa000 00:00 0
……
f1e1b000-f1e24000 rw-p f1e1b000 00:00 0
f1e24000-f2093000 r-xp 00000000 08:03 295549
.so
f2093000-f2094000 ---p 0026f000 08:03 295549
.so
f2094000-f2098000 r--p 0026f000 08:03 295549
.so
f2098000-f209c000 rw-p 00273000 08:03 295549
.so
f209c000-f209d000 rw-p f209c000 00:00 0
My questions are:
Gdb fails to insert internal breakpoint for
ni
command, but why does it try to access address0x36cc6dde
if the text section is at0xf1******
?That address is not included in the output of maps as you can see.More general question, I was told shared library starts at
0x40000000
but why this is not the case in my environment?
The shared library is compiled with -fPIC
. I hide some symbol names in the traces above.
回答1:
This is probably related to http://sourceware.org/bugzilla/show_bug.cgi?id=13987. Please, could you try the latest FSF GDB HEAD (can be obtained from: git://sourceware.org/git/gdb.git).
来源:https://stackoverflow.com/questions/9564417/gdb-cant-insert-internal-breakpoint