到达execve时如何防止GDB退出?

How to prevent GDB from exiting when reaching execve?

目前正在调试类似remake的tcsh,我用过:

set follow-fork-mode child 在 fork 之后跟随一个子程序但是到达 execve 系统调用 GDB 退出并且我收到以下消息:

process 11217 is executing new program: /usr/bin/cat zsh: suspended (tty output) gdb ./mysh

我该如何预防?

提前致谢!

看起来 child 被暂停了?

您可以让 child 运行 具有:

set detach-on-fork on

这是默认设置。您可以使用 show detach-on-fork 检查它是否已关闭(也许通过 .gdbinit?)。

要跟踪执行过程,您可以使用:

set follow-exec-mode new

您还可以使用 inferior 在多个进程之间切换。首先通过以下方式获得劣质数字:

info inferiors

然后切换:

inferior <num>