| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 72 | 72 | 
| 73 function ScriptTypeFlag(type) { | 73 function ScriptTypeFlag(type) { | 
| 74   return (1 << type); | 74   return (1 << type); | 
| 75 } | 75 } | 
| 76 | 76 | 
| 77 // Globals. | 77 // Globals. | 
| 78 var next_response_seq = 0; | 78 var next_response_seq = 0; | 
| 79 var next_break_point_number = 1; | 79 var next_break_point_number = 1; | 
| 80 var break_points = []; | 80 var break_points = []; | 
| 81 var script_break_points = []; | 81 var script_break_points = []; | 
|  | 82 var debugger_flags = { | 
|  | 83   breakPointsActive: { | 
|  | 84     value: true, | 
|  | 85     getValue: function() { return this.value; }, | 
|  | 86     setValue: function(value) { | 
|  | 87       this.value = !!value; | 
|  | 88       %SetDisableBreak(!this.value); | 
|  | 89     } | 
|  | 90   } | 
|  | 91 }; | 
| 82 | 92 | 
| 83 | 93 | 
| 84 // Create a new break point object and add it to the list of break points. | 94 // Create a new break point object and add it to the list of break points. | 
| 85 function MakeBreakPoint(source_position, opt_line, opt_column, opt_script_break_
      point) { | 95 function MakeBreakPoint(source_position, opt_line, opt_column, opt_script_break_
      point) { | 
| 86   var break_point = new BreakPoint(source_position, opt_line, opt_column, opt_sc
      ript_break_point); | 96   var break_point = new BreakPoint(source_position, opt_line, opt_column, opt_sc
      ript_break_point); | 
| 87   break_points.push(break_point); | 97   break_points.push(break_point); | 
| 88   return break_point; | 98   return break_point; | 
| 89 } | 99 } | 
| 90 | 100 | 
| 91 | 101 | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 239   this.break_points_ = []; | 249   this.break_points_ = []; | 
| 240 } | 250 } | 
| 241 | 251 | 
| 242 | 252 | 
| 243 //Creates a clone of script breakpoint that is linked to another script. | 253 //Creates a clone of script breakpoint that is linked to another script. | 
| 244 ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) { | 254 ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) { | 
| 245   var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, | 255   var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, | 
| 246       other_script.id, this.line_, this.column_, this.groupId_); | 256       other_script.id, this.line_, this.column_, this.groupId_); | 
| 247   copy.number_ = next_break_point_number++; | 257   copy.number_ = next_break_point_number++; | 
| 248   script_break_points.push(copy); | 258   script_break_points.push(copy); | 
| 249 | 259 | 
| 250   copy.hit_count_ = this.hit_count_; | 260   copy.hit_count_ = this.hit_count_; | 
| 251   copy.active_ = this.active_; | 261   copy.active_ = this.active_; | 
| 252   copy.condition_ = this.condition_; | 262   copy.condition_ = this.condition_; | 
| 253   copy.ignoreCount_ = this.ignoreCount_; | 263   copy.ignoreCount_ = this.ignoreCount_; | 
| 254   return copy; | 264   return copy; | 
| 255 } | 265 } | 
| 256 | 266 | 
| 257 | 267 | 
| 258 ScriptBreakPoint.prototype.number = function() { | 268 ScriptBreakPoint.prototype.number = function() { | 
| 259   return this.number_; | 269   return this.number_; | 
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 806   result += source.substring(prev_pos, pos); | 816   result += source.substring(prev_pos, pos); | 
| 807   return result; | 817   return result; | 
| 808 }; | 818 }; | 
| 809 | 819 | 
| 810 | 820 | 
| 811 // Get all the scripts currently loaded. Locating all the scripts is based on | 821 // Get all the scripts currently loaded. Locating all the scripts is based on | 
| 812 // scanning the heap. | 822 // scanning the heap. | 
| 813 Debug.scripts = function() { | 823 Debug.scripts = function() { | 
| 814   // Collect all scripts in the heap. | 824   // Collect all scripts in the heap. | 
| 815   return %DebugGetLoadedScripts(); | 825   return %DebugGetLoadedScripts(); | 
| 816 } | 826 }; | 
|  | 827 | 
|  | 828 | 
|  | 829 Debug.debuggerFlags = function() { | 
|  | 830   return debugger_flags; | 
|  | 831 }; | 
|  | 832 | 
| 817 | 833 | 
| 818 function MakeExecutionState(break_id) { | 834 function MakeExecutionState(break_id) { | 
| 819   return new ExecutionState(break_id); | 835   return new ExecutionState(break_id); | 
| 820 } | 836 } | 
| 821 | 837 | 
| 822 function ExecutionState(break_id) { | 838 function ExecutionState(break_id) { | 
| 823   this.break_id = break_id; | 839   this.break_id = break_id; | 
| 824   this.selected_frame = 0; | 840   this.selected_frame = 0; | 
| 825 } | 841 } | 
| 826 | 842 | 
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1318         this.sourceRequest_(request, response); | 1334         this.sourceRequest_(request, response); | 
| 1319       } else if (request.command == 'scripts') { | 1335       } else if (request.command == 'scripts') { | 
| 1320         this.scriptsRequest_(request, response); | 1336         this.scriptsRequest_(request, response); | 
| 1321       } else if (request.command == 'threads') { | 1337       } else if (request.command == 'threads') { | 
| 1322         this.threadsRequest_(request, response); | 1338         this.threadsRequest_(request, response); | 
| 1323       } else if (request.command == 'suspend') { | 1339       } else if (request.command == 'suspend') { | 
| 1324         this.suspendRequest_(request, response); | 1340         this.suspendRequest_(request, response); | 
| 1325       } else if (request.command == 'version') { | 1341       } else if (request.command == 'version') { | 
| 1326         this.versionRequest_(request, response); | 1342         this.versionRequest_(request, response); | 
| 1327       } else if (request.command == 'profile') { | 1343       } else if (request.command == 'profile') { | 
| 1328           this.profileRequest_(request, response); | 1344         this.profileRequest_(request, response); | 
| 1329       } else if (request.command == 'changelive') { | 1345       } else if (request.command == 'changelive') { | 
| 1330           this.changeLiveRequest_(request, response); | 1346         this.changeLiveRequest_(request, response); | 
|  | 1347       } else if (request.command == 'flags') { | 
|  | 1348         this.debuggerFlagsRequest_(request, response); | 
| 1331       } else { | 1349       } else { | 
| 1332         throw new Error('Unknown command "' + request.command + '" in request'); | 1350         throw new Error('Unknown command "' + request.command + '" in request'); | 
| 1333       } | 1351       } | 
| 1334     } catch (e) { | 1352     } catch (e) { | 
| 1335       // If there is no response object created one (without command). | 1353       // If there is no response object created one (without command). | 
| 1336       if (!response) { | 1354       if (!response) { | 
| 1337         response = this.createResponse(); | 1355         response = this.createResponse(); | 
| 1338       } | 1356       } | 
| 1339       response.success = false; | 1357       response.success = false; | 
| 1340       response.message = %ToString(e); | 1358       response.message = %ToString(e); | 
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1610     return; | 1628     return; | 
| 1611   } | 1629   } | 
| 1612 | 1630 | 
| 1613   // Clear break point. | 1631   // Clear break point. | 
| 1614   Debug.clearBreakPoint(break_point); | 1632   Debug.clearBreakPoint(break_point); | 
| 1615 | 1633 | 
| 1616   // Add the cleared break point number to the response. | 1634   // Add the cleared break point number to the response. | 
| 1617   response.body = { breakpoint: break_point } | 1635   response.body = { breakpoint: break_point } | 
| 1618 } | 1636 } | 
| 1619 | 1637 | 
|  | 1638 | 
| 1620 DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, resp
      onse) { | 1639 DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, resp
      onse) { | 
| 1621   var array = []; | 1640   var array = []; | 
| 1622   for (var i = 0; i < script_break_points.length; i++) { | 1641   for (var i = 0; i < script_break_points.length; i++) { | 
| 1623     var break_point = script_break_points[i]; | 1642     var break_point = script_break_points[i]; | 
| 1624 | 1643 | 
| 1625     var description = { | 1644     var description = { | 
| 1626       number: break_point.number(), | 1645       number: break_point.number(), | 
| 1627       line: break_point.line(), | 1646       line: break_point.line(), | 
| 1628       column: break_point.column(), | 1647       column: break_point.column(), | 
| 1629       groupId: break_point.groupId(), | 1648       groupId: break_point.groupId(), | 
| 1630       hit_count: break_point.hit_count(), | 1649       hit_count: break_point.hit_count(), | 
| 1631       active: break_point.active(), | 1650       active: break_point.active(), | 
| 1632       condition: break_point.condition(), | 1651       condition: break_point.condition(), | 
| 1633       ignoreCount: break_point.ignoreCount(), | 1652       ignoreCount: break_point.ignoreCount(), | 
| 1634       actual_locations: break_point.actual_locations() | 1653       actual_locations: break_point.actual_locations() | 
| 1635     } | 1654     } | 
| 1636 | 1655 | 
| 1637     if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 1656     if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 
| 1638       description.type = 'scriptId'; | 1657       description.type = 'scriptId'; | 
| 1639       description.script_id = break_point.script_id(); | 1658       description.script_id = break_point.script_id(); | 
| 1640     } else { | 1659     } else { | 
| 1641       description.type = 'scriptName'; | 1660       description.type = 'scriptName'; | 
| 1642       description.script_name = break_point.script_name(); | 1661       description.script_name = break_point.script_name(); | 
| 1643     } | 1662     } | 
| 1644     array.push(description); | 1663     array.push(description); | 
| 1645   } | 1664   } | 
| 1646 | 1665 | 
| 1647   response.body = { breakpoints: array } | 1666   response.body = { breakpoints: array } | 
| 1648 } | 1667 } | 
| 1649 | 1668 | 
| 1650 | 1669 | 
| 1651 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) 
      { | 1670 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) 
      { | 
| 1652   // Get the number of frames. | 1671   // Get the number of frames. | 
| 1653   var total_frames = this.exec_state_.frameCount(); | 1672   var total_frames = this.exec_state_.frameCount(); | 
| 1654 | 1673 | 
| 1655   // Create simple response if there are no frames. | 1674   // Create simple response if there are no frames. | 
| 1656   if (total_frames == 0) { | 1675   if (total_frames == 0) { | 
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2063 | 2082 | 
| 2064 | 2083 | 
| 2065 DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
       { | 2084 DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
       { | 
| 2066   if (!Debug.LiveEdit) { | 2085   if (!Debug.LiveEdit) { | 
| 2067     return response.failed('LiveEdit feature is not supported'); | 2086     return response.failed('LiveEdit feature is not supported'); | 
| 2068   } | 2087   } | 
| 2069   if (!request.arguments) { | 2088   if (!request.arguments) { | 
| 2070     return response.failed('Missing arguments'); | 2089     return response.failed('Missing arguments'); | 
| 2071   } | 2090   } | 
| 2072   var script_id = request.arguments.script_id; | 2091   var script_id = request.arguments.script_id; | 
| 2073 | 2092 | 
| 2074   var scripts = %DebugGetLoadedScripts(); | 2093   var scripts = %DebugGetLoadedScripts(); | 
| 2075 | 2094 | 
| 2076   var the_script = null; | 2095   var the_script = null; | 
| 2077   for (var i = 0; i < scripts.length; i++) { | 2096   for (var i = 0; i < scripts.length; i++) { | 
| 2078     if (scripts[i].id == script_id) { | 2097     if (scripts[i].id == script_id) { | 
| 2079       the_script = scripts[i]; | 2098       the_script = scripts[i]; | 
| 2080     } | 2099     } | 
| 2081   } | 2100   } | 
| 2082   if (!the_script) { | 2101   if (!the_script) { | 
| 2083     response.failed('Script not found'); | 2102     response.failed('Script not found'); | 
| 2084     return; | 2103     return; | 
| 2085   } | 2104   } | 
| 2086 | 2105 | 
| 2087   var change_log = new Array(); | 2106   var change_log = new Array(); | 
| 2088 | 2107 | 
| 2089   if (!IS_STRING(request.arguments.new_source)) { | 2108   if (!IS_STRING(request.arguments.new_source)) { | 
| 2090     throw "new_source argument expected"; | 2109     throw "new_source argument expected"; | 
| 2091   } | 2110   } | 
| 2092 | 2111 | 
| 2093   var new_source = request.arguments.new_source; | 2112   var new_source = request.arguments.new_source; | 
| 2094 | 2113 | 
| 2095   try { | 2114   try { | 
| 2096     Debug.LiveEdit.SetScriptSource(the_script, new_source, change_log); | 2115     Debug.LiveEdit.SetScriptSource(the_script, new_source, change_log); | 
| 2097   } catch (e) { | 2116   } catch (e) { | 
| 2098     if (e instanceof Debug.LiveEdit.Failure) { | 2117     if (e instanceof Debug.LiveEdit.Failure) { | 
| 2099       // Let's treat it as a "success" so that body with change_log will be | 2118       // Let's treat it as a "success" so that body with change_log will be | 
| 2100       // sent back. "change_log" will have "failure" field set. | 2119       // sent back. "change_log" will have "failure" field set. | 
| 2101       change_log.push( { failure: true, message: e.toString() } ); | 2120       change_log.push( { failure: true, message: e.toString() } ); | 
| 2102     } else { | 2121     } else { | 
| 2103       throw e; | 2122       throw e; | 
| 2104     } | 2123     } | 
| 2105   } | 2124   } | 
| 2106   response.body = {change_log: change_log}; | 2125   response.body = {change_log: change_log}; | 
| 2107 }; | 2126 }; | 
| 2108 | 2127 | 
| 2109 | 2128 | 
|  | 2129 DebugCommandProcessor.prototype.debuggerFlagsRequest_ = function(request, | 
|  | 2130                                                                  response) { | 
|  | 2131   // Check for legal request. | 
|  | 2132   if (!request.arguments) { | 
|  | 2133     response.failed('Missing arguments'); | 
|  | 2134     return; | 
|  | 2135   } | 
|  | 2136 | 
|  | 2137   // Pull out arguments. | 
|  | 2138   var flags = request.arguments.flags; | 
|  | 2139 | 
|  | 2140   response.body = { flags: [] }; | 
|  | 2141   if (!IS_UNDEFINED(flags)) { | 
|  | 2142     for (var i = 0; i < flags.length; i++) { | 
|  | 2143       var name = flags[i].name; | 
|  | 2144       var debugger_flag = debugger_flags[name]; | 
|  | 2145       if (!debugger_flag) { | 
|  | 2146         continue; | 
|  | 2147       } | 
|  | 2148       if ('value' in flags[i]) { | 
|  | 2149         debugger_flag.setValue(flags[i].value); | 
|  | 2150       } | 
|  | 2151       response.body.flags.push({ name: name, value: debugger_flag.getValue() }); | 
|  | 2152     } | 
|  | 2153   } else { | 
|  | 2154     for (var name in debugger_flags) { | 
|  | 2155       var value = debugger_flags[name].getValue(); | 
|  | 2156       response.body.flags.push({ name: name, value: value }); | 
|  | 2157     } | 
|  | 2158   } | 
|  | 2159 } | 
|  | 2160 | 
|  | 2161 | 
| 2110 // Check whether the previously processed command caused the VM to become | 2162 // Check whether the previously processed command caused the VM to become | 
| 2111 // running. | 2163 // running. | 
| 2112 DebugCommandProcessor.prototype.isRunning = function() { | 2164 DebugCommandProcessor.prototype.isRunning = function() { | 
| 2113   return this.running_; | 2165   return this.running_; | 
| 2114 } | 2166 } | 
| 2115 | 2167 | 
| 2116 | 2168 | 
| 2117 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { | 2169 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { | 
| 2118   return %SystemBreak(); | 2170   return %SystemBreak(); | 
| 2119 }; | 2171 }; | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2226     case 'string': | 2278     case 'string': | 
| 2227     case 'number': | 2279     case 'number': | 
| 2228       json = value; | 2280       json = value; | 
| 2229       break | 2281       break | 
| 2230 | 2282 | 
| 2231     default: | 2283     default: | 
| 2232       json = null; | 2284       json = null; | 
| 2233   } | 2285   } | 
| 2234   return json; | 2286   return json; | 
| 2235 } | 2287 } | 
| OLD | NEW | 
|---|