gdb在默认设置下调试多进程程序时只会去调试主进程。gdb版本高于v7.0支持多进程的同时调试。只需要设置follow-fork-mode和detach-on-fork即可。
Socket服务端调试过程:
[root@localhost bin]# gdb socketserver
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /opt/testgdb/bin/socketserver...done.
(gdb) b main
Breakpoint 1 at 0x401515: fil

本文介绍了如何使用gdb 7.0以上版本调试多进程程序,重点讲解了如何设置follow-fork-mode和detach-on-fork参数,以实现对子进程的跟踪。通过实例展示了在Socket服务端调试过程中,如何同时监视主进程和子进程的操作。
最低0.47元/天 解锁文章
1040

被折叠的 条评论
为什么被折叠?



