diff --git a/mozilla/js/src/xpconnect/src/XPCNativeWrapper.cpp b/mozilla/js/src/xpconnect/src/XPCNativeWrapper.cpp index 005cf819835..f18d43f4ce4 100644 --- a/mozilla/js/src/xpconnect/src/XPCNativeWrapper.cpp +++ b/mozilla/js/src/xpconnect/src/XPCNativeWrapper.cpp @@ -944,6 +944,21 @@ XPCNativeWrapperCtor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, return JS_FALSE; } +#ifdef DEBUG_XPCNativeWrapper + { + XPCCallContext ccx(JS_CALLER, cx); + + // Keep wrapperObj alive while we mess with strings + AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(wrapperObj)); + + char *s = wrappedNative->ToString(ccx); + printf("Created new XPCNativeWrapper %p for wrapped native %s\n", + (void*)wrapperObj, s); + if (s) + JS_smprintf_free(s); + } +#endif + *rval = OBJECT_TO_JSVAL(wrapperObj); { @@ -1152,6 +1167,22 @@ XPCNativeWrapper::GetNewOrUsed(JSContext *cx, XPCWrappedNative *wrapper) } wrapper->SetNativeWrapper(obj); + +#ifdef DEBUG_XPCNativeWrapper + { + XPCCallContext ccx(NATIVE_CALLER, cx); + + // Keep obj alive while we mess with strings + AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(obj)); + + char *s = wrapper->ToString(ccx); + printf("Created new XPCNativeWrapper %p for wrapped native %s\n", + (void*)obj, s); + if (s) + JS_smprintf_free(s); + } +#endif + return obj; } diff --git a/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp b/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp index b7960b591f6..5327361ed1f 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappednative.cpp @@ -402,6 +402,17 @@ XPCWrappedNative::GetNewOrUsed(XPCCallContext& ccx, return rv; } +#if DEBUG_XPCNativeWrapper + { + char* s = wrapper->ToString(ccx); + NS_ASSERTION(wrapper->GetFlatJSObject(), "eh?"); + printf("Created wrapped native %s, flat JSObject is %p\n", + s, (void*)wrapper->GetFlatJSObject()); + if (s) + JS_smprintf_free(s); + } +#endif + // Redundant wrapper must be killed outside of the map lock. XPCWrappedNative* wrapperToKill = nsnull; @@ -2462,9 +2473,11 @@ XPCWrappedNative::ToString(XPCCallContext& ccx, { #ifdef DEBUG # define FMT_ADDR " @ 0x%p" +# define FMT_STR(str) str # define PARAM_ADDR(w) , w #else # define FMT_ADDR "" +# define FMT_STR(str) # define PARAM_ADDR(w) #endif @@ -2510,12 +2523,13 @@ XPCWrappedNative::ToString(XPCCallContext& ccx, { return nsnull; } - const char* fmt = "[xpconnect wrapped %s" FMT_ADDR "]"; + const char* fmt = "[xpconnect wrapped %s" FMT_ADDR FMT_STR(" (native") + FMT_ADDR FMT_STR(")") "]"; if(si) { - fmt = "[object %s" FMT_ADDR "]"; + fmt = "[object %s" FMT_ADDR FMT_STR(" (native") FMT_ADDR FMT_STR(")") "]"; } - sz = JS_smprintf(fmt, name PARAM_ADDR(this)); + sz = JS_smprintf(fmt, name PARAM_ADDR(this) PARAM_ADDR(mIdentity)); JS_smprintf_free(name);