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

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

Issue 1302533002: Native context: debug.js does not load from js builtins object anymore. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: make importing requirement more explicit Created 5 years, 4 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
« no previous file with comments | « src/date.js ('k') | src/debug/mirrors.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 (function (global, utils) { 5 (function (global, utils) {
6 "use strict"; 6 "use strict";
7 7
8 // ---------------------------------------------------------------------------- 8 // ----------------------------------------------------------------------------
9 // Imports 9 // Imports
10 10
11 var FrameMirror = global.FrameMirror; 11 var FrameMirror = global.FrameMirror;
12 var GlobalArray = global.Array; 12 var GlobalArray = global.Array;
13 var GlobalRegExp = global.RegExp; 13 var GlobalRegExp = global.RegExp;
14 var IsNaN = global.isNaN; 14 var IsNaN = global.isNaN;
15 var JSONParse = global.JSON.parse; 15 var JSONParse = global.JSON.parse;
16 var JSONStringify = global.JSON.stringify; 16 var JSONStringify = global.JSON.stringify;
17 var LookupMirror = global.LookupMirror; 17 var LookupMirror = global.LookupMirror;
18 var MakeMirror = global.MakeMirror; 18 var MakeMirror = global.MakeMirror;
19 var MakeMirrorSerializer = global.MakeMirrorSerializer; 19 var MakeMirrorSerializer = global.MakeMirrorSerializer;
20 var MathMin = global.Math.min; 20 var MathMin = global.Math.min;
21 var Mirror = global.Mirror; 21 var Mirror = global.Mirror;
22 var MirrorType; 22 var MirrorType;
23 var ParseInt = global.parseInt; 23 var ParseInt = global.parseInt;
24 var ToBoolean;
25 var ToNumber;
26 var ToString;
24 var ValueMirror = global.ValueMirror; 27 var ValueMirror = global.ValueMirror;
25 28
26 utils.Import(function(from) { 29 utils.Import(function(from) {
27 MirrorType = from.MirrorType; 30 MirrorType = from.MirrorType;
31 ToBoolean = from.ToBoolean;
32 ToNumber = from.ToNumber;
33 ToString = from.ToString;
28 }); 34 });
29 35
30 //---------------------------------------------------------------------------- 36 //----------------------------------------------------------------------------
31 37
32 // Default number of frames to include in the response to backtrace request. 38 // Default number of frames to include in the response to backtrace request.
33 var kDefaultBacktraceLength = 10; 39 var kDefaultBacktraceLength = 10;
34 40
35 var Debug = {}; 41 var Debug = {};
36 42
37 // Regular expression to skip "crud" at the beginning of a source line which is 43 // Regular expression to skip "crud" at the beginning of a source line which is
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 BreakPoint.prototype.isTriggered = function(exec_state) { 227 BreakPoint.prototype.isTriggered = function(exec_state) {
222 // Break point not active - not triggered. 228 // Break point not active - not triggered.
223 if (!this.active()) return false; 229 if (!this.active()) return false;
224 230
225 // Check for conditional break point. 231 // Check for conditional break point.
226 if (this.condition()) { 232 if (this.condition()) {
227 // If break point has condition try to evaluate it in the top frame. 233 // If break point has condition try to evaluate it in the top frame.
228 try { 234 try {
229 var mirror = exec_state.frame(0).evaluate(this.condition()); 235 var mirror = exec_state.frame(0).evaluate(this.condition());
230 // If no sensible mirror or non true value break point not triggered. 236 // If no sensible mirror or non true value break point not triggered.
231 if (!(mirror instanceof ValueMirror) || !$toBoolean(mirror.value_)) { 237 if (!(mirror instanceof ValueMirror) || !ToBoolean(mirror.value_)) {
232 return false; 238 return false;
233 } 239 }
234 } catch (e) { 240 } catch (e) {
235 // Exception evaluating condition counts as not triggered. 241 // Exception evaluating condition counts as not triggered.
236 return false; 242 return false;
237 } 243 }
238 } 244 }
239 245
240 // Update the hit count. 246 // Update the hit count.
241 this.hit_count_++; 247 this.hit_count_++;
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 943 }
938 944
939 function ExecutionState(break_id) { 945 function ExecutionState(break_id) {
940 this.break_id = break_id; 946 this.break_id = break_id;
941 this.selected_frame = 0; 947 this.selected_frame = 0;
942 } 948 }
943 949
944 ExecutionState.prototype.prepareStep = function(opt_action, opt_count, 950 ExecutionState.prototype.prepareStep = function(opt_action, opt_count,
945 opt_callframe) { 951 opt_callframe) {
946 var action = Debug.StepAction.StepIn; 952 var action = Debug.StepAction.StepIn;
947 if (!IS_UNDEFINED(opt_action)) action = $toNumber(opt_action); 953 if (!IS_UNDEFINED(opt_action)) action = ToNumber(opt_action);
948 var count = opt_count ? $toNumber(opt_count) : 1; 954 var count = opt_count ? ToNumber(opt_count) : 1;
949 var callFrameId = 0; 955 var callFrameId = 0;
950 if (!IS_UNDEFINED(opt_callframe)) { 956 if (!IS_UNDEFINED(opt_callframe)) {
951 callFrameId = opt_callframe.details_.frameId(); 957 callFrameId = opt_callframe.details_.frameId();
952 } 958 }
953 959
954 return %PrepareStep(this.break_id, action, count, callFrameId); 960 return %PrepareStep(this.break_id, action, count, callFrameId);
955 }; 961 };
956 962
957 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, 963 ExecutionState.prototype.evaluateGlobal = function(source, disable_break,
958 opt_additional_context) { 964 opt_additional_context) {
959 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source, 965 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source,
960 $toBoolean(disable_break), 966 ToBoolean(disable_break),
961 opt_additional_context)); 967 opt_additional_context));
962 }; 968 };
963 969
964 ExecutionState.prototype.frameCount = function() { 970 ExecutionState.prototype.frameCount = function() {
965 return %GetFrameCount(this.break_id); 971 return %GetFrameCount(this.break_id);
966 }; 972 };
967 973
968 ExecutionState.prototype.threadCount = function() { 974 ExecutionState.prototype.threadCount = function() {
969 return %GetThreadCount(this.break_id); 975 return %GetThreadCount(this.break_id);
970 }; 976 };
971 977
972 ExecutionState.prototype.frame = function(opt_index) { 978 ExecutionState.prototype.frame = function(opt_index) {
973 // If no index supplied return the selected frame. 979 // If no index supplied return the selected frame.
974 if (opt_index == null) opt_index = this.selected_frame; 980 if (opt_index == null) opt_index = this.selected_frame;
975 if (opt_index < 0 || opt_index >= this.frameCount()) { 981 if (opt_index < 0 || opt_index >= this.frameCount()) {
976 throw MakeTypeError(kDebuggerFrame); 982 throw MakeTypeError(kDebuggerFrame);
977 } 983 }
978 return new FrameMirror(this.break_id, opt_index); 984 return new FrameMirror(this.break_id, opt_index);
979 }; 985 };
980 986
981 ExecutionState.prototype.setSelectedFrame = function(index) { 987 ExecutionState.prototype.setSelectedFrame = function(index) {
982 var i = $toNumber(index); 988 var i = ToNumber(index);
983 if (i < 0 || i >= this.frameCount()) { 989 if (i < 0 || i >= this.frameCount()) {
984 throw MakeTypeError(kDebuggerFrame); 990 throw MakeTypeError(kDebuggerFrame);
985 } 991 }
986 this.selected_frame = i; 992 this.selected_frame = i;
987 }; 993 };
988 994
989 ExecutionState.prototype.selectedFrame = function() { 995 ExecutionState.prototype.selectedFrame = function() {
990 return this.selected_frame; 996 return this.selected_frame;
991 }; 997 };
992 998
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 } else { 1425 } else {
1420 throw MakeError(kDebugger, 1426 throw MakeError(kDebugger,
1421 'Unknown command "' + request.command + '" in request'); 1427 'Unknown command "' + request.command + '" in request');
1422 } 1428 }
1423 } catch (e) { 1429 } catch (e) {
1424 // If there is no response object created one (without command). 1430 // If there is no response object created one (without command).
1425 if (!response) { 1431 if (!response) {
1426 response = this.createResponse(); 1432 response = this.createResponse();
1427 } 1433 }
1428 response.success = false; 1434 response.success = false;
1429 response.message = $toString(e); 1435 response.message = ToString(e);
1430 } 1436 }
1431 1437
1432 // Return the response as a JSON encoded string. 1438 // Return the response as a JSON encoded string.
1433 try { 1439 try {
1434 if (!IS_UNDEFINED(response.running)) { 1440 if (!IS_UNDEFINED(response.running)) {
1435 // Response controls running state. 1441 // Response controls running state.
1436 this.running_ = response.running; 1442 this.running_ = response.running;
1437 } 1443 }
1438 response.running = this.running_; 1444 response.running = this.running_;
1439 return response.toJSONProtocol(); 1445 return response.toJSONProtocol();
1440 } catch (e) { 1446 } catch (e) {
1441 // Failed to generate response - return generic error. 1447 // Failed to generate response - return generic error.
1442 return '{"seq":' + response.seq + ',' + 1448 return '{"seq":' + response.seq + ',' +
1443 '"request_seq":' + request.seq + ',' + 1449 '"request_seq":' + request.seq + ',' +
1444 '"type":"response",' + 1450 '"type":"response",' +
1445 '"success":false,' + 1451 '"success":false,' +
1446 '"message":"Internal error: ' + $toString(e) + '"}'; 1452 '"message":"Internal error: ' + ToString(e) + '"}';
1447 } 1453 }
1448 } catch (e) { 1454 } catch (e) {
1449 // Failed in one of the catch blocks above - most generic error. 1455 // Failed in one of the catch blocks above - most generic error.
1450 return '{"seq":0,"type":"response","success":false,"message":"Internal error "}'; 1456 return '{"seq":0,"type":"response","success":false,"message":"Internal error "}';
1451 } 1457 }
1452 }; 1458 };
1453 1459
1454 1460
1455 DebugCommandProcessor.prototype.continueRequest_ = function(request, response) { 1461 DebugCommandProcessor.prototype.continueRequest_ = function(request, response) {
1456 // Check for arguments for continue. 1462 // Check for arguments for continue.
1457 if (request.arguments) { 1463 if (request.arguments) {
1458 var count = 1; 1464 var count = 1;
1459 var action = Debug.StepAction.StepIn; 1465 var action = Debug.StepAction.StepIn;
1460 1466
1461 // Pull out arguments. 1467 // Pull out arguments.
1462 var stepaction = request.arguments.stepaction; 1468 var stepaction = request.arguments.stepaction;
1463 var stepcount = request.arguments.stepcount; 1469 var stepcount = request.arguments.stepcount;
1464 1470
1465 // Get the stepcount argument if any. 1471 // Get the stepcount argument if any.
1466 if (stepcount) { 1472 if (stepcount) {
1467 count = $toNumber(stepcount); 1473 count = ToNumber(stepcount);
1468 if (count < 0) { 1474 if (count < 0) {
1469 throw MakeError(kDebugger, 1475 throw MakeError(kDebugger,
1470 'Invalid stepcount argument "' + stepcount + '".'); 1476 'Invalid stepcount argument "' + stepcount + '".');
1471 } 1477 }
1472 } 1478 }
1473 1479
1474 // Get the stepaction argument. 1480 // Get the stepaction argument.
1475 if (stepaction) { 1481 if (stepaction) {
1476 if (stepaction == 'in') { 1482 if (stepaction == 'in') {
1477 action = Debug.StepAction.StepIn; 1483 action = Debug.StepAction.StepIn;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 // Handle function break point. 1538 // Handle function break point.
1533 if (!IS_STRING(target)) { 1539 if (!IS_STRING(target)) {
1534 response.failed('Argument "target" is not a string value'); 1540 response.failed('Argument "target" is not a string value');
1535 return; 1541 return;
1536 } 1542 }
1537 var f; 1543 var f;
1538 try { 1544 try {
1539 // Find the function through a global evaluate. 1545 // Find the function through a global evaluate.
1540 f = this.exec_state_.evaluateGlobal(target).value(); 1546 f = this.exec_state_.evaluateGlobal(target).value();
1541 } catch (e) { 1547 } catch (e) {
1542 response.failed('Error: "' + $toString(e) + 1548 response.failed('Error: "' + ToString(e) +
1543 '" evaluating "' + target + '"'); 1549 '" evaluating "' + target + '"');
1544 return; 1550 return;
1545 } 1551 }
1546 if (!IS_FUNCTION(f)) { 1552 if (!IS_FUNCTION(f)) {
1547 response.failed('"' + target + '" does not evaluate to a function'); 1553 response.failed('"' + target + '" does not evaluate to a function');
1548 return; 1554 return;
1549 } 1555 }
1550 1556
1551 // Set function break point. 1557 // Set function break point.
1552 break_point_number = Debug.setBreakPoint(f, line, column, condition); 1558 break_point_number = Debug.setBreakPoint(f, line, column, condition);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 1627
1622 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function( 1628 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(
1623 request, response) { 1629 request, response) {
1624 // Check for legal request. 1630 // Check for legal request.
1625 if (!request.arguments) { 1631 if (!request.arguments) {
1626 response.failed('Missing arguments'); 1632 response.failed('Missing arguments');
1627 return; 1633 return;
1628 } 1634 }
1629 1635
1630 // Pull out arguments. 1636 // Pull out arguments.
1631 var break_point = $toNumber(request.arguments.breakpoint); 1637 var break_point = ToNumber(request.arguments.breakpoint);
1632 var enabled = request.arguments.enabled; 1638 var enabled = request.arguments.enabled;
1633 var condition = request.arguments.condition; 1639 var condition = request.arguments.condition;
1634 var ignoreCount = request.arguments.ignoreCount; 1640 var ignoreCount = request.arguments.ignoreCount;
1635 1641
1636 // Check for legal arguments. 1642 // Check for legal arguments.
1637 if (!break_point) { 1643 if (!break_point) {
1638 response.failed('Missing argument "breakpoint"'); 1644 response.failed('Missing argument "breakpoint"');
1639 return; 1645 return;
1640 } 1646 }
1641 1647
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 1703
1698 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function( 1704 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(
1699 request, response) { 1705 request, response) {
1700 // Check for legal request. 1706 // Check for legal request.
1701 if (!request.arguments) { 1707 if (!request.arguments) {
1702 response.failed('Missing arguments'); 1708 response.failed('Missing arguments');
1703 return; 1709 return;
1704 } 1710 }
1705 1711
1706 // Pull out arguments. 1712 // Pull out arguments.
1707 var break_point = $toNumber(request.arguments.breakpoint); 1713 var break_point = ToNumber(request.arguments.breakpoint);
1708 1714
1709 // Check for legal arguments. 1715 // Check for legal arguments.
1710 if (!break_point) { 1716 if (!break_point) {
1711 response.failed('Missing argument "breakpoint"'); 1717 response.failed('Missing argument "breakpoint"');
1712 return; 1718 return;
1713 } 1719 }
1714 1720
1715 // Clear break point. 1721 // Clear break point.
1716 Debug.clearBreakPoint(break_point); 1722 Debug.clearBreakPoint(break_point);
1717 1723
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 }; 1961 };
1956 1962
1957 1963
1958 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { 1964 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) {
1959 // Get the frame or function for which the scope is requested. 1965 // Get the frame or function for which the scope is requested.
1960 var scope_holder = this.resolveScopeHolder_(request.arguments); 1966 var scope_holder = this.resolveScopeHolder_(request.arguments);
1961 1967
1962 // With no scope argument just return top scope. 1968 // With no scope argument just return top scope.
1963 var scope_index = 0; 1969 var scope_index = 0;
1964 if (request.arguments && !IS_UNDEFINED(request.arguments.number)) { 1970 if (request.arguments && !IS_UNDEFINED(request.arguments.number)) {
1965 scope_index = $toNumber(request.arguments.number); 1971 scope_index = ToNumber(request.arguments.number);
1966 if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) { 1972 if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) {
1967 return response.failed('Invalid scope number'); 1973 return response.failed('Invalid scope number');
1968 } 1974 }
1969 } 1975 }
1970 1976
1971 response.body = scope_holder.scope(scope_index); 1977 response.body = scope_holder.scope(scope_index);
1972 }; 1978 };
1973 1979
1974 1980
1975 // Reads value from protocol description. Description may be in form of type 1981 // Reads value from protocol description. Description may be in form of type
1976 // (for singletons), raw value (primitive types supported in JSON), 1982 // (for singletons), raw value (primitive types supported in JSON),
1977 // string value description plus type (for primitive values) or handle id. 1983 // string value description plus type (for primitive values) or handle id.
1978 // Returns raw value or throws exception. 1984 // Returns raw value or throws exception.
1979 DebugCommandProcessor.resolveValue_ = function(value_description) { 1985 DebugCommandProcessor.resolveValue_ = function(value_description) {
1980 if ("handle" in value_description) { 1986 if ("handle" in value_description) {
1981 var value_mirror = LookupMirror(value_description.handle); 1987 var value_mirror = LookupMirror(value_description.handle);
1982 if (!value_mirror) { 1988 if (!value_mirror) {
1983 throw MakeError(kDebugger, "Failed to resolve value by handle, ' #" + 1989 throw MakeError(kDebugger, "Failed to resolve value by handle, ' #" +
1984 value_description.handle + "# not found"); 1990 value_description.handle + "# not found");
1985 } 1991 }
1986 return value_mirror.value(); 1992 return value_mirror.value();
1987 } else if ("stringDescription" in value_description) { 1993 } else if ("stringDescription" in value_description) {
1988 if (value_description.type == MirrorType.BOOLEAN_TYPE) { 1994 if (value_description.type == MirrorType.BOOLEAN_TYPE) {
1989 return $toBoolean(value_description.stringDescription); 1995 return ToBoolean(value_description.stringDescription);
1990 } else if (value_description.type == MirrorType.NUMBER_TYPE) { 1996 } else if (value_description.type == MirrorType.NUMBER_TYPE) {
1991 return $toNumber(value_description.stringDescription); 1997 return ToNumber(value_description.stringDescription);
1992 } if (value_description.type == MirrorType.STRING_TYPE) { 1998 } if (value_description.type == MirrorType.STRING_TYPE) {
1993 return $toString(value_description.stringDescription); 1999 return ToString(value_description.stringDescription);
1994 } else { 2000 } else {
1995 throw MakeError(kDebugger, "Unknown type"); 2001 throw MakeError(kDebugger, "Unknown type");
1996 } 2002 }
1997 } else if ("value" in value_description) { 2003 } else if ("value" in value_description) {
1998 return value_description.value; 2004 return value_description.value;
1999 } else if (value_description.type == MirrorType.UNDEFINED_TYPE) { 2005 } else if (value_description.type == MirrorType.UNDEFINED_TYPE) {
2000 return UNDEFINED; 2006 return UNDEFINED;
2001 } else if (value_description.type == MirrorType.NULL_TYPE) { 2007 } else if (value_description.type == MirrorType.NULL_TYPE) {
2002 return null; 2008 return null;
2003 } else { 2009 } else {
(...skipping 15 matching lines...) Expand all
2019 var variable_name = request.arguments.name; 2025 var variable_name = request.arguments.name;
2020 2026
2021 var scope_description = request.arguments.scope; 2027 var scope_description = request.arguments.scope;
2022 2028
2023 // Get the frame or function for which the scope is requested. 2029 // Get the frame or function for which the scope is requested.
2024 var scope_holder = this.resolveScopeHolder_(scope_description); 2030 var scope_holder = this.resolveScopeHolder_(scope_description);
2025 2031
2026 if (IS_UNDEFINED(scope_description.number)) { 2032 if (IS_UNDEFINED(scope_description.number)) {
2027 response.failed('Missing scope number'); 2033 response.failed('Missing scope number');
2028 } 2034 }
2029 var scope_index = $toNumber(scope_description.number); 2035 var scope_index = ToNumber(scope_description.number);
2030 2036
2031 var scope = scope_holder.scope(scope_index); 2037 var scope = scope_holder.scope(scope_index);
2032 2038
2033 var new_value = 2039 var new_value =
2034 DebugCommandProcessor.resolveValue_(request.arguments.newValue); 2040 DebugCommandProcessor.resolveValue_(request.arguments.newValue);
2035 2041
2036 scope.setVariableValue(variable_name, new_value); 2042 scope.setVariableValue(variable_name, new_value);
2037 2043
2038 var new_value_mirror = MakeMirror(new_value); 2044 var new_value_mirror = MakeMirror(new_value);
2039 2045
(...skipping 11 matching lines...) Expand all
2051 // Pull out arguments. 2057 // Pull out arguments.
2052 var expression = request.arguments.expression; 2058 var expression = request.arguments.expression;
2053 var frame = request.arguments.frame; 2059 var frame = request.arguments.frame;
2054 var global = request.arguments.global; 2060 var global = request.arguments.global;
2055 var disable_break = request.arguments.disable_break; 2061 var disable_break = request.arguments.disable_break;
2056 var additional_context = request.arguments.additional_context; 2062 var additional_context = request.arguments.additional_context;
2057 2063
2058 // The expression argument could be an integer so we convert it to a 2064 // The expression argument could be an integer so we convert it to a
2059 // string. 2065 // string.
2060 try { 2066 try {
2061 expression = $toString(expression); 2067 expression = ToString(expression);
2062 } catch(e) { 2068 } catch(e) {
2063 return response.failed('Failed to convert expression argument to string'); 2069 return response.failed('Failed to convert expression argument to string');
2064 } 2070 }
2065 2071
2066 // Check for legal arguments. 2072 // Check for legal arguments.
2067 if (!IS_UNDEFINED(frame) && global) { 2073 if (!IS_UNDEFINED(frame) && global) {
2068 return response.failed('Arguments "frame" and "global" are exclusive'); 2074 return response.failed('Arguments "frame" and "global" are exclusive');
2069 } 2075 }
2070 2076
2071 var additional_context_object; 2077 var additional_context_object;
2072 if (additional_context) { 2078 if (additional_context) {
2073 additional_context_object = {}; 2079 additional_context_object = {};
2074 for (var i = 0; i < additional_context.length; i++) { 2080 for (var i = 0; i < additional_context.length; i++) {
2075 var mapping = additional_context[i]; 2081 var mapping = additional_context[i];
2076 2082
2077 if (!IS_STRING(mapping.name)) { 2083 if (!IS_STRING(mapping.name)) {
2078 return response.failed("Context element #" + i + 2084 return response.failed("Context element #" + i +
2079 " doesn't contain name:string property"); 2085 " doesn't contain name:string property");
2080 } 2086 }
2081 2087
2082 var raw_value = DebugCommandProcessor.resolveValue_(mapping); 2088 var raw_value = DebugCommandProcessor.resolveValue_(mapping);
2083 additional_context_object[mapping.name] = raw_value; 2089 additional_context_object[mapping.name] = raw_value;
2084 } 2090 }
2085 } 2091 }
2086 2092
2087 // Global evaluate. 2093 // Global evaluate.
2088 if (global) { 2094 if (global) {
2089 // Evaluate in the native context. 2095 // Evaluate in the native context.
2090 response.body = this.exec_state_.evaluateGlobal( 2096 response.body = this.exec_state_.evaluateGlobal(
2091 expression, $toBoolean(disable_break), additional_context_object); 2097 expression, ToBoolean(disable_break), additional_context_object);
2092 return; 2098 return;
2093 } 2099 }
2094 2100
2095 // Default value for disable_break is true. 2101 // Default value for disable_break is true.
2096 if (IS_UNDEFINED(disable_break)) { 2102 if (IS_UNDEFINED(disable_break)) {
2097 disable_break = true; 2103 disable_break = true;
2098 } 2104 }
2099 2105
2100 // No frames no evaluate in frame. 2106 // No frames no evaluate in frame.
2101 if (this.exec_state_.frameCount() == 0) { 2107 if (this.exec_state_.frameCount() == 0) {
2102 return response.failed('No frames'); 2108 return response.failed('No frames');
2103 } 2109 }
2104 2110
2105 // Check whether a frame was specified. 2111 // Check whether a frame was specified.
2106 if (!IS_UNDEFINED(frame)) { 2112 if (!IS_UNDEFINED(frame)) {
2107 var frame_number = $toNumber(frame); 2113 var frame_number = ToNumber(frame);
2108 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { 2114 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
2109 return response.failed('Invalid frame "' + frame + '"'); 2115 return response.failed('Invalid frame "' + frame + '"');
2110 } 2116 }
2111 // Evaluate in the specified frame. 2117 // Evaluate in the specified frame.
2112 response.body = this.exec_state_.frame(frame_number).evaluate( 2118 response.body = this.exec_state_.frame(frame_number).evaluate(
2113 expression, $toBoolean(disable_break), additional_context_object); 2119 expression, ToBoolean(disable_break), additional_context_object);
2114 return; 2120 return;
2115 } else { 2121 } else {
2116 // Evaluate in the selected frame. 2122 // Evaluate in the selected frame.
2117 response.body = this.exec_state_.frame().evaluate( 2123 response.body = this.exec_state_.frame().evaluate(
2118 expression, $toBoolean(disable_break), additional_context_object); 2124 expression, ToBoolean(disable_break), additional_context_object);
2119 return; 2125 return;
2120 } 2126 }
2121 }; 2127 };
2122 2128
2123 2129
2124 DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) { 2130 DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) {
2125 if (!request.arguments) { 2131 if (!request.arguments) {
2126 return response.failed('Missing arguments'); 2132 return response.failed('Missing arguments');
2127 } 2133 }
2128 2134
2129 // Pull out arguments. 2135 // Pull out arguments.
2130 var handles = request.arguments.handles; 2136 var handles = request.arguments.handles;
2131 2137
2132 // Check for legal arguments. 2138 // Check for legal arguments.
2133 if (IS_UNDEFINED(handles)) { 2139 if (IS_UNDEFINED(handles)) {
2134 return response.failed('Argument "handles" missing'); 2140 return response.failed('Argument "handles" missing');
2135 } 2141 }
2136 2142
2137 // Set 'includeSource' option for script lookup. 2143 // Set 'includeSource' option for script lookup.
2138 if (!IS_UNDEFINED(request.arguments.includeSource)) { 2144 if (!IS_UNDEFINED(request.arguments.includeSource)) {
2139 var includeSource = $toBoolean(request.arguments.includeSource); 2145 var includeSource = ToBoolean(request.arguments.includeSource);
2140 response.setOption('includeSource', includeSource); 2146 response.setOption('includeSource', includeSource);
2141 } 2147 }
2142 2148
2143 // Lookup handles. 2149 // Lookup handles.
2144 var mirrors = {}; 2150 var mirrors = {};
2145 for (var i = 0; i < handles.length; i++) { 2151 for (var i = 0; i < handles.length; i++) {
2146 var handle = handles[i]; 2152 var handle = handles[i];
2147 var mirror = LookupMirror(handle); 2153 var mirror = LookupMirror(handle);
2148 if (!mirror) { 2154 if (!mirror) {
2149 return response.failed('Object #' + handle + '# not found'); 2155 return response.failed('Object #' + handle + '# not found');
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2197 2203
2198 var from_line; 2204 var from_line;
2199 var to_line; 2205 var to_line;
2200 var frame = this.exec_state_.frame(); 2206 var frame = this.exec_state_.frame();
2201 if (request.arguments) { 2207 if (request.arguments) {
2202 // Pull out arguments. 2208 // Pull out arguments.
2203 from_line = request.arguments.fromLine; 2209 from_line = request.arguments.fromLine;
2204 to_line = request.arguments.toLine; 2210 to_line = request.arguments.toLine;
2205 2211
2206 if (!IS_UNDEFINED(request.arguments.frame)) { 2212 if (!IS_UNDEFINED(request.arguments.frame)) {
2207 var frame_number = $toNumber(request.arguments.frame); 2213 var frame_number = ToNumber(request.arguments.frame);
2208 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { 2214 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
2209 return response.failed('Invalid frame "' + frame + '"'); 2215 return response.failed('Invalid frame "' + frame + '"');
2210 } 2216 }
2211 frame = this.exec_state_.frame(frame_number); 2217 frame = this.exec_state_.frame(frame_number);
2212 } 2218 }
2213 } 2219 }
2214 2220
2215 // Get the script selected. 2221 // Get the script selected.
2216 var script = frame.func().script(); 2222 var script = frame.func().script();
2217 if (!script) { 2223 if (!script) {
(...skipping 15 matching lines...) Expand all
2233 }; 2239 };
2234 2240
2235 2241
2236 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { 2242 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
2237 var types = ScriptTypeFlag(Debug.ScriptType.Normal); 2243 var types = ScriptTypeFlag(Debug.ScriptType.Normal);
2238 var includeSource = false; 2244 var includeSource = false;
2239 var idsToInclude = null; 2245 var idsToInclude = null;
2240 if (request.arguments) { 2246 if (request.arguments) {
2241 // Pull out arguments. 2247 // Pull out arguments.
2242 if (!IS_UNDEFINED(request.arguments.types)) { 2248 if (!IS_UNDEFINED(request.arguments.types)) {
2243 types = $toNumber(request.arguments.types); 2249 types = ToNumber(request.arguments.types);
2244 if (IsNaN(types) || types < 0) { 2250 if (IsNaN(types) || types < 0) {
2245 return response.failed('Invalid types "' + 2251 return response.failed('Invalid types "' +
2246 request.arguments.types + '"'); 2252 request.arguments.types + '"');
2247 } 2253 }
2248 } 2254 }
2249 2255
2250 if (!IS_UNDEFINED(request.arguments.includeSource)) { 2256 if (!IS_UNDEFINED(request.arguments.includeSource)) {
2251 includeSource = $toBoolean(request.arguments.includeSource); 2257 includeSource = ToBoolean(request.arguments.includeSource);
2252 response.setOption('includeSource', includeSource); 2258 response.setOption('includeSource', includeSource);
2253 } 2259 }
2254 2260
2255 if (IS_ARRAY(request.arguments.ids)) { 2261 if (IS_ARRAY(request.arguments.ids)) {
2256 idsToInclude = {}; 2262 idsToInclude = {};
2257 var ids = request.arguments.ids; 2263 var ids = request.arguments.ids;
2258 for (var i = 0; i < ids.length; i++) { 2264 for (var i = 0; i < ids.length; i++) {
2259 idsToInclude[ids[i]] = true; 2265 idsToInclude[ids[i]] = true;
2260 } 2266 }
2261 } 2267 }
2262 2268
2263 var filterStr = null; 2269 var filterStr = null;
2264 var filterNum = null; 2270 var filterNum = null;
2265 if (!IS_UNDEFINED(request.arguments.filter)) { 2271 if (!IS_UNDEFINED(request.arguments.filter)) {
2266 var num = $toNumber(request.arguments.filter); 2272 var num = ToNumber(request.arguments.filter);
2267 if (!IsNaN(num)) { 2273 if (!IsNaN(num)) {
2268 filterNum = num; 2274 filterNum = num;
2269 } 2275 }
2270 filterStr = request.arguments.filter; 2276 filterStr = request.arguments.filter;
2271 } 2277 }
2272 } 2278 }
2273 2279
2274 // Collect all scripts in the heap. 2280 // Collect all scripts in the heap.
2275 var scripts = %DebugGetLoadedScripts(); 2281 var scripts = %DebugGetLoadedScripts();
2276 2282
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 var frame = request.arguments.frame; 2398 var frame = request.arguments.frame;
2393 2399
2394 // No frames to evaluate in frame. 2400 // No frames to evaluate in frame.
2395 if (this.exec_state_.frameCount() == 0) { 2401 if (this.exec_state_.frameCount() == 0) {
2396 return response.failed('No frames'); 2402 return response.failed('No frames');
2397 } 2403 }
2398 2404
2399 var frame_mirror; 2405 var frame_mirror;
2400 // Check whether a frame was specified. 2406 // Check whether a frame was specified.
2401 if (!IS_UNDEFINED(frame)) { 2407 if (!IS_UNDEFINED(frame)) {
2402 var frame_number = $toNumber(frame); 2408 var frame_number = ToNumber(frame);
2403 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { 2409 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
2404 return response.failed('Invalid frame "' + frame + '"'); 2410 return response.failed('Invalid frame "' + frame + '"');
2405 } 2411 }
2406 // Restart specified frame. 2412 // Restart specified frame.
2407 frame_mirror = this.exec_state_.frame(frame_number); 2413 frame_mirror = this.exec_state_.frame(frame_number);
2408 } else { 2414 } else {
2409 // Restart selected frame. 2415 // Restart selected frame.
2410 frame_mirror = this.exec_state_.frame(); 2416 frame_mirror = this.exec_state_.frame();
2411 } 2417 }
2412 2418
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 "IsBreakPointTriggered", IsBreakPointTriggered, 2620 "IsBreakPointTriggered", IsBreakPointTriggered,
2615 "UpdateScriptBreakPoints", UpdateScriptBreakPoints, 2621 "UpdateScriptBreakPoints", UpdateScriptBreakPoints,
2616 ]); 2622 ]);
2617 2623
2618 // Export to liveedit.js 2624 // Export to liveedit.js
2619 utils.Export(function(to) { 2625 utils.Export(function(to) {
2620 to.GetScriptBreakPoints = GetScriptBreakPoints; 2626 to.GetScriptBreakPoints = GetScriptBreakPoints;
2621 }); 2627 });
2622 2628
2623 }) 2629 })
OLDNEW
« no previous file with comments | « src/date.js ('k') | src/debug/mirrors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698