feat: read_events support with and without stacktraces

This commit is contained in:
Maarten A. Breddels 2021-01-06 19:59:29 +01:00
parent 43d9d470fc
commit 842015ba49
2 changed files with 5 additions and 5 deletions

View File

@ -136,15 +136,12 @@ def gil2trace(input, verbose=1, take_probe="python:take_gil$", take_probe_return
time_on_gil = defaultdict(int)
time_wait_gil = defaultdict(int)
jitter = 1e-3 # add 1 ns for proper sorting
for header in input:
for header, _ in read_events(input):
try:
header = header.rstrip()
if verbose >= 2:
print(header)
# just ignore stack traces and seperators
if not header or header.split()[0].isdigit():
continue
# parse the header
comm, pid, cpu, time, event, *other = header.split()
pid = int(pid)
@ -422,7 +419,7 @@ def perf2trace(input, verbose=1, store_runing=False, store_sleeping=True, all_tr
except BrokenPipeError:
break
except:
print("error on line", header, other, file=sys.stderr)
print("error on line", repr(header), stacktrace, file=sys.stderr)
raise

View File

@ -3,6 +3,9 @@ def read_events(input):
stacktrace = []
header = None
for line in input:
if first_line and line and line[0].isspace():
yield line, None
continue
line = line.strip()
if first_line:
header = line