OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --noturbo-osr --expose-debug-as debug |
| 6 |
| 7 var stdlib = this; |
| 8 var buffer = new ArrayBuffer(64 * 1024); |
| 9 var foreign = { thrower: thrower, debugme: debugme } |
| 10 |
| 11 // Get the Debug object exposed from the debug context global object. |
| 12 Debug = debug.Debug; |
| 13 |
| 14 var listenerCalled = false; |
| 15 function listener(event, exec_state, event_data, data) { |
| 16 try { |
| 17 if (event == Debug.DebugEvent.Break) { |
| 18 var frame = exec_state.frame(1); |
| 19 assertEquals(m.foo, frame.func().value()); |
| 20 listenerCalled = true; |
| 21 } |
| 22 } catch (e) { |
| 23 print("Caught: " + e + " " + e.stack); |
| 24 }; |
| 25 } |
| 26 |
| 27 function thrower() { throw "boom"; } |
| 28 function debugme() { Debug.setListener(listener); debugger; } |
| 29 |
| 30 function Module(stdlib, foreign, heap) { |
| 31 "use asm"; |
| 32 var thrower = foreign.thrower; |
| 33 var debugme = foreign.debugme; |
| 34 function foo(i) { |
| 35 i = i|0; |
| 36 var a = 101; // Local variables exist ... |
| 37 var b = 102; // ... to make the debugger ... |
| 38 var c = 103; // ... inspect them during break. |
| 39 if (i > 0) { |
| 40 debugme(); |
| 41 i = 23; |
| 42 } else { |
| 43 thrower(); |
| 44 i = 42; |
| 45 } |
| 46 return i|0; |
| 47 } |
| 48 return { foo: foo }; |
| 49 } |
| 50 |
| 51 var m = Module(stdlib, foreign, buffer); |
| 52 |
| 53 assertThrows("m.foo(0)"); |
| 54 assertEquals(23, m.foo(1)); |
| 55 assertTrue(listenerCalled); |
OLD | NEW |