Update chrome crash reports to require the exe name

When invoked from chrome we execute too late to get any of the crashing
process' info as it's already been cleaned up by the kernel. So, require
chrome to pass along the name too

BUG=chromium:216523
TEST=manual invocation of /sbin/crash_reporter, verified supplied name gets
  used & it doesn't check /proc for any info

Change-Id: Id74cae3ba93426bd0ac74959741a11baf83c2694
Reviewed-on: https://gerrit.chromium.org/gerrit/58929
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
diff --git a/crash_reporter/chrome_collector.cc b/crash_reporter/chrome_collector.cc
index 20170bd..d8250f7 100644
--- a/crash_reporter/chrome_collector.cc
+++ b/crash_reporter/chrome_collector.cc
@@ -40,7 +40,8 @@
 
 bool ChromeCollector::HandleCrash(const std::string &file_path,
                                   const std::string &pid_string,
-                                  const std::string &uid_string) {
+                                  const std::string &uid_string,
+                                  const std::string &exe_name) {
   if (!is_feedback_allowed_function_())
     return true;
 
@@ -53,13 +54,7 @@
     return false;
   }
 
-  std::string exec;
-  if (!GetExecutableBaseNameFromPid(pid, &exec)) {
-    LOG(ERROR) << "Can't get executable name for pid " << pid;
-    return false;
-  }
-
-  std::string dump_basename = FormatDumpBasename(exec, time(NULL), pid);
+  std::string dump_basename = FormatDumpBasename(exe_name, time(NULL), pid);
   FilePath meta_path = GetCrashPath(dir, dump_basename, "meta");
   FilePath minidump_path = GetCrashPath(dir, dump_basename, "dmp");
   FilePath log_path = GetCrashPath(dir, dump_basename, "log");
@@ -75,11 +70,11 @@
     return false;
   }
 
-  if (GetLogContents(FilePath(log_config_path_), exec, log_path))
+  if (GetLogContents(FilePath(log_config_path_), exe_name, log_path))
     AddCrashMetaData("log", log_path.value());
 
   // We're done.
-  WriteCrashMetaData(meta_path, exec, minidump_path.value());
+  WriteCrashMetaData(meta_path, exe_name, minidump_path.value());
 
   return true;
 }
diff --git a/crash_reporter/chrome_collector.h b/crash_reporter/chrome_collector.h
index 223bb00..e25cd86 100644
--- a/crash_reporter/chrome_collector.h
+++ b/crash_reporter/chrome_collector.h
@@ -21,7 +21,7 @@
 
   // Handle a specific chrome crash.  Returns true on success.
   bool HandleCrash(const std::string &file_path, const std::string &pid_string,
-                   const std::string &uid_string);
+                   const std::string &uid_string, const std::string &exe_name);
 
  private:
   friend class ChromeCollectorTest;
diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc
index 0334360..134e8e4 100644
--- a/crash_reporter/crash_reporter.cc
+++ b/crash_reporter/crash_reporter.cc
@@ -38,6 +38,7 @@
 DEFINE_string(chrome, "", "Chrome crash dump file");
 DEFINE_string(pid, "", "PID of crashing process");
 DEFINE_string(uid, "", "UID of crashing process");
+DEFINE_string(exe, "", "Executable name of crashing process");
 #pragma GCC diagnostic error "-Wstrict-aliasing"
 
 static const char kCrashCounterHistogram[] = "Logging.CrashCounter";
@@ -183,10 +184,11 @@
   CHECK(!FLAGS_chrome.empty()) << "--chrome= must be set";
   CHECK(!FLAGS_pid.empty()) << "--pid= must be set";
   CHECK(!FLAGS_uid.empty()) << "--uid= must be set";
+  CHECK(!FLAGS_exe.empty()) << "--exe= must be set";
 
   chromeos::LogToString(true);
   bool handled = chrome_collector->HandleCrash(FLAGS_chrome, FLAGS_pid,
-                                               FLAGS_uid);
+                                               FLAGS_uid, FLAGS_exe);
   chromeos::LogToString(false);
   if (!handled)
     return 1;