Debugging PHP interpreter with GDB
2 answers
- Do you want to get a debug build
mod_php
(with symbols) or create your own (configure --enable-debug
) - You should configure your Apache to always keep exactly one instance of the workflow (which will be the instance you are debugging), that is
MinSpareServers
,MaxSpareServers
andStartServers
all to 1. Also make sure the timeout options are generously set - Use
gdb
either any GUIgdb
(likeddd
or Eclipse CDT ) to attach to one and only Apache process. Stick to a breakpoint in one of the PHP sources, etc. And keep going. - Point your browser to your web server and refer to the PHP page. Your breakpoint will fire. If you want to wake up the debugger at a specific location in a PHP script execution, generate
SIGTRAP
from PHP andgdb
usually obliges you.
Good luck!
+5
source to share
Perhaps you could do this in windows.
However, it is best to do this in a Unix window. You will have to compile everything with debugging enabled. GDB will need access to these directories for the source.
Then you will need to start apache and then start the process.
To give time for the attaché while you are pushing to PHP / Apache using your browser, add a sleep call to your PHP script. If you are using ps, you will see the process in a waiting state. Or you can just write its process id to a file in tmp before it does sleep.
0
source to share