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 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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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_ = |
| 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 }; |
1694 } | 1778 } |
1695 | 1779 |
1696 | 1780 |
1697 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response)
{ | 1781 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response)
{ |
1698 // Get the number of frames. | 1782 // Get the number of frames. |
1699 var total_frames = this.exec_state_.frameCount(); | 1783 var total_frames = this.exec_state_.frameCount(); |
1700 | 1784 |
1701 // Create simple response if there are no frames. | 1785 // Create simple response if there are no frames. |
1702 if (total_frames == 0) { | 1786 if (total_frames == 0) { |
1703 response.body = { | 1787 response.body = { |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2040 response.setOption('includeSource', includeSource); | 2124 response.setOption('includeSource', includeSource); |
2041 } | 2125 } |
2042 | 2126 |
2043 if (IS_ARRAY(request.arguments.ids)) { | 2127 if (IS_ARRAY(request.arguments.ids)) { |
2044 idsToInclude = {}; | 2128 idsToInclude = {}; |
2045 var ids = request.arguments.ids; | 2129 var ids = request.arguments.ids; |
2046 for (var i = 0; i < ids.length; i++) { | 2130 for (var i = 0; i < ids.length; i++) { |
2047 idsToInclude[ids[i]] = true; | 2131 idsToInclude[ids[i]] = true; |
2048 } | 2132 } |
2049 } | 2133 } |
| 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 } |
2050 } | 2144 } |
2051 | 2145 |
2052 // Collect all scripts in the heap. | 2146 // Collect all scripts in the heap. |
2053 var scripts = %DebugGetLoadedScripts(); | 2147 var scripts = %DebugGetLoadedScripts(); |
2054 | 2148 |
2055 response.body = []; | 2149 response.body = []; |
2056 | 2150 |
2057 for (var i = 0; i < scripts.length; i++) { | 2151 for (var i = 0; i < scripts.length; i++) { |
2058 if (idsToInclude && !idsToInclude[scripts[i].id]) { | 2152 if (idsToInclude && !idsToInclude[scripts[i].id]) { |
2059 continue; | 2153 continue; |
2060 } | 2154 } |
| 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 } |
2061 if (types & ScriptTypeFlag(scripts[i].type)) { | 2170 if (types & ScriptTypeFlag(scripts[i].type)) { |
2062 response.body.push(MakeMirror(scripts[i])); | 2171 response.body.push(MakeMirror(scripts[i])); |
2063 } | 2172 } |
2064 } | 2173 } |
2065 }; | 2174 }; |
2066 | 2175 |
2067 | 2176 |
2068 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { | 2177 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { |
2069 // Get the number of threads. | 2178 // Get the number of threads. |
2070 var total_threads = this.exec_state_.threadCount(); | 2179 var total_threads = this.exec_state_.threadCount(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 } | 2298 } |
2190 } else { | 2299 } else { |
2191 for (var name in debugger_flags) { | 2300 for (var name in debugger_flags) { |
2192 var value = debugger_flags[name].getValue(); | 2301 var value = debugger_flags[name].getValue(); |
2193 response.body.flags.push({ name: name, value: value }); | 2302 response.body.flags.push({ name: name, value: value }); |
2194 } | 2303 } |
2195 } | 2304 } |
2196 } | 2305 } |
2197 | 2306 |
2198 | 2307 |
| 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 |
2199 // Check whether the previously processed command caused the VM to become | 2329 // Check whether the previously processed command caused the VM to become |
2200 // running. | 2330 // running. |
2201 DebugCommandProcessor.prototype.isRunning = function() { | 2331 DebugCommandProcessor.prototype.isRunning = function() { |
2202 return this.running_; | 2332 return this.running_; |
2203 } | 2333 } |
2204 | 2334 |
2205 | 2335 |
2206 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { | 2336 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { |
2207 return %SystemBreak(); | 2337 return %SystemBreak(); |
2208 }; | 2338 }; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2292 case 'string': | 2422 case 'string': |
2293 case 'number': | 2423 case 'number': |
2294 json = value; | 2424 json = value; |
2295 break | 2425 break |
2296 | 2426 |
2297 default: | 2427 default: |
2298 json = null; | 2428 json = null; |
2299 } | 2429 } |
2300 return json; | 2430 return json; |
2301 } | 2431 } |
OLD | NEW |