blob: a07c6a646678fae5f3a1d04fc24810e406e63002 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
7function f() {
8 for (var i = 10; i < 14; i++) { // 1
9 i; // 2
10 }
11} // 3
12
13var state = "conditional";
14var log = [];
15var exception = null;
16
17function listener(event, exec_state, event_data, data) {
18 if (event != Debug.DebugEvent.Break) return;
19 try {
20 var label = +exec_state.frame(0).sourceLineText().substr(-1);
21 log.push(label);
22 if (label == 2) log.push(exec_state.frame(0).evaluate("i").value());
23 exec_state.prepareStep(Debug.StepAction.StepNext);
24 } catch (e) {
25 exception = e;
26 print("Caught something. " + e + " " + e.stack);
27 };
28};
29
30
31var Debug = debug.Debug;
32Debug.setListener(listener);
33
34Debug.setBreakPoint(f, 2, 0, "i == 12");
35
36f();
37
38Debug.setListener(null); // 4
39
40assertEquals([2,12,1,1,2,13,1,1,3,4], log);
41assertNull(exception);