| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 "use strict"; | 4 "use strict"; |
| 5 | 5 |
| 6 // Default number of frames to include in the response to backtrace request. | 6 // Default number of frames to include in the response to backtrace request. |
| 7 var kDefaultBacktraceLength = 10; | 7 var kDefaultBacktraceLength = 10; |
| 8 | 8 |
| 9 var Debug = {}; | 9 var Debug = {}; |
| 10 | 10 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 BreakPoint.prototype.isTriggered = function(exec_state) { | 195 BreakPoint.prototype.isTriggered = function(exec_state) { |
| 196 // Break point not active - not triggered. | 196 // Break point not active - not triggered. |
| 197 if (!this.active()) return false; | 197 if (!this.active()) return false; |
| 198 | 198 |
| 199 // Check for conditional break point. | 199 // Check for conditional break point. |
| 200 if (this.condition()) { | 200 if (this.condition()) { |
| 201 // If break point has condition try to evaluate it in the top frame. | 201 // If break point has condition try to evaluate it in the top frame. |
| 202 try { | 202 try { |
| 203 var mirror = exec_state.frame(0).evaluate(this.condition()); | 203 var mirror = exec_state.frame(0).evaluate(this.condition()); |
| 204 // If no sensible mirror or non true value break point not triggered. | 204 // If no sensible mirror or non true value break point not triggered. |
| 205 if (!(mirror instanceof ValueMirror) || | 205 if (!(mirror instanceof ValueMirror) || !%ToBoolean(mirror.value_)) { |
| 206 !builtins.$toBoolean(mirror.value_)) { | |
| 207 return false; | 206 return false; |
| 208 } | 207 } |
| 209 } catch (e) { | 208 } catch (e) { |
| 210 // Exception evaluating condition counts as not triggered. | 209 // Exception evaluating condition counts as not triggered. |
| 211 return false; | 210 return false; |
| 212 } | 211 } |
| 213 } | 212 } |
| 214 | 213 |
| 215 // Update the hit count. | 214 // Update the hit count. |
| 216 this.hit_count_++; | 215 this.hit_count_++; |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 } | 917 } |
| 919 | 918 |
| 920 function ExecutionState(break_id) { | 919 function ExecutionState(break_id) { |
| 921 this.break_id = break_id; | 920 this.break_id = break_id; |
| 922 this.selected_frame = 0; | 921 this.selected_frame = 0; |
| 923 } | 922 } |
| 924 | 923 |
| 925 ExecutionState.prototype.prepareStep = function(opt_action, opt_count, | 924 ExecutionState.prototype.prepareStep = function(opt_action, opt_count, |
| 926 opt_callframe) { | 925 opt_callframe) { |
| 927 var action = Debug.StepAction.StepIn; | 926 var action = Debug.StepAction.StepIn; |
| 928 if (!IS_UNDEFINED(opt_action)) action = builtins.$toNumber(opt_action); | 927 if (!IS_UNDEFINED(opt_action)) action = %ToNumber(opt_action); |
| 929 var count = opt_count ? builtins.$toNumber(opt_count) : 1; | 928 var count = opt_count ? %ToNumber(opt_count) : 1; |
| 930 var callFrameId = 0; | 929 var callFrameId = 0; |
| 931 if (!IS_UNDEFINED(opt_callframe)) { | 930 if (!IS_UNDEFINED(opt_callframe)) { |
| 932 callFrameId = opt_callframe.details_.frameId(); | 931 callFrameId = opt_callframe.details_.frameId(); |
| 933 } | 932 } |
| 934 | 933 |
| 935 return %PrepareStep(this.break_id, action, count, callFrameId); | 934 return %PrepareStep(this.break_id, action, count, callFrameId); |
| 936 }; | 935 }; |
| 937 | 936 |
| 938 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, | 937 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, |
| 939 opt_additional_context) { | 938 opt_additional_context) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 953 ExecutionState.prototype.frame = function(opt_index) { | 952 ExecutionState.prototype.frame = function(opt_index) { |
| 954 // If no index supplied return the selected frame. | 953 // If no index supplied return the selected frame. |
| 955 if (opt_index == null) opt_index = this.selected_frame; | 954 if (opt_index == null) opt_index = this.selected_frame; |
| 956 if (opt_index < 0 || opt_index >= this.frameCount()) { | 955 if (opt_index < 0 || opt_index >= this.frameCount()) { |
| 957 throw new Error('Illegal frame index.'); | 956 throw new Error('Illegal frame index.'); |
| 958 } | 957 } |
| 959 return new FrameMirror(this.break_id, opt_index); | 958 return new FrameMirror(this.break_id, opt_index); |
| 960 }; | 959 }; |
| 961 | 960 |
| 962 ExecutionState.prototype.setSelectedFrame = function(index) { | 961 ExecutionState.prototype.setSelectedFrame = function(index) { |
| 963 var i = builtins.$toNumber(index); | 962 var i = %ToNumber(index); |
| 964 if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.'); | 963 if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.'); |
| 965 this.selected_frame = i; | 964 this.selected_frame = i; |
| 966 }; | 965 }; |
| 967 | 966 |
| 968 ExecutionState.prototype.selectedFrame = function() { | 967 ExecutionState.prototype.selectedFrame = function() { |
| 969 return this.selected_frame; | 968 return this.selected_frame; |
| 970 }; | 969 }; |
| 971 | 970 |
| 972 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) { | 971 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) { |
| 973 return new DebugCommandProcessor(this, opt_is_running); | 972 return new DebugCommandProcessor(this, opt_is_running); |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 %_CallFunction(this, request, response, handler); | 1395 %_CallFunction(this, request, response, handler); |
| 1397 } else { | 1396 } else { |
| 1398 throw new Error('Unknown command "' + request.command + '" in request'); | 1397 throw new Error('Unknown command "' + request.command + '" in request'); |
| 1399 } | 1398 } |
| 1400 } catch (e) { | 1399 } catch (e) { |
| 1401 // If there is no response object created one (without command). | 1400 // If there is no response object created one (without command). |
| 1402 if (!response) { | 1401 if (!response) { |
| 1403 response = this.createResponse(); | 1402 response = this.createResponse(); |
| 1404 } | 1403 } |
| 1405 response.success = false; | 1404 response.success = false; |
| 1406 response.message = builtins.$toString(e); | 1405 response.message = %ToString(e); |
| 1407 } | 1406 } |
| 1408 | 1407 |
| 1409 // Return the response as a JSON encoded string. | 1408 // Return the response as a JSON encoded string. |
| 1410 try { | 1409 try { |
| 1411 if (!IS_UNDEFINED(response.running)) { | 1410 if (!IS_UNDEFINED(response.running)) { |
| 1412 // Response controls running state. | 1411 // Response controls running state. |
| 1413 this.running_ = response.running; | 1412 this.running_ = response.running; |
| 1414 } | 1413 } |
| 1415 response.running = this.running_; | 1414 response.running = this.running_; |
| 1416 return response.toJSONProtocol(); | 1415 return response.toJSONProtocol(); |
| 1417 } catch (e) { | 1416 } catch (e) { |
| 1418 // Failed to generate response - return generic error. | 1417 // Failed to generate response - return generic error. |
| 1419 return '{"seq":' + response.seq + ',' + | 1418 return '{"seq":' + response.seq + ',' + |
| 1420 '"request_seq":' + request.seq + ',' + | 1419 '"request_seq":' + request.seq + ',' + |
| 1421 '"type":"response",' + | 1420 '"type":"response",' + |
| 1422 '"success":false,' + | 1421 '"success":false,' + |
| 1423 '"message":"Internal error: ' + builtins.$toString(e) + '"}'; | 1422 '"message":"Internal error: ' + %ToString(e) + '"}'; |
| 1424 } | 1423 } |
| 1425 } catch (e) { | 1424 } catch (e) { |
| 1426 // Failed in one of the catch blocks above - most generic error. | 1425 // Failed in one of the catch blocks above - most generic error. |
| 1427 return '{"seq":0,"type":"response","success":false,"message":"Internal error
"}'; | 1426 return '{"seq":0,"type":"response","success":false,"message":"Internal error
"}'; |
| 1428 } | 1427 } |
| 1429 }; | 1428 }; |
| 1430 | 1429 |
| 1431 | 1430 |
| 1432 DebugCommandProcessor.prototype.continueRequest_ = function(request, response) { | 1431 DebugCommandProcessor.prototype.continueRequest_ = function(request, response) { |
| 1433 // Check for arguments for continue. | 1432 // Check for arguments for continue. |
| 1434 if (request.arguments) { | 1433 if (request.arguments) { |
| 1435 var count = 1; | 1434 var count = 1; |
| 1436 var action = Debug.StepAction.StepIn; | 1435 var action = Debug.StepAction.StepIn; |
| 1437 | 1436 |
| 1438 // Pull out arguments. | 1437 // Pull out arguments. |
| 1439 var stepaction = request.arguments.stepaction; | 1438 var stepaction = request.arguments.stepaction; |
| 1440 var stepcount = request.arguments.stepcount; | 1439 var stepcount = request.arguments.stepcount; |
| 1441 | 1440 |
| 1442 // Get the stepcount argument if any. | 1441 // Get the stepcount argument if any. |
| 1443 if (stepcount) { | 1442 if (stepcount) { |
| 1444 count = builtins.$toNumber(stepcount); | 1443 count = %ToNumber(stepcount); |
| 1445 if (count < 0) { | 1444 if (count < 0) { |
| 1446 throw new Error('Invalid stepcount argument "' + stepcount + '".'); | 1445 throw new Error('Invalid stepcount argument "' + stepcount + '".'); |
| 1447 } | 1446 } |
| 1448 } | 1447 } |
| 1449 | 1448 |
| 1450 // Get the stepaction argument. | 1449 // Get the stepaction argument. |
| 1451 if (stepaction) { | 1450 if (stepaction) { |
| 1452 if (stepaction == 'in') { | 1451 if (stepaction == 'in') { |
| 1453 action = Debug.StepAction.StepIn; | 1452 action = Debug.StepAction.StepIn; |
| 1454 } else if (stepaction == 'min') { | 1453 } else if (stepaction == 'min') { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 // Handle function break point. | 1506 // Handle function break point. |
| 1508 if (!IS_STRING(target)) { | 1507 if (!IS_STRING(target)) { |
| 1509 response.failed('Argument "target" is not a string value'); | 1508 response.failed('Argument "target" is not a string value'); |
| 1510 return; | 1509 return; |
| 1511 } | 1510 } |
| 1512 var f; | 1511 var f; |
| 1513 try { | 1512 try { |
| 1514 // Find the function through a global evaluate. | 1513 // Find the function through a global evaluate. |
| 1515 f = this.exec_state_.evaluateGlobal(target).value(); | 1514 f = this.exec_state_.evaluateGlobal(target).value(); |
| 1516 } catch (e) { | 1515 } catch (e) { |
| 1517 response.failed('Error: "' + builtins.$toString(e) + | 1516 response.failed('Error: "' + %ToString(e) + |
| 1518 '" evaluating "' + target + '"'); | 1517 '" evaluating "' + target + '"'); |
| 1519 return; | 1518 return; |
| 1520 } | 1519 } |
| 1521 if (!IS_FUNCTION(f)) { | 1520 if (!IS_FUNCTION(f)) { |
| 1522 response.failed('"' + target + '" does not evaluate to a function'); | 1521 response.failed('"' + target + '" does not evaluate to a function'); |
| 1523 return; | 1522 return; |
| 1524 } | 1523 } |
| 1525 | 1524 |
| 1526 // Set function break point. | 1525 // Set function break point. |
| 1527 break_point_number = Debug.setBreakPoint(f, line, column, condition); | 1526 break_point_number = Debug.setBreakPoint(f, line, column, condition); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 | 1595 |
| 1597 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function( | 1596 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function( |
| 1598 request, response) { | 1597 request, response) { |
| 1599 // Check for legal request. | 1598 // Check for legal request. |
| 1600 if (!request.arguments) { | 1599 if (!request.arguments) { |
| 1601 response.failed('Missing arguments'); | 1600 response.failed('Missing arguments'); |
| 1602 return; | 1601 return; |
| 1603 } | 1602 } |
| 1604 | 1603 |
| 1605 // Pull out arguments. | 1604 // Pull out arguments. |
| 1606 var break_point = builtins.$toNumber(request.arguments.breakpoint); | 1605 var break_point = %ToNumber(request.arguments.breakpoint); |
| 1607 var enabled = request.arguments.enabled; | 1606 var enabled = request.arguments.enabled; |
| 1608 var condition = request.arguments.condition; | 1607 var condition = request.arguments.condition; |
| 1609 var ignoreCount = request.arguments.ignoreCount; | 1608 var ignoreCount = request.arguments.ignoreCount; |
| 1610 | 1609 |
| 1611 // Check for legal arguments. | 1610 // Check for legal arguments. |
| 1612 if (!break_point) { | 1611 if (!break_point) { |
| 1613 response.failed('Missing argument "breakpoint"'); | 1612 response.failed('Missing argument "breakpoint"'); |
| 1614 return; | 1613 return; |
| 1615 } | 1614 } |
| 1616 | 1615 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 | 1671 |
| 1673 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function( | 1672 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function( |
| 1674 request, response) { | 1673 request, response) { |
| 1675 // Check for legal request. | 1674 // Check for legal request. |
| 1676 if (!request.arguments) { | 1675 if (!request.arguments) { |
| 1677 response.failed('Missing arguments'); | 1676 response.failed('Missing arguments'); |
| 1678 return; | 1677 return; |
| 1679 } | 1678 } |
| 1680 | 1679 |
| 1681 // Pull out arguments. | 1680 // Pull out arguments. |
| 1682 var break_point = builtins.$toNumber(request.arguments.breakpoint); | 1681 var break_point = %ToNumber(request.arguments.breakpoint); |
| 1683 | 1682 |
| 1684 // Check for legal arguments. | 1683 // Check for legal arguments. |
| 1685 if (!break_point) { | 1684 if (!break_point) { |
| 1686 response.failed('Missing argument "breakpoint"'); | 1685 response.failed('Missing argument "breakpoint"'); |
| 1687 return; | 1686 return; |
| 1688 } | 1687 } |
| 1689 | 1688 |
| 1690 // Clear break point. | 1689 // Clear break point. |
| 1691 Debug.clearBreakPoint(break_point); | 1690 Debug.clearBreakPoint(break_point); |
| 1692 | 1691 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 }; | 1928 }; |
| 1930 | 1929 |
| 1931 | 1930 |
| 1932 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { | 1931 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { |
| 1933 // Get the frame or function for which the scope is requested. | 1932 // Get the frame or function for which the scope is requested. |
| 1934 var scope_holder = this.resolveScopeHolder_(request.arguments); | 1933 var scope_holder = this.resolveScopeHolder_(request.arguments); |
| 1935 | 1934 |
| 1936 // With no scope argument just return top scope. | 1935 // With no scope argument just return top scope. |
| 1937 var scope_index = 0; | 1936 var scope_index = 0; |
| 1938 if (request.arguments && !IS_UNDEFINED(request.arguments.number)) { | 1937 if (request.arguments && !IS_UNDEFINED(request.arguments.number)) { |
| 1939 scope_index = builtins.$toNumber(request.arguments.number); | 1938 scope_index = %ToNumber(request.arguments.number); |
| 1940 if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) { | 1939 if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) { |
| 1941 return response.failed('Invalid scope number'); | 1940 return response.failed('Invalid scope number'); |
| 1942 } | 1941 } |
| 1943 } | 1942 } |
| 1944 | 1943 |
| 1945 response.body = scope_holder.scope(scope_index); | 1944 response.body = scope_holder.scope(scope_index); |
| 1946 }; | 1945 }; |
| 1947 | 1946 |
| 1948 | 1947 |
| 1949 // Reads value from protocol description. Description may be in form of type | 1948 // Reads value from protocol description. Description may be in form of type |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 var variable_name = request.arguments.name; | 1992 var variable_name = request.arguments.name; |
| 1994 | 1993 |
| 1995 var scope_description = request.arguments.scope; | 1994 var scope_description = request.arguments.scope; |
| 1996 | 1995 |
| 1997 // Get the frame or function for which the scope is requested. | 1996 // Get the frame or function for which the scope is requested. |
| 1998 var scope_holder = this.resolveScopeHolder_(scope_description); | 1997 var scope_holder = this.resolveScopeHolder_(scope_description); |
| 1999 | 1998 |
| 2000 if (IS_UNDEFINED(scope_description.number)) { | 1999 if (IS_UNDEFINED(scope_description.number)) { |
| 2001 response.failed('Missing scope number'); | 2000 response.failed('Missing scope number'); |
| 2002 } | 2001 } |
| 2003 var scope_index = builtins.$toNumber(scope_description.number); | 2002 var scope_index = %ToNumber(scope_description.number); |
| 2004 | 2003 |
| 2005 var scope = scope_holder.scope(scope_index); | 2004 var scope = scope_holder.scope(scope_index); |
| 2006 | 2005 |
| 2007 var new_value = | 2006 var new_value = |
| 2008 DebugCommandProcessor.resolveValue_(request.arguments.newValue); | 2007 DebugCommandProcessor.resolveValue_(request.arguments.newValue); |
| 2009 | 2008 |
| 2010 scope.setVariableValue(variable_name, new_value); | 2009 scope.setVariableValue(variable_name, new_value); |
| 2011 | 2010 |
| 2012 var new_value_mirror = MakeMirror(new_value); | 2011 var new_value_mirror = MakeMirror(new_value); |
| 2013 | 2012 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2071 disable_break = true; | 2070 disable_break = true; |
| 2072 } | 2071 } |
| 2073 | 2072 |
| 2074 // No frames no evaluate in frame. | 2073 // No frames no evaluate in frame. |
| 2075 if (this.exec_state_.frameCount() == 0) { | 2074 if (this.exec_state_.frameCount() == 0) { |
| 2076 return response.failed('No frames'); | 2075 return response.failed('No frames'); |
| 2077 } | 2076 } |
| 2078 | 2077 |
| 2079 // Check whether a frame was specified. | 2078 // Check whether a frame was specified. |
| 2080 if (!IS_UNDEFINED(frame)) { | 2079 if (!IS_UNDEFINED(frame)) { |
| 2081 var frame_number = builtins.$toNumber(frame); | 2080 var frame_number = %ToNumber(frame); |
| 2082 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { | 2081 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { |
| 2083 return response.failed('Invalid frame "' + frame + '"'); | 2082 return response.failed('Invalid frame "' + frame + '"'); |
| 2084 } | 2083 } |
| 2085 // Evaluate in the specified frame. | 2084 // Evaluate in the specified frame. |
| 2086 response.body = this.exec_state_.frame(frame_number).evaluate( | 2085 response.body = this.exec_state_.frame(frame_number).evaluate( |
| 2087 expression, Boolean(disable_break), additional_context_object); | 2086 expression, Boolean(disable_break), additional_context_object); |
| 2088 return; | 2087 return; |
| 2089 } else { | 2088 } else { |
| 2090 // Evaluate in the selected frame. | 2089 // Evaluate in the selected frame. |
| 2091 response.body = this.exec_state_.frame().evaluate( | 2090 response.body = this.exec_state_.frame().evaluate( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2103 // Pull out arguments. | 2102 // Pull out arguments. |
| 2104 var handles = request.arguments.handles; | 2103 var handles = request.arguments.handles; |
| 2105 | 2104 |
| 2106 // Check for legal arguments. | 2105 // Check for legal arguments. |
| 2107 if (IS_UNDEFINED(handles)) { | 2106 if (IS_UNDEFINED(handles)) { |
| 2108 return response.failed('Argument "handles" missing'); | 2107 return response.failed('Argument "handles" missing'); |
| 2109 } | 2108 } |
| 2110 | 2109 |
| 2111 // Set 'includeSource' option for script lookup. | 2110 // Set 'includeSource' option for script lookup. |
| 2112 if (!IS_UNDEFINED(request.arguments.includeSource)) { | 2111 if (!IS_UNDEFINED(request.arguments.includeSource)) { |
| 2113 var includeSource = builtins.$toBoolean(request.arguments.includeSource); | 2112 var includeSource = %ToBoolean(request.arguments.includeSource); |
| 2114 response.setOption('includeSource', includeSource); | 2113 response.setOption('includeSource', includeSource); |
| 2115 } | 2114 } |
| 2116 | 2115 |
| 2117 // Lookup handles. | 2116 // Lookup handles. |
| 2118 var mirrors = {}; | 2117 var mirrors = {}; |
| 2119 for (var i = 0; i < handles.length; i++) { | 2118 for (var i = 0; i < handles.length; i++) { |
| 2120 var handle = handles[i]; | 2119 var handle = handles[i]; |
| 2121 var mirror = LookupMirror(handle); | 2120 var mirror = LookupMirror(handle); |
| 2122 if (!mirror) { | 2121 if (!mirror) { |
| 2123 return response.failed('Object #' + handle + '# not found'); | 2122 return response.failed('Object #' + handle + '# not found'); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 | 2170 |
| 2172 var from_line; | 2171 var from_line; |
| 2173 var to_line; | 2172 var to_line; |
| 2174 var frame = this.exec_state_.frame(); | 2173 var frame = this.exec_state_.frame(); |
| 2175 if (request.arguments) { | 2174 if (request.arguments) { |
| 2176 // Pull out arguments. | 2175 // Pull out arguments. |
| 2177 from_line = request.arguments.fromLine; | 2176 from_line = request.arguments.fromLine; |
| 2178 to_line = request.arguments.toLine; | 2177 to_line = request.arguments.toLine; |
| 2179 | 2178 |
| 2180 if (!IS_UNDEFINED(request.arguments.frame)) { | 2179 if (!IS_UNDEFINED(request.arguments.frame)) { |
| 2181 var frame_number = builtins.$toNumber(request.arguments.frame); | 2180 var frame_number = %ToNumber(request.arguments.frame); |
| 2182 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { | 2181 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { |
| 2183 return response.failed('Invalid frame "' + frame + '"'); | 2182 return response.failed('Invalid frame "' + frame + '"'); |
| 2184 } | 2183 } |
| 2185 frame = this.exec_state_.frame(frame_number); | 2184 frame = this.exec_state_.frame(frame_number); |
| 2186 } | 2185 } |
| 2187 } | 2186 } |
| 2188 | 2187 |
| 2189 // Get the script selected. | 2188 // Get the script selected. |
| 2190 var script = frame.func().script(); | 2189 var script = frame.func().script(); |
| 2191 if (!script) { | 2190 if (!script) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2207 }; | 2206 }; |
| 2208 | 2207 |
| 2209 | 2208 |
| 2210 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { | 2209 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { |
| 2211 var types = ScriptTypeFlag(Debug.ScriptType.Normal); | 2210 var types = ScriptTypeFlag(Debug.ScriptType.Normal); |
| 2212 var includeSource = false; | 2211 var includeSource = false; |
| 2213 var idsToInclude = null; | 2212 var idsToInclude = null; |
| 2214 if (request.arguments) { | 2213 if (request.arguments) { |
| 2215 // Pull out arguments. | 2214 // Pull out arguments. |
| 2216 if (!IS_UNDEFINED(request.arguments.types)) { | 2215 if (!IS_UNDEFINED(request.arguments.types)) { |
| 2217 types = builtins.$toNumber(request.arguments.types); | 2216 types = %ToNumber(request.arguments.types); |
| 2218 if (isNaN(types) || types < 0) { | 2217 if (isNaN(types) || types < 0) { |
| 2219 return response.failed('Invalid types "' + | 2218 return response.failed('Invalid types "' + |
| 2220 request.arguments.types + '"'); | 2219 request.arguments.types + '"'); |
| 2221 } | 2220 } |
| 2222 } | 2221 } |
| 2223 | 2222 |
| 2224 if (!IS_UNDEFINED(request.arguments.includeSource)) { | 2223 if (!IS_UNDEFINED(request.arguments.includeSource)) { |
| 2225 includeSource = builtins.$toBoolean(request.arguments.includeSource); | 2224 includeSource = %ToBoolean(request.arguments.includeSource); |
| 2226 response.setOption('includeSource', includeSource); | 2225 response.setOption('includeSource', includeSource); |
| 2227 } | 2226 } |
| 2228 | 2227 |
| 2229 if (IS_ARRAY(request.arguments.ids)) { | 2228 if (IS_ARRAY(request.arguments.ids)) { |
| 2230 idsToInclude = {}; | 2229 idsToInclude = {}; |
| 2231 var ids = request.arguments.ids; | 2230 var ids = request.arguments.ids; |
| 2232 for (var i = 0; i < ids.length; i++) { | 2231 for (var i = 0; i < ids.length; i++) { |
| 2233 idsToInclude[ids[i]] = true; | 2232 idsToInclude[ids[i]] = true; |
| 2234 } | 2233 } |
| 2235 } | 2234 } |
| 2236 | 2235 |
| 2237 var filterStr = null; | 2236 var filterStr = null; |
| 2238 var filterNum = null; | 2237 var filterNum = null; |
| 2239 if (!IS_UNDEFINED(request.arguments.filter)) { | 2238 if (!IS_UNDEFINED(request.arguments.filter)) { |
| 2240 var num = builtins.$toNumber(request.arguments.filter); | 2239 var num = %ToNumber(request.arguments.filter); |
| 2241 if (!isNaN(num)) { | 2240 if (!isNaN(num)) { |
| 2242 filterNum = num; | 2241 filterNum = num; |
| 2243 } | 2242 } |
| 2244 filterStr = request.arguments.filter; | 2243 filterStr = request.arguments.filter; |
| 2245 } | 2244 } |
| 2246 } | 2245 } |
| 2247 | 2246 |
| 2248 // Collect all scripts in the heap. | 2247 // Collect all scripts in the heap. |
| 2249 var scripts = %DebugGetLoadedScripts(); | 2248 var scripts = %DebugGetLoadedScripts(); |
| 2250 | 2249 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 var frame = request.arguments.frame; | 2365 var frame = request.arguments.frame; |
| 2367 | 2366 |
| 2368 // No frames to evaluate in frame. | 2367 // No frames to evaluate in frame. |
| 2369 if (this.exec_state_.frameCount() == 0) { | 2368 if (this.exec_state_.frameCount() == 0) { |
| 2370 return response.failed('No frames'); | 2369 return response.failed('No frames'); |
| 2371 } | 2370 } |
| 2372 | 2371 |
| 2373 var frame_mirror; | 2372 var frame_mirror; |
| 2374 // Check whether a frame was specified. | 2373 // Check whether a frame was specified. |
| 2375 if (!IS_UNDEFINED(frame)) { | 2374 if (!IS_UNDEFINED(frame)) { |
| 2376 var frame_number = builtins.$toNumber(frame); | 2375 var frame_number = %ToNumber(frame); |
| 2377 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { | 2376 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { |
| 2378 return response.failed('Invalid frame "' + frame + '"'); | 2377 return response.failed('Invalid frame "' + frame + '"'); |
| 2379 } | 2378 } |
| 2380 // Restart specified frame. | 2379 // Restart specified frame. |
| 2381 frame_mirror = this.exec_state_.frame(frame_number); | 2380 frame_mirror = this.exec_state_.frame(frame_number); |
| 2382 } else { | 2381 } else { |
| 2383 // Restart selected frame. | 2382 // Restart selected frame. |
| 2384 frame_mirror = this.exec_state_.frame(); | 2383 frame_mirror = this.exec_state_.frame(); |
| 2385 } | 2384 } |
| 2386 | 2385 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 case 'string': | 2559 case 'string': |
| 2561 case 'number': | 2560 case 'number': |
| 2562 json = value; | 2561 json = value; |
| 2563 break; | 2562 break; |
| 2564 | 2563 |
| 2565 default: | 2564 default: |
| 2566 json = null; | 2565 json = null; |
| 2567 } | 2566 } |
| 2568 return json; | 2567 return json; |
| 2569 } | 2568 } |
| OLD | NEW |