Store extra annotations directly on CrashReporterHost. (bug 1338281 part 1, r=billm)
authorDavid Anderson <dvander@alliedmods.net>
Wed, 15 Feb 2017 14:44:29 -0800
changeset 343205 7838f017fe4c83604dd7a93656b7a4b3360ecf2d
parent 343204 5a394ec7d209c5edd03760d056fe5fa8dcb9125d
child 343206 3f8622ecc4e65dff23c8932e44822a060d22d722
push id31372
push usercbook@mozilla.com
push dateThu, 16 Feb 2017 12:16:10 +0000
treeherdermozilla-central@2737f66ad6ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1338281
milestone54.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
Store extra annotations directly on CrashReporterHost. (bug 1338281 part 1, r=billm)
dom/media/gmp/GMPParent.cpp
dom/media/gmp/GMPParent.h
ipc/glue/CrashReporterHost.cpp
ipc/glue/CrashReporterHost.h
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -451,39 +451,34 @@ GMPParent::EnsureProcessLoaded()
 
   nsresult rv = LoadProcess();
 
   return NS_SUCCEEDED(rv);
 }
 
 #ifdef MOZ_CRASHREPORTER
 void
-GMPParent::WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes)
+GMPParent::WriteExtraDataForMinidump()
 {
-  notes.Put(NS_LITERAL_CSTRING("GMPPlugin"), NS_LITERAL_CSTRING("1"));
-  notes.Put(NS_LITERAL_CSTRING("PluginFilename"),
-                               NS_ConvertUTF16toUTF8(mName));
-  notes.Put(NS_LITERAL_CSTRING("PluginName"), mDisplayName);
-  notes.Put(NS_LITERAL_CSTRING("PluginVersion"), mVersion);
+  mCrashReporter->AddNote(NS_LITERAL_CSTRING("GMPPlugin"), NS_LITERAL_CSTRING("1"));
+  mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginFilename"), NS_ConvertUTF16toUTF8(mName));
+  mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginName"), mDisplayName);
+  mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginVersion"), mVersion);
 }
 
 bool
 GMPParent::GetCrashID(nsString& aResult)
 {
   if (!mCrashReporter) {
     return false;
   }
 
-  AnnotationTable notes(4);
-  WriteExtraDataForMinidump(notes);
+  WriteExtraDataForMinidump();
 
-  return mCrashReporter->GenerateCrashReport(
-    OtherPid(),
-    &notes,
-    &aResult);
+  return mCrashReporter->GenerateCrashReport(OtherPid(), &aResult);
 }
 
 static void
 GMPNotifyObservers(const uint32_t aPluginID, const nsACString& aPluginName, const nsAString& aPluginDumpID)
 {
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   nsCOMPtr<nsIWritablePropertyBag2> propbag =
     do_CreateInstance("@mozilla.org/hash-property-bag;1");
--- a/dom/media/gmp/GMPParent.h
+++ b/dom/media/gmp/GMPParent.h
@@ -156,17 +156,17 @@ private:
 
   RefPtr<GeckoMediaPluginServiceParent> mService;
   bool EnsureProcessLoaded();
   RefPtr<GenericPromise> ReadGMPMetaData();
   RefPtr<GenericPromise> ReadGMPInfoFile(nsIFile* aFile);
   RefPtr<GenericPromise> ParseChromiumManifest(const nsAString& aJSON); // Main thread.
   RefPtr<GenericPromise> ReadChromiumManifestFile(nsIFile* aFile); // GMP thread.
 #ifdef MOZ_CRASHREPORTER
-  void WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes);
+  void WriteExtraDataForMinidump();
   bool GetCrashID(nsString& aResult);
 #endif
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
   mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem) override;
 
   mozilla::ipc::IPCResult RecvPGMPStorageConstructor(PGMPStorageParent* actor) override;
   PGMPStorageParent* AllocPGMPStorageParent() override;
