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

Side by Side Diff: test/debugger/debug-evaluate-locals-optimized-double.js

Issue 2491543002: [debug-wrapper] Conditional breaks, locals, evaluate, scopes (Closed)
Patch Set: Rebase 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 | « no previous file | test/debugger/debug/debug-break-inline.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 27 matching lines...) Expand all
38 38
39 var input = [ 39 var input = [
40 {a: 1, b: 2}, 40 {a: 1, b: 2},
41 {a: 3, b: 4}, 41 {a: 3, b: 4},
42 {a: 5, b: 6}, 42 {a: 5, b: 6},
43 {a: 7, b: 8}, 43 {a: 7, b: 8},
44 {a: 9, b: 10} 44 {a: 9, b: 10}
45 ]; 45 ];
46 46
47 var expected = [ 47 var expected = [
48 { locals: {a0: 1.01, b0: 2.02}, 48 { locals: {i: 0, x0: 3.03, y0: 4.04, a0: 1.01, b0: 2.02},
49 args: { names: ["i", "x0", "y0"], values: [0, 3.03, 4.04] } }, 49 args: { names: ["i", "x0", "y0"], values: [0, 3.03, 4.04] } },
50 { locals: {a1: 3.03, b1: 4.04}, 50 { locals: {i: 1, x1: 5.05, y1: 6.06, a1: 3.03, b1: 4.04},
51 args: { names: ["i", "x1", "y1"], values: [1, 5.05, 6.06] } }, 51 args: { names: ["i", "x1", "y1"], values: [1, 5.05, 6.06] } },
52 { locals: {a2: 5.05, b2: 6.06}, 52 { locals: {i: 2, a2: 5.05, b2: 6.06},
53 args: { names: ["i"], values: [2] } }, 53 args: { names: ["i"], values: [2] } },
54 { locals: {a3: 7.07, b3: 8.08}, 54 { locals: {i: 3, x3: 9.09, y3: 10.10, z3: undefined, a3: 7.07, b3: 8.08},
55 args: { names: ["i", "x3", "y3", "z3"], 55 args: { names: ["i", "x3", "y3", "z3"],
56 values: [3, 9.09, 10.10, undefined] } }, 56 values: [3, 9.09, 10.10, undefined] } },
57 { locals: {a4: 9.09, b4: 10.10}, 57 { locals: {i: 4, x4: 11.11, y4: 12.12, a4: 9.09, b4: 10.10},
58 args: { names: ["i", "x4", "y4"], values: [4, 11.11, 12.12] } } 58 args: { names: ["i", "x4", "y4"], values: [4, 11.11, 12.12] } }
59 ]; 59 ];
60 60
61 function arraySum(arr) {
62 return arr.reduce(function (a, b) { return a + b; }, 0);
63 }
64
65 function listener(event, exec_state, event_data, data) { 61 function listener(event, exec_state, event_data, data) {
66 try { 62 try {
67 if (event == Debug.DebugEvent.Break) 63 if (event == Debug.DebugEvent.Break)
68 { 64 {
69 assertEquals(6, exec_state.frameCount()); 65 assertEquals(6, exec_state.frameCount());
70 66
71 for (var i = 0; i < exec_state.frameCount(); i++) { 67 for (var i = 0; i < exec_state.frameCount(); i++) {
72 var frame = exec_state.frame(i); 68 var frame = exec_state.frame(i);
73 if (i < exec_state.frameCount() - 1) { 69 if (i < exec_state.frameCount() - 1) {
74 var expected_args = expected[i].args; 70 var expected_args = expected[i].args;
75 var expected_locals = expected[i].locals; 71 var expected_locals = expected[i].locals;
76 72
77 // All frames except the bottom one have expected locals. 73 // All frames except the bottom one have expected locals.
78 var locals = {}; 74 var locals = {};
79 for (var j = 0; j < frame.localCount(); j++) { 75 for (var j = 0; j < frame.localCount(); j++) {
80 locals[frame.localName(j)] = frame.localValue(j).value(); 76 locals[frame.localName(j)] = frame.localValue(j).value();
81 } 77 }
82 assertPropertiesEqual(expected_locals, locals); 78 assertPropertiesEqual(expected_locals, locals);
83 79
84 // All frames except the bottom one have expected arguments.
85 for (var j = 0; j < expected_args.names.length; j++) {
86 assertEquals(expected_args.names[j], frame.argumentName(j));
87 assertEquals(expected_args.values[j],
88 frame.argumentValue(j).value());
89 }
90
91 // All frames except the bottom one have two scopes. 80 // All frames except the bottom one have two scopes.
92 assertEquals(3, frame.scopeCount()); 81 assertEquals(3, frame.scopeCount());
93 assertEquals(debug.ScopeType.Local, frame.scope(0).scopeType()); 82 assertEquals(debug.ScopeType.Local, frame.scope(0).scopeType());
94 assertEquals(debug.ScopeType.Script, frame.scope(1).scopeType()); 83 assertEquals(debug.ScopeType.Script, frame.scope(1).scopeType());
95 assertEquals(debug.ScopeType.Global, frame.scope(2).scopeType()); 84 assertEquals(debug.ScopeType.Global, frame.scope(2).scopeType());
96 85
97 Object.keys(expected_locals).forEach(function (name) { 86 Object.keys(expected_locals).forEach(function (name) {
98 assertEquals(expected_locals[name], 87 assertEquals(expected_locals[name],
99 frame.scope(0).scopeObject().value()[name]); 88 frame.scope(0).scopeObject().value()[name]);
100 }); 89 });
101 90
102 for (var j = 0; j < expected_args.names.length; j++) { 91 for (var j = 0; j < expected_args.names.length; j++) {
103 var arg_name = expected_args.names[j]; 92 var arg_name = expected_args.names[j];
104 var arg_value = expected_args.values[j]; 93 var arg_value = expected_args.values[j];
105 assertEquals(arg_value, 94 assertEquals(arg_value,
106 frame.scope(0).scopeObject().value()[arg_name]); 95 frame.scope(0).scopeObject().value()[arg_name]);
107 } 96 }
108 97
109 // Evaluate in the inlined frame. 98 // Evaluate in the inlined frame.
110 Object.keys(expected_locals).forEach(function (name) { 99 Object.keys(expected_locals).forEach(function (name) {
111 assertEquals(expected_locals[name], frame.evaluate(name).value()); 100 assertEquals(expected_locals[name], frame.evaluate(name).value());
112 }); 101 });
113 102
114 for (var j = 0; j < expected_args.names.length; j++) { 103 for (var j = 0; j < expected_args.names.length; j++) {
115 var arg_name = expected_args.names[j]; 104 var arg_name = expected_args.names[j];
116 var arg_value = expected_args.values[j]; 105 var arg_value = expected_args.values[j];
117 assertEquals(arg_value, frame.evaluate(arg_name).value()); 106 assertEquals(arg_value, frame.evaluate(arg_name).value());
118 assertEquals(arg_value, frame.evaluate('arguments['+j+']').value()); 107 assertEquals(arg_value, frame.evaluate('arguments['+j+']').value());
119 } 108 }
120
121 var expected_args_sum = arraySum(expected_args.values);
122 var expected_locals_sum =
123 arraySum(Object.keys(expected_locals).
124 map(function (k) { return expected_locals[k]; }));
125
126 assertEquals(expected_locals_sum + expected_args_sum,
127 frame.evaluate(Object.keys(expected_locals).join('+') +
128 ' + ' +
129 expected_args.names.join('+')).value());
130
131 var arguments_sum = expected_args.names.map(function(_, idx) {
132 return "arguments[" + idx + "]";
133 }).join('+');
134 assertEquals(expected_args_sum,
135 frame.evaluate(arguments_sum).value());
136 } else { 109 } else {
137 // The bottom frame only have the global scope. 110 // The bottom frame only have the global scope.
138 assertEquals(2, frame.scopeCount()); 111 assertEquals(2, frame.scopeCount());
139 assertEquals(debug.ScopeType.Script, frame.scope(0).scopeType()); 112 assertEquals(debug.ScopeType.Script, frame.scope(0).scopeType());
140 assertEquals(debug.ScopeType.Global, frame.scope(1).scopeType()); 113 assertEquals(debug.ScopeType.Global, frame.scope(1).scopeType());
141 } 114 }
142 115
143 // Check the frame function. 116 // Check the frame function.
144 switch (i) { 117 switch (i) {
145 case 0: assertEquals(h, frame.func().value()); break; 118 case 0: assertEquals("h", frame.func().name()); break;
146 case 1: assertEquals(g3, frame.func().value()); break; 119 case 1: assertEquals("g3", frame.func().name()); break;
147 case 2: assertEquals(g2, frame.func().value()); break; 120 case 2: assertEquals("g2", frame.func().name()); break;
148 case 3: assertEquals(g1, frame.func().value()); break; 121 case 3: assertEquals("g1", frame.func().name()); break;
149 case 4: assertEquals(f, frame.func().value()); break; 122 case 4: assertEquals("f", frame.func().name()); break;
150 case 5: break; 123 case 5: break;
151 default: assertUnreachable(); 124 default: assertUnreachable();
152 } 125 }
153
154 // Check for construct call.
155 if (i == 4) {
156 assertEquals(testingConstructCall, frame.isConstructCall());
157 } else if (i == 2) {
158 assertTrue(frame.isConstructCall());
159 } else {
160 assertFalse(frame.isConstructCall());
161 }
162
163 if (i > 4) {
164 assertFalse(frame.isOptimizedFrame());
165 assertFalse(frame.isInlinedFrame());
166 }
167 } 126 }
168 127
169 // Indicate that all was processed. 128 // Indicate that all was processed.
170 listenerComplete = true; 129 listenerComplete = true;
171 } 130 }
172 } catch (e) { 131 } catch (e) {
173 exception = e.toString() + e.stack; 132 exception = e.toString() + e.stack;
174 }; 133 };
175 }; 134 };
176 135
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 new f(input.length - 1, 11.11, 12.12, ""); 193 new f(input.length - 1, 11.11, 12.12, "");
235 194
236 // Make sure that the debug event listener was invoked. 195 // Make sure that the debug event listener was invoked.
237 assertFalse(exception, "exception in listener " + exception) 196 assertFalse(exception, "exception in listener " + exception)
238 assertTrue(listenerComplete); 197 assertTrue(listenerComplete);
239 198
240 //Throw away type information for next run. 199 //Throw away type information for next run.
241 gc(); 200 gc();
242 201
243 Debug.setListener(null); 202 Debug.setListener(null);
OLDNEW
« no previous file with comments | « no previous file | test/debugger/debug/debug-break-inline.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698