Is there any way to tell gdb to wait for a process to start and attach to it?

I have a process that is called by another process which is called by another process and so on ad nauseum. It's a child process in a long tool chain.

This process is crashing.

I would like to catch this process in gdb to understand why it's crashing. However, the only way I can think of is:

  1. start the original parent process in the commandline.
  2. poll ps -C and get the PID.
  3. launch gdb, attached to that process's PID.

This is cumbersome but usually does the job. The problem is that the current failure runs very quickly, and by the time I capture the PID and launch gdb, it's already passed the failure point.

I would like to launch gdb and instead of:

(gdb) attach <pid>

I would like to do:

(gdb) attach <process name when it launches>

Is there any way to do this?


I am using gdb 7.1 on linux

33
задан Nathan Fellman 7 December 2010 в 22:34
поделиться