trace_processor: associate rss stat and mem info events with process

Instead of associating these events with utids (which causes a lot of
duplicate counter tracks to appear), deal with them per-process instead.
When we have the args table, we will also associate the utid.

Bug: 119118907
Change-Id: Idc1d5f0f8eece1cdbdfd43a964143a803c16399b
diff --git a/src/trace_processor/proto_trace_parser.cc b/src/trace_processor/proto_trace_parser.cc
index 815deb1..f7e6a12 100644
--- a/src/trace_processor/proto_trace_parser.cc
+++ b/src/trace_processor/proto_trace_parser.cc
@@ -442,7 +442,14 @@
     }
   }
 
-  UniquePid upid = context_->process_tracker->UpdateProcess(pid);
+  UniqueTid utid = context_->process_tracker->UpdateThread(ts, pid, 0);
+  UniquePid upid = context_->storage->GetThread(utid).upid;
+  if (upid == 0) {
+    PERFETTO_DLOG("Could not find process associated with utid %" PRIu32
+                  " when parsing mem counters.",
+                  utid);
+    return;
+  }
 
   // Skip field_id 0 (invalid) and 1 (pid).
   for (size_t field_id = 2; field_id < counter_values.size(); field_id++) {
@@ -658,8 +665,16 @@
     return;
   }
   UniqueTid utid = context_->process_tracker->UpdateThread(timestamp, pid, 0);
+  UniquePid upid = context_->storage->GetThread(utid).upid;
+  if (upid == 0) {
+    PERFETTO_DLOG("Could not find process associated with utid %" PRIu32
+                  " when parsing rss stat.",
+                  utid);
+    return;
+  }
+
   context_->event_tracker->PushCounter(timestamp, size, rss_members_[member],
-                                       utid, RefType::kUtid);
+                                       upid, RefType::kUpid);
   PERFETTO_DCHECK(decoder.IsEndOfBuffer());
 }