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

Side by Side Diff: src/d8.js

Issue 2050007: Add listbreakpoints command to protocol (Closed)
Patch Set: follow codereview Created 10 years, 7 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 | « no previous file | src/debug-debugger.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 case 'scripts': 335 case 'scripts':
336 this.request_ = this.scriptsCommandToJSONRequest_(args); 336 this.request_ = this.scriptsCommandToJSONRequest_(args);
337 break; 337 break;
338 338
339 case 'break': 339 case 'break':
340 case 'b': 340 case 'b':
341 this.request_ = this.breakCommandToJSONRequest_(args); 341 this.request_ = this.breakCommandToJSONRequest_(args);
342 break; 342 break;
343 343
344 case 'breakpoints':
345 case 'bb':
346 this.request_ = this.breakpointsCommandToJSONRequest_(args);
347 break;
348
344 case 'clear': 349 case 'clear':
345 this.request_ = this.clearCommandToJSONRequest_(args); 350 this.request_ = this.clearCommandToJSONRequest_(args);
346 break; 351 break;
347 352
348 case 'threads': 353 case 'threads':
349 this.request_ = this.threadsCommandToJSONRequest_(args); 354 this.request_ = this.threadsCommandToJSONRequest_(args);
350 break; 355 break;
351 356
352 case 'trace': 357 case 'trace':
353 // Return undefined to indicate command handled internally (no JSON). 358 // Return undefined to indicate command handled internally (no JSON).
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 request.arguments.column = column; 768 request.arguments.column = column;
764 request.arguments.condition = condition; 769 request.arguments.condition = condition;
765 } else { 770 } else {
766 var request = this.createRequest('suspend'); 771 var request = this.createRequest('suspend');
767 } 772 }
768 773
769 return request.toJSONProtocol(); 774 return request.toJSONProtocol();
770 }; 775 };
771 776
772 777
778 DebugRequest.prototype.breakpointsCommandToJSONRequest_ = function(args) {
779 if (args && args.length > 0) {
780 throw new Error('Unexpected arguments.');
781 }
782 var request = this.createRequest('listbreakpoints');
783 return request.toJSONProtocol();
784 };
785
786
773 // Create a JSON request for the clear command. 787 // Create a JSON request for the clear command.
774 DebugRequest.prototype.clearCommandToJSONRequest_ = function(args) { 788 DebugRequest.prototype.clearCommandToJSONRequest_ = function(args) {
775 // Build a evaluate request from the text command. 789 // Build a evaluate request from the text command.
776 var request = this.createRequest('clearbreakpoint'); 790 var request = this.createRequest('clearbreakpoint');
777 791
778 // Process arguments if any. 792 // Process arguments if any.
779 if (args && args.length > 0) { 793 if (args && args.length > 0) {
780 request.arguments = {}; 794 request.arguments = {};
781 request.arguments.breakpoint = parseInt(args); 795 request.arguments.breakpoint = parseInt(args);
782 } else { 796 } else {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 result = 'set breakpoint #'; 954 result = 'set breakpoint #';
941 result += body.breakpoint; 955 result += body.breakpoint;
942 details.text = result; 956 details.text = result;
943 break; 957 break;
944 958
945 case 'clearbreakpoint': 959 case 'clearbreakpoint':
946 result = 'cleared breakpoint #'; 960 result = 'cleared breakpoint #';
947 result += body.breakpoint; 961 result += body.breakpoint;
948 details.text = result; 962 details.text = result;
949 break; 963 break;
964
965 case 'listbreakpoints':
966 result = 'breakpoints: (' + body.breakpoints.length + ')';
967 for (var i = 0; i < body.breakpoints.length; i++) {
968 var breakpoint = body.breakpoints[i];
969 result += '\n id=' + breakpoint.number;
970 result += ' type=' + breakpoint.type;
971 if (breakpoint.script_id) {
972 result += ' script_id=' + breakpoint.script_id;
973 }
974 if (breakpoint.script_name) {
975 result += ' script_name=' + breakpoint.script_name;
976 }
977 result += ' line=' + breakpoint.line;
978 if (breakpoint.column != null) {
979 result += ' column=' + breakpoint.column;
980 }
981 if (breakpoint.groupId) {
982 result += ' groupId=' + breakpoint.groupId;
983 }
984 if (breakpoint.ignoreCount) {
985 result += ' ignoreCount=' + breakpoint.ignoreCount;
986 }
987 if (breakpoint.active === false) {
988 result += ' inactive';
989 }
990 if (breakpoint.condition) {
991 result += ' condition=' + breakpoint.condition;
992 }
993 result += ' hit_count=' + breakpoint.hit_count;
994 }
995 details.text = result;
996 break;
950 997
951 case 'backtrace': 998 case 'backtrace':
952 if (body.totalFrames == 0) { 999 if (body.totalFrames == 0) {
953 result = '(empty stack)'; 1000 result = '(empty stack)';
954 } else { 1001 } else {
955 var result = 'Frames #' + body.fromFrame + ' to #' + 1002 var result = 'Frames #' + body.fromFrame + ' to #' +
956 (body.toFrame - 1) + ' of ' + body.totalFrames + '\n'; 1003 (body.toFrame - 1) + ' of ' + body.totalFrames + '\n';
957 for (i = 0; i < body.frames.length; i++) { 1004 for (i = 0; i < body.frames.length; i++) {
958 if (i != 0) result += '\n'; 1005 if (i != 0) result += '\n';
959 result += body.frames[i].text; 1006 result += body.frames[i].text;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 } 1176 }
1130 details.text = result; 1177 details.text = result;
1131 break; 1178 break;
1132 1179
1133 case 'continue': 1180 case 'continue':
1134 details.text = "(running)"; 1181 details.text = "(running)";
1135 break; 1182 break;
1136 1183
1137 default: 1184 default:
1138 details.text = 1185 details.text =
1139 'Response for unknown command \'' + response.command + '\'' + 1186 'Response for unknown command \'' + response.command() + '\'' +
1140 ' (' + json_response + ')'; 1187 ' (' + response.raw_json() + ')';
1141 } 1188 }
1142 } catch (e) { 1189 } catch (e) {
1143 details.text = 'Error: "' + e + '" formatting response'; 1190 details.text = 'Error: "' + e + '" formatting response';
1144 } 1191 }
1145 1192
1146 return details; 1193 return details;
1147 }; 1194 };
1148 1195
1149 1196
1150 /** 1197 /**
1151 * Protocol packages send from the debugger. 1198 * Protocol packages send from the debugger.
1152 * @param {string} json - raw protocol packet as JSON string. 1199 * @param {string} json - raw protocol packet as JSON string.
1153 * @constructor 1200 * @constructor
1154 */ 1201 */
1155 function ProtocolPackage(json) { 1202 function ProtocolPackage(json) {
1203 this.raw_json_ = json;
1156 this.packet_ = JSON.parse(json); 1204 this.packet_ = JSON.parse(json);
1157 this.refs_ = []; 1205 this.refs_ = [];
1158 if (this.packet_.refs) { 1206 if (this.packet_.refs) {
1159 for (var i = 0; i < this.packet_.refs.length; i++) { 1207 for (var i = 0; i < this.packet_.refs.length; i++) {
1160 this.refs_[this.packet_.refs[i].handle] = this.packet_.refs[i]; 1208 this.refs_[this.packet_.refs[i].handle] = this.packet_.refs[i];
1161 } 1209 }
1162 } 1210 }
1163 } 1211 }
1164 1212
1165 1213
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 ProtocolPackage.prototype.lookup = function(handle) { 1284 ProtocolPackage.prototype.lookup = function(handle) {
1237 var value = this.refs_[handle]; 1285 var value = this.refs_[handle];
1238 if (value) { 1286 if (value) {
1239 return new ProtocolValue(value, this); 1287 return new ProtocolValue(value, this);
1240 } else { 1288 } else {
1241 return new ProtocolReference(handle); 1289 return new ProtocolReference(handle);
1242 } 1290 }
1243 } 1291 }
1244 1292
1245 1293
1294 ProtocolPackage.prototype.raw_json = function() {
1295 return this.raw_json_;
1296 }
1297
1298
1246 function ProtocolValue(value, packet) { 1299 function ProtocolValue(value, packet) {
1247 this.value_ = value; 1300 this.value_ = value;
1248 this.packet_ = packet; 1301 this.packet_ = packet;
1249 } 1302 }
1250 1303
1251 1304
1252 /** 1305 /**
1253 * Get the value type. 1306 * Get the value type.
1254 * @return {String} the value type 1307 * @return {String} the value type
1255 */ 1308 */
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 json += NumberToJSON_(elem); 1674 json += NumberToJSON_(elem);
1622 } else if (typeof(elem) === 'string') { 1675 } else if (typeof(elem) === 'string') {
1623 json += StringToJSON_(elem); 1676 json += StringToJSON_(elem);
1624 } else { 1677 } else {
1625 json += elem; 1678 json += elem;
1626 } 1679 }
1627 } 1680 }
1628 json += ']'; 1681 json += ']';
1629 return json; 1682 return json;
1630 } 1683 }
OLDNEW
« no previous file with comments | « no previous file | src/debug-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698