pinboost_debugme.py 986 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python
  2. import sys, os, tempfile
  3. pid = int(sys.argv[1])
  4. mytid = int(sys.argv[2])
  5. # FIXME: optionally attach GDB to each thread since GDB won't find Pintool threads by itself
  6. #for tid in os.listdir('/proc/%d/task' % pid):
  7. # tid = int(tid)
  8. # print >> sys.stderr, "Starting screen with GDB for thread %d; resume using screen -r gdb-%d" % (tid, tid)
  9. # os.system('screen -d -m -S gdb-%d -- gdb $SNIPER_ROOT/pin_kit/intel64/bin/pinbin %d' % (tid, tid))
  10. cmdfile = '/tmp/gdbcmd-%d' % mytid
  11. open(cmdfile, 'w').write('''\
  12. # Continue execution past the sleep in pinboost_debugme() and into the real exception
  13. continue
  14. # Show a backtrace at the exception
  15. backtrace
  16. ''')
  17. print >> sys.stderr
  18. print >> sys.stderr, "[PINBOOST] Starting screen session with GDB attached to thread %d; resume using" % mytid
  19. print >> sys.stderr, "# screen -r gdb-%d" % mytid
  20. os.system('screen -d -m -S gdb-%d -- gdb -command=%s $SNIPER_ROOT/pin_kit/intel64/bin/pinbin %d' % (mytid, cmdfile, mytid))