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

Side by Side Diff: src/debug-debugger.js

Issue 5980006: Misc debugger enhancements and bug fixes.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 12 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
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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 break_point.actual_location = { line: actual_location.line, 647 break_point.actual_location = { line: actual_location.line,
648 column: actual_location.column }; 648 column: actual_location.column };
649 break_point.setCondition(opt_condition); 649 break_point.setCondition(opt_condition);
650 return break_point.number(); 650 return break_point.number();
651 } 651 }
652 }; 652 };
653 653
654 654
655 Debug.enableBreakPoint = function(break_point_number) { 655 Debug.enableBreakPoint = function(break_point_number) {
656 var break_point = this.findBreakPoint(break_point_number, false); 656 var break_point = this.findBreakPoint(break_point_number, false);
657 break_point.enable(); 657 // Only enable if the breakpoint hasn't been deleted:
658 if (break_point) {
659 break_point.enable();
660 }
658 }; 661 };
659 662
660 663
661 Debug.disableBreakPoint = function(break_point_number) { 664 Debug.disableBreakPoint = function(break_point_number) {
662 var break_point = this.findBreakPoint(break_point_number, false); 665 var break_point = this.findBreakPoint(break_point_number, false);
663 break_point.disable(); 666 // Only enable if the breakpoint hasn't been deleted:
667 if (break_point) {
668 break_point.disable();
669 }
664 }; 670 };
665 671
666 672
667 Debug.changeBreakPointCondition = function(break_point_number, condition) { 673 Debug.changeBreakPointCondition = function(break_point_number, condition) {
668 var break_point = this.findBreakPoint(break_point_number, false); 674 var break_point = this.findBreakPoint(break_point_number, false);
669 break_point.setCondition(condition); 675 break_point.setCondition(condition);
670 }; 676 };
671 677
672 678
673 Debug.changeBreakPointIgnoreCount = function(break_point_number, ignoreCount) { 679 Debug.changeBreakPointIgnoreCount = function(break_point_number, ignoreCount) {
(...skipping 20 matching lines...) Expand all
694 700
695 Debug.clearAllBreakPoints = function() { 701 Debug.clearAllBreakPoints = function() {
696 for (var i = 0; i < break_points.length; i++) { 702 for (var i = 0; i < break_points.length; i++) {
697 break_point = break_points[i]; 703 break_point = break_points[i];
698 %ClearBreakPoint(break_point); 704 %ClearBreakPoint(break_point);
699 } 705 }
700 break_points = []; 706 break_points = [];
701 }; 707 };
702 708
703 709
710 Debug.disableAllBreakPoints = function() {
711 // Disable all user defined breakpoints:
712 for (var i = 1; i < next_break_point_number; i++) {
713 Debug.disableBreakPoint(i);
714 }
715 // Disable all exception breakpoints:
716 %ChangeBreakOnException(Debug.ExceptionBreak.Caught, false);
717 %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, false);
718 };
719
720
704 Debug.findScriptBreakPoint = function(break_point_number, remove) { 721 Debug.findScriptBreakPoint = function(break_point_number, remove) {
705 var script_break_point; 722 var script_break_point;
706 for (var i = 0; i < script_break_points.length; i++) { 723 for (var i = 0; i < script_break_points.length; i++) {
707 if (script_break_points[i].number() == break_point_number) { 724 if (script_break_points[i].number() == break_point_number) {
708 script_break_point = script_break_points[i]; 725 script_break_point = script_break_points[i];
709 // Remove the break point from the list if requested. 726 // Remove the break point from the list if requested.
710 if (remove) { 727 if (remove) {
711 script_break_point.clear(); 728 script_break_point.clear();
712 script_break_points.splice(i,1); 729 script_break_points.splice(i,1);
713 } 730 }
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 } else if (request.command == 'break') { 1351 } else if (request.command == 'break') {
1335 this.breakRequest_(request, response); 1352 this.breakRequest_(request, response);
1336 } else if (request.command == 'setbreakpoint') { 1353 } else if (request.command == 'setbreakpoint') {
1337 this.setBreakPointRequest_(request, response); 1354 this.setBreakPointRequest_(request, response);
1338 } else if (request.command == 'changebreakpoint') { 1355 } else if (request.command == 'changebreakpoint') {
1339 this.changeBreakPointRequest_(request, response); 1356 this.changeBreakPointRequest_(request, response);
1340 } else if (request.command == 'clearbreakpoint') { 1357 } else if (request.command == 'clearbreakpoint') {
1341 this.clearBreakPointRequest_(request, response); 1358 this.clearBreakPointRequest_(request, response);
1342 } else if (request.command == 'clearbreakpointgroup') { 1359 } else if (request.command == 'clearbreakpointgroup') {
1343 this.clearBreakPointGroupRequest_(request, response); 1360 this.clearBreakPointGroupRequest_(request, response);
1361 } else if (request.command == 'disconnect') {
1362 this.disconnectRequest_(request, response);
1363 } else if (request.command == 'setexceptionbreak') {
1364 this.setExceptionBreakRequest_(request, response);
1344 } else if (request.command == 'listbreakpoints') { 1365 } else if (request.command == 'listbreakpoints') {
1345 this.listBreakpointsRequest_(request, response); 1366 this.listBreakpointsRequest_(request, response);
1346 } else if (request.command == 'backtrace') { 1367 } else if (request.command == 'backtrace') {
1347 this.backtraceRequest_(request, response); 1368 this.backtraceRequest_(request, response);
1348 } else if (request.command == 'frame') { 1369 } else if (request.command == 'frame') {
1349 this.frameRequest_(request, response); 1370 this.frameRequest_(request, response);
1350 } else if (request.command == 'scopes') { 1371 } else if (request.command == 'scopes') {
1351 this.scopesRequest_(request, response); 1372 this.scopesRequest_(request, response);
1352 } else if (request.command == 'scope') { 1373 } else if (request.command == 'scope') {
1353 this.scopeRequest_(request, response); 1374 this.scopeRequest_(request, response);
(...skipping 12 matching lines...) Expand all
1366 } else if (request.command == 'suspend') { 1387 } else if (request.command == 'suspend') {
1367 this.suspendRequest_(request, response); 1388 this.suspendRequest_(request, response);
1368 } else if (request.command == 'version') { 1389 } else if (request.command == 'version') {
1369 this.versionRequest_(request, response); 1390 this.versionRequest_(request, response);
1370 } else if (request.command == 'profile') { 1391 } else if (request.command == 'profile') {
1371 this.profileRequest_(request, response); 1392 this.profileRequest_(request, response);
1372 } else if (request.command == 'changelive') { 1393 } else if (request.command == 'changelive') {
1373 this.changeLiveRequest_(request, response); 1394 this.changeLiveRequest_(request, response);
1374 } else if (request.command == 'flags') { 1395 } else if (request.command == 'flags') {
1375 this.debuggerFlagsRequest_(request, response); 1396 this.debuggerFlagsRequest_(request, response);
1397 } else if (request.command == 'v8flags') {
1398 this.v8FlagsRequest_(request, response);
1399
1400 // GC tools:
1401 } else if (request.command == 'gc') {
1402 this.gcRequest_(request, response);
1403
1376 } else { 1404 } else {
1377 throw new Error('Unknown command "' + request.command + '" in request'); 1405 throw new Error('Unknown command "' + request.command + '" in request');
1378 } 1406 }
1379 } catch (e) { 1407 } catch (e) {
1380 // If there is no response object created one (without command). 1408 // If there is no response object created one (without command).
1381 if (!response) { 1409 if (!response) {
1382 response = this.createResponse(); 1410 response = this.createResponse();
1383 } 1411 }
1384 response.success = false; 1412 response.success = false;
1385 response.message = %ToString(e); 1413 response.message = %ToString(e);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { 1711 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
1684 description.type = 'scriptId'; 1712 description.type = 'scriptId';
1685 description.script_id = break_point.script_id(); 1713 description.script_id = break_point.script_id();
1686 } else { 1714 } else {
1687 description.type = 'scriptName'; 1715 description.type = 'scriptName';
1688 description.script_name = break_point.script_name(); 1716 description.script_name = break_point.script_name();
1689 } 1717 }
1690 array.push(description); 1718 array.push(description);
1691 } 1719 }
1692 1720
1693 response.body = { breakpoints: array } 1721 response.body = {
1722 breakpoints: array,
1723 breakOnExceptions: Debug.isBreakOnException(),
1724 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException()
1725 }
1726 }
1727
1728
1729 DebugCommandProcessor.prototype.disconnectRequest_ = function(request, response) {
Søren Thygesen Gjesse 2011/01/03 08:56:07 Long line.
marklam 2011/01/04 20:12:13 Done.
1730 Debug.disableAllBreakPoints();
1731 this.continueRequest_(request, response);
1732 }
1733
1734
1735 DebugCommandProcessor.prototype.setExceptionBreakRequest_ = function(request, re sponse) {
Søren Thygesen Gjesse 2011/01/03 08:56:07 Ditto.
marklam 2011/01/04 20:12:13 Done.
1736 // Check for legal request.
1737 if (!request.arguments) {
1738 response.failed('Missing arguments');
1739 return;
1740 }
1741
1742 // Pull out and check the 'type' argument:
1743 var type = request.arguments.type;
1744 if (!type) {
1745 response.failed('Missing argument "type"');
1746 return;
1747 }
1748
1749 // Initialize the default value of enable:
1750 var enabled;
1751 if (type == 'all') {
1752 enabled = !Debug.isBreakOnException();
1753 } else if (type == 'uncaught') {
1754 enabled = !Debug.isBreakOnUncaughtException();
1755 }
1756
1757 // Pull out and check the 'enabled' argument if present:
1758 if (!IS_UNDEFINED(request.arguments.enabled)) {
1759 enabled = request.arguments.enabled;
1760 if ((enabled != true) && (enabled != false)) {
1761 response.failed('Illegal value for "enabled":"' + enabled + '"');
1762 }
1763 }
1764
1765 // Now set the exception break state:
1766 if (type == 'all') {
1767 %ChangeBreakOnException(Debug.ExceptionBreak.Caught, enabled);
1768 } else if (type == 'uncaught') {
1769 %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, enabled);
1770 } else {
1771 response.failed('Unknown "type":"' + type + '"');
1772 }
1773
1774 // Add the cleared break point number to the response.
1775 response.body = { 'type': type, 'enabled': enabled };
1694 } 1776 }
1695 1777
1696 1778
1697 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) { 1779 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) {
1698 // Get the number of frames. 1780 // Get the number of frames.
1699 var total_frames = this.exec_state_.frameCount(); 1781 var total_frames = this.exec_state_.frameCount();
1700 1782
1701 // Create simple response if there are no frames. 1783 // Create simple response if there are no frames.
1702 if (total_frames == 0) { 1784 if (total_frames == 0) {
1703 response.body = { 1785 response.body = {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 response.setOption('includeSource', includeSource); 2122 response.setOption('includeSource', includeSource);
2041 } 2123 }
2042 2124
2043 if (IS_ARRAY(request.arguments.ids)) { 2125 if (IS_ARRAY(request.arguments.ids)) {
2044 idsToInclude = {}; 2126 idsToInclude = {};
2045 var ids = request.arguments.ids; 2127 var ids = request.arguments.ids;
2046 for (var i = 0; i < ids.length; i++) { 2128 for (var i = 0; i < ids.length; i++) {
2047 idsToInclude[ids[i]] = true; 2129 idsToInclude[ids[i]] = true;
2048 } 2130 }
2049 } 2131 }
2132
2133 var filterStr = null;
2134 var filterNum = null;
2135 if (!IS_UNDEFINED(request.arguments.filter)) {
2136 var num = %ToNumber(request.arguments.filter);
2137 if (!isNaN(num)) {
2138 filterNum = num;
2139 }
2140 filterStr = request.arguments.filter;
2141 }
2050 } 2142 }
2051 2143
2052 // Collect all scripts in the heap. 2144 // Collect all scripts in the heap.
2053 var scripts = %DebugGetLoadedScripts(); 2145 var scripts = %DebugGetLoadedScripts();
2054 2146
2055 response.body = []; 2147 response.body = [];
2056 2148
2057 for (var i = 0; i < scripts.length; i++) { 2149 for (var i = 0; i < scripts.length; i++) {
2058 if (idsToInclude && !idsToInclude[scripts[i].id]) { 2150 if (idsToInclude && !idsToInclude[scripts[i].id]) {
2059 continue; 2151 continue;
2060 } 2152 }
2153 if (filterStr || filterNum) {
2154 var script = scripts[i];
2155 var found = false;
2156 if (filterNum && !found) {
2157 if (script.id && script.id === filterNum) {
2158 found = true;
2159 }
2160 }
2161 if (filterStr && !found) {
2162 if (script.name && script.name.indexOf(filterStr) >= 0) {
2163 found = true;
2164 }
2165 }
2166 if (!found) continue;
2167 }
2061 if (types & ScriptTypeFlag(scripts[i].type)) { 2168 if (types & ScriptTypeFlag(scripts[i].type)) {
2062 response.body.push(MakeMirror(scripts[i])); 2169 response.body.push(MakeMirror(scripts[i]));
2063 } 2170 }
2064 } 2171 }
2065 }; 2172 };
2066 2173
2067 2174
2068 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { 2175 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) {
2069 // Get the number of threads. 2176 // Get the number of threads.
2070 var total_threads = this.exec_state_.threadCount(); 2177 var total_threads = this.exec_state_.threadCount();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 } 2296 }
2190 } else { 2297 } else {
2191 for (var name in debugger_flags) { 2298 for (var name in debugger_flags) {
2192 var value = debugger_flags[name].getValue(); 2299 var value = debugger_flags[name].getValue();
2193 response.body.flags.push({ name: name, value: value }); 2300 response.body.flags.push({ name: name, value: value });
2194 } 2301 }
2195 } 2302 }
2196 } 2303 }
2197 2304
2198 2305
2306 DebugCommandProcessor.prototype.v8FlagsRequest_ = function(request, response) {
2307 var flags = request.arguments.flags;
2308 if (!flags) flags = '';
2309 %SetFlag(flags);
2310 };
2311
2312
2313 DebugCommandProcessor.prototype.gcRequest_ = function(request, response) {
2314 var type = request.arguments.type;
2315 if (!type) type = 'all';
2316
2317 var before = %GetHeapUsage();
2318 %DoGC(type);
2319 var after = %GetHeapUsage();
2320
2321 response.body = { "before": before, "after": after };
2322 };
2323
2324
2325
2326
2199 // Check whether the previously processed command caused the VM to become 2327 // Check whether the previously processed command caused the VM to become
2200 // running. 2328 // running.
2201 DebugCommandProcessor.prototype.isRunning = function() { 2329 DebugCommandProcessor.prototype.isRunning = function() {
2202 return this.running_; 2330 return this.running_;
2203 } 2331 }
2204 2332
2205 2333
2206 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { 2334 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) {
2207 return %SystemBreak(); 2335 return %SystemBreak();
2208 }; 2336 };
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 case 'string': 2420 case 'string':
2293 case 'number': 2421 case 'number':
2294 json = value; 2422 json = value;
2295 break 2423 break
2296 2424
2297 default: 2425 default:
2298 json = null; 2426 json = null;
2299 } 2427 }
2300 return json; 2428 return json;
2301 } 2429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698