Home >
Article > Backend Development >
Through debugging, you can easily locate problems and solve bugs.
This article mainly summarizes the content mentioned in the book. The specific details will be updated slowly, because the details are experienced while reading slowly.
Tracking and debugging, It is mainly divided into 6 parts:
1. Debugging with GDB:
For specific debugging methods, please refer to: Nginx Learning 14-GDB Debugging Nginx Preliminary Test, and the blog of the author of "In-depth Analysis of Nginx": Click to open the link
In fact, through the method in the previous section, you can easily debug the code through eclipse. Of course, gdb is more flexible through the command line.
Enter gdb debugging with parameters:
gdb --args ./nginx -c /home/zy/code/web/nginx-1.6.2/conf/nginx.confAfter entering, it is the break point/single Step debugging/setting observation points and other specific debugging techniques.
2. Use log information to track Nginx:
We know that printf is the printing function of small programs, but when the program is large, printf is not so flexible. Therefore, large programs All systems will provide different levels of output control. For example, Linux kernel/NS3 network simulation tools, etc. Set the directory and level of the log information in the configuration file. Then call the ngx_log_xxx() series of functions in the program.
3. Use strace/pstack to debug the program:
You can use these two commands to view the system function calls and dynamic library function calls initiated by the application during the running process. Then, pstack itself is a shell script implemented using gdb.
4. Stubbing debugging:
The concept of unit testing. For example, if we write an algorithm to implement a function, in order to verify its correctness, we need to construct the output in the main function and print out these. These additional Testing the code is stub testing. And stub testing can also be performed in eclipse: click to open the link
5. Special application testing:
Write your own client for socket communication to test certain things that will only be executed under specific circumstances The code arrived
The above introduces nginx tracking and debugging, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.