Linux
提供しているようには提供pstack
されませんがSolaris
、RedHat
提供するスクリプトは同じことを行うことができます:
#!/bin/bash
if test $# -ne 1; then
echo "Usage: `basename $0 .sh` <process-id>" 1>&2
exit 1
fi
if test ! -r /proc/$1; then
echo "Process $1 not found." 1>&2
exit 1
fi
# GDB doesn't allow "thread apply all bt" when the process isn't
# threaded; need to peek at the process to determine if that or the
# simpler "bt" should be used.
backtrace="bt"
if test -d /proc/$1/task ; then
# Newer kernel; has a task/ directory.
if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then
backtrace="thread apply all bt"
fi
elif test -f /proc/$1/maps ; then
# Older kernel; go by it loading libpthread.
if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then
backtrace="thread apply all bt"
fi
fi
GDB=${GDB:-/usr/bin/gdb}
if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then
readnever=--readnever
else
readnever=
fi
# Run GDB, strip out unwanted noise.
$GDB --quiet $readnever -nx /proc/$1/exe $1 <<EOF 2>&1 |
$backtrace
EOF
/bin/sed -n \
-e 's/^(gdb) //' \
-e '/^#/p' \
-e '/^Thread/p'
でスクリプトを実行するSuse
:
linux:~ # pstack 7286
Thread 3 (Thread 0x7f7c074b5700 (LWP 7287)):
#0 0x00007f7c055f7a9d in read () from /lib64/libpthread.so.0
#1 0x00007f7c050a3b76 in ?? () from /usr/lib64/libxenstore.so.3.0
#2 0x00007f7c050a3c2f in ?? () from /usr/lib64/libxenstore.so.3.0
#3 0x00007f7c050a3f72 in ?? () from /usr/lib64/libxenstore.so.3.0
#4 0x00007f7c055f10a4 in start_thread () from /lib64/libpthread.so.0
#5 0x00007f7c03c9104d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7f7bfe4b0700 (LWP 7288)):
#0 0x00007f7c055f505f in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007f7c07199d99 in ?? ()
#2 0x00007f7c0709a213 in ?? ()
#3 0x00007f7c0709a610 in ?? ()
#4 0x00007f7c055f10a4 in start_thread () from /lib64/libpthread.so.0
#5 0x00007f7c03c9104d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7f7c07483980 (LWP 7286)):
#0 0x00007f7c03c88cdf in ppoll () from /lib64/libc.so.6
#1 0x00007f7c07060ec9 in ?? ()
#2 0x00007f7c07026654 in ?? ()
#3 0x00007f7c06edcb36 in ?? ()
#4 0x00007f7c03bcdb05 in __libc_start_main () from /lib64/libc.so.6
#5 0x00007f7c06ee0eec in ?? ()
私の質問は、アドレスから関数名を解決する方法ですか? など0x00007fe4ab73eb36
。パッケージをインストールすることでわかるかもしれませんdebug-info
が、どのパッケージをインストールするかを知るにはどうすればよいですか?
更新:
Mark Plotnick のコメントによると、次のコマンドを使用して、debuginfo
不足しているパッケージ を取得します。
linux:~ # gdb --quiet -nx --readnever /proc/7286/exe 7286
......
Missing separate debuginfos, use: zypper install glibc-debuginfo-2.19-31.5.x86_64 ......
必要なパッケージをすべてインストールしdebuginfo
たら、シンボルを解決できます。
linux:~ # pstack 7286
Thread 3 (Thread 0x7f7c074b5700 (LWP 7287)):
#0 0x00007f7c055f7a9d in read () from /lib64/libpthread.so.0
#1 0x00007f7c050a3b76 in read_all.part.1.constprop ()
#2 0x00007f7c050a3c2f in read_message.constprop ()
#3 0x00007f7c050a3f72 in read_thread () from /usr/lib64/libxenstore.so.3.0
#4 0x00007f7c055f10a4 in start_thread () from /lib64/libpthread.so.0
#5 0x00007f7c03c9104d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7f7bfe4b0700 (LWP 7288)):
#0 0x00007f7c055f505f in pthread_cond_wait@@GLIBC_2.3.2 ()
#1 0x00007f7c07199d99 in qemu_cond_wait ()
#2 0x00007f7c0709a213 in vnc_worker_thread_loop ()
#3 0x00007f7c0709a610 in vnc_worker_thread ()
#4 0x00007f7c055f10a4 in start_thread () from /lib64/libpthread.so.0
#5 0x00007f7c03c9104d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7f7c07483980 (LWP 7286)):
#0 0x00007f7c03c88cdf in ppoll () from /lib64/libc.so.6
#1 0x00007f7c07060ec9 in qemu_poll_ns ()
#2 0x00007f7c07026654 in main_loop_wait ()
#3 0x00007f7c06edcb36 in main ()
しかし " objdump -t /proc/7286/exe | grep main
" は何も出力しません:
linux:~ # objdump -t /proc/7286/exe | grep main
linux:~ #