--- a/ipc/glue/CrashReporterHost.cpp
+++ b/ipc/glue/CrashReporterHost.cpp
@@ -23,17 +23,16 @@ CrashReporterHost::CrashReporterHost(Gec
    mShmem(aShmem),
    mStartTime(::time(nullptr))
 {
 }
 
 #ifdef MOZ_CRASHREPORTER
 bool
 CrashReporterHost::GenerateCrashReport(RefPtr<nsIFile> aCrashDump,
-                                       const AnnotationTable* aExtraNotes,
                                        nsString* aOutMinidumpID)
 {
   nsString dumpID;
   if (!CrashReporter::GetIDFromMinidump(aCrashDump, dumpID)) {
     return false;
   }
 
   CrashReporter::AnnotationTable notes;
@@ -56,19 +55,17 @@ CrashReporterHost::GenerateCrashReport(R
   }
   notes.Put(NS_LITERAL_CSTRING("ProcessType"), type);
 
   char startTime[32];
   SprintfLiteral(startTime, "%lld", static_cast<long long>(mStartTime));
   notes.Put(NS_LITERAL_CSTRING("StartupTime"), nsDependentCString(startTime));
 
   CrashReporterMetadataShmem::ReadAppNotes(mShmem, &notes);
-  if (aExtraNotes) {
-    CrashReporter::AppendExtraData(dumpID, *aExtraNotes);
-  }
+  CrashReporter::AppendExtraData(dumpID, mExtraNotes);
   CrashReporter::AppendExtraData(dumpID, notes);
 
   NotifyCrashService(mProcessType, dumpID, &notes);
 
   *aOutMinidumpID = dumpID;
   return true;
 }
 
@@ -264,12 +261,18 @@ CrashReporterHost::NotifyCrashService(Ge
     default:
       NS_ERROR("unknown process type");
       return;
   }
 
   AsyncAddCrash(processType, crashType, aChildDumpID);
   Telemetry::Accumulate(Telemetry::SUBPROCESS_CRASHES_WITH_DUMP, telemetryKey, 1);
 }
+
+void
+CrashReporterHost::AddNote(const nsCString& aKey, const nsCString& aValue)
+{
+  mExtraNotes.Put(aKey, aValue);
+}
 #endif
 
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/glue/CrashReporterHost.h
+++ b/ipc/glue/CrashReporterHost.h
@@ -25,46 +25,46 @@ class CrashReporterHost
   typedef mozilla::ipc::Shmem Shmem;
   typedef CrashReporter::AnnotationTable AnnotationTable;
 
 public:
   CrashReporterHost(GeckoProcessType aProcessType, const Shmem& aShmem);
 
 #ifdef MOZ_CRASHREPORTER
   bool GenerateCrashReport(base::ProcessId aPid,
-                           const AnnotationTable* aExtraNotes = nullptr,
                            nsString* aOutMinidumpID = nullptr)
   {
     RefPtr<nsIFile> crashDump;
     if (!XRE_TakeMinidumpForChild(aPid, getter_AddRefs(crashDump), nullptr)) {
       return false;
     }
-    return GenerateCrashReport(crashDump, aExtraNotes, aOutMinidumpID);
+    return GenerateCrashReport(crashDump, aOutMinidumpID);
   }
 
   // This is a static helper function to notify the crash service that a
   // crash has occurred. When PCrashReporter is removed, we can make this
   // a member function. This can be called from any thread, and if not
   // called from the main thread, will post a synchronous message to the
   // main thread.
   static void NotifyCrashService(
     GeckoProcessType aProcessType,
     const nsString& aChildDumpID,
     const AnnotationTable* aNotes);
+
+  void AddNote(const nsCString& aKey, const nsCString& aValue);
 #endif
 
 private:
-  bool GenerateCrashReport(RefPtr<nsIFile> aCrashDump,
-                           const AnnotationTable* aExtraNotes,
-                           nsString* aOutMinidumpID);
+  bool GenerateCrashReport(RefPtr<nsIFile> aCrashDump, nsString* aOutMinidumpID);
   static void AsyncAddCrash(int32_t aProcessType, int32_t aCrashType,
                             const nsString& aChildDumpID);
 
 private:
   GeckoProcessType mProcessType;
   Shmem mShmem;
   time_t mStartTime;
+  AnnotationTable mExtraNotes;
 };
 
 } // namespace ipc
 } // namespace mozilla
 
 #endif // mozilla_ipc_CrashReporterHost_h