Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one automatically attach a debugger to a process at process start on OS X?

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.

like image 436
i_am_jorf Avatar asked Sep 05 '09 21:09

i_am_jorf


2 Answers

Use gdb --wait. For example, try

gdb --wait TextEdit

from the command line, and then launch TextEdit.

like image 90
Ken Avatar answered Sep 28 '22 18:09

Ken


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.

like image 35
D.Shawley Avatar answered Sep 28 '22 17:09

D.Shawley