Store the child process thread id in CrashReporterHost. (bug 1338281 part 2, r=billm)
authorDavid Anderson <dvander@alliedmods.net>
Wed, 15 Feb 2017 14:44:29 -0800
changeset 343206 3f8622ecc4e65dff23c8932e44822a060d22d722
parent 343205 7838f017fe4c83604dd7a93656b7a4b3360ecf2d
child 343207 5d5c80258cb2c6e5d84c70ea832a2fcd708afde3
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 the child process thread id in CrashReporterHost. (bug 1338281 part 2, r=billm)
dom/media/gmp/GMPParent.cpp
dom/media/gmp/GMPParent.h
dom/media/gmp/PGMP.ipdl
gfx/ipc/GPUChild.cpp
gfx/ipc/GPUChild.h
gfx/ipc/PGPU.ipdl
ipc/glue/CrashReporterClient.cpp
ipc/glue/CrashReporterClient.h
ipc/glue/CrashReporterHost.cpp
ipc/glue/CrashReporterHost.h
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -531,22 +531,23 @@ GMPParent::ActorDestroy(ActorDestroyReas
     MOZ_ASSERT(mState == GMPStateClosing);
     DeleteProcess();
     // Note: final destruction will be Dispatched to ourself
     mService->ReAddOnGMPThread(self);
   }
 }
 
 mozilla::ipc::IPCResult
-GMPParent::RecvInitCrashReporter(Shmem&& aShmem)
+GMPParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId)
 {
 #ifdef MOZ_CRASHREPORTER
   mCrashReporter = MakeUnique<ipc::CrashReporterHost>(
     GeckoProcessType_GMPlugin,
-    aShmem);
+    aShmem,
+    aThreadId);
 #endif
   return IPC_OK();
 }
 
 PGMPStorageParent*
 GMPParent::AllocPGMPStorageParent()
 {
   GMPStorageParent* p = new GMPStorageParent(mNodeId, this);
--- a/dom/media/gmp/GMPParent.h
+++ b/dom/media/gmp/GMPParent.h
@@ -161,17 +161,17 @@ private:
   RefPtr<GenericPromise> ParseChromiumManifest(const nsAString& aJSON); // Main thread.
   RefPtr<GenericPromise> ReadChromiumManifestFile(nsIFile* aFile); // GMP thread.
 #ifdef MOZ_CRASHREPORTER
   void WriteExtraDataForMinidump();
   bool GetCrashID(nsString& aResult);
 #endif
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
-  mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem) override;
+  mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem, const NativeThreadId& aThreadId) override;
 
   mozilla::ipc::IPCResult RecvPGMPStorageConstructor(PGMPStorageParent* actor) override;
   PGMPStorageParent* AllocPGMPStorageParent() override;
   bool DeallocPGMPStorageParent(PGMPStorageParent* aActor) override;
 
   mozilla::ipc::IPCResult RecvPGMPTimerConstructor(PGMPTimerParent* actor) override;
   PGMPTimerParent* AllocPGMPTimerParent() override;
   bool DeallocPGMPTimerParent(PGMPTimerParent* aActor) override;
