Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: test/debugger/debugger/debug-step-4.js

Issue 2447073007: [debugger] Various break-related functionality in test wrapper (Closed)
Patch Set: Move DebugEvent to DebugWrapper to preserve old API Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/debugger/debugger/debug-step-3.js ('k') | test/debugger/test-api.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Tests how debugger can step over not necessarily in the top frame.
9
10 // Simple 3 functions, that protocol their execution state in global
11 // variable state.
12 var state;
13
14 function f() {
15 var a = 1978;
16 for (state[2] = 0; state[2] < 3; state[2]++) {
17 void String(a);
18 }
19 }
20 function g() {
21 for (state[1] = 0; state[1] < 3; state[1]++) {
22 f();
23 }
24 }
25 function h() {
26 state = [-1, -1, -1];
27 for (state[0] = 0; state[0] < 3; state[0]++) {
28 g();
29 }
30 }
31
32 function TestCase(expected_final_state) {
33 var listener_exception = null;
34 var state_snapshot;
35 var listener_state;
36 var bp;
37
38 function listener(event, exec_state, event_data, data) {
39 const location = exec_state.frames[0].location
40 print("Here (" + event + "/" + listener_state + "): " +
41 location.lineNumber + ":" + location.columnNumber);
42 try {
43 if (event == Debug.DebugEvent.Break) {
44 if (listener_state == 0) {
45 Debug.clearBreakPoint(bp);
46 Debug.stepOver();
47 listener_state = 1;
48 } else if (listener_state == 1) {
49 state_snapshot = String(state);
50 print("State: " + state_snapshot);
51 Debug.setListener(null);
52 listener_state = 2;
53 }
54 }
55 } catch (e) {
56 listener_exception = e;
57 }
58 }
59
60
61 // Add the debug event listener.
62 listener_state = 0;
63 Debug.setListener(listener);
64 bp = Debug.setBreakPoint(f, 1);
65
66 h();
67 Debug.setListener(null);
68 if (listener_exception !== null) {
69 print("Exception caught: " + listener_exception);
70 assertUnreachable();
71 }
72
73 assertEquals(expected_final_state, state_snapshot);
74 }
75
76
77 // Warm-up -- make sure all is compiled and ready for breakpoint.
78 h();
79
80 TestCase("0,0,-1");
OLDNEW
« no previous file with comments | « test/debugger/debugger/debug-step-3.js ('k') | test/debugger/test-api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698