Home > Backend Development > PHP Tutorial > nginx tracking and debugging

nginx tracking and debugging

WBOY
Release: 2016-08-08 09:30:52
Original
1280 people have browsed it

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.conf
Copy after login
After 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.

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