<< 使用 GNU profiler 来提高代码运行速度 | 首页 | 使用 GDB 调试 Linux 软件 >>

使用 gdb 抓取进程Stack Trace

[root@centos ~]# ps -ef|grep nginx

root      1348     1  0 12:01 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx

nobody    1350  1348  0 12:01 ?        00:00:00 nginx: worker process

root      2457  2223  0 12:05 pts/0    00:00:00 grep nginx

[root@centos ~]# gdb /usr/local/nginx/sbin/nginx 1350

GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6)

Copyright (C) 2010 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "i686-redhat-linux-gnu".

For bug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>...

Reading symbols from /usr/local/nginx/sbin/nginx...done.

Attaching to program: /usr/local/nginx/sbin/nginx, process 1350

Reading symbols from /lib/libpthread.so.0...(no debugging symbols found)...done.

[Thread debugging using libthread_db enabled]

Loaded symbols for /lib/libpthread.so.0

Reading symbols from /lib/libcrypt.so.1...(no debugging symbols found)...done.

Loaded symbols for /lib/libcrypt.so.1

Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.

Loaded symbols for /lib/libc.so.6

Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.

Loaded symbols for /lib/ld-linux.so.2

Reading symbols from /lib/libfreebl3.so...(no debugging symbols found)...done.

Loaded symbols for /lib/libfreebl3.so

Reading symbols from /lib/libdl.so.2...(no debugging symbols found)...done.

Loaded symbols for /lib/libdl.so.2

Reading symbols from /lib/libnss_files.so.2...(no debugging symbols found)...done.

Loaded symbols for /lib/libnss_files.so.2

0x00399416 in __kernel_vsyscall ()

Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.132.el6_5.2.i686 nss-softokn-freebl-3.12.9-11.el6.i686

(gdb) bt

#0  0x00399416 in __kernel_vsyscall ()

#1  0x00a055c8 in __epoll_wait_nocancel () from /lib/libc.so.6

#2  0x08066d18 in ngx_epoll_process_events (cycle=0x946eeb8, timer=53791, flags=1) at src/event/modules/ngx_epoll_module.c:579

#3  0x0805fd41 in ngx_process_events_and_timers (cycle=0x946eeb8) at src/event/ngx_event.c:248

#4  0x08065add in ngx_worker_process_cycle (cycle=0x946eeb8, data=0x0) at src/os/unix/ngx_process_cycle.c:816

#5  0x080643a4 in ngx_spawn_process (cycle=0x946eeb8, proc=0x8065a26 <ngx_worker_process_cycle>, data=0x0, name=0x80c153a "worker process", respawn=-3)

    at src/os/unix/ngx_process.c:198

#6  0x08064fbf in ngx_start_worker_processes (cycle=0x946eeb8, n=1, type=-3) at src/os/unix/ngx_process_cycle.c:364

#7  0x08066035 in ngx_master_process_cycle (cycle=0x946eeb8) at src/os/unix/ngx_process_cycle.c:136

#8  0x0804b38d in main (argc=1, argv=0xbfba0114) at src/core/nginx.c:407

(gdb) n

Single stepping until exit from function __kernel_vsyscall,

which has no line number information.

0x00a055c8 in __epoll_wait_nocancel () from /lib/libc.so.6

(gdb)

 

 

标签 :



发表评论 发送引用通报