From ab754697b8196854c8918d15cd7586044dfd577e Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 30 Mar 2010 19:24:47 -0500 Subject: [PATCH] Bug 555309, part 3: Grab the plugin thread's ID on startup and blame it in hang dumps. r=bsmedberg --- dom/plugins/PPluginModule.ipdl | 4 +++- dom/plugins/PluginMessageUtils.h | 10 ++++++++++ dom/plugins/PluginModuleChild.cpp | 8 +++++++- dom/plugins/PluginModuleChild.h | 2 +- dom/plugins/PluginModuleParent.cpp | 7 ++++--- dom/plugins/PluginModuleParent.h | 2 ++ 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/dom/plugins/PPluginModule.ipdl b/dom/plugins/PPluginModule.ipdl index 514ac8b068b..c798d91bd02 100644 --- a/dom/plugins/PPluginModule.ipdl +++ b/dom/plugins/PPluginModule.ipdl @@ -45,6 +45,7 @@ include "mozilla/plugins/PluginMessageUtils.h"; using NPError; using NPNVariable; +using mozilla::plugins::NativeThreadId; namespace mozilla { namespace plugins { @@ -67,8 +68,9 @@ both: int32_t aInt); child: + // Return the plugin's thread ID, if it can be found. rpc NP_Initialize() - returns (NPError rv); + returns (NativeThreadId tid, NPError rv); rpc PPluginInstance(nsCString aMimeType, uint16_t aMode, diff --git a/dom/plugins/PluginMessageUtils.h b/dom/plugins/PluginMessageUtils.h index f2c57138a97..a47a9583019 100644 --- a/dom/plugins/PluginMessageUtils.h +++ b/dom/plugins/PluginMessageUtils.h @@ -53,6 +53,9 @@ #include "nsThreadUtils.h" #include "prlog.h" #include "nsHashKeys.h" +#ifdef MOZ_CRASHREPORTER +# include "nsExceptionHandler.h" +#endif namespace mozilla { @@ -128,6 +131,13 @@ typedef intptr_t NativeWindowHandle; // never actually used, will always be 0 #error Need NativeWindowHandle for this platform #endif +#ifdef MOZ_CRASHREPORTER +typedef CrashReporter::ThreadId NativeThreadId; +#else +// unused in this case +typedef int32 NativeThreadId; +#endif + // XXX maybe not the best place for these. better one? #define VARSTR(v_) case v_: return #v_ diff --git a/dom/plugins/PluginModuleChild.cpp b/dom/plugins/PluginModuleChild.cpp index 4732de2e039..1661c286845 100644 --- a/dom/plugins/PluginModuleChild.cpp +++ b/dom/plugins/PluginModuleChild.cpp @@ -1468,11 +1468,17 @@ _convertpoint(NPP instance, //----------------------------------------------------------------------------- bool -PluginModuleChild::AnswerNP_Initialize(NPError* _retval) +PluginModuleChild::AnswerNP_Initialize(NativeThreadId* tid, NPError* _retval) { PLUGIN_LOG_DEBUG_METHOD; AssertPluginThread(); +#ifdef MOZ_CRASHREPORTER + *tid = CrashReporter::CurrentThreadId(); +#else + *tid = 0; +#endif + #if defined(OS_LINUX) *_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions); return true; diff --git a/dom/plugins/PluginModuleChild.h b/dom/plugins/PluginModuleChild.h index 99c82cadb71..3824295db0a 100644 --- a/dom/plugins/PluginModuleChild.h +++ b/dom/plugins/PluginModuleChild.h @@ -103,7 +103,7 @@ protected: } // Implement the PPluginModuleChild interface - virtual bool AnswerNP_Initialize(NPError* rv); + virtual bool AnswerNP_Initialize(NativeThreadId* tid, NPError* rv); virtual PPluginIdentifierChild* AllocPPluginIdentifier(const nsCString& aString, diff --git a/dom/plugins/PluginModuleParent.cpp b/dom/plugins/PluginModuleParent.cpp index cd9254f75f4..8ab2fa1a79a 100644 --- a/dom/plugins/PluginModuleParent.cpp +++ b/dom/plugins/PluginModuleParent.cpp @@ -91,6 +91,7 @@ PluginModuleParent::LoadModule(const char* aFilePath) PluginModuleParent::PluginModuleParent(const char* aFilePath) : mSubprocess(new PluginProcessParent(aFilePath)) + , mPluginThread(0) , mShutdown(false) , mNPNIface(NULL) , mPlugin(NULL) @@ -217,7 +218,7 @@ PluginModuleParent::ShouldContinueFromReplyTimeout() nsCOMPtr pluginDump; nsCOMPtr browserDump; if (CrashReporter::CreatePairedMinidumps(OtherProcess(), - 0, // FIXME/bug 555309 + mPluginThread, &mHangID, getter_AddRefs(pluginDump), getter_AddRefs(browserDump)) && @@ -607,7 +608,7 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs return NS_ERROR_FAILURE; } - if (!CallNP_Initialize(error)) { + if (!CallNP_Initialize(&mPluginThread, error)) { return NS_ERROR_FAILURE; } else if (*error != NPERR_NO_ERROR) { @@ -630,7 +631,7 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) return NS_ERROR_FAILURE; } - if (!CallNP_Initialize(error)) + if (!CallNP_Initialize(&mPluginThread, error)) return NS_ERROR_FAILURE; return NS_OK; diff --git a/dom/plugins/PluginModuleParent.h b/dom/plugins/PluginModuleParent.h index fd85e9cfdaf..279f9dd7dec 100644 --- a/dom/plugins/PluginModuleParent.h +++ b/dom/plugins/PluginModuleParent.h @@ -229,6 +229,8 @@ private: nsCString mCrashNotes; PluginProcessParent* mSubprocess; + // the plugin thread in mSubprocess + NativeThreadId mPluginThread; bool mShutdown; const NPNetscapeFuncs* mNPNIface; nsDataHashtable mIdentifiers;