-
Notifications
You must be signed in to change notification settings - Fork 13
/
gdbpmp.py
executable file
·49 lines (41 loc) · 1.14 KB
/
gdbpmp.py
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
43
44
45
46
47
48
49
#!/usr/bin/env python3
# Copyright (c) 2017 Mark Nelson
import sys
import os
try:
import common
except ImportError:
sys.path.append(os.path.dirname(__file__))
import common
import gdbtypes
import subprocess
import signal
import time
def main():
ctx = common.parse_args()
if ctx.input:
threads = common.load_threads(ctx.input)
if ctx.invert:
common.print_inverted_callgraph(ctx, threads)
else:
common.print_callgraph(ctx, threads)
elif ctx.pid:
this_path = os.path.realpath(__file__)
pargs = ' '.join(sys.argv[1:])
args = [ctx.gdb_path, "-q", "--ex", "source %s" % this_path, "--ex", "gdbpmp %s" % pargs]
proc = subprocess.Popen(args)
try:
while proc.poll() is None:
time.sleep(0.1)
except KeyboardInterrupt:
proc.send_signal(signal.SIGINT)
while proc.poll() is None:
time.sleep(0.1)
if __name__ == "__main__":
try:
import tracer
except ImportError:
main()
sys.exit(0)
sys.setrecursionlimit(5000)
tracer.ProfileCommand()