首页 > 编程知识 正文

pstack Inputoutput error failed to read target解决

时间:2023-05-05 16:47:57 阅读:243427 作者:3990

1.pstack获取进程死锁堆栈信息报错# sudo pstack 3200 //pid3200: ./a.outpstack: Input/output errorfailed to read target.2.pstack是gdb封装的shell脚本:# sudo emacs pstack#!/bin/shif test $# -ne 1; then echo "Usage: `basename $0 .sh` <process-id>" 1>&2 exit 1fiif test ! -r /proc/$1; then echo "Process $1 not found." 1>&2 exit 1fi# 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" fielif 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" fifiGDB=${GDB:-/usr/bin/gdb}if $GDB -nx --quiet --batch --readnever > /dev/null 2>&1; then readnever=--readneverelse readnever=fi# Run GDB, strip out unwanted noise.$GDB --quiet $readnever -nx /proc/$1/exe $1 <<EOF 2>&1 | set width 0set height 0set pagination no$backtraceEOF/bin/sed -n -e 's/^((gdb) )*//' -e '/^#/p' -e '/^Thread/p'3.pstack配置到系统# sudo cp pstack /usr/bin# sudo pstack 3200Thread 2 (Thread 0x7f5ba59a0700 (LWP 3202)):#0 0x00007f5ba65a411d in __lll_lock_wait () from /lib/x86_64-linux-gnu/libpthread.so.0#1 0x0000000000000000 in ?? ()Thread 1 (Thread 0x7f5ba69a9740 (LWP 3200)):#0 0x00007f5ba659bd2d in __pthread_timedjoin_ex () from /lib/x86_64-linux-gnu/libpthread.so.0#1 0x0000563ada6da4d0 in ?? ()#2 0x00007f5ba4f89138 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1#3 0x00007f5ba659bb90 in ?? () from /lib/x86_64-linux-gnu/libpthread.so.0#4 0x00007f5ba59a0d28 in ?? ()#5 0x000000000000003a in ?? ()#6 0x0000000000000000 in ?? ()

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。