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 const Debug = new DebugWrapper(); | |
6 Debug.enable(); | |
7 | |
8 // This test tests that full code compiled without debug break slots | |
9 // is recompiled with debug break slots when debugging is started. | |
10 | |
11 var bp; | |
12 var done = false; | |
13 var step_count = 0; | |
14 | |
15 // Debug event listener which steps until the global variable done is true. | |
16 function listener(event, exec_state, event_data, data) { | |
17 if (event == Debug.DebugEvent.Break) { | |
18 if (!done) Debug.stepOver(); | |
19 step_count++; | |
20 } | |
21 }; | |
22 | |
23 // Set the global variables state to prpare the stepping test. | |
24 function prepare_step_test() { | |
25 done = false; | |
26 step_count = 0; | |
27 } | |
28 | |
29 // Test function to step through. | |
30 function f() { | |
31 var i = 1; | |
32 var j = 2; | |
33 done = true; | |
34 }; | |
35 | |
36 prepare_step_test(); | |
37 f(); | |
38 | |
39 // Add the debug event listener. | |
40 Debug.setListener(listener); | |
41 | |
42 bp = Debug.setBreakPoint(f, 1); | |
43 | |
44 prepare_step_test(); | |
45 f(); | |
46 assertEquals(4, step_count); | |
47 Debug.clearBreakPoint(bp); | |
48 | |
49 // Set a breakpoint on the first var statement (line 1). | |
50 bp = Debug.setBreakPoint(f, 1); | |
51 | |
52 // Step through the function ensuring that the var statements are hit as well. | |
53 prepare_step_test(); | |
54 f(); | |
55 assertEquals(4, step_count); | |
56 | |
57 // Clear the breakpoint and check that no stepping happens. | |
58 Debug.clearBreakPoint(bp); | |
59 prepare_step_test(); | |
60 f(); | |
61 assertEquals(0, step_count); | |
OLD | NEW |