Re: Embedded, Debugger-API: force stop current thread of JS execution

Shu-yu Guo <[email protected]> Tue, 24 Jan 2017 16:34:43 -0800
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <CACVBLKJA+1NdKKN=jx89rugD_XVP9UnMoH=ME32JsEbNX3yijA@mail.gmail.com>
Hi Benjamin,

Using the Debugger API to terminate execution is easy: return `null` from
any Debugger handler that expects a completion value [1] to be returned.
For example, returning null from a breakpoint handler or an onEnterFrame
will terminate debuggee execution.

[1]
https://developer.mozilla.org/en-US/docs/Tools/Debugger-API/Conventions#completion-values

HTH,

On Tue, Jan 24, 2017 at 1:30 PM, Benjamin Kircher <
[email protected]> wrote:

> Hi there!
>
> tl/dr;
> How to forcefully terminate the current thread of JavaScript execution?
>
>
> I'm currently working on a JS remote debugger engine that is used to debug
> JS scripts running in an embedded SpiderMonkey. Of course, the debugger
> engine is using Debugger-API.
>
> Now I want to implement a 'Stop' feature that is whenever a user hits the
> 'Stop' button in his IDE, the current debuggee should stop its execution,
> but I fail to see how I would do something like this with the Debugger-API.
>
> Besides Debugger-API, one idea I had in mind is to use
> JS_SetOperationCallback, or JS_SetInterruptCallback, respectively, to check
> a flag variable and terminate the script by returning false from the
> callback but I am really not sure if this is the way to go. Another guess
> of mine is to look for an "uncatchable" exception that I can throw, or
> return false from a native function w/o setting an exception.
>
> I'm looking for something like V8::TerminateExecution in SpiderMonkey.
>
> Any advice is greatly appreciated.
>
> BK
> _______________________________________________
> dev-tech-js-engine mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>



-- 
       shu