diff --git a/dom/plugins/PluginModuleParent.cpp b/dom/plugins/PluginModuleParent.cpp index da5a4602a382..748774e03a87 100644 --- a/dom/plugins/PluginModuleParent.cpp +++ b/dom/plugins/PluginModuleParent.cpp @@ -48,9 +48,6 @@ #include "nsContentUtils.h" #include "nsCRT.h" -#ifdef MOZ_CRASHREPORTER -# include "nsExceptionHandler.h" -#endif #include "nsNPAPIPlugin.h" using base::KillProcess; @@ -261,10 +258,8 @@ PluginModuleParent::ActorDestroy(ActorDestroyReason why) { switch (why) { case AbnormalShutdown: { -#ifdef MOZ_CRASHREPORTER nsCOMPtr dump; - if (CrashReporter::TakeMinidumpForChild(ChildProcessHandle(), - getter_AddRefs(dump))) { + if (TakeMinidump(getter_AddRefs(dump))) { WriteExtraDataForMinidump(dump); if (NS_SUCCEEDED(dump->GetLeafName(mDumpID))) { mDumpID.Replace(mDumpID.Length() - 4, 4, @@ -274,7 +269,6 @@ PluginModuleParent::ActorDestroy(ActorDestroyReason why) else { NS_WARNING("[PluginModuleParent::ActorDestroy] abnormal shutdown without minidump!"); } -#endif mShutdown = true; // Defer the PluginCrashed method so that we don't re-enter diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index a7fe48e2087d..31b4acdd78c6 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -2944,6 +2944,39 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): if p.usesShmem(): self.cls.addstmts(self.makeShmemIface()) + if ptype.isToplevel() and self.side is 'parent': + ## bool GetMinidump(nsIFile** dump) + self.cls.addstmt(Label.PROTECTED) + + otherpidvar = ExprVar('OtherSidePID') + otherpid = MethodDefn(MethodDecl( + otherpidvar.name, params=[ ], + ret=Type('base::ProcessId'), + const=1)) + otherpid.addstmts([ + StmtReturn(ExprCall( + ExprVar('base::GetProcId'), + args=[ p.otherProcessVar() ])), + ]) + + dumpvar = ExprVar('aDump') + getdump = MethodDefn(MethodDecl( + 'TakeMinidump', + params=[ Decl(Type('nsIFile', ptrptr=1), dumpvar.name) ], + ret=Type.BOOL, + const=1)) + getdump.addstmts([ + CppDirective('ifdef', 'MOZ_CRASHREPORTER'), + StmtReturn(ExprCall( + ExprVar('XRE_TakeMinidumpForChild'), + args=[ ExprCall(otherpidvar), dumpvar ])), + CppDirective('else'), + StmtReturn(ExprLiteral.FALSE), + CppDirective('endif') + ]) + self.cls.addstmts([ otherpid, Whitespace.NL, + getdump, Whitespace.NL ]) + if (ptype.isToplevel() and self.side is 'parent' and ptype.talksRpc()): # offer BlockChild() and UnblockChild(). diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index debbca29b11a..6e48808c593c 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -1418,19 +1418,17 @@ SetRemoteExceptionHandler() bool -TakeMinidumpForChild(ProcessHandle childPid, nsIFile** dump) +TakeMinidumpForChild(PRUint32 childPid, nsIFile** dump) { if (!GetEnabled()) return false; - PRUint32 key = PRUint32(childPid); - MutexAutoLock lock(*dumpMapLock); nsCOMPtr d; - bool found = pidToMinidump->Get(key, getter_AddRefs(d)); + bool found = pidToMinidump->Get(childPid, getter_AddRefs(d)); if (found) - pidToMinidump->Remove(key); + pidToMinidump->Remove(childPid); *dump = NULL; d.swap(*dump); diff --git a/toolkit/crashreporter/nsExceptionHandler.h b/toolkit/crashreporter/nsExceptionHandler.h index 05212f23e2fb..151f6955e43b 100644 --- a/toolkit/crashreporter/nsExceptionHandler.h +++ b/toolkit/crashreporter/nsExceptionHandler.h @@ -76,16 +76,10 @@ nsresult SetSubmitReports(PRBool aSubmitReport); #ifdef MOZ_IPC // Out-of-process crash reporter API. -#if defined(XP_WIN32) -typedef HANDLE ProcessHandle; -#else -typedef int ProcessHandle; -#endif - // Return true iff a dump was found for |childPid|, and return the // path in |dump|. The caller owns the last reference to |dump| if it // is non-NULL. -bool TakeMinidumpForChild(ProcessHandle childPid, nsIFile** dump NS_OUTPARAM); +bool TakeMinidumpForChild(PRUint32 childPid, nsIFile** dump NS_OUTPARAM); # if defined(XP_WIN32) // Parent-side API for children diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index a8edb528a3e8..3ecb05eaff83 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -251,6 +251,15 @@ GeckoProcessType sChildProcessType = GeckoProcessType_Default; static MessageLoop* sIOMessageLoop; #if defined(MOZ_CRASHREPORTER) +// FIXME/bug 539522: this out-of-place function is stuck here because +// IPDL wants access to this crashreporter interface, and +// crashreporter is built in such a way to make that awkward +PRBool +XRE_TakeMinidumpForChild(PRUint32 aChildPid, nsIFile** aDump) +{ + return CrashReporter::TakeMinidumpForChild(aChildPid, aDump); +} + PRBool XRE_SetRemoteExceptionHandler(const char* aPipe/*= 0*/) { diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index ccd37d844400..504038c0e4b2 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -450,6 +450,10 @@ XRE_API(GeckoProcessType, XRE_StringToChildProcessType, (const char* aProcessTypeString)) #if defined(MOZ_CRASHREPORTER) +// Used in the "master" parent process hosting the crash server +XRE_API(PRBool, + XRE_TakeMinidumpForChild, (PRUint32 aChildPid, nsIFile** aDump)) + // Used in child processes. XRE_API(PRBool, XRE_SetRemoteExceptionHandler, (const char* aPipe))