PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/debug/breakpoint-multi-03.js

http://github.com/zpao/v8monkey
JavaScript | 27 lines | 22 code | 4 blank | 1 comment | 2 complexity | a6bc3974625770b4e9bba76f6860983e MD5 | raw file
 1// Multiple Debugger objects can set breakpoints at the same instruction.
 2
 3var g = newGlobal('new-compartment');
 4function attach(g, i) {
 5    var dbg = Debugger(g);
 6    dbg.onDebuggerStatement = function (frame) {
 7        var s = frame.eval("f").return.script;
 8        var offs = s.getLineOffsets(g.line0 + 3);
 9        for (var j = 0; j < offs.length; j++)
10            s.setBreakpoint(offs[j], {hit: function () { g.log += "" + i; }});
11    };
12}
13
14g.eval("var line0 = Error().lineNumber;\n" +
15       "function f() {\n" +     // line0 + 1
16       "    log += 'a';\n" +    // line0 + 2
17       "    log += 'b';\n" +    // line0 + 3
18       "}\n");
19
20for (var i = 0; i < 3; i++)
21    attach(g, i);
22
23g.log = '';
24g.eval('debugger;');
25g.log += 'x';
26g.f();
27assertEq(g.log, 'xa012b');