From 07ffb5471cb247fd1daae92fd624425f256ef53d Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Wed, 21 Jan 2004 21:09:18 +0000 Subject: [PATCH] Print more information about nsXPCWrappedJS objects in GC_MARK_DEBUG. b=231384 r=brendan sr=bryner git-svn-id: svn://10.0.0.236/trunk@151653 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/xpconnect/src/xpcprivate.h | 4 ++++ mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp | 20 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mozilla/js/src/xpconnect/src/xpcprivate.h b/mozilla/js/src/xpconnect/src/xpcprivate.h index 9a02811a814..7540da77be2 100644 --- a/mozilla/js/src/xpconnect/src/xpcprivate.h +++ b/mozilla/js/src/xpconnect/src/xpcprivate.h @@ -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 }; /***************************************************************************/ diff --git a/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp b/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp index a9e100f2b09..0576ec850c7 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp @@ -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;