ubuntu下pstack乱码解决

将以下源码粘贴在/usr/bin/pstack;
修改文件权限chmod 777 pstack;
over

#!/bin/shif test $# -ne 1; thenecho "Usage: `basename $0 .sh` " 1>&2exit 1
fiif test ! -r /proc/$1; thenecho "Process $1 not found." 1>&2exit 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 ; thenbacktrace="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 ; thenbacktrace="thread apply all bt"fi
fiGDB=${GDB:-gdb}# Run GDB, strip out unwanted noise.
# --readnever is no longer used since .gdb_index is now in use.
$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <&1 |
set width 0
set height 0
set pagination no
$backtrace
EOF
/bin/sed -n \-e 's/^\((gdb) \)*//' \-e '/^#/p' \-e '/^Thread/p'


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部