From 469e1ca0801a611274b7c48d6f951ffc2c008a37 Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 22 Jun 2006 16:04:49 +0000 Subject: - Updated the tools/stackdump script to also handle sig-plugin generated backtraces. Now it will also auto-determine whether the exe needs a .exe at the end or not. - Usage is "stackdump [number]". When a number is given, sig-plugin stackdumps are assumed, otherwise it parses the normal stackdump as before. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7296 54d463be-8e91-2dee-dedb-b68131a5f0ec --- tools/stackdump | 58 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'tools/stackdump') diff --git a/tools/stackdump b/tools/stackdump index d5e89f415..1826b0c76 100644 --- a/tools/stackdump +++ b/tools/stackdump @@ -1,35 +1,47 @@ #!/bin/bash case "$1" in - ""|help) - echo "Usage 1: ${0##*/} [server-type] [sql]" + 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] [number]" - echo Server type has to be the full name of the file. Examples: - echo "$ ./${0##*/} map-server 0001" - echo "$ ./${0##*/} login-server_sql 0002" + 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 - map|char|login) - # Check for SQL postfix - if [ "$2" = "sql" ]; then - sql="_sql" - fi - STACK="$1-server$sql.exe.stackdump" - SERVER="$1-server$sql.exe" - ;; +# Check if server file needs .exe (Windows/Cygwin) +if [ ! -e $SERVER ]; then + if [ -e $SERVER.exe ]; then + SERVER=$SERVER.exe + else + echo Error: $SERVER not found! + exit + fi +fi - *) - STACK="$1$2.stackdump" - SERVER="$1.exe" - ;; -esac +# Assemble stackdump filename +if [ $# > 2 ]; then + STACK="$SERVER$3.stackdump" +else + STACK="$SERVER.stackdump" +fi # Check if file exists. # Try looking under '/log' if it isn't @@ -44,5 +56,9 @@ if [ ! -e $STACK ]; then fi # Finally dump the backtrace - -awk '/^[0-9]/{print $2}' $STACK | addr2line -f -e $SERVER \ No newline at end of file +# If number is given, Sig-plugin format. otherwise, standard stackdump format +if [ $# > 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 -- cgit v1.2.3-60-g2f50