Reprinted from: http://blog.csdn.net/a600423444/article/details/12720543
Foreword
An essential part of development is debugging, and the way of debugging directly affects development efficiency and Software quality.
When I developed PHP extensions before, I never knew how to debug. Every time I debugged, I recompiled, executed and then ran the PHP script to check the running status before debugging. It's too painful and affects efficiency too much. I also searched on Baidu and Google about how to debug PHP extensions, but the answers were almost all GDB. Unfortunately, I don’t know how to actually operate it.
VS is not used much, and I don’t know what many of its functions are for. A few days ago, a colleague said that you can use VS’s “Attach to Process” to debug PHP extensions. I suddenly felt like I was saved. Of course, it's also because I'm not familiar with C debugging.
Enter the topic:
1. Building a PHP extension development environment for Windows
Check out my other article: http://blog.csdn.net/a600423444/article/details/81089932. Configure the debugging environment
When selecting, please note that it must be the same as the downloaded PHP binary version. For example, when you set up the PHP development environment in the first step, you selected VC9 x86 Non Thread Safe, then DEBUG PACK should download the same version of DEBUG PACK.
The Debug pack compressed package contains all PHP debugging related symbol files (*.pdb), and introducing them is the key to debugging.
Note: Only in debugging state, the Load all symbols button can be clicked
Tools-"Options-"Debugging-"Symbols-"Add the decompression path to the symbol location
Project-》Properties-》Linker-》Debugging-》Generate debug information-》Set to "Yes"
When compiling and generating the Release version DLL, it will Generate vc110.pdb and put it into the PDB path decompressed earlier. In order to unify the naming format, you can rename it with the same name as the extension. What I changed here is "php_test.pdb"
Now the configuration has been completed, let's see how to use debugging.
3. Attach to the process
[php] view
plaincopy
2. Add breakpoint location
3. Attach process
Now, just wait for the program to run to the breakpoint location to see the debugging information:
Over.