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

Side by Side Diff: src/debug-delay.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 | « src/debug.cc ('k') | test/mjsunit/debug-backtrace.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 ExecutionState.prototype.setSelectedFrame = function(index) { 788 ExecutionState.prototype.setSelectedFrame = function(index) {
789 var i = %ToNumber(index); 789 var i = %ToNumber(index);
790 if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.'); 790 if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.');
791 this.selected_frame = i; 791 this.selected_frame = i;
792 }; 792 };
793 793
794 ExecutionState.prototype.selectedFrame = function() { 794 ExecutionState.prototype.selectedFrame = function() {
795 return this.selected_frame; 795 return this.selected_frame;
796 }; 796 };
797 797
798 ExecutionState.prototype.debugCommandProcessor = function(protocol) { 798 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) {
799 return new DebugCommandProcessor(this, protocol); 799 return new DebugCommandProcessor(this, opt_is_running);
800 }; 800 };
801 801
802 802
803 function MakeBreakEvent(exec_state, break_points_hit) { 803 function MakeBreakEvent(exec_state, break_points_hit) {
804 return new BreakEvent(exec_state, break_points_hit); 804 return new BreakEvent(exec_state, break_points_hit);
805 } 805 }
806 806
807 807
808 function BreakEvent(exec_state, break_points_hit) { 808 function BreakEvent(exec_state, break_points_hit) {
809 this.exec_state_ = exec_state; 809 this.exec_state_ = exec_state;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 if (!IS_UNDEFINED(script.data())) { 1074 if (!IS_UNDEFINED(script.data())) {
1075 o.data = script.data(); 1075 o.data = script.data();
1076 } 1076 }
1077 if (include_source) { 1077 if (include_source) {
1078 o.source = script.source(); 1078 o.source = script.source();
1079 } 1079 }
1080 return o; 1080 return o;
1081 }; 1081 };
1082 1082
1083 1083
1084 function DebugCommandProcessor(exec_state) { 1084 function DebugCommandProcessor(exec_state, opt_is_running) {
1085 this.exec_state_ = exec_state; 1085 this.exec_state_ = exec_state;
1086 this.running_ = false; 1086 this.running_ = opt_is_running || false;
1087 }; 1087 };
1088 1088
1089 1089
1090 DebugCommandProcessor.prototype.processDebugRequest = function (request) { 1090 DebugCommandProcessor.prototype.processDebugRequest = function (request) {
1091 return this.processDebugJSONRequest(request); 1091 return this.processDebugJSONRequest(request);
1092 } 1092 }
1093 1093
1094 1094
1095 function ProtocolMessage(request) { 1095 function ProtocolMessage(request) {
1096 // Update sequence number. 1096 // Update sequence number.
1097 this.seq = next_response_seq++; 1097 this.seq = next_response_seq++;
1098 1098
1099 if (request) { 1099 if (request) {
1100 // If message is based on a request this is a response. Fill the initial 1100 // If message is based on a request this is a response. Fill the initial
1101 // response from the request. 1101 // response from the request.
1102 this.type = 'response'; 1102 this.type = 'response';
1103 this.request_seq = request.seq; 1103 this.request_seq = request.seq;
1104 this.command = request.command; 1104 this.command = request.command;
1105 } else { 1105 } else {
1106 // If message is not based on a request it is a dabugger generated event. 1106 // If message is not based on a request it is a dabugger generated event.
1107 this.type = 'event'; 1107 this.type = 'event';
1108 } 1108 }
1109 this.success = true; 1109 this.success = true;
1110 this.running = false; 1110 // Handler may set this field to control debugger state.
1111 this.running = undefined;
1111 } 1112 }
1112 1113
1113 1114
1114 ProtocolMessage.prototype.setOption = function(name, value) { 1115 ProtocolMessage.prototype.setOption = function(name, value) {
1115 if (!this.options_) { 1116 if (!this.options_) {
1116 this.options_ = {}; 1117 this.options_ = {};
1117 } 1118 }
1118 this.options_[name] = value; 1119 this.options_[name] = value;
1119 } 1120 }
1120 1121
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 } 1162 }
1162 } else { 1163 } else {
1163 bodyJson = ObjectToProtocolObject_(this.body, serializer); 1164 bodyJson = ObjectToProtocolObject_(this.body, serializer);
1164 } 1165 }
1165 json.body = bodyJson; 1166 json.body = bodyJson;
1166 json.refs = serializer.serializeReferencedObjects(); 1167 json.refs = serializer.serializeReferencedObjects();
1167 } 1168 }
1168 if (this.message) { 1169 if (this.message) {
1169 json.message = this.message; 1170 json.message = this.message;
1170 } 1171 }
1171 if (this.running) { 1172 json.running = this.running;
1172 json.running = true;
1173 } else {
1174 json.running = false;
1175 }
1176 return JSON.stringify(json); 1173 return JSON.stringify(json);
1177 } 1174 }
1178 1175
1179 1176
1180 DebugCommandProcessor.prototype.createResponse = function(request) { 1177 DebugCommandProcessor.prototype.createResponse = function(request) {
1181 return new ProtocolMessage(request); 1178 return new ProtocolMessage(request);
1182 }; 1179 };
1183 1180
1184 1181
1185 DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request) { 1182 DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 } else if (request.command == 'lookup') { 1234 } else if (request.command == 'lookup') {
1238 this.lookupRequest_(request, response); 1235 this.lookupRequest_(request, response);
1239 } else if (request.command == 'references') { 1236 } else if (request.command == 'references') {
1240 this.referencesRequest_(request, response); 1237 this.referencesRequest_(request, response);
1241 } else if (request.command == 'source') { 1238 } else if (request.command == 'source') {
1242 this.sourceRequest_(request, response); 1239 this.sourceRequest_(request, response);
1243 } else if (request.command == 'scripts') { 1240 } else if (request.command == 'scripts') {
1244 this.scriptsRequest_(request, response); 1241 this.scriptsRequest_(request, response);
1245 } else if (request.command == 'threads') { 1242 } else if (request.command == 'threads') {
1246 this.threadsRequest_(request, response); 1243 this.threadsRequest_(request, response);
1244 } else if (request.command == 'suspend') {
1245 this.suspendRequest_(request, response);
1247 } else { 1246 } else {
1248 throw new Error('Unknown command "' + request.command + '" in request'); 1247 throw new Error('Unknown command "' + request.command + '" in request');
1249 } 1248 }
1250 } catch (e) { 1249 } catch (e) {
1251 // If there is no response object created one (without command). 1250 // If there is no response object created one (without command).
1252 if (!response) { 1251 if (!response) {
1253 response = this.createResponse(); 1252 response = this.createResponse();
1254 } 1253 }
1255 response.success = false; 1254 response.success = false;
1256 response.message = %ToString(e); 1255 response.message = %ToString(e);
1257 } 1256 }
1258 1257
1259 // Return the response as a JSON encoded string. 1258 // Return the response as a JSON encoded string.
1260 try { 1259 try {
1261 this.running_ = response.running; // Store the running state. 1260 if (!IS_UNDEFINED(response.running)) {
1261 // Response controls running state.
1262 this.running_ = response.running;
1263 }
1264 response.running = this.running_;
1262 return response.toJSONProtocol(); 1265 return response.toJSONProtocol();
1263 } catch (e) { 1266 } catch (e) {
1264 // Failed to generate response - return generic error. 1267 // Failed to generate response - return generic error.
1265 return '{"seq":' + response.seq + ',' + 1268 return '{"seq":' + response.seq + ',' +
1266 '"request_seq":' + request.seq + ',' + 1269 '"request_seq":' + request.seq + ',' +
1267 '"type":"response",' + 1270 '"type":"response",' +
1268 '"success":false,' + 1271 '"success":false,' +
1269 '"message":"Internal error: ' + %ToString(e) + '"}'; 1272 '"message":"Internal error: ' + %ToString(e) + '"}';
1270 } 1273 }
1271 } catch (e) { 1274 } catch (e) {
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 } 1903 }
1901 1904
1902 // Create the response body. 1905 // Create the response body.
1903 response.body = { 1906 response.body = {
1904 totalThreads: total_threads, 1907 totalThreads: total_threads,
1905 threads: threads 1908 threads: threads
1906 } 1909 }
1907 }; 1910 };
1908 1911
1909 1912
1913 DebugCommandProcessor.prototype.suspendRequest_ = function(request, response) {
1914 // TODO(peter.rybin): probably we need some body field here.
1915 response.running = false;
1916 };
1917
1918
1910 // Check whether the previously processed command caused the VM to become 1919 // Check whether the previously processed command caused the VM to become
1911 // running. 1920 // running.
1912 DebugCommandProcessor.prototype.isRunning = function() { 1921 DebugCommandProcessor.prototype.isRunning = function() {
1913 return this.running_; 1922 return this.running_;
1914 } 1923 }
1915 1924
1916 1925
1917 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { 1926 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) {
1918 return %SystemBreak(); 1927 return %SystemBreak();
1919 }; 1928 };
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 case 'string': 2035 case 'string':
2027 case 'number': 2036 case 'number':
2028 json = value; 2037 json = value;
2029 break 2038 break
2030 2039
2031 default: 2040 default:
2032 json = null; 2041 json = null;
2033 } 2042 }
2034 return json; 2043 return json;
2035 } 2044 }
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | test/mjsunit/debug-backtrace.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698