tags:

views:

52

answers:

2

Using gdb, I am trying to trace the function calls of a web server. I set breakpoints on every function call and when I tell gdb to 'run' it breaks at all the right places while the server starts up. Then gdb says 'Program ended with code 01' and doesn't stop at breakpoints anymore (obviously). However, the web server is still running.

I want to be able to trace the function calls made on an incoming HTTP request, so just breaking during server startup is useless to me.

Is there some trick to using gdb when tracing a daemon server so that it doesn't just end like above?

+1  A: 

set follow-fork-mode child

see http://www.delorie.com/gnu/docs/gdb/gdb%5F26.html for example

GregS
If the web server in question is Apache, merely setting follow-fork-mode will likely *not* work: by default Apache forks several children, and you don't know which one will handle a particular request. Setting "MaxClients 1" is likely also required.
Employed Russian
A: 

You didn't say which server you are trying to trace, but likely it is Apache.

Detailed instructions are here. Note the -X command line argument, which prevents httpd from forking children.

Also note that the instructions are the first result for this search.

Employed Russian