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

Side by Side Diff: src/d8.js

Issue 11975012: Remove support for Live Object List and inspector module. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/d8.cc ('k') | 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 var kNoFrame = -1; 116 var kNoFrame = -1;
117 Debug.State = { 117 Debug.State = {
118 currentFrame: kNoFrame, 118 currentFrame: kNoFrame,
119 displaySourceStartLine: -1, 119 displaySourceStartLine: -1,
120 displaySourceEndLine: -1, 120 displaySourceEndLine: -1,
121 currentSourceLine: -1 121 currentSourceLine: -1
122 }; 122 };
123 var trace_compile = false; // Tracing all compile events? 123 var trace_compile = false; // Tracing all compile events?
124 var trace_debug_json = false; // Tracing all debug json packets? 124 var trace_debug_json = false; // Tracing all debug json packets?
125 var last_cmd = ''; 125 var last_cmd = '';
126 //var lol_is_enabled; // Set to true in d8.cc if LIVE_OBJECT_LIST is defined.
127 var lol_next_dump_index = 0;
128 var kDefaultLolLinesToPrintAtATime = 10;
129 var kMaxLolLinesToPrintAtATime = 1000;
130 var repeat_cmd_line = ''; 126 var repeat_cmd_line = '';
131 var is_running = true; 127 var is_running = true;
132 // Global variable used to store whether a handle was requested. 128 // Global variable used to store whether a handle was requested.
133 var lookup_handle = null; 129 var lookup_handle = null;
134 130
135 // Copied from debug-delay.js. This is needed below: 131 // Copied from debug-delay.js. This is needed below:
136 function ScriptTypeFlag(type) { 132 function ScriptTypeFlag(type) {
137 return (1 << type); 133 return (1 << type);
138 } 134 }
139 135
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 this.traceCommand_(args); 496 this.traceCommand_(args);
501 break; 497 break;
502 498
503 case 'help': 499 case 'help':
504 case '?': 500 case '?':
505 this.helpCommand_(args); 501 this.helpCommand_(args);
506 // Return undefined to indicate command handled internally (no JSON). 502 // Return undefined to indicate command handled internally (no JSON).
507 this.request_ = void 0; 503 this.request_ = void 0;
508 break; 504 break;
509 505
510 case 'liveobjectlist':
511 case 'lol':
512 if (lol_is_enabled) {
513 this.request_ = this.lolToJSONRequest_(args, is_repeating);
514 break;
515 }
516
517 default: 506 default:
518 throw new Error('Unknown command "' + cmd + '"'); 507 throw new Error('Unknown command "' + cmd + '"');
519 } 508 }
520 } 509 }
521 510
522 DebugRequest.prototype.JSONRequest = function() { 511 DebugRequest.prototype.JSONRequest = function() {
523 return this.request_; 512 return this.request_;
524 }; 513 };
525 514
526 515
(...skipping 24 matching lines...) Expand all
551 json += '}'; 540 json += '}';
552 return json; 541 return json;
553 }; 542 };
554 543
555 544
556 DebugRequest.prototype.createRequest = function(command) { 545 DebugRequest.prototype.createRequest = function(command) {
557 return new RequestPacket(command); 546 return new RequestPacket(command);
558 }; 547 };
559 548
560 549
561 // Note: we use detected command repetition as a signal for continuation here.
562 DebugRequest.prototype.createLOLRequest = function(command,
563 start_index,
564 lines_to_dump,
565 is_continuation) {
566 if (is_continuation) {
567 start_index = lol_next_dump_index;
568 }
569
570 if (lines_to_dump) {
571 lines_to_dump = parseInt(lines_to_dump);
572 } else {
573 lines_to_dump = kDefaultLolLinesToPrintAtATime;
574 }
575 if (lines_to_dump > kMaxLolLinesToPrintAtATime) {
576 lines_to_dump = kMaxLolLinesToPrintAtATime;
577 }
578
579 // Save the next start_index to dump from:
580 lol_next_dump_index = start_index + lines_to_dump;
581
582 var request = this.createRequest(command);
583 request.arguments = {};
584 request.arguments.start = start_index;
585 request.arguments.count = lines_to_dump;
586
587 return request;
588 };
589
590
591 // Create a JSON request for the evaluation command. 550 // Create a JSON request for the evaluation command.
592 DebugRequest.prototype.makeEvaluateJSONRequest_ = function(expression) { 551 DebugRequest.prototype.makeEvaluateJSONRequest_ = function(expression) {
593 lookup_handle = null; 552 lookup_handle = null;
594 553
595 if (lol_is_enabled) {
596 // Check if the expression is a obj id in the form @<obj id>.
597 var obj_id_match = expression.match(/^@([0-9]+)$/);
598 if (obj_id_match) {
599 var obj_id = parseInt(obj_id_match[1]);
600 // Build a dump request.
601 var request = this.createRequest('getobj');
602 request.arguments = {};
603 request.arguments.obj_id = obj_id;
604 return request.toJSONProtocol();
605 }
606 }
607
608 // Check if the expression is a handle id in the form #<handle>#. 554 // Check if the expression is a handle id in the form #<handle>#.
609 var handle_match = expression.match(/^#([0-9]*)#$/); 555 var handle_match = expression.match(/^#([0-9]*)#$/);
610 if (handle_match) { 556 if (handle_match) {
611 // Remember the handle requested in a global variable. 557 // Remember the handle requested in a global variable.
612 lookup_handle = parseInt(handle_match[1]); 558 lookup_handle = parseInt(handle_match[1]);
613 // Build a lookup request. 559 // Build a lookup request.
614 var request = this.createRequest('lookup'); 560 var request = this.createRequest('lookup');
615 request.arguments = {}; 561 request.arguments = {};
616 request.arguments.handles = [ lookup_handle ]; 562 request.arguments.handles = [ lookup_handle ];
617 return request.toJSONProtocol(); 563 return request.toJSONProtocol();
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 request = this.createRequest('listbreakpoints'); 1109 request = this.createRequest('listbreakpoints');
1164 last_cmd = 'info break'; 1110 last_cmd = 'info break';
1165 } else if (args && (args == 'locals' || args == 'lo')) { 1111 } else if (args && (args == 'locals' || args == 'lo')) {
1166 // Build a evaluate request from the text command. 1112 // Build a evaluate request from the text command.
1167 request = this.createRequest('frame'); 1113 request = this.createRequest('frame');
1168 last_cmd = 'info locals'; 1114 last_cmd = 'info locals';
1169 } else if (args && (args == 'args' || args == 'ar')) { 1115 } else if (args && (args == 'args' || args == 'ar')) {
1170 // Build a evaluate request from the text command. 1116 // Build a evaluate request from the text command.
1171 request = this.createRequest('frame'); 1117 request = this.createRequest('frame');
1172 last_cmd = 'info args'; 1118 last_cmd = 'info args';
1173 } else if (lol_is_enabled &&
1174 args && (args == 'liveobjectlist' || args == 'lol')) {
1175 // Build a evaluate request from the text command.
1176 return this.liveObjectListToJSONRequest_(null);
1177 } else { 1119 } else {
1178 throw new Error('Invalid info arguments.'); 1120 throw new Error('Invalid info arguments.');
1179 } 1121 }
1180 1122
1181 return request.toJSONProtocol(); 1123 return request.toJSONProtocol();
1182 }; 1124 };
1183 1125
1184 1126
1185 DebugRequest.prototype.v8FlagsToJSONRequest_ = function(args) { 1127 DebugRequest.prototype.v8FlagsToJSONRequest_ = function(args) {
1186 var request; 1128 var request;
(...skipping 30 matching lines...) Expand all
1217 break; 1159 break;
1218 } 1160 }
1219 // Else fall thru to the default case below to report the error. 1161 // Else fall thru to the default case below to report the error.
1220 default: 1162 default:
1221 throw new Error('Missing arguments after ' + cmd + '.'); 1163 throw new Error('Missing arguments after ' + cmd + '.');
1222 } 1164 }
1223 return request.toJSONProtocol(); 1165 return request.toJSONProtocol();
1224 }; 1166 };
1225 1167
1226 1168
1227 // Args: [v[erbose]] [<N>] [i[ndex] <i>] [t[ype] <type>] [sp[ace] <space>]
1228 DebugRequest.prototype.lolMakeListRequest =
1229 function(cmd, args, first_arg_index, is_repeating) {
1230
1231 var request;
1232 var start_index = 0;
1233 var dump_limit = void 0;
1234 var type_filter = void 0;
1235 var space_filter = void 0;
1236 var prop_filter = void 0;
1237 var is_verbose = false;
1238 var i;
1239
1240 for (i = first_arg_index; i < args.length; i++) {
1241 var arg = args[i];
1242 // Check for [v[erbose]]:
1243 if (arg === 'verbose' || arg === 'v') {
1244 // Nothing to do. This is already implied by args.length > 3.
1245 is_verbose = true;
1246
1247 // Check for [<N>]:
1248 } else if (arg.match(/^[0-9]+$/)) {
1249 dump_limit = arg;
1250 is_verbose = true;
1251
1252 // Check for i[ndex] <i>:
1253 } else if (arg === 'index' || arg === 'i') {
1254 i++;
1255 if (args.length < i) {
1256 throw new Error('Missing index after ' + arg + '.');
1257 }
1258 start_index = parseInt(args[i]);
1259 // The user input start index starts at 1:
1260 if (start_index <= 0) {
1261 throw new Error('Invalid index ' + args[i] + '.');
1262 }
1263 start_index -= 1;
1264 is_verbose = true;
1265
1266 // Check for t[ype] <type>:
1267 } else if (arg === 'type' || arg === 't') {
1268 i++;
1269 if (args.length < i) {
1270 throw new Error('Missing type after ' + arg + '.');
1271 }
1272 type_filter = args[i];
1273
1274 // Check for space <heap space name>:
1275 } else if (arg === 'space' || arg === 'sp') {
1276 i++;
1277 if (args.length < i) {
1278 throw new Error('Missing space name after ' + arg + '.');
1279 }
1280 space_filter = args[i];
1281
1282 // Check for property <prop name>:
1283 } else if (arg === 'property' || arg === 'prop') {
1284 i++;
1285 if (args.length < i) {
1286 throw new Error('Missing property name after ' + arg + '.');
1287 }
1288 prop_filter = args[i];
1289
1290 } else {
1291 throw new Error('Unknown args at ' + arg + '.');
1292 }
1293 }
1294
1295 // Build the verbose request:
1296 if (is_verbose) {
1297 request = this.createLOLRequest('lol-'+cmd,
1298 start_index,
1299 dump_limit,
1300 is_repeating);
1301 request.arguments.verbose = true;
1302 } else {
1303 request = this.createRequest('lol-'+cmd);
1304 request.arguments = {};
1305 }
1306
1307 request.arguments.filter = {};
1308 if (type_filter) {
1309 request.arguments.filter.type = type_filter;
1310 }
1311 if (space_filter) {
1312 request.arguments.filter.space = space_filter;
1313 }
1314 if (prop_filter) {
1315 request.arguments.filter.prop = prop_filter;
1316 }
1317
1318 return request;
1319 };
1320
1321
1322 function extractObjId(args) {
1323 var id = args;
1324 id = id.match(/^@([0-9]+)$/);
1325 if (id) {
1326 id = id[1];
1327 } else {
1328 throw new Error('Invalid obj id ' + args + '.');
1329 }
1330 return parseInt(id);
1331 }
1332
1333
1334 DebugRequest.prototype.lolToJSONRequest_ = function(args, is_repeating) {
1335 var request;
1336 // Use default command if one is not specified:
1337 if (!args) {
1338 args = 'info';
1339 }
1340
1341 var orig_args = args;
1342 var first_arg_index;
1343
1344 var arg, i;
1345 var args = args.split(/\s+/g);
1346 var cmd = args[0];
1347 var id;
1348
1349 // Command: <id> [v[erbose]] ...
1350 if (cmd.match(/^[0-9]+$/)) {
1351 // Convert to the padded list command:
1352 // Command: l[ist] <dummy> <id> [v[erbose]] ...
1353
1354 // Insert the implicit 'list' in front and process as normal:
1355 cmd = 'list';
1356 args.unshift(cmd);
1357 }
1358
1359 switch(cmd) {
1360 // Command: c[apture]
1361 case 'capture':
1362 case 'c':
1363 request = this.createRequest('lol-capture');
1364 break;
1365
1366 // Command: clear|d[elete] <id>|all
1367 case 'clear':
1368 case 'delete':
1369 case 'del': {
1370 if (args.length < 2) {
1371 throw new Error('Missing argument after ' + cmd + '.');
1372 } else if (args.length > 2) {
1373 throw new Error('Too many arguments after ' + cmd + '.');
1374 }
1375 id = args[1];
1376 if (id.match(/^[0-9]+$/)) {
1377 // Delete a specific lol record:
1378 request = this.createRequest('lol-delete');
1379 request.arguments = {};
1380 request.arguments.id = parseInt(id);
1381 } else if (id === 'all') {
1382 // Delete all:
1383 request = this.createRequest('lol-reset');
1384 } else {
1385 throw new Error('Invalid argument after ' + cmd + '.');
1386 }
1387 break;
1388 }
1389
1390 // Command: diff <id1> <id2> [<dump options>]
1391 case 'diff':
1392 first_arg_index = 3;
1393
1394 // Command: list <dummy> <id> [<dump options>]
1395 case 'list':
1396
1397 // Command: ret[ainers] <obj id> [<dump options>]
1398 case 'retainers':
1399 case 'ret':
1400 case 'retaining-paths':
1401 case 'rp': {
1402 if (cmd === 'ret') cmd = 'retainers';
1403 else if (cmd === 'rp') cmd = 'retaining-paths';
1404
1405 if (!first_arg_index) first_arg_index = 2;
1406
1407 if (args.length < first_arg_index) {
1408 throw new Error('Too few arguments after ' + cmd + '.');
1409 }
1410
1411 var request_cmd = (cmd === 'list') ? 'diff':cmd;
1412 request = this.lolMakeListRequest(request_cmd,
1413 args,
1414 first_arg_index,
1415 is_repeating);
1416
1417 if (cmd === 'diff') {
1418 request.arguments.id1 = parseInt(args[1]);
1419 request.arguments.id2 = parseInt(args[2]);
1420 } else if (cmd == 'list') {
1421 request.arguments.id1 = 0;
1422 request.arguments.id2 = parseInt(args[1]);
1423 } else {
1424 request.arguments.id = extractObjId(args[1]);
1425 }
1426 break;
1427 }
1428
1429 // Command: getid
1430 case 'getid': {
1431 request = this.createRequest('lol-getid');
1432 request.arguments = {};
1433 request.arguments.address = args[1];
1434 break;
1435 }
1436
1437 // Command: inf[o] [<N>]
1438 case 'info':
1439 case 'inf': {
1440 if (args.length > 2) {
1441 throw new Error('Too many arguments after ' + cmd + '.');
1442 }
1443 // Built the info request:
1444 request = this.createLOLRequest('lol-info', 0, args[1], is_repeating);
1445 break;
1446 }
1447
1448 // Command: path <obj id 1> <obj id 2>
1449 case 'path': {
1450 request = this.createRequest('lol-path');
1451 request.arguments = {};
1452 if (args.length > 2) {
1453 request.arguments.id1 = extractObjId(args[1]);
1454 request.arguments.id2 = extractObjId(args[2]);
1455 } else {
1456 request.arguments.id1 = 0;
1457 request.arguments.id2 = extractObjId(args[1]);
1458 }
1459 break;
1460 }
1461
1462 // Command: print
1463 case 'print': {
1464 request = this.createRequest('lol-print');
1465 request.arguments = {};
1466 request.arguments.id = extractObjId(args[1]);
1467 break;
1468 }
1469
1470 // Command: reset
1471 case 'reset': {
1472 request = this.createRequest('lol-reset');
1473 break;
1474 }
1475
1476 default:
1477 throw new Error('Invalid arguments.');
1478 }
1479 return request.toJSONProtocol();
1480 };
1481
1482
1483 // Create a JSON request for the threads command. 1169 // Create a JSON request for the threads command.
1484 DebugRequest.prototype.threadsCommandToJSONRequest_ = function(args) { 1170 DebugRequest.prototype.threadsCommandToJSONRequest_ = function(args) {
1485 // Build a threads request from the text command. 1171 // Build a threads request from the text command.
1486 var request = this.createRequest('threads'); 1172 var request = this.createRequest('threads');
1487 return request.toJSONProtocol(); 1173 return request.toJSONProtocol();
1488 }; 1174 };
1489 1175
1490 1176
1491 // Handle the trace command. 1177 // Handle the trace command.
1492 DebugRequest.prototype.traceCommand_ = function(args) { 1178 DebugRequest.prototype.traceCommand_ = function(args) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 print('f[rame] - prints info about the current frame contex t'); 1224 print('f[rame] - prints info about the current frame contex t');
1539 print('f[rame] <frame #> - set context to specified frame #'); 1225 print('f[rame] <frame #> - set context to specified frame #');
1540 print('scopes'); 1226 print('scopes');
1541 print('scope <scope #>'); 1227 print('scope <scope #>');
1542 print(''); 1228 print('');
1543 print('up - set context to caller of current frame'); 1229 print('up - set context to caller of current frame');
1544 print('do[wn] - set context to callee of current frame'); 1230 print('do[wn] - set context to callee of current frame');
1545 print('inf[o] br[eak] - prints info about breakpoints in use'); 1231 print('inf[o] br[eak] - prints info about breakpoints in use');
1546 print('inf[o] ar[gs] - prints info about arguments of the current function'); 1232 print('inf[o] ar[gs] - prints info about arguments of the current function');
1547 print('inf[o] lo[cals] - prints info about locals in the current fu nction'); 1233 print('inf[o] lo[cals] - prints info about locals in the current fu nction');
1548 print('inf[o] liveobjectlist|lol - same as \'lol info\'');
1549 print(''); 1234 print('');
1550 print('step [in | next | out| min [step count]]'); 1235 print('step [in | next | out| min [step count]]');
1551 print('c[ontinue] - continue executing after a breakpoint'); 1236 print('c[ontinue] - continue executing after a breakpoint');
1552 print('s[tep] [<N>] - step into the next N callees (default N is 1)'); 1237 print('s[tep] [<N>] - step into the next N callees (default N is 1)');
1553 print('s[tep]i [<N>] - step into the next N callees (default N is 1)'); 1238 print('s[tep]i [<N>] - step into the next N callees (default N is 1)');
1554 print('n[ext] [<N>] - step over the next N callees (default N is 1)'); 1239 print('n[ext] [<N>] - step over the next N callees (default N is 1)');
1555 print('fin[ish] [<N>] - step out of N frames (default N is 1)'); 1240 print('fin[ish] [<N>] - step out of N frames (default N is 1)');
1556 print(''); 1241 print('');
1557 print('p[rint] <expression> - prints the result of the specified express ion'); 1242 print('p[rint] <expression> - prints the result of the specified express ion');
1558 print('dir <expression> - prints the object structure of the result' ); 1243 print('dir <expression> - prints the object structure of the result' );
1559 print('set <var> = <expression> - executes the specified statement'); 1244 print('set <var> = <expression> - executes the specified statement');
1560 print(''); 1245 print('');
1561 print('l[ist] - list the source code around for the curren t pc'); 1246 print('l[ist] - list the source code around for the curren t pc');
1562 print('l[ist] [- | <start>,<end>] - list the specified range of source code'); 1247 print('l[ist] [- | <start>,<end>] - list the specified range of source code');
1563 print('source [from line [num lines]]'); 1248 print('source [from line [num lines]]');
1564 print('scr[ipts] [native|extensions|all]'); 1249 print('scr[ipts] [native|extensions|all]');
1565 print('scr[ipts] [<filter text>] - list scripts with the specified text in it s description'); 1250 print('scr[ipts] [<filter text>] - list scripts with the specified text in it s description');
1566 print(''); 1251 print('');
1567 print('gc - runs the garbage collector'); 1252 print('gc - runs the garbage collector');
1568 print(''); 1253 print('');
1569
1570 if (lol_is_enabled) {
1571 print('liveobjectlist|lol <command> - live object list tracking.');
1572 print(' where <command> can be:');
1573 print(' c[apture] - captures a LOL list.');
1574 print(' clear|del[ete] <id>|all - clears LOL of id <id>.');
1575 print(' If \'all\' is unspecified instead, will c lear all.');
1576 print(' diff <id1> <id2> [<dump options>]');
1577 print(' - prints the diff between LOLs id1 and id2. ');
1578 print(' - also see <dump options> below.');
1579 print(' getid <address> - gets the obj id for the specified address if available.');
1580 print(' The address must be in hex form prefixed with 0x.');
1581 print(' inf[o] [<N>] - lists summary info of all LOL lists.');
1582 print(' If N is specified, will print N items at a time.');
1583 print(' [l[ist]] <id> [<dump options>]');
1584 print(' - prints the listing of objects in LOL id.' );
1585 print(' - also see <dump options> below.');
1586 print(' reset - clears all LOL lists.');
1587 print(' ret[ainers] <id> [<dump options>]');
1588 print(' - prints the list of retainers of obj id.') ;
1589 print(' - also see <dump options> below.');
1590 print(' path <id1> <id2> - prints the retaining path from obj id1 to id2.');
1591 print(' If only one id is specified, will print t he path from');
1592 print(' roots to the specified object if availabl e.');
1593 print(' print <id> - prints the obj for the specified obj id i f available.');
1594 print('');
1595 print(' <dump options> includes:');
1596 print(' [v[erbose]] - do verbose dump.');
1597 print(' [<N>] - dump N items at a time. Implies verbos e dump.');
1598 print(' If unspecified, N will default to '+
1599 kDefaultLolLinesToPrintAtATime+'. Max N is '+
1600 kMaxLolLinesToPrintAtATime+'.');
1601 print(' [i[ndex] <i>] - start dump from index i. Implies verbo se dump.');
1602 print(' [t[ype] <type>] - filter by type.');
1603 print(' [sp[ace] <space name>] - filter by heap space where <space name> is one of');
1604 print(' { cell, code, lo, map, new, old-data, o ld-pointer }.');
1605 print('');
1606 print(' If the verbose option, or an option that implies a verbose dump' );
1607 print(' is specified, then a verbose dump will requested. Else, a summa ry dump');
1608 print(' will be requested.');
1609 print('');
1610 }
1611
1612 print('trace compile'); 1254 print('trace compile');
1613 // hidden command: trace debug json - toggles tracing of debug json packets 1255 // hidden command: trace debug json - toggles tracing of debug json packets
1614 print(''); 1256 print('');
1615 print('disconnect|exit|quit - disconnects and quits the debugger'); 1257 print('disconnect|exit|quit - disconnects and quits the debugger');
1616 print('help - prints this help information'); 1258 print('help - prints this help information');
1617 }; 1259 };
1618 1260
1619 1261
1620 function formatHandleReference_(value) { 1262 function formatHandleReference_(value) {
1621 if (value.handle() >= 0) { 1263 if (value.handle() >= 0) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 result = '"' + value.value() + '"'; 1344 result = '"' + value.value() + '"';
1703 } else if (value.isPrimitive()) { 1345 } else if (value.isPrimitive()) {
1704 result = value.valueString(); 1346 result = value.valueString();
1705 } else if (value.isObject()) { 1347 } else if (value.isObject()) {
1706 result += formatObject_(value, true); 1348 result += formatObject_(value, true);
1707 } 1349 }
1708 return result; 1350 return result;
1709 } 1351 }
1710 1352
1711 1353
1712 function decodeLolCaptureResponse(body) {
1713 var result;
1714 result = 'Captured live object list '+ body.id +
1715 ': count '+ body.count + ' size ' + body.size;
1716 return result;
1717 }
1718
1719
1720 function decodeLolDeleteResponse(body) {
1721 var result;
1722 result = 'Deleted live object list '+ body.id;
1723 return result;
1724 }
1725
1726
1727 function digitsIn(value) {
1728 var digits = 0;
1729 if (value === 0) value = 1;
1730 while (value >= 1) {
1731 digits++;
1732 value /= 10;
1733 }
1734 return digits;
1735 }
1736
1737
1738 function padding(value, max_digits) {
1739 var padding_digits = max_digits - digitsIn(value);
1740 var padding = '';
1741 while (padding_digits > 0) {
1742 padding += ' ';
1743 padding_digits--;
1744 }
1745 return padding;
1746 }
1747
1748
1749 function decodeLolInfoResponse(body) {
1750 var result;
1751 var lists = body.lists;
1752 var length = lists.length;
1753 var first_index = body.first_index + 1;
1754 var has_more = ((first_index + length) <= body.count);
1755 result = 'captured live object lists';
1756 if (has_more || (first_index != 1)) {
1757 result += ' ['+ length +' of '+ body.count +
1758 ': starting from '+ first_index +']';
1759 }
1760 result += ':\n';
1761 var max_digits = digitsIn(body.count);
1762 var last_count = 0;
1763 var last_size = 0;
1764 for (var i = 0; i < length; i++) {
1765 var entry = lists[i];
1766 var count = entry.count;
1767 var size = entry.size;
1768 var index = first_index + i;
1769 result += ' [' + padding(index, max_digits) + index + '] id '+ entry.id +
1770 ': count '+ count;
1771 if (last_count > 0) {
1772 result += '(+' + (count - last_count) + ')';
1773 }
1774 result += ' size '+ size;
1775 if (last_size > 0) {
1776 result += '(+' + (size - last_size) + ')';
1777 }
1778 result += '\n';
1779 last_count = count;
1780 last_size = size;
1781 }
1782 result += ' total: '+length+' lists\n';
1783 if (has_more) {
1784 result += ' -- press <enter> for more --\n';
1785 } else {
1786 repeat_cmd_line = '';
1787 }
1788 if (length === 0) result += ' none\n';
1789
1790 return result;
1791 }
1792
1793
1794 function decodeLolListResponse(body, title) {
1795
1796 var result;
1797 var total_count = body.count;
1798 var total_size = body.size;
1799 var length;
1800 var max_digits;
1801 var i;
1802 var entry;
1803 var index;
1804
1805 var max_count_digits = digitsIn(total_count);
1806 var max_size_digits;
1807
1808 var summary = body.summary;
1809 if (summary) {
1810
1811 var roots_count = 0;
1812 var found_root = body.found_root || 0;
1813 var found_weak_root = body.found_weak_root || 0;
1814
1815 // Print the summary result:
1816 result = 'summary of objects:\n';
1817 length = summary.length;
1818 if (found_root !== 0) {
1819 roots_count++;
1820 }
1821 if (found_weak_root !== 0) {
1822 roots_count++;
1823 }
1824 max_digits = digitsIn(length + roots_count);
1825 max_size_digits = digitsIn(total_size);
1826
1827 index = 1;
1828 if (found_root !== 0) {
1829 result += ' [' + padding(index, max_digits) + index + '] ' +
1830 ' count '+ 1 + padding(0, max_count_digits) +
1831 ' '+ padding(0, max_size_digits+1) +
1832 ' : <root>\n';
1833 index++;
1834 }
1835 if (found_weak_root !== 0) {
1836 result += ' [' + padding(index, max_digits) + index + '] ' +
1837 ' count '+ 1 + padding(0, max_count_digits) +
1838 ' '+ padding(0, max_size_digits+1) +
1839 ' : <weak root>\n';
1840 index++;
1841 }
1842
1843 for (i = 0; i < length; i++) {
1844 entry = summary[i];
1845 var count = entry.count;
1846 var size = entry.size;
1847 result += ' [' + padding(index, max_digits) + index + '] ' +
1848 ' count '+ count + padding(count, max_count_digits) +
1849 ' size '+ size + padding(size, max_size_digits) +
1850 ' : <' + entry.desc + '>\n';
1851 index++;
1852 }
1853 result += '\n total count: '+(total_count+roots_count)+'\n';
1854 if (body.size) {
1855 result += ' total size: '+body.size+'\n';
1856 }
1857
1858 } else {
1859 // Print the full dump result:
1860 var first_index = body.first_index + 1;
1861 var elements = body.elements;
1862 length = elements.length;
1863 var has_more = ((first_index + length) <= total_count);
1864 result = title;
1865 if (has_more || (first_index != 1)) {
1866 result += ' ['+ length +' of '+ total_count +
1867 ': starting from '+ first_index +']';
1868 }
1869 result += ':\n';
1870 if (length === 0) result += ' none\n';
1871 max_digits = digitsIn(length);
1872
1873 var max_id = 0;
1874 var max_size = 0;
1875 for (i = 0; i < length; i++) {
1876 entry = elements[i];
1877 if (entry.id > max_id) max_id = entry.id;
1878 if (entry.size > max_size) max_size = entry.size;
1879 }
1880 var max_id_digits = digitsIn(max_id);
1881 max_size_digits = digitsIn(max_size);
1882
1883 for (i = 0; i < length; i++) {
1884 entry = elements[i];
1885 index = first_index + i;
1886 result += ' ['+ padding(index, max_digits) + index +']';
1887 if (entry.id !== 0) {
1888 result += ' @' + entry.id + padding(entry.id, max_id_digits) +
1889 ': size ' + entry.size + ', ' +
1890 padding(entry.size, max_size_digits) + entry.desc + '\n';
1891 } else {
1892 // Must be a root or weak root:
1893 result += ' ' + entry.desc + '\n';
1894 }
1895 }
1896 if (has_more) {
1897 result += ' -- press <enter> for more --\n';
1898 } else {
1899 repeat_cmd_line = '';
1900 }
1901 if (length === 0) result += ' none\n';
1902 }
1903
1904 return result;
1905 }
1906
1907
1908 function decodeLolDiffResponse(body) {
1909 var title = 'objects';
1910 return decodeLolListResponse(body, title);
1911 }
1912
1913
1914 function decodeLolRetainersResponse(body) {
1915 var title = 'retainers for @' + body.id;
1916 return decodeLolListResponse(body, title);
1917 }
1918
1919
1920 function decodeLolPathResponse(body) {
1921 return body.path;
1922 }
1923
1924
1925 function decodeLolResetResponse(body) {
1926 return 'Reset all live object lists.';
1927 }
1928
1929
1930 function decodeLolGetIdResponse(body) {
1931 if (body.id == 0) {
1932 return 'Address is invalid, or object has been moved or collected';
1933 }
1934 return 'obj id is @' + body.id;
1935 }
1936
1937
1938 function decodeLolPrintResponse(body) {
1939 return body.dump;
1940 }
1941
1942
1943 // Rounds number 'num' to 'length' decimal places. 1354 // Rounds number 'num' to 'length' decimal places.
1944 function roundNumber(num, length) { 1355 function roundNumber(num, length) {
1945 var factor = Math.pow(10, length); 1356 var factor = Math.pow(10, length);
1946 return Math.round(num * factor) / factor; 1357 return Math.round(num * factor) / factor;
1947 } 1358 }
1948 1359
1949 1360
1950 // Convert a JSON response to text for display in a text based debugger. 1361 // Convert a JSON response to text for display in a text based debugger.
1951 function DebugResponseDetails(response) { 1362 function DebugResponseDetails(response) {
1952 var details = { text: '', running: false }; 1363 var details = { text: '', running: false };
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 details.text += 1680 details.text +=
2270 " (" + roundNumber(body.before/(1024*1024), 1) + "M => " + 1681 " (" + roundNumber(body.before/(1024*1024), 1) + "M => " +
2271 roundNumber(body.after/(1024*1024), 1) + "M)"; 1682 roundNumber(body.after/(1024*1024), 1) + "M)";
2272 } else if (body.after > 1024) { 1683 } else if (body.after > 1024) {
2273 details.text += 1684 details.text +=
2274 " (" + roundNumber(body.before/1024, 1) + "K => " + 1685 " (" + roundNumber(body.before/1024, 1) + "K => " +
2275 roundNumber(body.after/1024, 1) + "K)"; 1686 roundNumber(body.after/1024, 1) + "K)";
2276 } 1687 }
2277 break; 1688 break;
2278 1689
2279 case 'lol-capture':
2280 details.text = decodeLolCaptureResponse(body);
2281 break;
2282 case 'lol-delete':
2283 details.text = decodeLolDeleteResponse(body);
2284 break;
2285 case 'lol-diff':
2286 details.text = decodeLolDiffResponse(body);
2287 break;
2288 case 'lol-getid':
2289 details.text = decodeLolGetIdResponse(body);
2290 break;
2291 case 'lol-info':
2292 details.text = decodeLolInfoResponse(body);
2293 break;
2294 case 'lol-print':
2295 details.text = decodeLolPrintResponse(body);
2296 break;
2297 case 'lol-reset':
2298 details.text = decodeLolResetResponse(body);
2299 break;
2300 case 'lol-retainers':
2301 details.text = decodeLolRetainersResponse(body);
2302 break;
2303 case 'lol-path':
2304 details.text = decodeLolPathResponse(body);
2305 break;
2306
2307 default: 1690 default:
2308 details.text = 1691 details.text =
2309 'Response for unknown command \'' + response.command() + '\'' + 1692 'Response for unknown command \'' + response.command() + '\'' +
2310 ' (' + response.raw_json() + ')'; 1693 ' (' + response.raw_json() + ')';
2311 } 1694 }
2312 } catch (e) { 1695 } catch (e) {
2313 details.text = 'Error: "' + e + '" formatting response'; 1696 details.text = 'Error: "' + e + '" formatting response';
2314 } 1697 }
2315 1698
2316 return details; 1699 return details;
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 json += NumberToJSON_(elem); 2187 json += NumberToJSON_(elem);
2805 } else if (typeof(elem) === 'string') { 2188 } else if (typeof(elem) === 'string') {
2806 json += StringToJSON_(elem); 2189 json += StringToJSON_(elem);
2807 } else { 2190 } else {
2808 json += elem; 2191 json += elem;
2809 } 2192 }
2810 } 2193 }
2811 json += ']'; 2194 json += ']';
2812 return json; 2195 return json;
2813 } 2196 }
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | src/debug-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698