Bug 1514044 - part 2 - change CrashReporterHost to use GeckoProcessTypes.h; r=gsvelto
authorNathan Froyd <froydnj@mozilla.com>
Thu, 10 Jan 2019 10:52:51 -0500
changeset 453269 65f14286370124a5dd07b810c1bb967cf3b181f1
parent 453268 1abd03bcbfa3520c8c0263606c792183ddaa073d
child 453270 de7c04ff60015787b787416797252148902e4bfb
push id35351
push userccoroiu@mozilla.com
push dateThu, 10 Jan 2019 21:42:10 +0000
treeherdermozilla-central@ed68c008e5d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto
bugs1514044
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1514044 - part 2 - change CrashReporterHost to use GeckoProcessTypes.h; r=gsvelto
ipc/glue/CrashReporterHost.cpp
toolkit/crashreporter/CrashAnnotations.yaml
--- a/ipc/glue/CrashReporterHost.cpp
+++ b/ipc/glue/CrashReporterHost.cpp
@@ -72,33 +72,34 @@ int32_t CrashReporterHost::GetCrashType(
 
 bool CrashReporterHost::FinalizeCrashReport() {
   MOZ_ASSERT(!mFinalized);
   MOZ_ASSERT(HasMinidump());
 
   CrashReporter::AnnotationTable annotations;
 
   nsAutoCString type;
-  switch (mProcessType) {
-    case GeckoProcessType_Content:
-      type = NS_LITERAL_CSTRING("content");
-      break;
-    case GeckoProcessType_Plugin:
-    case GeckoProcessType_GMPlugin:
-      type = NS_LITERAL_CSTRING("plugin");
-      break;
-    case GeckoProcessType_GPU:
-      type = NS_LITERAL_CSTRING("gpu");
-      break;
-    case GeckoProcessType_RDD:
-      type = NS_LITERAL_CSTRING("rdd");
-      break;
+  // The gecko media plugin and normal plugin processes are lumped together
+  // as a historical artifact.
+  if (mProcessType == GeckoProcessType_GMPlugin) {
+    type.AssignLiteral("plugin");
+  } else {
+    // This check will pick up some cases that will never happen (e.g. IPDL
+    // unit tests), but that's OK.
+    switch (mProcessType) {
+#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name) \
+      case GeckoProcessType_##enum_name: \
+        type.AssignLiteral(string_name); \
+        break;
+#include "mozilla/GeckoProcessTypes.h"
+#undef GECKO_PROCESS_TYPE
     default:
       NS_ERROR("unknown process type");
       break;
+    }
   }
   annotations[CrashReporter::Annotation::ProcessType] = type;
 
   char startTime[32];
   SprintfLiteral(startTime, "%lld", static_cast<long long>(mStartTime));
   annotations[CrashReporter::Annotation::StartupTime] =
       nsDependentCString(startTime);
 
@@ -139,43 +140,53 @@ bool CrashReporterHost::FinalizeCrashRep
   }
 
   int32_t processType;
   nsCString telemetryKey;
 
   switch (aProcessType) {
     case GeckoProcessType_Content:
       processType = nsICrashService::PROCESS_TYPE_CONTENT;
-      telemetryKey.AssignLiteral("content");
       break;
     case GeckoProcessType_Plugin:
       processType = nsICrashService::PROCESS_TYPE_PLUGIN;
-      if (aCrashType == nsICrashService::CRASH_TYPE_HANG) {
-        telemetryKey.AssignLiteral("pluginhang");
-      } else {
-        telemetryKey.AssignLiteral("plugin");
-      }
       break;
     case GeckoProcessType_GMPlugin:
       processType = nsICrashService::PROCESS_TYPE_GMPLUGIN;
-      telemetryKey.AssignLiteral("gmplugin");
       break;
     case GeckoProcessType_GPU:
       processType = nsICrashService::PROCESS_TYPE_GPU;
-      telemetryKey.AssignLiteral("gpu");
       break;
     case GeckoProcessType_RDD:
       processType = nsICrashService::PROCESS_TYPE_RDD;
-      telemetryKey.AssignLiteral("rdd");
       break;
     default:
       NS_ERROR("unknown process type");
       return;
   }
 
+  if (aProcessType == GeckoProcessType_Plugin &&
+      aCrashType == nsICrashService::CRASH_TYPE_HANG) {
+    telemetryKey.AssignLiteral("pluginhang");
+  } else {
+    switch (aProcessType) {
+#define GECKO_PROCESS_TYPE(enum_name, string_name, xre_name) \
+      case GeckoProcessType_##enum_name:                     \
+        telemetryKey.AssignLiteral(string_name);             \
+        break;
+#include "mozilla/GeckoProcessTypes.h"
+#undef GECKO_PROCESS_TYPE
+      // We can't really hit this, thanks to the above switch, but having it here
+      // will placate the compiler.
+      default:
+        NS_ERROR("unknown process type");
+        return;
+    }
+  }
+
   RefPtr<Promise> promise;
   crashService->AddCrash(processType, aCrashType, aChildDumpID,
                          getter_AddRefs(promise));
   Telemetry::Accumulate(Telemetry::SUBPROCESS_CRASHES_WITH_DUMP, telemetryKey,
                         1);
 }
 
 void CrashReporterHost::AddAnnotation(CrashReporter::Annotation aKey,
--- a/toolkit/crashreporter/CrashAnnotations.yaml
+++ b/toolkit/crashreporter/CrashAnnotations.yaml
@@ -557,18 +557,18 @@ PluginName:
 PluginVersion:
   description: >
     Version of a plugin, only the process holding the plugin has this
     annotation.
   type: string
 
 ProcessType:
   description: >
-    Type of the process that crashed, can hold the values "content", "plugin",
-    "gpu" or "rdd" currently.
+    Type of the process that crashed, the possible values are defined in
+    GeckoProcessTypes.h.
   type: string
 
 ProductName:
   description: >
     Application name (e.g. Firefox).
   type: string
   ping: true