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

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

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 10 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/debug-agent.cc ('k') | src/deoptimizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /branches/bleeding_edge/src/debug-debugger.js:r6169-6800
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 Debug.setBreakOnUncaughtException(); 105 Debug.setBreakOnUncaughtException();
106 } else { 106 } else {
107 Debug.clearBreakOnUncaughtException(); 107 Debug.clearBreakOnUncaughtException();
108 } 108 }
109 } 109 }
110 }, 110 },
111 }; 111 };
112 112
113 113
114 // Create a new break point object and add it to the list of break points. 114 // Create a new break point object and add it to the list of break points.
115 function MakeBreakPoint(source_position, opt_line, opt_column, opt_script_break_ point) { 115 function MakeBreakPoint(source_position, opt_script_break_point) {
116 var break_point = new BreakPoint(source_position, opt_line, opt_column, opt_sc ript_break_point); 116 var break_point = new BreakPoint(source_position, opt_script_break_point);
117 break_points.push(break_point); 117 break_points.push(break_point);
118 return break_point; 118 return break_point;
119 } 119 }
120 120
121 121
122 // Object representing a break point. 122 // Object representing a break point.
123 // NOTE: This object does not have a reference to the function having break 123 // NOTE: This object does not have a reference to the function having break
124 // point as this would cause function not to be garbage collected when it is 124 // point as this would cause function not to be garbage collected when it is
125 // not used any more. We do not want break points to keep functions alive. 125 // not used any more. We do not want break points to keep functions alive.
126 function BreakPoint(source_position, opt_line, opt_column, opt_script_break_poin t) { 126 function BreakPoint(source_position, opt_script_break_point) {
127 this.source_position_ = source_position; 127 this.source_position_ = source_position;
128 this.source_line_ = opt_line;
129 this.source_column_ = opt_column;
130 if (opt_script_break_point) { 128 if (opt_script_break_point) {
131 this.script_break_point_ = opt_script_break_point; 129 this.script_break_point_ = opt_script_break_point;
132 } else { 130 } else {
133 this.number_ = next_break_point_number++; 131 this.number_ = next_break_point_number++;
134 } 132 }
135 this.hit_count_ = 0; 133 this.hit_count_ = 0;
136 this.active_ = true; 134 this.active_ = true;
137 this.condition_ = null; 135 this.condition_ = null;
138 this.ignoreCount_ = 0; 136 this.ignoreCount_ = 0;
139 } 137 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 415 }
418 416
419 // Convert the line and column into an absolute position within the script. 417 // Convert the line and column into an absolute position within the script.
420 var position = Debug.findScriptSourcePosition(script, this.line(), column); 418 var position = Debug.findScriptSourcePosition(script, this.line(), column);
421 419
422 // If the position is not found in the script (the script might be shorter 420 // If the position is not found in the script (the script might be shorter
423 // than it used to be) just ignore it. 421 // than it used to be) just ignore it.
424 if (position === null) return; 422 if (position === null) return;
425 423
426 // Create a break point object and set the break point. 424 // Create a break point object and set the break point.
427 break_point = MakeBreakPoint(position, this.line(), this.column(), this); 425 break_point = MakeBreakPoint(position, this);
428 break_point.setIgnoreCount(this.ignoreCount()); 426 break_point.setIgnoreCount(this.ignoreCount());
429 var actual_position = %SetScriptBreakPoint(script, position, break_point); 427 var actual_position = %SetScriptBreakPoint(script, position, break_point);
430 if (IS_UNDEFINED(actual_position)) { 428 if (IS_UNDEFINED(actual_position)) {
431 actual_position = position; 429 actual_position = position;
432 } 430 }
433 var actual_location = script.locationFromPosition(actual_position, true); 431 var actual_location = script.locationFromPosition(actual_position, true);
434 break_point.actual_location = { line: actual_location.line, 432 break_point.actual_location = { line: actual_location.line,
435 column: actual_location.column }; 433 column: actual_location.column };
436 this.break_points_.push(break_point); 434 this.break_points_.push(break_point);
437 return break_point; 435 return break_point;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 // Adjust the source position to be script relative. 630 // Adjust the source position to be script relative.
633 source_position += %FunctionGetScriptSourcePosition(func); 631 source_position += %FunctionGetScriptSourcePosition(func);
634 // Find line and column for the position in the script and set a script 632 // Find line and column for the position in the script and set a script
635 // break point from that. 633 // break point from that.
636 var location = script.locationFromPosition(source_position, false); 634 var location = script.locationFromPosition(source_position, false);
637 return this.setScriptBreakPointById(script.id, 635 return this.setScriptBreakPointById(script.id,
638 location.line, location.column, 636 location.line, location.column,
639 opt_condition); 637 opt_condition);
640 } else { 638 } else {
641 // Set a break point directly on the function. 639 // Set a break point directly on the function.
642 var break_point = MakeBreakPoint(source_position, opt_line, opt_column); 640 var break_point = MakeBreakPoint(source_position);
643 var actual_position = 641 var actual_position =
644 %SetFunctionBreakPoint(func, source_position, break_point); 642 %SetFunctionBreakPoint(func, source_position, break_point);
645 actual_position += this.sourcePosition(func); 643 actual_position += this.sourcePosition(func);
646 var actual_location = script.locationFromPosition(actual_position, true); 644 var actual_location = script.locationFromPosition(actual_position, true);
647 break_point.actual_location = { line: actual_location.line, 645 break_point.actual_location = { line: actual_location.line,
648 column: actual_location.column }; 646 column: actual_location.column };
649 break_point.setCondition(opt_condition); 647 break_point.setCondition(opt_condition);
650 return break_point.number(); 648 return break_point.number();
651 } 649 }
652 }; 650 };
653 651
654 652
653 Debug.setBreakPointByScriptIdAndPosition = function(script_id, position,
654 condition, enabled)
655 {
656 break_point = MakeBreakPoint(position);
657 break_point.setCondition(condition);
658 if (!enabled)
659 break_point.disable();
660 var scripts = this.scripts();
661 for (var i = 0; i < scripts.length; i++) {
662 if (script_id == scripts[i].id) {
663 break_point.actual_position = %SetScriptBreakPoint(scripts[i], position,
664 break_point);
665 break;
666 }
667 }
668 return break_point;
669 };
670
671
655 Debug.enableBreakPoint = function(break_point_number) { 672 Debug.enableBreakPoint = function(break_point_number) {
656 var break_point = this.findBreakPoint(break_point_number, false); 673 var break_point = this.findBreakPoint(break_point_number, false);
657 break_point.enable(); 674 // Only enable if the breakpoint hasn't been deleted:
675 if (break_point) {
676 break_point.enable();
677 }
658 }; 678 };
659 679
660 680
661 Debug.disableBreakPoint = function(break_point_number) { 681 Debug.disableBreakPoint = function(break_point_number) {
662 var break_point = this.findBreakPoint(break_point_number, false); 682 var break_point = this.findBreakPoint(break_point_number, false);
663 break_point.disable(); 683 // Only enable if the breakpoint hasn't been deleted:
684 if (break_point) {
685 break_point.disable();
686 }
664 }; 687 };
665 688
666 689
667 Debug.changeBreakPointCondition = function(break_point_number, condition) { 690 Debug.changeBreakPointCondition = function(break_point_number, condition) {
668 var break_point = this.findBreakPoint(break_point_number, false); 691 var break_point = this.findBreakPoint(break_point_number, false);
669 break_point.setCondition(condition); 692 break_point.setCondition(condition);
670 }; 693 };
671 694
672 695
673 Debug.changeBreakPointIgnoreCount = function(break_point_number, ignoreCount) { 696 Debug.changeBreakPointIgnoreCount = function(break_point_number, ignoreCount) {
(...skipping 20 matching lines...) Expand all
694 717
695 Debug.clearAllBreakPoints = function() { 718 Debug.clearAllBreakPoints = function() {
696 for (var i = 0; i < break_points.length; i++) { 719 for (var i = 0; i < break_points.length; i++) {
697 break_point = break_points[i]; 720 break_point = break_points[i];
698 %ClearBreakPoint(break_point); 721 %ClearBreakPoint(break_point);
699 } 722 }
700 break_points = []; 723 break_points = [];
701 }; 724 };
702 725
703 726
727 Debug.disableAllBreakPoints = function() {
728 // Disable all user defined breakpoints:
729 for (var i = 1; i < next_break_point_number; i++) {
730 Debug.disableBreakPoint(i);
731 }
732 // Disable all exception breakpoints:
733 %ChangeBreakOnException(Debug.ExceptionBreak.Caught, false);
734 %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, false);
735 };
736
737
704 Debug.findScriptBreakPoint = function(break_point_number, remove) { 738 Debug.findScriptBreakPoint = function(break_point_number, remove) {
705 var script_break_point; 739 var script_break_point;
706 for (var i = 0; i < script_break_points.length; i++) { 740 for (var i = 0; i < script_break_points.length; i++) {
707 if (script_break_points[i].number() == break_point_number) { 741 if (script_break_points[i].number() == break_point_number) {
708 script_break_point = script_break_points[i]; 742 script_break_point = script_break_points[i];
709 // Remove the break point from the list if requested. 743 // Remove the break point from the list if requested.
710 if (remove) { 744 if (remove) {
711 script_break_point.clear(); 745 script_break_point.clear();
712 script_break_points.splice(i,1); 746 script_break_points.splice(i,1);
713 } 747 }
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 } else if (request.command == 'break') { 1368 } else if (request.command == 'break') {
1335 this.breakRequest_(request, response); 1369 this.breakRequest_(request, response);
1336 } else if (request.command == 'setbreakpoint') { 1370 } else if (request.command == 'setbreakpoint') {
1337 this.setBreakPointRequest_(request, response); 1371 this.setBreakPointRequest_(request, response);
1338 } else if (request.command == 'changebreakpoint') { 1372 } else if (request.command == 'changebreakpoint') {
1339 this.changeBreakPointRequest_(request, response); 1373 this.changeBreakPointRequest_(request, response);
1340 } else if (request.command == 'clearbreakpoint') { 1374 } else if (request.command == 'clearbreakpoint') {
1341 this.clearBreakPointRequest_(request, response); 1375 this.clearBreakPointRequest_(request, response);
1342 } else if (request.command == 'clearbreakpointgroup') { 1376 } else if (request.command == 'clearbreakpointgroup') {
1343 this.clearBreakPointGroupRequest_(request, response); 1377 this.clearBreakPointGroupRequest_(request, response);
1378 } else if (request.command == 'disconnect') {
1379 this.disconnectRequest_(request, response);
1380 } else if (request.command == 'setexceptionbreak') {
1381 this.setExceptionBreakRequest_(request, response);
1344 } else if (request.command == 'listbreakpoints') { 1382 } else if (request.command == 'listbreakpoints') {
1345 this.listBreakpointsRequest_(request, response); 1383 this.listBreakpointsRequest_(request, response);
1346 } else if (request.command == 'backtrace') { 1384 } else if (request.command == 'backtrace') {
1347 this.backtraceRequest_(request, response); 1385 this.backtraceRequest_(request, response);
1348 } else if (request.command == 'frame') { 1386 } else if (request.command == 'frame') {
1349 this.frameRequest_(request, response); 1387 this.frameRequest_(request, response);
1350 } else if (request.command == 'scopes') { 1388 } else if (request.command == 'scopes') {
1351 this.scopesRequest_(request, response); 1389 this.scopesRequest_(request, response);
1352 } else if (request.command == 'scope') { 1390 } else if (request.command == 'scope') {
1353 this.scopeRequest_(request, response); 1391 this.scopeRequest_(request, response);
(...skipping 12 matching lines...) Expand all
1366 } else if (request.command == 'suspend') { 1404 } else if (request.command == 'suspend') {
1367 this.suspendRequest_(request, response); 1405 this.suspendRequest_(request, response);
1368 } else if (request.command == 'version') { 1406 } else if (request.command == 'version') {
1369 this.versionRequest_(request, response); 1407 this.versionRequest_(request, response);
1370 } else if (request.command == 'profile') { 1408 } else if (request.command == 'profile') {
1371 this.profileRequest_(request, response); 1409 this.profileRequest_(request, response);
1372 } else if (request.command == 'changelive') { 1410 } else if (request.command == 'changelive') {
1373 this.changeLiveRequest_(request, response); 1411 this.changeLiveRequest_(request, response);
1374 } else if (request.command == 'flags') { 1412 } else if (request.command == 'flags') {
1375 this.debuggerFlagsRequest_(request, response); 1413 this.debuggerFlagsRequest_(request, response);
1414 } else if (request.command == 'v8flags') {
1415 this.v8FlagsRequest_(request, response);
1416
1417 // GC tools:
1418 } else if (request.command == 'gc') {
1419 this.gcRequest_(request, response);
1420
1376 } else { 1421 } else {
1377 throw new Error('Unknown command "' + request.command + '" in request'); 1422 throw new Error('Unknown command "' + request.command + '" in request');
1378 } 1423 }
1379 } catch (e) { 1424 } catch (e) {
1380 // If there is no response object created one (without command). 1425 // If there is no response object created one (without command).
1381 if (!response) { 1426 if (!response) {
1382 response = this.createResponse(); 1427 response = this.createResponse();
1383 } 1428 }
1384 response.success = false; 1429 response.success = false;
1385 response.message = %ToString(e); 1430 response.message = %ToString(e);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { 1728 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
1684 description.type = 'scriptId'; 1729 description.type = 'scriptId';
1685 description.script_id = break_point.script_id(); 1730 description.script_id = break_point.script_id();
1686 } else { 1731 } else {
1687 description.type = 'scriptName'; 1732 description.type = 'scriptName';
1688 description.script_name = break_point.script_name(); 1733 description.script_name = break_point.script_name();
1689 } 1734 }
1690 array.push(description); 1735 array.push(description);
1691 } 1736 }
1692 1737
1693 response.body = { breakpoints: array } 1738 response.body = {
1739 breakpoints: array,
1740 breakOnExceptions: Debug.isBreakOnException(),
1741 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException()
1742 }
1743 }
1744
1745
1746 DebugCommandProcessor.prototype.disconnectRequest_ =
1747 function(request, response) {
1748 Debug.disableAllBreakPoints();
1749 this.continueRequest_(request, response);
1750 }
1751
1752
1753 DebugCommandProcessor.prototype.setExceptionBreakRequest_ =
1754 function(request, response) {
1755 // Check for legal request.
1756 if (!request.arguments) {
1757 response.failed('Missing arguments');
1758 return;
1759 }
1760
1761 // Pull out and check the 'type' argument:
1762 var type = request.arguments.type;
1763 if (!type) {
1764 response.failed('Missing argument "type"');
1765 return;
1766 }
1767
1768 // Initialize the default value of enable:
1769 var enabled;
1770 if (type == 'all') {
1771 enabled = !Debug.isBreakOnException();
1772 } else if (type == 'uncaught') {
1773 enabled = !Debug.isBreakOnUncaughtException();
1774 }
1775
1776 // Pull out and check the 'enabled' argument if present:
1777 if (!IS_UNDEFINED(request.arguments.enabled)) {
1778 enabled = request.arguments.enabled;
1779 if ((enabled != true) && (enabled != false)) {
1780 response.failed('Illegal value for "enabled":"' + enabled + '"');
1781 }
1782 }
1783
1784 // Now set the exception break state:
1785 if (type == 'all') {
1786 %ChangeBreakOnException(Debug.ExceptionBreak.Caught, enabled);
1787 } else if (type == 'uncaught') {
1788 %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, enabled);
1789 } else {
1790 response.failed('Unknown "type":"' + type + '"');
1791 }
1792
1793 // Add the cleared break point number to the response.
1794 response.body = { 'type': type, 'enabled': enabled };
1694 } 1795 }
1695 1796
1696 1797
1697 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) { 1798 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) {
1698 // Get the number of frames. 1799 // Get the number of frames.
1699 var total_frames = this.exec_state_.frameCount(); 1800 var total_frames = this.exec_state_.frameCount();
1700 1801
1701 // Create simple response if there are no frames. 1802 // Create simple response if there are no frames.
1702 if (total_frames == 0) { 1803 if (total_frames == 0) {
1703 response.body = { 1804 response.body = {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 response.setOption('includeSource', includeSource); 2141 response.setOption('includeSource', includeSource);
2041 } 2142 }
2042 2143
2043 if (IS_ARRAY(request.arguments.ids)) { 2144 if (IS_ARRAY(request.arguments.ids)) {
2044 idsToInclude = {}; 2145 idsToInclude = {};
2045 var ids = request.arguments.ids; 2146 var ids = request.arguments.ids;
2046 for (var i = 0; i < ids.length; i++) { 2147 for (var i = 0; i < ids.length; i++) {
2047 idsToInclude[ids[i]] = true; 2148 idsToInclude[ids[i]] = true;
2048 } 2149 }
2049 } 2150 }
2151
2152 var filterStr = null;
2153 var filterNum = null;
2154 if (!IS_UNDEFINED(request.arguments.filter)) {
2155 var num = %ToNumber(request.arguments.filter);
2156 if (!isNaN(num)) {
2157 filterNum = num;
2158 }
2159 filterStr = request.arguments.filter;
2160 }
2050 } 2161 }
2051 2162
2052 // Collect all scripts in the heap. 2163 // Collect all scripts in the heap.
2053 var scripts = %DebugGetLoadedScripts(); 2164 var scripts = %DebugGetLoadedScripts();
2054 2165
2055 response.body = []; 2166 response.body = [];
2056 2167
2057 for (var i = 0; i < scripts.length; i++) { 2168 for (var i = 0; i < scripts.length; i++) {
2058 if (idsToInclude && !idsToInclude[scripts[i].id]) { 2169 if (idsToInclude && !idsToInclude[scripts[i].id]) {
2059 continue; 2170 continue;
2060 } 2171 }
2172 if (filterStr || filterNum) {
2173 var script = scripts[i];
2174 var found = false;
2175 if (filterNum && !found) {
2176 if (script.id && script.id === filterNum) {
2177 found = true;
2178 }
2179 }
2180 if (filterStr && !found) {
2181 if (script.name && script.name.indexOf(filterStr) >= 0) {
2182 found = true;
2183 }
2184 }
2185 if (!found) continue;
2186 }
2061 if (types & ScriptTypeFlag(scripts[i].type)) { 2187 if (types & ScriptTypeFlag(scripts[i].type)) {
2062 response.body.push(MakeMirror(scripts[i])); 2188 response.body.push(MakeMirror(scripts[i]));
2063 } 2189 }
2064 } 2190 }
2065 }; 2191 };
2066 2192
2067 2193
2068 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { 2194 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) {
2069 // Get the number of threads. 2195 // Get the number of threads.
2070 var total_threads = this.exec_state_.threadCount(); 2196 var total_threads = this.exec_state_.threadCount();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 } 2315 }
2190 } else { 2316 } else {
2191 for (var name in debugger_flags) { 2317 for (var name in debugger_flags) {
2192 var value = debugger_flags[name].getValue(); 2318 var value = debugger_flags[name].getValue();
2193 response.body.flags.push({ name: name, value: value }); 2319 response.body.flags.push({ name: name, value: value });
2194 } 2320 }
2195 } 2321 }
2196 } 2322 }
2197 2323
2198 2324
2325 DebugCommandProcessor.prototype.v8FlagsRequest_ = function(request, response) {
2326 var flags = request.arguments.flags;
2327 if (!flags) flags = '';
2328 %SetFlags(flags);
2329 };
2330
2331
2332 DebugCommandProcessor.prototype.gcRequest_ = function(request, response) {
2333 var type = request.arguments.type;
2334 if (!type) type = 'all';
2335
2336 var before = %GetHeapUsage();
2337 %CollectGarbage(type);
2338 var after = %GetHeapUsage();
2339
2340 response.body = { "before": before, "after": after };
2341 };
2342
2343
2344
2345
2199 // Check whether the previously processed command caused the VM to become 2346 // Check whether the previously processed command caused the VM to become
2200 // running. 2347 // running.
2201 DebugCommandProcessor.prototype.isRunning = function() { 2348 DebugCommandProcessor.prototype.isRunning = function() {
2202 return this.running_; 2349 return this.running_;
2203 } 2350 }
2204 2351
2205 2352
2206 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { 2353 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) {
2207 return %SystemBreak(); 2354 return %SystemBreak();
2208 }; 2355 };
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 case 'string': 2439 case 'string':
2293 case 'number': 2440 case 'number':
2294 json = value; 2441 json = value;
2295 break 2442 break
2296 2443
2297 default: 2444 default:
2298 json = null; 2445 json = null;
2299 } 2446 }
2300 return json; 2447 return json;
2301 } 2448 }
OLDNEW
« no previous file with comments | « src/debug-agent.cc ('k') | src/deoptimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698