diff options
author | Trojal <trojal@gmail.com> | 2013-01-10 20:09:39 -0800 |
---|---|---|
committer | Trojal <trojal@gmail.com> | 2013-01-10 20:32:02 -0800 |
commit | 83e7a4954437c13aec639b0b512252cc20a8f36c (patch) | |
tree | b7f6d11b2058248d026f2d9944e8f4b6ac288d50 /tools/stackdump | |
parent | 51bfeb38eb139e97e0e1c096c85c15fba234f35b (diff) | |
parent | 38e583df21eccd9e4f31d38acaae32579c6f0d27 (diff) | |
download | hercules-83e7a4954437c13aec639b0b512252cc20a8f36c.tar.gz hercules-83e7a4954437c13aec639b0b512252cc20a8f36c.tar.bz2 hercules-83e7a4954437c13aec639b0b512252cc20a8f36c.tar.xz hercules-83e7a4954437c13aec639b0b512252cc20a8f36c.zip |
Merge rathena repository to form Hercules initial commit.
Diffstat (limited to 'tools/stackdump')
-rwxr-xr-x | tools/stackdump | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/stackdump b/tools/stackdump new file mode 100755 index 000000000..25b1fa46a --- /dev/null +++ b/tools/stackdump @@ -0,0 +1,62 @@ +#!/bin/bash + +case "$1" in + map|char|login) + # Check for SQL postfix + if [ "$2" = "sql" ]; then + SERVER="$1-server_sql" + else + SERVER="$1-server" + fi + ;; + + *|""|help) + echo "Usage 1: ${0##*/} [server-type] [txt/sql]" + echo Server type can be map, login, or char. Examples: + echo "$ ./${0##*/} map" + echo "$ ./${0##*/} login sql" + echo + echo "Usage 2: ${0##*/} [server-type] [txt/sql] [number]" + echo Server type can be map, login, or char. Examples: + echo "$ ./${0##*/} map txt 0001" + echo "$ ./${0##*/} login sql 0002" + echo + echo Note: Dump files inside /log will also be scanned. + exit + ;; +esac + +# Check if server file needs .exe (Windows/Cygwin) +if [ -e $SERVER.exe ]; then + SERVER="$SERVER.exe" +elif [ ! -e $SERVER ]; then + echo Error: $SERVER not found! + exit +fi + +# Assemble stackdump filename +if [ $# -gt 2 ]; then + STACK="$SERVER$3.stackdump" +else + STACK="$SERVER.stackdump" +fi + +# Check if file exists. +# Try looking under '/log' if it isn't + +if [ ! -e $STACK ]; then + if [ -e log/$STACK ]; then + STACK=log/$STACK + else + echo Error: $STACK not found! + exit + fi +fi + +# Finally dump the backtrace +# If number is given, Sig-plugin format. otherwise, standard stackdump format +if [ $# -gt 2 ]; then + awk '$2 ~ /[0-9a-eA-E]\]$/{print $2}' $STACK | tr -d \[\] | addr2line -f -e $SERVER +else + awk '/^[0-9]/{print $2}' $STACK | addr2line -f -e $SERVER +fi |