js/src/jit-test/tests/debug/Frame-onStep-04.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Frame-onStep-04.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,34 @@
     1.4 +// When a recursive function has many frames on the stack, onStep may be set or
     1.5 +// not independently on each frame.
     1.6 +
     1.7 +var g = newGlobal();
     1.8 +g.eval("function f(x) {\n" +
     1.9 +       "    if (x > 0)\n" +
    1.10 +       "        f(x - 1);\n" +
    1.11 +       "    else\n" +
    1.12 +       "        debugger;\n" +
    1.13 +       "    return x;\n" +
    1.14 +       "}");
    1.15 +
    1.16 +var dbg = Debugger(g);
    1.17 +var seen = [0, 0, 0, 0, 0, 0, 0, 0];
    1.18 +function step() {
    1.19 +    seen[this.arguments[0]] = 1;
    1.20 +}
    1.21 +dbg.onEnterFrame = function (frame) {
    1.22 +    // Turn on stepping for even-numbered frames.
    1.23 +    var x = frame.arguments[0];
    1.24 +    if (x % 2 === 0)
    1.25 +        frame.onStep = step;
    1.26 +};
    1.27 +dbg.onDebuggerStatement = function (frame) {
    1.28 +    // This is called with 8 call frames on the stack, 7 down to 0.
    1.29 +    // At this point we should have seen all the even-numbered frames.
    1.30 +    assertEq(seen.join(""), "10101010");
    1.31 +
    1.32 +    // Now reset seen to see which frames fire onStep on the way out.
    1.33 +    seen = [0, 0, 0, 0, 0, 0, 0, 0];
    1.34 +};
    1.35 +
    1.36 +g.f(7);
    1.37 +assertEq(seen.join(""), "10101010");

mercurial