您的位置:程序门 -> linux/unix社区 -> 程序开发区



高分求gdb如何调试多进程


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


高分求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子进程中的某一个函数进行跟踪呢
发表于:2007-05-16 12:34:391楼 得分:0
这个跟系统相关。跟你说一个,在gdb中执行set   follow-fork-makde   child
发表于:2007-05-16 13:12:132楼 得分:0
这个可以设置线程内的函数断点.
发表于:2007-05-16 23:34:133楼 得分:0
需要的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.
发表于:2007-05-17 03:14:324楼 得分:0
软件开发与技术交流群40271625


快速检索

最新资讯
热门点击