probes: invalidate seen pids on task_rename event

Task rename events on Android often signal also a change in the name
of the process (think zygote specializing to become an app - this
changes both the name of the main thread and the name of the process).
Since we don't rescrape a pid once we've ever seen it (modulo
incremental state invalidation), we never see the updated names for
these processes either.

Rescrape any pid which undergoes a task rename by removing it from the
seen pids. This is a heuristic (as processes many rename without thread
renames and threads which are not the main process often get renamed)
but it is a good one as it covers the cases we are most interested in.

Bug: 131733942
Bug: 130543265
Change-Id: If20c3518391f8b766b8080c23886cbc145fcae59
diff --git a/src/traced/probes/probes_producer.cc b/src/traced/probes/probes_producer.cc
index 202fadc..ebe6867 100644
--- a/src/traced/probes/probes_producer.cc
+++ b/src/traced/probes/probes_producer.cc
@@ -428,8 +428,13 @@
     if (it == session_data_sources_.end() || it->first != last_session_id) {
       bool has_inodes = metadata && !metadata->inode_and_device.empty();
       bool has_pids = metadata && !metadata->pids.empty();
+      bool has_rename_pids = metadata && !metadata->rename_pids.empty();
       if (has_inodes && inode_data_source)
         inode_data_source->OnInodes(metadata->inode_and_device);
+      // Ordering the rename pids before the seen pids is important so that any
+      // renamed processes get scraped in the OnPids call.
+      if (has_rename_pids && ps_data_source)
+        ps_data_source->OnRenamePids(metadata->rename_pids);
       if (has_pids && ps_data_source)
         ps_data_source->OnPids(metadata->pids);
       if (metadata)