Bug 555309, part 3: Grab the plugin thread's ID on startup and blame it in hang dumps. r=bsmedberg

This commit is contained in:
Chris Jones 2010-03-30 19:24:47 -05:00
parent 7c77dc07ff
commit ab754697b8
6 changed files with 27 additions and 6 deletions

View File

@ -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,

View File

@ -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_

View File

@ -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;

View File

@ -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,

View File

@ -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<nsILocalFile> pluginDump;
nsCOMPtr<nsILocalFile> 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;

View File

@ -229,6 +229,8 @@ private:
nsCString mCrashNotes;
PluginProcessParent* mSubprocess;
// the plugin thread in mSubprocess
NativeThreadId mPluginThread;
bool mShutdown;
const NPNetscapeFuncs* mNPNIface;
nsDataHashtable<nsVoidPtrHashKey, PluginIdentifierParent*> mIdentifiers;