stackdump 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # !TODO upd me
  3. case "$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. *|""|help)
  13. echo "Usage 1: ${0##*/} [server-type] [txt/sql]"
  14. echo Server type can be map, login, or char. Examples:
  15. echo "$ ./${0##*/} map"
  16. echo "$ ./${0##*/} login sql"
  17. echo
  18. echo "Usage 2: ${0##*/} [server-type] [txt/sql] [number]"
  19. echo Server type can be map, login, or char. Examples:
  20. echo "$ ./${0##*/} map txt 0001"
  21. echo "$ ./${0##*/} login sql 0002"
  22. echo
  23. echo Note: Dump files inside /log will also be scanned.
  24. exit
  25. ;;
  26. esac
  27. # Check if server file needs .exe (Windows/Cygwin)
  28. if [ -e $SERVER.exe ]; then
  29. SERVER="$SERVER.exe"
  30. elif [ ! -e $SERVER ]; then
  31. echo Error: $SERVER not found!
  32. exit
  33. fi
  34. # Assemble stackdump filename
  35. if [ $# -gt 2 ]; then
  36. STACK="$SERVER$3.stackdump"
  37. else
  38. STACK="$SERVER.stackdump"
  39. fi
  40. # Check if file exists.
  41. # Try looking under '/log' if it isn't
  42. if [ ! -e $STACK ]; then
  43. if [ -e log/$STACK ]; then
  44. STACK=log/$STACK
  45. else
  46. echo Error: $STACK not found!
  47. exit
  48. fi
  49. fi
  50. # Finally dump the backtrace
  51. # If number is given, Sig-plugin format. otherwise, standard stackdump format
  52. if [ $# -gt 2 ]; then
  53. awk '$2 ~ /[0-9a-eA-E]\]$/{print $2}' $STACK | tr -d \[\] | addr2line -f -e $SERVER
  54. else
  55. awk '/^[0-9]/{print $2}' $STACK | addr2line -f -e $SERVER
  56. fi