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 var set_bp = false | |
15 | |
16 // Debug event listener which steps until the global variable done is true. | |
17 function listener(event, exec_state, event_data, data) { | |
18 if (event == Debug.DebugEvent.Break) { | |
19 if (!done) Debug.stepOver(); | |
20 step_count++; | |
21 } | |
22 }; | |
23 | |
24 // Set the global variables state to prepare the stepping test. | |
25 function prepare_step_test() { | |
26 done = false; | |
27 step_count = 0; | |
28 } | |
29 | |
30 // Test function to step through. | |
31 function f() { | |
32 var a = 0; | |
33 if (set_bp) { bp = Debug.setBreakPoint(f, 3); } | |
34 var i = 1; | |
35 var j = 2; | |
36 done = true; | |
37 }; | |
38 | |
39 prepare_step_test(); | |
40 f(); | |
41 | |
42 // Add the debug event listener. | |
43 Debug.setListener(listener); | |
44 | |
45 // Make f set a breakpoint with an activation on the stack. | |
46 prepare_step_test(); | |
47 set_bp = true; | |
48 f(); | |
49 assertEquals(4, step_count); | |
50 Debug.clearBreakPoint(bp); | |
51 | |
52 // Set a breakpoint on the first var statement (line 1). | |
53 set_bp = false; | |
54 bp = Debug.setBreakPoint(f, 3); | |
55 | |
56 // Step through the function ensuring that the var statements are hit as well. | |
57 prepare_step_test(); | |
58 f(); | |
59 assertEquals(4, step_count); | |
60 | |
61 // Clear the breakpoint and check that no stepping happens. | |
62 Debug.clearBreakPoint(bp); | |
63 prepare_step_test(); | |
64 f(); | |
65 assertEquals(0, step_count); | |
66 | |
67 // Get rid of the debug event listener. | |
68 Debug.setListener(null); | |
OLD | NEW |