michael@0: // Q: But who shall debug the debuggers? A: jimb michael@0: michael@0: var log = ''; michael@0: michael@0: function addDebug(g, id) { michael@0: var debuggerGlobal = newGlobal(); michael@0: debuggerGlobal.debuggee = g; michael@0: debuggerGlobal.id = id; michael@0: debuggerGlobal.print = function (s) { log += s; }; michael@0: debuggerGlobal.eval( michael@0: 'var dbg = new Debugger(debuggee);\n' + michael@0: 'dbg.onDebuggerStatement = function () { print(id); debugger; print(id); };\n'); michael@0: return debuggerGlobal; michael@0: } michael@0: michael@0: var base = newGlobal(); michael@0: var top = base; michael@0: for (var i = 0; i < 8; i++) // why have 2 debuggers when you can have 8 michael@0: top = addDebug(top, i); michael@0: base.eval("debugger;"); michael@0: assertEq(log, '0123456776543210');