Print more information about nsXPCWrappedJS objects in GC_MARK_DEBUG. b=231384 r=brendan sr=bryner

This commit is contained in:
dbaron%dbaron.org 2004-01-21 21:09:18 +00:00
parent 240541d85f
commit 0511192cec
2 changed files with 22 additions and 2 deletions

View File

@ -78,6 +78,7 @@
#include "jsinterp.h"
#include "jscntxt.h"
#include "jsdbgapi.h"
#include "jsgc.h"
#include "xptinfo.h"
#include "xpcforwards.h"
#include "xpclog.h"
@ -2172,6 +2173,9 @@ private:
nsXPCWrappedJS* mRoot;
nsXPCWrappedJS* mNext;
nsISupports* mOuter; // only set in root
#ifdef GC_MARK_DEBUG
char *mGCRootName;
#endif
};
/***************************************************************************/

View File

@ -127,8 +127,16 @@ nsXPCWrappedJS::AddRef(void)
if(2 == cnt && IsValid())
{
XPCCallContext ccx(NATIVE_CALLER);
if(ccx.IsValid())
if(ccx.IsValid()) {
#ifdef GC_MARK_DEBUG
mGCRootName = JS_smprintf("nsXPCWrappedJS::mJSObj[%s,0x%p,0x%p]",
GetClass()->GetInterfaceName(),
this, mJSObj);
JS_AddNamedRoot(ccx.GetJSContext(), &mJSObj, mGCRootName);
#else
JS_AddNamedRoot(ccx.GetJSContext(), &mJSObj, "nsXPCWrappedJS::mJSObj");
#endif
}
}
return cnt;
@ -159,8 +167,13 @@ do_decrement:
if(IsValid())
{
XPCJSRuntime* rt = mClass->GetRuntime();
if(rt)
if(rt) {
JS_RemoveRootRT(rt->GetJSRuntime(), &mJSObj);
#ifdef GC_MARK_DEBUG
JS_smprintf_free(mGCRootName);
mGCRootName = nsnull;
#endif
}
}
// If we are not the root wrapper or if we are not being used from a
@ -309,6 +322,9 @@ nsXPCWrappedJS::nsXPCWrappedJS(XPCCallContext& ccx,
mRoot(root ? root : this),
mNext(nsnull),
mOuter(root ? nsnull : aOuter)
#ifdef GC_MARK_DEBUG
, mGCRootName(nsnull)
#endif
{
#ifdef DEBUG_stats_jband
static int count = 0;