From d57c27e7a08a45333a59367a18ebc0b962bd09a7 Mon Sep 17 00:00:00 2001 From: "rginda%netscape.com" Date: Mon, 21 May 2001 07:18:10 +0000 Subject: [PATCH] - not built - add enumerateScripts() method to jsdIDebugger service don't create a new debugger context if the user trys to call on[ForRuntime]() multiple times --- js/jsd/idl/jsdIDebuggerService.idl | 8 ++++++++ js/jsd/jsd_xpc.cpp | 26 ++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/js/jsd/idl/jsdIDebuggerService.idl b/js/jsd/idl/jsdIDebuggerService.idl index 08c6bcc99d8..fe64a055c5a 100644 --- a/js/jsd/idl/jsdIDebuggerService.idl +++ b/js/jsd/idl/jsdIDebuggerService.idl @@ -243,6 +243,13 @@ interface jsdIExecutionHook : nsISupports in unsigned long type, inout jsdIValue val); }; +/* script enumeration callback */ +[scriptable, uuid(4c2f706e-1dd2-11b2-9ebc-85a06e948830)] +interface jsdIScriptEnumerator : nsISupports +{ + boolean enumerateScript (in jsdIScript script); +}; + /* debugger service */ [scriptable, uuid(01be7f9a-1dd2-11b2-9d55-aaf919b27c73)] interface jsdIDebuggerService : nsISupports @@ -258,6 +265,7 @@ interface jsdIDebuggerService : nsISupports [noscript] void onForRuntime (in JSRuntime rt); /* native version of on() */ void off (); + void enumerateScripts (in jsdIScriptEnumerator enumerator); void clearAllBreakpoints (); /* XXX temporary hacks */ diff --git a/js/jsd/jsd_xpc.cpp b/js/jsd/jsd_xpc.cpp index 48ae5976586..157d89c8a1a 100644 --- a/js/jsd/jsd_xpc.cpp +++ b/js/jsd/jsd_xpc.cpp @@ -897,8 +897,9 @@ jsdService::OnForRuntime (JSRuntime *rt) if (gLastGCProc == jsds_GCCallbackProc) /* condition indicates that the callback proc has not been set yet */ gLastGCProc = JS_SetGCCallbackRT (rt, jsds_GCCallbackProc); - - mCx = JSD_DebuggerOnForUser (rt, NULL, NULL); + + if (!mOn) + mCx = JSD_DebuggerOnForUser (rt, NULL, NULL); if (!mCx) return NS_ERROR_FAILURE; @@ -911,10 +912,31 @@ NS_IMETHODIMP jsdService::Off (void) { JSD_DebuggerOff (mCx); + mCx = 0; mOn = PR_FALSE; return NS_OK; } +NS_IMETHODIMP +jsdService::EnumerateScripts (jsdIScriptEnumerator *enumerator) +{ + JSDScript *script; + JSDScript *iter = NULL; + PRBool cont_flag; + nsresult rv = NS_OK; + + JSD_LockScriptSubsystem(mCx); + while((script = JSD_IterateScripts(mCx, &iter)) != NULL) { + rv = enumerator->EnumerateScript (jsdScript::FromPtr(mCx, script), + &cont_flag); + if (NS_FAILED(rv) || !cont_flag) + break; + } + JSD_UnlockScriptSubsystem(mCx); + + return rv; +} + NS_IMETHODIMP jsdService::ClearAllBreakpoints (void) {