Created
July 18, 2017 14:12
-
-
Save rghose/ac5d5bdbc42b19f22768b15e534654ff to your computer and use it in GitHub Desktop.
Generate stack trace of a running process on OS X
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
# Written by Cheng Zhao([email protected]). | |
# Published under Public Domain. | |
# Usage: stackshot.sh pid | |
# Path to stackshot tool. | |
STACKSHOT='/usr/libexec/stackshot' | |
# Path to symbolicated report. | |
TRACEFILE='/Library/Logs/stackshot-syms.log' | |
if [ -z $1 ]; then | |
echo "Usage: $0 pid" | |
exit 1 | |
elif [ $EUID != 0 ]; then | |
echo 'Please run this script as root user' | |
exit 2 | |
elif [ ${OSTYPE%%[0-9.]*} != 'darwin' ]; then | |
echo 'This script can only run on OS X' | |
exit 3 | |
fi | |
# Run stackshot. | |
rm $TRACEFILE | |
$STACKSHOT -p $1 -i -u || exit $? | |
# Print report. | |
cat $TRACEFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment