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