static JSBool vm_dumpObject(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { #if defined(DEBUG) JS_FRIEND_API(void) js_DumpObject(jsval val); if (argc != 1) return gpsee_throw(cx, MODULE_ID ".dumpObject.arguments.count"); if (!JSVAL_IS_OBJECT(argv[0])) return gpsee_throw(cx, MODULE_ID ".dumpObject.arguments.0.type: must be an object"); js_DumpObject(argv[0]); return JS_TRUE; #else return gpsee_throw(cx, MODULE_ID ".dumpObject.undefined: requires a debug JSAPI build"); #endif }
void DEBUG_CheckForComponentsInScope(JSContext* cx, JSObject* obj, JSObject* startingObj, JSBool OKIfNotInitialized, XPCJSRuntime* runtime) { if(OKIfNotInitialized) return; if(!(JS_GetOptions(cx) & JSOPTION_PRIVATE_IS_NSISUPPORTS)) return; const char* name = runtime->GetStringName(XPCJSRuntime::IDX_COMPONENTS); jsval prop; if(JS_LookupProperty(cx, obj, name, &prop) && !JSVAL_IS_PRIMITIVE(prop)) return; // This is pretty much always bad. It usually means that native code is // making a callback to an interface implemented in JavaScript, but the // document where the JS object was created has already been cleared and the // 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! (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); } }
void Dump(Handle<Object> obj) { js_DumpObject(**obj); }