зеркало из https://github.com/mozilla/pjs.git
fix a warning and add JS stack dumper with a test.
This commit is contained in:
Родитель
ba34c29f9d
Коммит
7cc103b757
|
@ -103,6 +103,8 @@ interface nsIEcho : nsISupports {
|
|||
|
||||
void PseudoQueryInterface(in nsIIDRef uuid,
|
||||
[iid_is(uuid),retval] out nsQIResult result);
|
||||
|
||||
void DebugDumpJSStack();
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
|
@ -248,6 +248,8 @@ public:
|
|||
/* pass nsnull to clear pending exception */
|
||||
NS_IMETHOD SetPendingException(nsIXPCException* aException) = 0;
|
||||
|
||||
NS_IMETHOD DebugDumpJSStack() = 0;
|
||||
|
||||
// XXX other methods?
|
||||
};
|
||||
|
||||
|
|
|
@ -740,3 +740,40 @@ nsXPConnect::DebugDumpObject(nsISupports* p, int depth)
|
|||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPConnect::DebugDumpJSStack()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
||||
nsIJSStackFrameLocation* stack;
|
||||
if(NS_FAILED(GetCurrentJSStack(&stack)) || !stack)
|
||||
{
|
||||
printf("call to GetCurrentJSStack failed\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIJSStackFrameLocation* current = stack;
|
||||
NS_ADDREF(current);
|
||||
|
||||
while(1)
|
||||
{
|
||||
char* text;
|
||||
if(NS_FAILED(current->ToString(&text)))
|
||||
{
|
||||
printf("nsIJSStackFrameLocation::ToString failed!\n");
|
||||
NS_RELEASE(current);
|
||||
break;
|
||||
}
|
||||
printf("%s\n", text);
|
||||
nsAllocator::Free(text);
|
||||
nsIJSStackFrameLocation* prev = current;
|
||||
nsresult rv = prev->GetCaller(¤t);
|
||||
NS_RELEASE(prev);
|
||||
if(NS_FAILED(rv) || !current)
|
||||
break;
|
||||
}
|
||||
NS_RELEASE(stack);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ class nsXPConnect : public nsIXPConnect
|
|||
|
||||
NS_IMETHOD DebugDump(int depth);
|
||||
NS_IMETHOD DebugDumpObject(nsISupports* p, int depth);
|
||||
NS_IMETHOD DebugDumpJSStack();
|
||||
|
||||
NS_IMETHOD AbandonJSContext(JSContext* aJSContext);
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
|||
uint8 type_tag = type.TagPart();
|
||||
nsID* iid;
|
||||
|
||||
if(type.TagPart() == nsXPTType::T_INTERFACE)
|
||||
if(type_tag == nsXPTType::T_INTERFACE)
|
||||
{
|
||||
if(NS_FAILED(GetInterfaceInfo()->
|
||||
GetIIDForParam(methodIndex, ¶m, &iid)))
|
||||
|
@ -352,7 +352,7 @@ nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
|||
}
|
||||
*iidIsOwned = JS_TRUE;
|
||||
}
|
||||
else if(type.TagPart() == nsXPTType::T_INTERFACE_IS)
|
||||
else if(type_tag == nsXPTType::T_INTERFACE_IS)
|
||||
{
|
||||
uint8 argnum;
|
||||
nsresult rv;
|
||||
|
|
|
@ -453,6 +453,19 @@ MyEcho::PseudoQueryInterface(const nsIID & uuid, void * *result)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void DebugDumpJSStack (); */
|
||||
NS_IMETHODIMP
|
||||
MyEcho::DebugDumpJSStack()
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIXPConnect, xpc, nsIXPConnect::GetCID(), &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = xpc->DebugDumpJSStack();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// security manager test class
|
||||
|
||||
|
@ -1091,7 +1104,6 @@ sm_test_done:
|
|||
|
||||
printf("ThreadJSContextStack tests...\n");
|
||||
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIJSContextStack, stack, "nsThreadJSContextStack", &rv);
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
|
@ -1188,7 +1200,6 @@ sm_test_done:
|
|||
#if 0
|
||||
// a fun test...
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIComponentManager, cm, kComponentManagerCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
|
|
@ -280,6 +280,19 @@ xpctestEcho::PseudoQueryInterface(const nsIID & uuid, void * *result)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void DebugDumpJSStack (); */
|
||||
NS_IMETHODIMP
|
||||
xpctestEcho::DebugDumpJSStack()
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIXPConnect, xpc, nsIXPConnect::GetCID(), &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = xpc->DebugDumpJSStack();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
// static
|
||||
|
@ -304,3 +317,4 @@ xpctest::ConstructEcho(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
|||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче