08_Nginx_使用gdb进行调试
因使用
gdb
调试
Nginx
不熟练,特此记录过程,防止后续忘记。
1. 修改配置
1.1 在源码中的auto/cc/conf
中
ngx_compile_opt="-c"
变为
ngx_compile_opt="-c -g"
2.1 确认在MakeFile的编译项目中有‘-g’![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/30a1b762385f04ca8570b6834ef218d0.png)
2. Nginx相关配置
因为Nginx
会有工作进程,所以我们可以通过配置设置只有一个主进程运行。
master_process off;
daemon off; //前台显示进程
3. 开始调试
3.1 先编译Nginx
3.2. 运行Nginx
在安装目录或者objs目录下运行
./Nginx
3.3 查看Nginx进程号
可以得到进程ID为41861
[root@tianyiyi ngx_TAP]# ps -ef|grep nginx
root 41861 4214 0 02:26 pts/1 00:00:00 ./nginx
root 41864 38735 0 02:26 pts/5 00:00:00 grep --color=auto nginx
3.4 使用gdb调试
这样就进入了 ,后续命令完全是gdb调试的常用命令。
[root@tianyiyi ngx_TAP]# gdb -p 41861