Re: Embedded, Debugger-API: force stop current thread of JS execution
Benjamin Kircher <[email protected]> Thu, 2 Feb 2017 08:34:59 +0100
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
> On 25 Jan 2017, at 01:34, Shu-yu Guo <[email protected]> wrote: > > 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 Thank you! Exactly what I'm looking for! It took me some time to find some useful example code out there. Until I looked at the test suite and there it is, blindingly obvious. This is from js/src/jit-test/tests/debug/Frame-onStep-resumption-03.js: // If frame.onStep returns null, the debuggee terminates. var g = newGlobal('new-compartment'); g.eval("function h() { debugger; }"); var dbg = Debugger(g); var hits = 0; dbg.onDebuggerStatement = function (frame) { hits++; if (hits == 1) { var rv = frame.eval("h();\n" + "throw 'fail';\n"); assertEq(rv, null); } else { frame.older.onStep = function () { return null; }; } }; g.h(); assertEq(hits, 2); BK