Log creation of XPCNativeWrapper and XPCWrappedNative objects if

DEBUG_XPCNativeWrapper is defined.  Bug 295435, r+sr=jst, a=shaver.
This commit is contained in:
bzbarsky%mit.edu 2005-06-01 19:26:24 +00:00
Родитель 888311c91a
Коммит bbd38864c2
2 изменённых файлов: 48 добавлений и 3 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);