Created
April 7, 2015 08:39
-
-
Save theirix/ceacb52b1e5cf1a9594a to your computer and use it in GitHub Desktop.
pstack for osx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Script prints gdb stack of the process with a specified pid | |
if [ -z $1 ]; then | |
echo "Usage: $0 pid" | |
exit 1 | |
fi | |
PID=$1 | |
BINARY=`ps -o comm= -p $PID` | |
SCRIPT_DIR=`dirname $0` | |
if [ -z "$BINARY" ]; then | |
echo "Cannot determine binary" | |
exit 1 | |
fi | |
TMPFILE=`mktemp -t pstack.XXXXXX` || exit 1 | |
trap "rm -f $TMPFILE" exit | |
echo "thread apply all bt\ndetach\nquit" > $TMPFILE | |
/usr/bin/gdb -q -x $TMPFILE "$BINARY" $PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment