Dump JS stack and information about the object for the assertion about using XPConnect on a scope with no Components in scope. (Bug 510489) r=mrbkap a2.0=DEBUG-only

This commit is contained in:
L. David Baron 2010-12-09 20:38:52 -08:00
parent 646156de91
commit 7de448d78d

View File

@ -42,6 +42,7 @@
#include "xpcprivate.h"
#include "XPCWrapper.h"
#include "jsproxy.h"
/***************************************************************************/
@ -756,6 +757,7 @@ GetScopeOfObject(JSObject* obj)
#ifdef DEBUG
void DEBUG_CheckForComponentsInScope(JSContext* cx, JSObject* obj,
JSObject* startingObj,
JSBool OKIfNotInitialized,
XPCJSRuntime* runtime)
{
@ -776,10 +778,25 @@ void DEBUG_CheckForComponentsInScope(JSContext* cx, JSObject* obj,
// global properties of that document's window are *gone*. Generally this
// indicates a problem that should be addressed in the design and use of the
// callback code.
NS_ERROR("XPConnect is being called on a scope without a 'Components' property!");
NS_ERROR("XPConnect is being called on a scope without a 'Components' property! (stack and details follow)");
printf("The current JS stack is:\n");
xpc_DumpJSStack(cx, JS_TRUE, JS_TRUE, JS_TRUE);
printf("And the object whose scope lacks a 'Components' property is:\n");
js_DumpObject(startingObj);
JSObject *p = startingObj;
while(p->isWrapper())
{
p = p->getProxyPrivate().toObjectOrNull();
if(!p)
break;
printf("which is a wrapper for:\n");
js_DumpObject(p);
}
}
#else
#define DEBUG_CheckForComponentsInScope(ccx, obj, OKIfNotInitialized, runtime) \
#define DEBUG_CheckForComponentsInScope(ccx, obj, startingObj, OKIfNotInitialized, runtime) \
((void)0)
#endif
@ -806,6 +823,10 @@ XPCWrappedNativeScope::FindInJSObjectScope(JSContext* cx, JSObject* obj,
JSAutoEnterCompartment ac;
ac.enterAndIgnoreErrors(cx, obj);
#ifdef DEBUG
JSObject *startingObj = obj;
#endif
obj = JS_GetGlobalForObject(cx, obj);
if(!runtime)
@ -834,7 +855,8 @@ XPCWrappedNativeScope::FindInJSObjectScope(JSContext* cx, JSObject* obj,
if(found) {
// This cannot be called within the map lock!
DEBUG_CheckForComponentsInScope(cx, obj, OKIfNotInitialized, runtime);
DEBUG_CheckForComponentsInScope(cx, obj, startingObj,
OKIfNotInitialized, runtime);
return found;
}