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

Side by Side Diff: test/mjsunit/debug-handle.js

Issue 242034: Redo "running" field in debug-delay.js and support "suspend" command (Closed)
Patch Set: do not remove body from backtrace Created 11 years, 2 months 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/mjsunit/debug-evaluate-recursive.js ('k') | test/mjsunit/debug-mirror-cache.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 25 matching lines...) Expand all
36 try { 36 try {
37 return eval('(' + code + ')'); 37 return eval('(' + code + ')');
38 } catch (e) { 38 } catch (e) {
39 assertEquals(void 0, e); 39 assertEquals(void 0, e);
40 return undefined; 40 return undefined;
41 } 41 }
42 } 42 }
43 43
44 44
45 // Send an evaluation request and return the handle of the result. 45 // Send an evaluation request and return the handle of the result.
46 function evaluateRequest(dcp, arguments) { 46 function evaluateRequest(exec_state, arguments) {
47 // Get the debug command processor.
48 var dcp = exec_state.debugCommandProcessor("unspecified_running_state");
49
47 // The base part of all evaluate requests. 50 // The base part of all evaluate requests.
48 var base_request = '"seq":0,"type":"request","command":"evaluate"' 51 var base_request = '"seq":0,"type":"request","command":"evaluate"'
49 52
50 // Generate request with the supplied arguments. 53 // Generate request with the supplied arguments.
51 var request; 54 var request;
52 if (arguments) { 55 if (arguments) {
53 request = '{' + base_request + ',"arguments":' + arguments + '}'; 56 request = '{' + base_request + ',"arguments":' + arguments + '}';
54 } else { 57 } else {
55 request = '{' + base_request + '}' 58 request = '{' + base_request + '}'
56 } 59 }
57 60
58 var response = safeEval(dcp.processDebugJSONRequest(request)); 61 var response = safeEval(dcp.processDebugJSONRequest(request));
59 assertTrue(response.success, request + ' -> ' + response.message); 62 assertTrue(response.success, request + ' -> ' + response.message);
60 63
61 return response.body.handle; 64 return response.body.handle;
62 } 65 }
63 66
64 67
65 // Send a lookup request and return the evaluated JSON response. 68 // Send a lookup request and return the evaluated JSON response.
66 function lookupRequest(dcp, arguments, success) { 69 function lookupRequest(exec_state, arguments, success) {
70 // Get the debug command processor.
71 var dcp = exec_state.debugCommandProcessor("unspecified_running_state");
72
67 // The base part of all lookup requests. 73 // The base part of all lookup requests.
68 var base_request = '"seq":0,"type":"request","command":"lookup"' 74 var base_request = '"seq":0,"type":"request","command":"lookup"'
69 75
70 // Generate request with the supplied arguments. 76 // Generate request with the supplied arguments.
71 var request; 77 var request;
72 if (arguments) { 78 if (arguments) {
73 request = '{' + base_request + ',"arguments":' + arguments + '}'; 79 request = '{' + base_request + ',"arguments":' + arguments + '}';
74 } else { 80 } else {
75 request = '{' + base_request + '}' 81 request = '{' + base_request + '}'
76 } 82 }
77 83
78 var response = safeEval(dcp.processDebugJSONRequest(request)); 84 var response = safeEval(dcp.processDebugJSONRequest(request));
79 if (success) { 85 if (success) {
80 assertTrue(response.success, request + ' -> ' + response.message); 86 assertTrue(response.success, request + ' -> ' + response.message);
81 } else { 87 } else {
82 assertFalse(response.success, request + ' -> ' + response.message); 88 assertFalse(response.success, request + ' -> ' + response.message);
83 } 89 }
84 assertFalse(response.running, request + ' -> expected not running'); 90 assertEquals(response.running, dcp.isRunning(), request + ' -> expected not ru nning');
85 91
86 return response; 92 return response;
87 } 93 }
88 94
89 95
90 function listener(event, exec_state, event_data, data) { 96 function listener(event, exec_state, event_data, data) {
91 try { 97 try {
92 if (event == Debug.DebugEvent.Break) { 98 if (event == Debug.DebugEvent.Break) {
93 // Get the debug command processor.
94 var dcp = exec_state.debugCommandProcessor();
95
96 // Test some illegal lookup requests. 99 // Test some illegal lookup requests.
97 lookupRequest(dcp, void 0, false); 100 lookupRequest(exec_state, void 0, false);
98 lookupRequest(dcp, '{"handles":["a"]}', false); 101 lookupRequest(exec_state, '{"handles":["a"]}', false);
99 lookupRequest(dcp, '{"handles":[-1]}', false); 102 lookupRequest(exec_state, '{"handles":[-1]}', false);
100 103
101 // Evaluate and get some handles. 104 // Evaluate and get some handles.
102 var handle_o = evaluateRequest(dcp, '{"expression":"o"}'); 105 var handle_o = evaluateRequest(exec_state, '{"expression":"o"}');
103 var handle_p = evaluateRequest(dcp, '{"expression":"p"}'); 106 var handle_p = evaluateRequest(exec_state, '{"expression":"p"}');
104 var handle_b = evaluateRequest(dcp, '{"expression":"a"}'); 107 var handle_b = evaluateRequest(exec_state, '{"expression":"a"}');
105 var handle_a = evaluateRequest(dcp, '{"expression":"b","frame":1}'); 108 var handle_a = evaluateRequest(exec_state, '{"expression":"b","frame":1}');
106 assertEquals(handle_o, handle_a); 109 assertEquals(handle_o, handle_a);
107 assertEquals(handle_a, handle_b); 110 assertEquals(handle_a, handle_b);
108 assertFalse(handle_o == handle_p, "o and p have he same handle"); 111 assertFalse(handle_o == handle_p, "o and p have he same handle");
109 112
110 var response; 113 var response;
111 var count; 114 var count;
112 response = lookupRequest(dcp, '{"handles":[' + handle_o + ']}', true); 115 response = lookupRequest(exec_state, '{"handles":[' + handle_o + ']}', true) ;
113 var obj = response.body[handle_o]; 116 var obj = response.body[handle_o];
114 assertTrue(!!obj, 'Object not found: ' + handle_o); 117 assertTrue(!!obj, 'Object not found: ' + handle_o);
115 assertEquals(handle_o, obj.handle); 118 assertEquals(handle_o, obj.handle);
116 count = 0; 119 count = 0;
117 for (i in obj.properties) { 120 for (i in obj.properties) {
118 switch (obj.properties[i].name) { 121 switch (obj.properties[i].name) {
119 case 'o': 122 case 'o':
120 obj.properties[i].ref = handle_o; 123 obj.properties[i].ref = handle_o;
121 count++; 124 count++;
122 break; 125 break;
123 case 'p': 126 case 'p':
124 obj.properties[i].ref = handle_p; 127 obj.properties[i].ref = handle_p;
125 count++; 128 count++;
126 break; 129 break;
127 } 130 }
128 } 131 }
129 assertEquals(2, count, 'Either "o" or "p" not found'); 132 assertEquals(2, count, 'Either "o" or "p" not found');
130 response = lookupRequest(dcp, '{"handles":[' + handle_p + ']}', true); 133 response = lookupRequest(exec_state, '{"handles":[' + handle_p + ']}', true) ;
131 obj = response.body[handle_p]; 134 obj = response.body[handle_p];
132 assertTrue(!!obj, 'Object not found: ' + handle_p); 135 assertTrue(!!obj, 'Object not found: ' + handle_p);
133 assertEquals(handle_p, obj.handle); 136 assertEquals(handle_p, obj.handle);
134 137
135 // Check handles for functions on the stack. 138 // Check handles for functions on the stack.
136 var handle_f = evaluateRequest(dcp, '{"expression":"f"}'); 139 var handle_f = evaluateRequest(exec_state, '{"expression":"f"}');
137 var handle_g = evaluateRequest(dcp, '{"expression":"g"}'); 140 var handle_g = evaluateRequest(exec_state, '{"expression":"g"}');
138 var handle_caller = evaluateRequest(dcp, '{"expression":"f.caller"}'); 141 var handle_caller = evaluateRequest(exec_state, '{"expression":"f.caller"}') ;
139 142
140 assertFalse(handle_f == handle_g, "f and g have he same handle"); 143 assertFalse(handle_f == handle_g, "f and g have he same handle");
141 assertEquals(handle_g, handle_caller, "caller for f should be g"); 144 assertEquals(handle_g, handle_caller, "caller for f should be g");
142 145
143 response = lookupRequest(dcp, '{"handles":[' + handle_f + ']}', true); 146 response = lookupRequest(exec_state, '{"handles":[' + handle_f + ']}', true) ;
144 obj = response.body[handle_f]; 147 obj = response.body[handle_f];
145 assertEquals(handle_f, obj.handle); 148 assertEquals(handle_f, obj.handle);
146 149
147 count = 0; 150 count = 0;
148 for (i in obj.properties) { 151 for (i in obj.properties) {
149 var ref = obj.properties[i].ref; 152 var ref = obj.properties[i].ref;
150 var arguments = '{"handles":[' + ref + ']}'; 153 var arguments = '{"handles":[' + ref + ']}';
151 switch (obj.properties[i].name) { 154 switch (obj.properties[i].name) {
152 case 'name': 155 case 'name':
153 var response_name; 156 var response_name;
154 response_name = lookupRequest(dcp, arguments, true); 157 response_name = lookupRequest(exec_state, arguments, true);
155 assertEquals('string', response_name.body[ref].type); 158 assertEquals('string', response_name.body[ref].type);
156 assertEquals("f", response_name.body[ref].value); 159 assertEquals("f", response_name.body[ref].value);
157 count++; 160 count++;
158 break; 161 break;
159 case 'length': 162 case 'length':
160 var response_length; 163 var response_length;
161 response_length = lookupRequest(dcp, arguments, true); 164 response_length = lookupRequest(exec_state, arguments, true);
162 assertEquals('number', response_length.body[ref].type); 165 assertEquals('number', response_length.body[ref].type);
163 assertEquals(1, response_length.body[ref].value); 166 assertEquals(1, response_length.body[ref].value);
164 count++; 167 count++;
165 break; 168 break;
166 case 'caller': 169 case 'caller':
167 assertEquals(handle_g, obj.properties[i].ref); 170 assertEquals(handle_g, obj.properties[i].ref);
168 count++; 171 count++;
169 break; 172 break;
170 } 173 }
171 } 174 }
172 assertEquals(3, count, 'Either "name", "length" or "caller" not found'); 175 assertEquals(3, count, 'Either "name", "length" or "caller" not found');
173 176
174 177
175 // Resolve all at once. 178 // Resolve all at once.
176 var refs = []; 179 var refs = [];
177 for (i in obj.properties) { 180 for (i in obj.properties) {
178 refs.push(obj.properties[i].ref); 181 refs.push(obj.properties[i].ref);
179 } 182 }
180 183
181 var arguments = '{"handles":[' + refs.join(',') + ']}'; 184 var arguments = '{"handles":[' + refs.join(',') + ']}';
182 response = lookupRequest(dcp, arguments, true); 185 response = lookupRequest(exec_state, arguments, true);
183 count = 0; 186 count = 0;
184 for (i in obj.properties) { 187 for (i in obj.properties) {
185 var ref = obj.properties[i].ref; 188 var ref = obj.properties[i].ref;
186 var val = response.body[ref]; 189 var val = response.body[ref];
187 assertTrue(!!val, 'Failed to lookup "' + obj.properties[i].name + '"'); 190 assertTrue(!!val, 'Failed to lookup "' + obj.properties[i].name + '"');
188 switch (obj.properties[i].name) { 191 switch (obj.properties[i].name) {
189 case 'name': 192 case 'name':
190 assertEquals('string', val.type); 193 assertEquals('string', val.type);
191 assertEquals("f", val.value); 194 assertEquals("f", val.value);
192 count++; 195 count++;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Set a break point at return in f and invoke g to hit the breakpoint. 240 // Set a break point at return in f and invoke g to hit the breakpoint.
238 Debug.setBreakPoint(f, 2, 0); 241 Debug.setBreakPoint(f, 2, 0);
239 o = {}; 242 o = {};
240 p = {} 243 p = {}
241 o.o = o; 244 o.o = o;
242 o.p = p; 245 o.p = p;
243 p.o = o; 246 p.o = o;
244 p.p = p; 247 p.p = p;
245 g(o); 248 g(o);
246 249
250 assertFalse(exception, "exception in listener")
247 // Make sure that the debug event listener vas invoked. 251 // Make sure that the debug event listener vas invoked.
248 assertTrue(listenerComplete, "listener did not run to completion: " + exception) ; 252 assertTrue(listenerComplete, "listener did not run to completion: " + exception) ;
249 assertFalse(exception, "exception in listener")
OLDNEW
« no previous file with comments | « test/mjsunit/debug-evaluate-recursive.js ('k') | test/mjsunit/debug-mirror-cache.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698