def debugTrace(trace):
t = perfetto_trace_pb2.Trace()
with open(trace, "rb") as f:
t.ParseFromString(f.read())
for packet in t.packet:
if packet.HasField("process_tree"):
process_tree = packet.process_tree
for process in process_tree.processes:
pid = process.pid
if pid not in process_dict:
process_dict[pid] = {
"threads": {}
}
for thread in process_tree.threads:
tid = thread.tid
tgid = thread.tgid
thread_name =
thread.name if thread.HasField("name") else "Unknown"
if tgid in process_dict:
process_dict[tgid]["threads"][tid] = thread_name