2011/05/16

pstack - 列印出process stack trace

有時候遇到process hang住了,我們想知道各thread目前function call stack為何就可以利用pstack。使用前提是binary還保有symbol(還未strip)

用法︰
$  pstack pid

e.g.
$ pstack `pgrep syslog-ng`

Backtrace for pid 21374
A syntax error in expression, near `'.
#0  0x00000034bb6cb14f in poll () from /lib64/libc.so.6
#1  0x0000000000402957 in main_context_poll (ufds=0x9b1920, nfsd=22,
    timeout_=14303) at main.c:134
#2  0x00002b3ba086a90f in g_main_context_poll (context=0x966400, block=1,
    dispatch=1, self=) at gmain.c:3093
#3  g_main_context_iterate (context=0x966400, block=1, dispatch=1,
    self=) at gmain.c:2775
#4  0x00002b3ba086af0b in g_main_context_iteration (context=0x966400,
    may_block=1) at gmain.c:2843
#5  0x0000000000402421 in main_loop_run (cfg=0x7ffff43c6040) at main.c:170
#6  0x00000000004028d9 in main (argc=1, argv=0x7ffff43c6138) at main.c:448
這個訊息跟在gdb下thread apply all bt是一樣的。

下載︰
我只找到Oracol Project: GDB pstack


沒有留言:

張貼留言