stackdump 1.3 KB

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