OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 Debug = new DebugWrapper(); | |
6 Debug.enable(); | |
7 | |
8 // Simple debug event handler which performs 100 steps and then retrieves | |
9 // the resulting value of "i" in f(). | |
10 | |
11 function listener(event, exec_state, event_data, data) { | |
12 if (event == Debug.DebugEvent.Break) { | |
13 if (step_count > 0) { | |
14 Debug.stepInto(); | |
15 step_count--; | |
16 } else { | |
17 const frameid = exec_state.frames[0].callFrameId; | |
18 result = Debug.evaluate(frameid, "i").value; | |
19 } | |
20 } | |
21 }; | |
22 | |
23 // Add the debug event listener. | |
24 Debug.setListener(listener); | |
25 | |
26 // Test debug event for break point. | |
27 function f() { | |
28 var i; // Line 1. | |
29 for (i = 0; i < 100; i++) { // Line 2. | |
30 x = 1; // Line 3. | |
31 } | |
32 }; | |
33 | |
34 // Set a breakpoint on the for statement (line 1). | |
35 Debug.setBreakPoint(f, 1); | |
36 | |
37 // Check that performing 100 steps will make i 33. | |
38 let step_count = 100; | |
39 let result = -1; | |
40 | |
41 f(); | |
42 | |
43 assertEquals(33, result); | |
OLD | NEW |