How to automatically attach a debugger to a process when a process starts in OS X?

I have a process that spawns a helper process. Sometimes I need to debug startup errors 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.

+4
source share
3 answers

Use gdb --wait. For example, try

 gdb --wait TextEdit 

from the command line, then run TextEdit.

+7
source

I do not think you can run gdb in the same way. Instead, start the parent process from gdb or attach it to the running process before it disables the helper. There is a parameter called follow-fork-mode that determines which process follows the debugger. See the GDB Handbook for a nice description.

+2
source

If you use startd to start processes, that is, WaitForDebugger logical key that is included in the job plist file. If so, then startd waits (surprisingly!) For the debugger to execute exec() the job.

+2
source

All Articles