高分求GDB如何调试多进程

oyxiaoyu0 2007-05-16 11:35:37
我有一个总控进程maincollect.c,这个总控进程负责启动多个子进程collect来处理
程序编译后会生成两个可执行文件maincollect.c和collect.
我启动maincollect start
然后gdb maincollect (gdb) b maincollect.c:152说No source file named maincollect.c.
gdb collect
(gdb) b zftp.c:3556也说No source file named maincollect.c.

请问该如何能够进入collect子进程中的某一个函数进行跟踪呢
...全文
275 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
coolfishbone_joey 2011-07-30
  • 打赏
  • 举报
回复
这个比较有用,但是如果要用到信号怎么切换进程呢。能否请教您一下。谢谢。
liukai60268 2007-05-17
  • 打赏
  • 举报
回复
软件开发与技术交流群40271625
悠悠长风 2007-05-16
  • 打赏
  • 举报
回复
这个跟系统相关。跟你说一个,在gdb中执行set follow-fork-makde child
hundlom 2007-05-16
  • 打赏
  • 举报
回复
需要的gdb版本高一些
详细解释如下:
Multiprocess Application Debugging
One problem with the debugging of multiprocess applications is which process to follow when a new process is created. Recall from Chapter 12, “Introduction to Sockets Programming,” that the fork function returns to both the parent and child processes. We can tell GDB which to returns to follow using the follow-fork-mode command. For example, if we wanted to debug the child process, we’d specify to follow the child process as:

set follow-fork-mode child
Or, if we instead wanted to follow the parent (the default mode), we’d specify this as:

set follow-fork-mode parent
In either case, when GDB follows one process, the other process (child or parent) continues to run unimpeded. We can also tell GDB to ask us which process to follow when a fork occurs, as:

set follow-fork-mode ask
When the fork occurs, GDB will ask which to follow. Whichever is not followed will execute normally.
  • 打赏
  • 举报
回复
这个可以设置线程内的函数断点.

23,116

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