From b42bfa59ab1dca0e59d76fedad6b2624ab669d24 Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Mon, 24 Jan 2011 13:21:18 -0800 Subject: [PATCH] Bug 626830 - Allow JSD to turn on debugging when no JS code is running, not just when XPConnect stack is completely empty, r=dmandelin --HG-- extra : rebase_source : 3f177904d2708642dfec8d5937964ec8fc83427a --- js/src/xpconnect/src/nsXPConnect.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/js/src/xpconnect/src/nsXPConnect.cpp b/js/src/xpconnect/src/nsXPConnect.cpp index 77bc9c13fde3..4414621c3374 100644 --- a/js/src/xpconnect/src/nsXPConnect.cpp +++ b/js/src/xpconnect/src/nsXPConnect.cpp @@ -2498,14 +2498,19 @@ nsXPConnect::Push(JSContext * cx) if(!data) return NS_ERROR_FAILURE; - PRInt32 count; - nsresult rv; - rv = data->GetJSContextStack()->GetCount(&count); - if (NS_FAILED(rv)) - return rv; - - if (count == 0) - CheckForDebugMode(mRuntime->GetJSRuntime()); + if (gDebugMode != gDesiredDebugMode && NS_IsMainThread()) { + const nsTArray* stack = data->GetJSContextStack()->GetStack(); + bool runningJS = false; + for (PRUint32 i = 0; i < stack->Length(); ++i) { + JSContext *cx = (*stack)[i].cx; + if (cx && cx->regs) { + runningJS = true; + break; + } + } + if (!runningJS) + CheckForDebugMode(mRuntime->GetJSRuntime()); + } return data->GetJSContextStack()->Push(cx); }