VS2013 development and debugging PHP extension

WBOY
Release: 2016-08-08 09:22:13
Original
1493 people have browsed it

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/8108993
The article introduces PHP5. The construction method of 4 is similar if you want to change to PHP5.5, and the steps are the same.

2. Configure the debugging environment

1. Download the PHP_DEBUG_PACK file

http://windows.php.net/download/#php-5.4

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.

2. Introduce symbol files

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


3. Extension to enable DEBUG information

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

1. Write a PHP script and run it in the terminal as a permanent process.

[php] view plaincopy

  1. while(1){
  2. '11'); sleep( 4);
  3. }
Here, permanent residence is not necessary. Just for my local convenience for testing.

2. Add breakpoint location


3. Attach process

Debugging - "Attach to process: Select the process generated by executing PHP in 1 above.


Now, just wait for the program to run to the breakpoint location to see the debugging information:


Over.


The above introduces the development and debugging of PHP extensions in VS2013, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!