gdb 在使用观察点时停止(就像 ctrl-Z)
gdb stops when using watchpoints (as if ctrl-Z)
我已经使用 gdb
多年,但以前从未见过这种行为。
为了调试来自程序某处双精度 free()
的 SIGABRT
,我在指向缓冲区的指针上设置了一个观察点。现在,当我再次 运行 程序时,gdb 'stops' 就好像我按下了 ctrl-Z 或者它收到了 SIGSTOP。
知道那里发生了什么吗?我该如何避免?
# gdb --version
GNU gdb (GDB) Red Hat Enterprise Linux 8.2-6.el8
# uname -a
Linux Centos8 4.18.0-147.el8.x86_64 #1 SMP Wed Dec 4 21:51:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
错误:
(gdb) run
free(): invalid pointer
Program received signal SIGABRT, Aborted.
0x00007ffff6ad48df in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff6ad48df in raise () from /lib64/libc.so.6
#1 0x00007ffff6abecf5 in abort () from /lib64/libc.so.6
#2 0x00007ffff6b17c17 in __libc_message () from /lib64/libc.so.6
#3 0x00007ffff6b1e53c in malloc_printerr () from /lib64/libc.so.6
#4 0x00007ffff6b2210e in free_check.part () from /lib64/libc.so.6
#5 0x00007ffff7bbde99 in MyProgram::parseTSPayload (this=0x6165b0) at MyProgram.cpp:284
...
#8 0x0000000000401b4c in main (argc=6, argv=0x7fffffffea28) at MyProgram.cpp:169
(gdb) f 5
#5 0x00007ffff7bbde99 in MyProgram::parseTSPayload (this=0x6165b0) at MyProgram.cpp:284
284 delete [] mpPESBuf;
设置观察点:
(gdb) watch mpPESBuf
Hardware watchpoint 2: mpPESBuf
(gdb) info watch
Num Type Disp Enb Address What
2 hw watchpoint keep y mpPESBuf
现在,当我再次 运行 程序时,gdb 'stops' 就好像我按下了 ctrl-Z 或者它收到了 SIGSTOP:
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: MyProgram
[1]+ Stopped gdb MyProgram
# fg
gdb MyProgram
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
warning: Loadable section ".note.gnu.property" outside of ELF segments
warning: Loadable section ".note.gnu.property" outside of ELF segments
[1]+ Stopped gdb MyProgram
# fg
gdb MyProgram
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
[PID 687305] MyProgram Version 1.1-18
Built 2020.11.24-11:43:08. Launched 2020-11-24 11:56:17.
free(): invalid pointer
Program received signal SIGABRT, Aborted.
0x00007ffff6ad48df in raise () from /lib64/libc.so.6
这是 GDB 中的一个错误,已通过此提交修复:
https://sourceware.org/legacy-ml/gdb-patches/2019-05/msg00361.html
此提交是在 GDB 9 中进行的,而您使用的是 8.2。您需要更新 GDB 版本以避免此问题。
我已经使用 gdb
多年,但以前从未见过这种行为。
为了调试来自程序某处双精度 free()
的 SIGABRT
,我在指向缓冲区的指针上设置了一个观察点。现在,当我再次 运行 程序时,gdb 'stops' 就好像我按下了 ctrl-Z 或者它收到了 SIGSTOP。
知道那里发生了什么吗?我该如何避免?
# gdb --version
GNU gdb (GDB) Red Hat Enterprise Linux 8.2-6.el8
# uname -a
Linux Centos8 4.18.0-147.el8.x86_64 #1 SMP Wed Dec 4 21:51:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
错误:
(gdb) run
free(): invalid pointer
Program received signal SIGABRT, Aborted.
0x00007ffff6ad48df in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff6ad48df in raise () from /lib64/libc.so.6
#1 0x00007ffff6abecf5 in abort () from /lib64/libc.so.6
#2 0x00007ffff6b17c17 in __libc_message () from /lib64/libc.so.6
#3 0x00007ffff6b1e53c in malloc_printerr () from /lib64/libc.so.6
#4 0x00007ffff6b2210e in free_check.part () from /lib64/libc.so.6
#5 0x00007ffff7bbde99 in MyProgram::parseTSPayload (this=0x6165b0) at MyProgram.cpp:284
...
#8 0x0000000000401b4c in main (argc=6, argv=0x7fffffffea28) at MyProgram.cpp:169
(gdb) f 5
#5 0x00007ffff7bbde99 in MyProgram::parseTSPayload (this=0x6165b0) at MyProgram.cpp:284
284 delete [] mpPESBuf;
设置观察点:
(gdb) watch mpPESBuf
Hardware watchpoint 2: mpPESBuf
(gdb) info watch
Num Type Disp Enb Address What
2 hw watchpoint keep y mpPESBuf
现在,当我再次 运行 程序时,gdb 'stops' 就好像我按下了 ctrl-Z 或者它收到了 SIGSTOP:
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: MyProgram
[1]+ Stopped gdb MyProgram
# fg
gdb MyProgram
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
warning: Loadable section ".note.gnu.property" outside of ELF segments
warning: Loadable section ".note.gnu.property" outside of ELF segments
[1]+ Stopped gdb MyProgram
# fg
gdb MyProgram
Error in re-setting breakpoint 2: No symbol "mpPESBuf" in current context.
[PID 687305] MyProgram Version 1.1-18
Built 2020.11.24-11:43:08. Launched 2020-11-24 11:56:17.
free(): invalid pointer
Program received signal SIGABRT, Aborted.
0x00007ffff6ad48df in raise () from /lib64/libc.so.6
这是 GDB 中的一个错误,已通过此提交修复:
https://sourceware.org/legacy-ml/gdb-patches/2019-05/msg00361.html
此提交是在 GDB 9 中进行的,而您使用的是 8.2。您需要更新 GDB 版本以避免此问题。