16 logs = collections.deque(maxlen=500)
18 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
19 stderr=subprocess.STDOUT,
20 encoding=
'ISO-8859-1')
21 for line
in iter(proc.stdout.readline,
''):
22 sys.stdout.write(line)
25 print(
'Command exited with code %s' % proc.returncode)
28 subprocess.check_call([
'addr2line',
'--help'],
29 stdout=subprocess.DEVNULL,
30 stderr=subprocess.DEVNULL)
32 print(
'addr2line not found on PATH. Skipping symbolization.')
45 stack_line =
r'^(?P<path>.+)\(\+?(?P<addr>.*)\) ?\[(?P<addr2>.+)\]'
50 extra_path =
r'/.*\.\./'
61 m = re.search(stack_line, line)
64 print(
'#######################################')
65 print(
'symbolized stacktrace follows')
66 print(
'#######################################')
69 path = m.group(
'path')
70 addr = m.group(
'addr')
71 addr2 = m.group(
'addr2')
72 if os.path.exists(path):
73 if not addr
or not addr.startswith(
'0x'):
76 sym = subprocess.check_output([
77 'addr2line',
'--demangle',
'--pretty-print',
'--functions',
80 except subprocess.CalledProcessError:
85 if sym
and not sym.startswith(
'?'):
86 if path.startswith(basedir):
87 path = path[
len(basedir) + 1:]
88 sym = re.sub(extra_path,
'', sym)
89 line = path +
' ' + sym
92 sys.exit(proc.returncode)
95if __name__ ==
'__main__':
97 print(
'USAGE: %s working_dir cmd_and_args...' % sys.argv[0],
100 main(sys.argv[1], sys.argv[2:])
def print(*args, **kwargs)
static DecodeResult decode(std::string path)