trace_processor: extract actual argv0 from Chrome cmdline

Chrome child processes overwrites /proc/self/cmdline and replaces all
'\0' with ' ', which makes argv0 contain the full cmdline. This makes
the UI display incorrect and unusably long track group names.

This change adds a heuristics in the trace processor by looking for
"/chrome " in argv0 and extracts the actual argv0 for Chrome processes.

Bug: 208788164
Change-Id: I869d6a08d5aa6cd82b54f87a064a4694eb108d16
diff --git a/src/trace_processor/importers/proto/system_probes_parser.cc b/src/trace_processor/importers/proto/system_probes_parser.cc
index 5072bad..952184a 100644
--- a/src/trace_processor/importers/proto/system_probes_parser.cc
+++ b/src/trace_processor/importers/proto/system_probes_parser.cc
@@ -306,6 +306,14 @@
     } else {
       auto raw_cmdline = proc.cmdline();
       base::StringView argv0 = raw_cmdline ? *raw_cmdline : base::StringView();
+      // Chrome child process overwrites /proc/self/cmdline and replaces all
+      // '\0' with ' '. This makes argv0 contain the full command line. Extract
+      // the actual argv0 if it's Chrome.
+      static const char kChromeBinary[] = "/chrome ";
+      auto pos = argv0.find(kChromeBinary);
+      if (pos != base::StringView::npos) {
+        argv0 = argv0.substr(0, pos + strlen(kChromeBinary) - 1);
+      }
 
       std::string cmdline_str;
       for (auto cmdline_it = raw_cmdline; cmdline_it;) {