perfetto: handle mock traces setting data about tid and tgid == 0
Legacy traces with fake data don't treat pid (i.e. both tid and tgid) = 0
as anything special. Instead they use it as any other pid.
Support these sort of traces by ensuring that we don't treat them any
specially (apart from the mapping from tid/tgid 0 -> utid/upid 0).
Bug: 118826940
Change-Id: I7f136ac73a16b65cb69969ed55b4bc06507b2f90
diff --git a/src/trace_processor/proto_trace_parser.cc b/src/trace_processor/proto_trace_parser.cc
index fc6ad1f..f765a33 100644
--- a/src/trace_processor/proto_trace_parser.cc
+++ b/src/trace_processor/proto_trace_parser.cc
@@ -443,8 +443,8 @@
}
UniqueTid utid = context_->process_tracker->UpdateThread(ts, pid, 0);
- UniquePid upid = context_->storage->GetThread(utid).upid;
- if (upid == 0) {
+ auto opt_upid = context_->storage->GetThread(utid).upid;
+ if (!opt_upid.has_value()) {
PERFETTO_DLOG("Could not find process associated with utid %" PRIu32
" when parsing mem counters.",
utid);
@@ -461,7 +461,8 @@
// pre-cached |proc_mem_counter_names_| map.
StringId name = proc_mem_counter_names_[field_id];
uint64_t value = counter_values[field_id];
- context_->event_tracker->PushCounter(ts, value, name, upid, RefType::kUpid);
+ context_->event_tracker->PushCounter(ts, value, name, opt_upid.value(),
+ RefType::kUpid);
}
PERFETTO_DCHECK(decoder.IsEndOfBuffer());
@@ -666,8 +667,8 @@
return;
}
UniqueTid utid = context_->process_tracker->UpdateThread(timestamp, pid, 0);
- UniquePid upid = context_->storage->GetThread(utid).upid;
- if (upid == 0) {
+ auto opt_upid = context_->storage->GetThread(utid).upid;
+ if (!opt_upid.has_value()) {
PERFETTO_DLOG("Could not find process associated with utid %" PRIu32
" when parsing rss stat.",
utid);
@@ -676,7 +677,7 @@
}
context_->event_tracker->PushCounter(timestamp, size, rss_members_[member],
- upid, RefType::kUpid);
+ opt_upid.value(), RefType::kUpid);
PERFETTO_DCHECK(decoder.IsEndOfBuffer());
}