Bug 1039575 - Hook up crash reporting for GMP plugins to the point where we have a crash ID in GMPParent::ActorDestroy, r=ted

* * *
Bug 1039575 followup - always return from GMPChild
This commit is contained in:
Benjamin Smedberg 2014-07-18 13:35:44 -04:00
parent 61929e46c9
commit 214fd35cc4
6 changed files with 117 additions and 1 deletions

View File

@ -12,6 +12,9 @@
#include "gmp-video-decode.h"
#include "gmp-video-encode.h"
#include "GMPPlatform.h"
#include "mozilla/dom/CrashReporterChild.h"
using mozilla::dom::CrashReporterChild;
#ifdef XP_WIN
#include <stdlib.h> // for _exit()
@ -44,6 +47,9 @@ GMPChild::Init(const std::string& aPluginPath,
MessageLoop* aIOLoop,
IPC::Channel* aChannel)
{
#ifdef MOZ_CRASHREPORTER
SendPCrashReporterConstructor(CrashReporter::CurrentThreadId());
#endif
#if defined(XP_WIN)
mozilla::SandboxTarget::Instance()->StartSandbox();
#endif
@ -153,6 +159,19 @@ GMPChild::ProcessingError(Result aWhat)
}
}
mozilla::dom::PCrashReporterChild*
GMPChild::AllocPCrashReporterChild(const NativeThreadId& aThread)
{
return new CrashReporterChild();
}
bool
GMPChild::DeallocPCrashReporterChild(PCrashReporterChild* aCrashReporter)
{
delete aCrashReporter;
return true;
}
PGMPVideoDecoderChild*
GMPChild::AllocPGMPVideoDecoderChild()
{

View File

@ -27,6 +27,8 @@ public:
MessageLoop* GMPMessageLoop();
private:
virtual PCrashReporterChild* AllocPCrashReporterChild(const NativeThreadId& aThread) MOZ_OVERRIDE;
virtual bool DeallocPCrashReporterChild(PCrashReporterChild*) MOZ_OVERRIDE;
virtual PGMPVideoDecoderChild* AllocPGMPVideoDecoderChild() MOZ_OVERRIDE;
virtual bool DeallocPGMPVideoDecoderChild(PGMPVideoDecoderChild* aActor) MOZ_OVERRIDE;
virtual PGMPVideoEncoderChild* AllocPGMPVideoEncoderChild() MOZ_OVERRIDE;

View File

@ -15,6 +15,14 @@
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/unused.h"
#ifdef MOZ_CRASHREPORTER
#include "mozilla/dom/CrashReporterParent.h"
using mozilla::dom::CrashReporterParent;
using CrashReporter::AnnotationTable;
using CrashReporter::GetIDFromMinidump;
#endif
namespace mozilla {
namespace gmp {
@ -243,12 +251,72 @@ GMPParent::GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE)
return NS_OK;
}
#ifdef MOZ_CRASHREPORTER
void
GMPParent::WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes)
{
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);
}
void
GMPParent::GetCrashID(nsString& aResult)
{
CrashReporterParent* cr = nullptr;
if (ManagedPCrashReporterParent().Length() > 0) {
cr = static_cast<CrashReporterParent*>(ManagedPCrashReporterParent()[0]);
}
if (NS_WARN_IF(!cr)) {
return;
}
AnnotationTable notes(4);
WriteExtraDataForMinidump(notes);
nsCOMPtr<nsIFile> dumpFile;
TakeMinidump(getter_AddRefs(dumpFile), nullptr);
if (!dumpFile) {
NS_WARNING("GMP crash without crash report");
return;
}
GetIDFromMinidump(dumpFile, aResult);
cr->GenerateCrashReportForMinidump(dumpFile, &notes);
}
#endif
void
GMPParent::ActorDestroy(ActorDestroyReason aWhy)
{
if (AbnormalShutdown == aWhy) {
nsString dumpID;
#ifdef MOZ_CRASHREPORTER
GetCrashID(dumpID);
#endif
// now do something with the crash ID, bug 1038961
}
UnloadProcess();
}
mozilla::dom::PCrashReporterParent*
GMPParent::AllocPCrashReporterParent(const NativeThreadId& aThread)
{
#ifndef MOZ_CRASHREPORTER
MOZ_ASSERT(false, "Should only be sent if crash reporting is enabled.");
#endif
CrashReporterParent* cr = new CrashReporterParent();
cr->SetChildData(aThread, GeckoProcessType_GMPlugin);
return cr;
}
bool
GMPParent::DeallocPCrashReporterParent(PCrashReporterParent* aCrashReporter)
{
delete aCrashReporter;
return true;
}
PGMPVideoDecoderParent*
GMPParent::AllocPGMPVideoDecoderParent()
{

View File

@ -21,6 +21,17 @@
class nsILineInputStream;
class nsIThread;
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
namespace mozilla {
namespace dom {
class PCrashReporterParent;
class CrashReporterParent;
}
}
#endif
namespace mozilla {
namespace gmp {
@ -86,7 +97,14 @@ private:
~GMPParent();
bool EnsureProcessLoaded();
nsresult ReadGMPMetaData();
#ifdef MOZ_CRASHREPORTER
void WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes);
void GetCrashID(nsString& aResult);
#endif
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
virtual PCrashReporterParent* AllocPCrashReporterParent(const NativeThreadId& aThread) MOZ_OVERRIDE;
virtual bool DeallocPCrashReporterParent(PCrashReporterParent* aCrashReporter) MOZ_OVERRIDE;
virtual PGMPVideoDecoderParent* AllocPGMPVideoDecoderParent() MOZ_OVERRIDE;
virtual bool DeallocPGMPVideoDecoderParent(PGMPVideoDecoderParent* aActor) MOZ_OVERRIDE;
virtual PGMPVideoEncoderParent* AllocPGMPVideoEncoderParent() MOZ_OVERRIDE;

View File

@ -5,6 +5,9 @@
include protocol PGMPVideoDecoder;
include protocol PGMPVideoEncoder;
include protocol PCrashReporter;
using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
namespace mozilla {
namespace gmp {
@ -13,6 +16,11 @@ intr protocol PGMP
{
manages PGMPVideoDecoder;
manages PGMPVideoEncoder;
manages PCrashReporter;
parent:
async PCrashReporter(NativeThreadId tid);
child:
async PGMPVideoDecoder();
async PGMPVideoEncoder();

View File

@ -6,6 +6,7 @@
include protocol PContent;
include protocol PPluginModule;
include protocol PGMP;
namespace mozilla {
namespace dom {
@ -19,7 +20,7 @@ struct Mapping {
};
intr protocol PCrashReporter {
manager PContent or PPluginModule;
manager PContent or PPluginModule or PGMP;
parent:
AnnotateCrashReport(nsCString key, nsCString data);
AppendAppNotes(nsCString data);