File: cin-debug

package info (click to toggle)
cinnamon 6.4.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,300 kB
  • sloc: javascript: 54,298; ansic: 51,499; python: 21,971; xml: 2,803; sh: 96; makefile: 27; perl: 13
file content (42 lines) | stat: -rwxr-xr-x 625 bytes parent folder | download | duplicates (5)
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()