本文介绍了如何从App1的app2的main()中触发gdb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
提供的app2由app1触发,其中有类似system(./ app2)的内容。 app1也做了很多准备工作,例如创建dirs,文件,配置等等,以便运行app2。
我怎样才能从其主要的第一行gdb app2 )?
我试过以下的方法无效。
gdb app2
b main
shell ./app1
解决方案 div>
有几种方法可以实现这一点:
- 如果
app1
不会关闭stdin,stdout,stderr
,您可以修改app1
来代替:`system (gdb ./app2) - 您可以修改
app2
为 wait ,例如显示。然后运行app1
,并从另一个窗口使用gdb -p $ child_pid
。
- 如果
app1
没有在app2
之前分支任何子元素,则可以使用( gdb)设置follow-fork子
并让GDB在app1
分叉后自动开始调试app2
它。
Provided app2 is triggered by app1 in which there is something like system("./app2"). app1 also does a lot of preparation such as creating dirs, files, configuration... for app2 running.
How can I gdb app2 from the first line of its main()?
What I tried as below doesn't work.
gdb app2
b main
shell ./app1
解决方案
There are a few ways to achieve this:
- If
app1
doesn't closestdin, stdout, stderr
, you could modifyapp1
to do this instead: `system("gdb ./app2") - You could modify
app2
to wait for debugger to be attached, as e.g. this answer shows. Then runapp1
, and usegdb -p $child_pid
from another window. - If
app1
doesn't fork any children prior toapp2
, you could use(gdb) set follow-fork child
and have GDB automatically start debuggingapp2
afterapp1
forks it.
这篇关于如何从App1的app2的main()中触发gdb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-17 03:34