blob: e47816a4d5a33c2140bff2d54350f02b83f74487 [file] [log] [blame]
Andrew Topef837fa2017-10-04 22:44:25 -07001// 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
5const Debug = new DebugWrapper();
6Debug.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
11var bp;
12var done = false;
13var step_count = 0;
14
15// Debug event listener which steps until the global variable done is true.
16function 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.
24function prepare_step_test() {
25 done = false;
26 step_count = 0;
27}
28
29// Test function to step through.
30function f() {
31 var i = 1;
32 var j = 2;
33 done = true;
34};
35
36prepare_step_test();
37f();
38
39// Add the debug event listener.
40Debug.setListener(listener);
41
42bp = Debug.setBreakPoint(f, 1);
43
44prepare_step_test();
45f();
46assertEquals(4, step_count);
47Debug.clearBreakPoint(bp);
48
49// Set a breakpoint on the first var statement (line 1).
50bp = Debug.setBreakPoint(f, 1);
51
52// Step through the function ensuring that the var statements are hit as well.
53prepare_step_test();
54f();
55assertEquals(4, step_count);
56
57// Clear the breakpoint and check that no stepping happens.
58Debug.clearBreakPoint(bp);
59prepare_step_test();
60f();
61assertEquals(0, step_count);