Reputation: 9655
I am debugging a process on a web server running Linux. The process is invoked once a request is coming from a web-page. In order to debug the process, I look at the running processes list (using top
), I spot the relevant process (named apache2
) by it's CPU usage (quite easy, since it is usually on top of the list), and I attach the gdb session to the process id. Of course I can call the attach PID
command only after the process is up.
The only problem is that this process-id-spotting takes a second or two, so I cannot stop at functions which are called during the first second or two. (The whole process takes about a minute so in most cases it is not a problem).
Is there any way of doing this automatically, so I can save these couple of seconds and start the attachment earlier?
Upvotes: 2
Views: 796
Reputation: 84239
You can attach to the parent process and catch fork
s. Don't forget to set follow-fork-mode child
.
Upvotes: 4