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 --noturbo-inlining --expose-debug-as debug 6 7var stdlib = this; 8var buffer = new ArrayBuffer(64 * 1024); 9var foreign = { thrower: thrower, debugme: debugme } 10 11// Get the Debug object exposed from the debug context global object. 12Debug = debug.Debug; 13 14var listenerCalled = false; 15function 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 27function thrower() { throw "boom"; } 28function debugme() { Debug.setListener(listener); debugger; } 29 30function 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 51var m = Module(stdlib, foreign, buffer); 52 53assertThrows("m.foo(0)"); 54assertEquals(23, m.foo(1)); 55assertTrue(listenerCalled); 56