如何在 OS X 上的进程启动时自动将调试器附加到进程?

发布于 2024-08-04 09:43:29 字数 137 浏览 6 评论 0原文

我有一个生成辅助进程的进程。有时我需要调试第二个进程的启动失败。

在 Windows 上,我会使用图像文件执行选项ntsd -o。但是,我不知道如何在 OS X 上使用 GDB 来执行此操作。

I have a process that spawns a helper process. Sometimes I need to debug start-up failures in the second process.

On Windows, I would use Image File Execution Options, or ntsd -o. However, I have no idea how to do this with GDB on OS X.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凉世弥音 2024-08-11 09:43:29

使用gdb --wait。例如,尝试

gdb --wait TextEdit

从命令行,然后启动 TextEdit。

Use gdb --wait. For example, try

gdb --wait TextEdit

from the command line, and then launch TextEdit.

倥絔 2024-08-11 09:43:29

我认为你不能以同样的方式启动 GDB。

相反,请从 GDB 中运行父进程,或者在分叉助手之前附加到正在运行的进程。有一个名为 follow-fork-mode 的设置,用于控制调试器遵循哪个进程。请参阅GDB 手册以获得详细说明。

I don't think that you can have GDB launch in the same manner.

Instead, run your parent process from within GDB or attach to the running process before it forks the helper off. There is a setting called follow-fork-mode that controls which process the debugger follows. Take a look at the GDB Manual for a nice description.

林空鹿饮溪 2024-08-11 09:43:29

如果您使用 launchd 来生成进程,那么就会有一个 WaitForDebugger 位于作业的 p-list 文件 中的布尔键。如果是,则 launchd 在执行作业之前会等待(令人惊讶!)调试器。

If you're using launchd to spawn processes, then there's a WaitForDebugger Boolean key which goes in the job's p-list file. If it's yes, then launchd waits (surprisingly!) for the debugger before exec()ing the job.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文