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

Benjamin Kircher <[email protected]> Tue, 24 Jan 2017 22:30:14 +0100
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
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