Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Generate core file and get few details from running process
  4.  
  5. if [ $# -ne 1 ]
  6. then
  7. echo "Usage: `basename $0` <PID>"
  8. exit -1
  9. else
  10. pid=$1
  11. fi
  12.  
  13. gdblogfile="$pid.log"
  14. rm $gdblogfile
  15.  
  16. corefile="$pid.core"
  17.  
  18. gdb -batch \
  19. -ex "set logging file $gdblogfile" \
  20. -ex "set logging on" \
  21. -ex "set pagination off" \
  22. -ex "printf \"**\n** Process info for PID=$pid \n** Generated `date`\n\"" \
  23. -ex "printf \"**\n** Core: $corefile \n**\n\"" \
  24. -ex "attach $pid" \
  25. -ex "bt" \
  26. -ex "info proc" \
  27. -ex "printf \"*\n* Libraries \n*\n\"" \
  28. -ex "info sharedlib" \
  29. -ex "printf \"*\n* Memory map \n*\n\"" \
  30. -ex "info target" \
  31. -ex "printf \"*\n* Registers \n*\n\"" \
  32. -ex "info registers" \
  33. -ex "printf \"*\n* Current instructions \n*\n\"" -ex "x/16i \$pc" \
  34. -ex "printf \"*\n* Threads (full) \n*\n\"" \
  35. -ex "info threads" \
  36. -ex "bt" \
  37. -ex "thread apply all bt full" \
  38. -ex "printf \"*\n* Threads (basic) \n*\n\"" \
  39. -ex "info threads" \
  40. -ex "thread apply all bt" \
  41. -ex "printf \"*\n* Done \n*\n\"" \
  42. -ex "generate-core-file $corefile" \
  43. -ex "detach" \
  44. -ex "quit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement