借助gdb实现pstack

pstack.sh:

 

#! /bin/sh

if [ -z $1 ]

then

    echo "gdb script for print stack"

    echo "usage: $0 pid"

    exit

fi

 

gdb --batch --quiet -x cmds -p $1

 

 

cmds:

 

echo /nProcess:/n

info proc

 

echo /nStack:

thread apply all backtrace

 

detach

quit

你可能感兴趣的:(借助gdb实现pstack)