1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#!/usr/bin/python3
import sys
import subprocess
import datetime
import os
home = os.path.expanduser("~")
if len(sys.argv) != 2:
print("""
Run as:
cin-debug <process-name>
""")
quit()
pname = sys.argv[1]
pid = subprocess.check_output(["pidof", pname]).decode('utf-8')
logfile = "%s/%s-%s.log" % (home, pname, datetime.datetime.now().strftime("%Y-%m-%d-%l:%M:%S"))
gdb_script = \
"""
set logging file %s
set logging on
set pagination off
attach %s
define hook-stop
thread apply all bt
quit
end
continue
""" % (logfile, pid)
os.system("echo '%s' | sudo gdb" % gdb_script)
quit()
|