Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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: --expose-debug-as debug |
| 6 | |
| 7 | function f() { |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 8 | print(1); |
| 9 | print(2); |
| 10 | print(3); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | var Debug = debug.Debug; |
| 14 | var exception = null; |
| 15 | var breaks = []; |
| 16 | |
| 17 | function listener(event, exec_state, event_data, data) { |
| 18 | if (event != Debug.DebugEvent.Break) return; |
| 19 | try { |
| 20 | Debug.debuggerFlags().breakPointsActive.setValue(false); |
| 21 | breaks.push(exec_state.frame().sourceLineText().trimLeft()); |
| 22 | exec_state.prepareStep(Debug.StepAction.StepIn); |
| 23 | } catch (e) { |
| 24 | exception = e; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | Debug.setListener(listener); |
| 29 | Debug.setBreakPoint(f, 0, 0); |
| 30 | |
| 31 | f(); |
| 32 | |
| 33 | Debug.setListener(null); |
| 34 | Debug.debuggerFlags().breakPointsActive.setValue(true); |
| 35 | |
| 36 | assertNull(exception); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 37 | assertEquals(breaks, ["print(1);", "print(2);", "print(3);", "}", |
| 38 | "Debug.setListener(null);"]); |