./nginx -c conf/nginx.conf
在任意目录
gdb -d /usr/local/nginx/objs/ nginx 10776
或者gdb -d /usr/local/nginx/objs/ nginx
进入后再attach 10777
(gdb) info program Using the running image of attached Thread 0x2af36f21d520 (LWP 10776). Program stopped at 0x6e23079a. (gdb) show env (gdb) show paths (gdb)info terminal (gdb)pwd
在gdb中,我们可以有以下几种暂停方式:断点(BreakPoint)、观
察点(Watch Point)、捕捉点(Catch Point)、信号(Signals)、
线程停止(Thread Stops)。如果要恢复程序运行,可以使用c或是
continue命令
---------------
ps -ef|grep nginx
gcore 5518
生成core文件
[root@red54apple 0921]# pstack 5518 #0 0x0000003b6e23079a in sigsuspend () from /lib64/libc.so.6 #1 0x000000000042d5bd in ngx_master_process_cycle () #2 0x00000000004031c7 in main () [root@red54apple 0921]#
gdb /usr/local/nginx/objs/nginx ./core.5518
(gdb) search ngx_master_process_cycle
(gdb) b ngx_master_process_cycle
(gdb)bt
(gdb)frame
参考http://www.yuanma.org/data/2009/0407/article_3605.htm
(gdb)help all
-----------------
commands
(gdb) b 19 Breakpoint 2 at 0x4004e9: file tst.c, line 19. (gdb) commands Type commands for when breakpoint 2 is hit, one per line. End with a line saying just "end". >printf "haha" >end (gdb) r Starting program: /root/gdbtest/0919/tst Breakpoint 2, main () at tst.c:19 19 result += i; haha(gdb) (gdb)
info args
打印出当前函数的参数名及其值。
info locals
打印出当前函数中所有局部变量及其值。
info catch
打印出当前的函数中的异常处理信息。
forward-search <regexp>
search <regexp>
向前面搜索。
reverse-search <regexp>