root/tools/stackdump @ 1

Revision 1, 1.4 kB (checked in by jinshiro, 17 years ago)
Line 
1#!/bin/bash
2
3case "$1" in
4        map|char|login)
5                # Check for SQL postfix
6                if [ "$2" = "sql" ]; then
7                        SERVER="$1-server_sql"
8                else
9                        SERVER="$1-server"
10                fi
11                ;;
12
13        *|""|help)
14                echo "Usage 1: ${0##*/} [server-type] [txt/sql]"
15                echo Server type can be map, login, or char. Examples:
16                echo "$ ./${0##*/} map"
17                echo "$ ./${0##*/} login sql"
18                echo
19                echo "Usage 2: ${0##*/} [server-type] [txt/sql] [number]"
20                echo Server type can be map, login, or char. Examples:
21                echo "$ ./${0##*/} map txt 0001"
22                echo "$ ./${0##*/} login sql 0002"
23                echo
24                echo Note: Dump files inside /log will also be scanned.
25                exit
26                ;;
27esac
28
29# Check if server file needs .exe (Windows/Cygwin)
30if [ -e $SERVER.exe ]; then
31        SERVER="$SERVER.exe"
32elif [ ! -e $SERVER ]; then
33        echo Error: $SERVER not found!
34        exit
35fi
36
37# Assemble stackdump filename
38if [ $# -gt 2 ]; then
39        STACK="$SERVER$3.stackdump"
40else
41        STACK="$SERVER.stackdump"
42fi
43
44# Check if file exists.
45# Try looking under '/log' if it isn't
46
47if [ ! -e $STACK ]; then
48        if [ -e log/$STACK ]; then
49                STACK=log/$STACK
50        else
51                echo Error: $STACK not found!
52                exit
53        fi
54fi
55
56# Finally dump the backtrace
57# If number is given, Sig-plugin format. otherwise, standard stackdump format
58if [ $# -gt 2 ]; then
59        awk '$2 ~ /[0-9a-eA-E]\]$/{print $2}' $STACK | tr -d \[\] | addr2line -f -e $SERVER
60else
61        awk '/^[0-9]/{print $2}' $STACK | addr2line -f -e $SERVER
62fi
Note: See TracBrowser for help on using the browser.