Re: Debug Interface for the mozjs, how to start/stop/pause/continue the js engine

Steve Fink <[email protected]> Sat, 11 Apr 2020 09:45:19 -0700
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
On 4/11/20 9:39 AM, lemmel wrote:
> Hi !
>
> I did a lot of work, and I'm now able to:
> - run arbitrary JS code through a call to JS::Evaluate (and I know now that the JSContext - obtained via JS_NewContext - must stick to only one thread) any number of time I want
> - retrieve an error generated from the code (in this order: JS_IsExceptionPending, JS_GetPendingException, js::ErrorReport, JS_ClearPendingException)
> - "pause" the engine execution (registered my callback with JS_AddInterruptCallback and triggered the pause via JS_RequestInterruptCallback)
> - stop all graciously
>
> But I don't know how to set a debugger (the object Debugger is not defined):
> - can't achieve to load jsdebugger.jsm (JS::Evaluate of Components.utils.import("resource://gre/modules/jsdebugger.jsm"); does nothing as there is no Component object)
> - even copy/path of the content of jsdebugger.jsm failed (JS::Evaluate of     >  const init = Cc["@mozilla.org/jsdebugger;1"].createInstance(Ci.IJSDebugger);  < failed on Cc that is unknown)

jsdebugger.jsm requires the full browser. If you're only embedding 
mozjs, you will need to use the Debugger interface directly. 
https://developer.mozilla.org/en-US/docs/Tools/Debugger-API