--- a/dom/media/gmp/PGMP.ipdl
+++ b/dom/media/gmp/PGMP.ipdl
@@ -13,17 +13,17 @@ namespace mozilla {
 namespace gmp {
 
 intr protocol PGMP
 {
   manages PGMPTimer;
   manages PGMPStorage;
 
 parent:
-  async InitCrashReporter(Shmem shmem);
+  async InitCrashReporter(Shmem shmem, NativeThreadId threadId);
   async PGMPTimer();
   async PGMPStorage();
 
   async PGMPContentChildDestroyed();
 
 child:
   async CrashPluginNow();
   intr StartPlugin(nsString adapter);
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -116,20 +116,23 @@ GPUChild::RecvGraphicsError(const nsCStr
     std::stringstream message;
     message << "GP+" << aError.get();
     lf->UpdateStringsVector(message.str());
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-GPUChild::RecvInitCrashReporter(Shmem&& aShmem)
+GPUChild::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId)
 {
 #ifdef MOZ_CRASHREPORTER
-  mCrashReporter = MakeUnique<ipc::CrashReporterHost>(GeckoProcessType_GPU, aShmem);
+  mCrashReporter = MakeUnique<ipc::CrashReporterHost>(
+    GeckoProcessType_GPU,
+    aShmem,
+    aThreadId);
 #endif
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvNotifyUiObservers(const nsCString& aTopic)
 {
   nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
--- a/gfx/ipc/GPUChild.h
+++ b/gfx/ipc/GPUChild.h
@@ -37,17 +37,17 @@ public:
   void EnsureGPUReady();
 
   // gfxVarReceiver overrides.
   void OnVarChanged(const GfxVarUpdate& aVar) override;
 
   // PGPUChild overrides.
   mozilla::ipc::IPCResult RecvInitComplete(const GPUDeviceData& aData) override;
   mozilla::ipc::IPCResult RecvReportCheckerboard(const uint32_t& aSeverity, const nsCString& aLog) override;
-  mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem) override;
+  mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem, const NativeThreadId& aThreadId) override;
   mozilla::ipc::IPCResult RecvAccumulateChildHistogram(InfallibleTArray<Accumulation>&& aAccumulations) override;
   mozilla::ipc::IPCResult RecvAccumulateChildKeyedHistogram(InfallibleTArray<KeyedAccumulation>&& aAccumulations) override;
   mozilla::ipc::IPCResult RecvUpdateChildScalars(InfallibleTArray<ScalarAction>&& aScalarActions) override;
   mozilla::ipc::IPCResult RecvUpdateChildKeyedScalars(InfallibleTArray<KeyedScalarAction>&& aScalarActions) override;
   void ActorDestroy(ActorDestroyReason aWhy) override;
   mozilla::ipc::IPCResult RecvGraphicsError(const nsCString& aError) override;
   mozilla::ipc::IPCResult RecvNotifyUiObservers(const nsCString& aTopic) override;
   mozilla::ipc::IPCResult RecvNotifyDeviceReset() override;
--- a/gfx/ipc/PGPU.ipdl
+++ b/gfx/ipc/PGPU.ipdl
@@ -10,16 +10,17 @@ include protocol PImageBridge;
 include protocol PVRManager;
 include protocol PVsyncBridge;
 include protocol PUiCompositorController;
 include protocol PVideoDecoderManager;
 
 using base::ProcessId from "base/process.h";
 using mozilla::TimeDuration from "mozilla/TimeStamp.h";
 using mozilla::CSSToLayoutDeviceScale from "Units.h";
+using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/2D.h";
 using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h";
 using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::KeyedAccumulation from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::ScalarAction from "mozilla/TelemetryComms.h";
 using mozilla::Telemetry::KeyedScalarAction from "mozilla/TelemetryComms.h";
 
 namespace mozilla {
@@ -97,17 +98,17 @@ child:
   async InitComplete(GPUDeviceData data);
 
   // Sent when APZ detects checkerboarding and apz checkerboard reporting is enabled.
   async ReportCheckerboard(uint32_t severity, nsCString log);
 
   // Graphics errors, analogous to PContent::GraphicsError
   async GraphicsError(nsCString aError);
 
-  async InitCrashReporter(Shmem shmem);
+  async InitCrashReporter(Shmem shmem, NativeThreadId threadId);
 
   // Have a message be broadcasted to the UI process by the UI process
   // observer service.
   async NotifyUiObservers(nsCString aTopic);
 
   // Messages for reporting telemetry to the UI process.
   async AccumulateChildHistogram(Accumulation[] accumulations);
   async AccumulateChildKeyedHistogram(KeyedAccumulation[] accumulations);
--- a/ipc/glue/CrashReporterClient.cpp
+++ b/ipc/glue/CrashReporterClient.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CrashReporterClient.h"
 #include "CrashReporterMetadataShmem.h"
 #include "nsISupportsImpl.h"
 
+#ifdef MOZ_CRASHREPORTER
 namespace mozilla {
 namespace ipc {
 
 StaticMutex CrashReporterClient::sLock;
 StaticRefPtr<CrashReporterClient> CrashReporterClient::sClientSingleton;
 
 CrashReporterClient::CrashReporterClient(const Shmem& aShmem)
  : mMetadata(new CrashReporterMetadataShmem(aShmem))
@@ -59,8 +60,9 @@ CrashReporterClient::DestroySingleton()
 CrashReporterClient::GetSingleton()
 {
   StaticMutexAutoLock lock(sLock);
   return sClientSingleton;
 }
 
 } // namespace ipc
 } // namespace mozilla
+#endif // MOZ_CRASHREPORTER
--- a/ipc/glue/CrashReporterClient.h
+++ b/ipc/glue/CrashReporterClient.h
@@ -7,16 +7,17 @@
 #ifndef mozilla_ipc_CrashReporterClient_h
 #define mozilla_ipc_CrashReporterClient_h
 
 #include "mozilla/StaticMutex.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Unused.h"
 #include "mozilla/ipc/Shmem.h"
 
+#ifdef MOZ_CRASHREPORTER
 namespace mozilla {
 namespace ipc {
 
 class CrashReporterMetadataShmem;
 
 class CrashReporterClient
 {
 public:
@@ -40,17 +41,19 @@ public:
       kShmemSize,
       SharedMemory::TYPE_BASIC,
       &shmem);
     if (!rv) {
       return false;
     }
 
     InitSingletonWithShmem(shmem);
-    Unused << aToplevelProtocol->SendInitCrashReporter(shmem);
+    Unused << aToplevelProtocol->SendInitCrashReporter(
+      shmem,
+      CrashReporter::CurrentThreadId());
     return true;
   }
 
   static void DestroySingleton();
   static RefPtr<CrashReporterClient> GetSingleton();
 
   void AnnotateCrashReport(const nsCString& aKey, const nsCString& aData);
   void AppendAppNotes(const nsCString& aData);
@@ -66,11 +69,12 @@ private:
   static StaticRefPtr<CrashReporterClient> sClientSingleton;
 
 private:
   UniquePtr<CrashReporterMetadataShmem> mMetadata;
 };
 
 } // namespace ipc
 } // namespace mozilla
+#endif // MOZ_CRASHREPORTER
 
 #endif // mozilla_ipc_CrashReporterClient_h
 
--- a/ipc/glue/CrashReporterHost.cpp
+++ b/ipc/glue/CrashReporterHost.cpp
@@ -13,19 +13,22 @@
 #ifdef MOZ_CRASHREPORTER
 # include "nsIAsyncShutdown.h"
 # include "nsICrashService.h"
 #endif
 
 namespace mozilla {
 namespace ipc {
 
-CrashReporterHost::CrashReporterHost(GeckoProcessType aProcessType, const Shmem& aShmem)
+CrashReporterHost::CrashReporterHost(GeckoProcessType aProcessType,
+                                     const Shmem& aShmem,
+                                     CrashReporter::ThreadId aThreadId)
  : mProcessType(aProcessType),
    mShmem(aShmem),
+   mThreadId(aThreadId),
    mStartTime(::time(nullptr))
 {
 }
 
 #ifdef MOZ_CRASHREPORTER
 bool
 CrashReporterHost::GenerateCrashReport(RefPtr<nsIFile> aCrashDump,
                                        nsString* aOutMinidumpID)
--- a/ipc/glue/CrashReporterHost.h
+++ b/ipc/glue/CrashReporterHost.h
@@ -21,17 +21,19 @@ namespace ipc {
 // terminates abnormally, the top-level should call GenerateCrashReport to
 // automatically integrate metadata.
 class CrashReporterHost
 {
   typedef mozilla::ipc::Shmem Shmem;
   typedef CrashReporter::AnnotationTable AnnotationTable;
 
 public:
-  CrashReporterHost(GeckoProcessType aProcessType, const Shmem& aShmem);
+  CrashReporterHost(GeckoProcessType aProcessType,
+                    const Shmem& aShmem,
+                    CrashReporter::ThreadId aThreadId);
 
 #ifdef MOZ_CRASHREPORTER
   bool GenerateCrashReport(base::ProcessId aPid,
                            nsString* aOutMinidumpID = nullptr)
   {
     RefPtr<nsIFile> crashDump;
     if (!XRE_TakeMinidumpForChild(aPid, getter_AddRefs(crashDump), nullptr)) {
       return false;
@@ -55,16 +57,17 @@ public:
 private:
   bool GenerateCrashReport(RefPtr<nsIFile> aCrashDump, nsString* aOutMinidumpID);
   static void AsyncAddCrash(int32_t aProcessType, int32_t aCrashType,
                             const nsString& aChildDumpID);
 
 private:
   GeckoProcessType mProcessType;
   Shmem mShmem;
+  CrashReporter::ThreadId mThreadId;
   time_t mStartTime;
   AnnotationTable mExtraNotes;
 };
 
 } // namespace ipc
 } // namespace mozilla
 
 #endif // mozilla_ipc_CrashReporterHost_h