-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_stack_vec
executable file
·40 lines (37 loc) · 1.03 KB
/
get_stack_vec
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
#!/usr/bin/env python2.7
import subprocess
import argparse
import json
import sys
import os
LLDB_COMMAND = os.path.dirname(os.path.realpath(__file__))+"/debugger %s \"%s\""
def main(args):
infile,m = (args.file,subprocess.check_output(LLDB_COMMAND % (args.file, args.program), shell=True))
newstack = []
b = m.split("\n")
start1 = False
start = False
for i in b[2:]:
iu = i.strip().rstrip()
ij = iu.find("thread backtrace all")
if ij != -1:
start1 = True
continue
if start1 == True:
if iu.find("thread #") != -1:
start = True
continue
if len(iu) > 0 and (iu[0] == '#' or iu[0] == '*') and start == True:
a = iu.find("#")
newstack.append(iu[a+1:])
umap = {}
umap['file'] = args.file
umap['stack'] = newstack
print json.dumps(umap)
return 0
if __name__ == '__main__':
parser = argparse.ArgumentParser("getstacks")
parser.add_argument("program", type=str)
parser.add_argument("file", type=str, help="input file")
args = parser.parse_args()
sys.exit(main(args))