From da43dac7993c3af4a78a081756e41c89b884280e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 15 Feb 2017 14:44:29 -0800 Subject: [PATCH] Store the child process thread id in CrashReporterHost. (bug 1338281 part 2, r=billm) --- dom/media/gmp/GMPParent.cpp | 5 +++-- dom/media/gmp/GMPParent.h | 2 +- dom/media/gmp/PGMP.ipdl | 2 +- gfx/ipc/GPUChild.cpp | 7 +++++-- gfx/ipc/GPUChild.h | 2 +- gfx/ipc/PGPU.ipdl | 3 ++- ipc/glue/CrashReporterClient.cpp | 2 ++ ipc/glue/CrashReporterClient.h | 6 +++++- ipc/glue/CrashReporterHost.cpp | 5 ++++- ipc/glue/CrashReporterHost.h | 5 ++++- 10 files changed, 28 insertions(+), 11 deletions(-) diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index b2968a1a8c55..2a9392161766 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -536,12 +536,13 @@ GMPParent::ActorDestroy(ActorDestroyReason aWhy) } mozilla::ipc::IPCResult -GMPParent::RecvInitCrashReporter(Shmem&& aShmem) +GMPParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) { #ifdef MOZ_CRASHREPORTER mCrashReporter = MakeUnique( GeckoProcessType_GMPlugin, - aShmem); + aShmem, + aThreadId); #endif return IPC_OK(); } diff --git a/dom/media/gmp/GMPParent.h b/dom/media/gmp/GMPParent.h index 6acb5312e802..091d26386f0b 100644 --- a/dom/media/gmp/GMPParent.h +++ b/dom/media/gmp/GMPParent.h @@ -166,7 +166,7 @@ private: #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; diff --git a/dom/media/gmp/PGMP.ipdl b/dom/media/gmp/PGMP.ipdl index 2810d3280f63..707517b49f89 100644 --- a/dom/media/gmp/PGMP.ipdl +++ b/dom/media/gmp/PGMP.ipdl @@ -18,7 +18,7 @@ intr protocol PGMP manages PGMPStorage; parent: - async InitCrashReporter(Shmem shmem); + async InitCrashReporter(Shmem shmem, NativeThreadId threadId); async PGMPTimer(); async PGMPStorage(); diff --git a/gfx/ipc/GPUChild.cpp b/gfx/ipc/GPUChild.cpp index f2d98424084e..9e23e422f77d 100644 --- a/gfx/ipc/GPUChild.cpp +++ b/gfx/ipc/GPUChild.cpp @@ -121,10 +121,13 @@ GPUChild::RecvGraphicsError(const nsCString& aError) } mozilla::ipc::IPCResult -GPUChild::RecvInitCrashReporter(Shmem&& aShmem) +GPUChild::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) { #ifdef MOZ_CRASHREPORTER - mCrashReporter = MakeUnique(GeckoProcessType_GPU, aShmem); + mCrashReporter = MakeUnique( + GeckoProcessType_GPU, + aShmem, + aThreadId); #endif return IPC_OK(); } diff --git a/gfx/ipc/GPUChild.h b/gfx/ipc/GPUChild.h index d14ba300e222..41af5bb72ebf 100644 --- a/gfx/ipc/GPUChild.h +++ b/gfx/ipc/GPUChild.h @@ -42,7 +42,7 @@ public: // 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&& aAccumulations) override; mozilla::ipc::IPCResult RecvAccumulateChildKeyedHistogram(InfallibleTArray&& aAccumulations) override; mozilla::ipc::IPCResult RecvUpdateChildScalars(InfallibleTArray&& aScalarActions) override; diff --git a/gfx/ipc/PGPU.ipdl b/gfx/ipc/PGPU.ipdl index 63fc2862d495..2b236fc3974a 100644 --- a/gfx/ipc/PGPU.ipdl +++ b/gfx/ipc/PGPU.ipdl @@ -15,6 +15,7 @@ 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"; @@ -102,7 +103,7 @@ child: // 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. diff --git a/ipc/glue/CrashReporterClient.cpp b/ipc/glue/CrashReporterClient.cpp index 004ca3b57448..36da3971469d 100644 --- a/ipc/glue/CrashReporterClient.cpp +++ b/ipc/glue/CrashReporterClient.cpp @@ -8,6 +8,7 @@ #include "CrashReporterMetadataShmem.h" #include "nsISupportsImpl.h" +#ifdef MOZ_CRASHREPORTER namespace mozilla { namespace ipc { @@ -64,3 +65,4 @@ CrashReporterClient::GetSingleton() } // namespace ipc } // namespace mozilla +#endif // MOZ_CRASHREPORTER diff --git a/ipc/glue/CrashReporterClient.h b/ipc/glue/CrashReporterClient.h index 512533da8626..bd8a7397b38f 100644 --- a/ipc/glue/CrashReporterClient.h +++ b/ipc/glue/CrashReporterClient.h @@ -12,6 +12,7 @@ #include "mozilla/Unused.h" #include "mozilla/ipc/Shmem.h" +#ifdef MOZ_CRASHREPORTER namespace mozilla { namespace ipc { @@ -45,7 +46,9 @@ public: } InitSingletonWithShmem(shmem); - Unused << aToplevelProtocol->SendInitCrashReporter(shmem); + Unused << aToplevelProtocol->SendInitCrashReporter( + shmem, + CrashReporter::CurrentThreadId()); return true; } @@ -71,6 +74,7 @@ private: } // namespace ipc } // namespace mozilla +#endif // MOZ_CRASHREPORTER #endif // mozilla_ipc_CrashReporterClient_h diff --git a/ipc/glue/CrashReporterHost.cpp b/ipc/glue/CrashReporterHost.cpp index 540996c67ff4..0eba21ad4919 100644 --- a/ipc/glue/CrashReporterHost.cpp +++ b/ipc/glue/CrashReporterHost.cpp @@ -18,9 +18,12 @@ 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)) { } diff --git a/ipc/glue/CrashReporterHost.h b/ipc/glue/CrashReporterHost.h index 2d4875af5517..40512d8e406b 100644 --- a/ipc/glue/CrashReporterHost.h +++ b/ipc/glue/CrashReporterHost.h @@ -26,7 +26,9 @@ class CrashReporterHost 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, @@ -60,6 +62,7 @@ private: private: GeckoProcessType mProcessType; Shmem mShmem; + CrashReporter::ThreadId mThreadId; time_t mStartTime; AnnotationTable mExtraNotes; };