michael@0: // When a recursive function has many frames on the stack, onStep may be set or michael@0: // not independently on each frame. michael@0: michael@0: var g = newGlobal(); michael@0: g.eval("function f(x) {\n" + michael@0: " if (x > 0)\n" + michael@0: " f(x - 1);\n" + michael@0: " else\n" + michael@0: " debugger;\n" + michael@0: " return x;\n" + michael@0: "}"); michael@0: michael@0: var dbg = Debugger(g); michael@0: var seen = [0, 0, 0, 0, 0, 0, 0, 0]; michael@0: function step() { michael@0: seen[this.arguments[0]] = 1; michael@0: } michael@0: dbg.onEnterFrame = function (frame) { michael@0: // Turn on stepping for even-numbered frames. michael@0: var x = frame.arguments[0]; michael@0: if (x % 2 === 0) michael@0: frame.onStep = step; michael@0: }; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: // This is called with 8 call frames on the stack, 7 down to 0. michael@0: // At this point we should have seen all the even-numbered frames. michael@0: assertEq(seen.join(""), "10101010"); michael@0: michael@0: // Now reset seen to see which frames fire onStep on the way out. michael@0: seen = [0, 0, 0, 0, 0, 0, 0, 0]; michael@0: }; michael@0: michael@0: g.f(7); michael@0: assertEq(seen.join(""), "10101010");