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

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

Issue 1282793002: Debugger: load debugger builtins as normal native JS. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use InstallFunctions and InstallConstants 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/debug/debug.cc ('k') | src/debug/debug-evaluate.cc » ('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
5 (function (global, utils) {
4 "use strict"; 6 "use strict";
5 7
8 // ----------------------------------------------------------------------------
9 // Imports
10
11 var FrameMirror = global.FrameMirror;
12 var GlobalArray = global.Array;
13 var GlobalRegExp = global.RegExp;
14 var IsNaN = global.isNaN;
15 var JSONParse = global.JSON.parse;
16 var JSONStringify = global.JSON.stringify;
17 var LookupMirror = global.LookupMirror;
18 var MakeMirror = global.MakeMirror;
19 var MakeMirrorSerializer = global.MakeMirrorSerializer;
20 var MathMin = global.Math.min;
21 var Mirror = global.Mirror;
22 var MirrorType;
23 var ParseInt = global.parseInt;
24 var ValueMirror = global.ValueMirror;
25
26 utils.Import(function(from) {
27 MirrorType = from.MirrorType;
28 });
29
30 //----------------------------------------------------------------------------
31
6 // Default number of frames to include in the response to backtrace request. 32 // Default number of frames to include in the response to backtrace request.
7 var kDefaultBacktraceLength = 10; 33 var kDefaultBacktraceLength = 10;
8 34
9 var Debug = {}; 35 var Debug = {};
10 36
11 // Regular expression to skip "crud" at the beginning of a source line which is 37 // Regular expression to skip "crud" at the beginning of a source line which is
12 // not really code. Currently the regular expression matches whitespace and 38 // not really code. Currently the regular expression matches whitespace and
13 // comments. 39 // comments.
14 var sourceLineBeginningSkip = /^(?:\s*(?:\/\*.*?\*\/)*)*/; 40 var sourceLineBeginningSkip = /^(?:\s*(?:\/\*.*?\*\/)*)*/;
15 41
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 BreakPoint.prototype.isTriggered = function(exec_state) { 221 BreakPoint.prototype.isTriggered = function(exec_state) {
196 // Break point not active - not triggered. 222 // Break point not active - not triggered.
197 if (!this.active()) return false; 223 if (!this.active()) return false;
198 224
199 // Check for conditional break point. 225 // Check for conditional break point.
200 if (this.condition()) { 226 if (this.condition()) {
201 // If break point has condition try to evaluate it in the top frame. 227 // If break point has condition try to evaluate it in the top frame.
202 try { 228 try {
203 var mirror = exec_state.frame(0).evaluate(this.condition()); 229 var mirror = exec_state.frame(0).evaluate(this.condition());
204 // If no sensible mirror or non true value break point not triggered. 230 // If no sensible mirror or non true value break point not triggered.
205 if (!(mirror instanceof ValueMirror) || 231 if (!(mirror instanceof ValueMirror) || !$toBoolean(mirror.value_)) {
206 !builtins.$toBoolean(mirror.value_)) {
207 return false; 232 return false;
208 } 233 }
209 } catch (e) { 234 } catch (e) {
210 // Exception evaluating condition counts as not triggered. 235 // Exception evaluating condition counts as not triggered.
211 return false; 236 return false;
212 } 237 }
213 } 238 }
214 239
215 // Update the hit count. 240 // Update the hit count.
216 this.hit_count_++; 241 this.hit_count_++;
(...skipping 23 matching lines...) Expand all
240 // script name or script id and the break point is represented as line and 265 // script name or script id and the break point is represented as line and
241 // column. 266 // column.
242 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, 267 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
243 opt_groupId, opt_position_alignment) { 268 opt_groupId, opt_position_alignment) {
244 this.type_ = type; 269 this.type_ = type;
245 if (type == Debug.ScriptBreakPointType.ScriptId) { 270 if (type == Debug.ScriptBreakPointType.ScriptId) {
246 this.script_id_ = script_id_or_name; 271 this.script_id_ = script_id_or_name;
247 } else if (type == Debug.ScriptBreakPointType.ScriptName) { 272 } else if (type == Debug.ScriptBreakPointType.ScriptName) {
248 this.script_name_ = script_id_or_name; 273 this.script_name_ = script_id_or_name;
249 } else if (type == Debug.ScriptBreakPointType.ScriptRegExp) { 274 } else if (type == Debug.ScriptBreakPointType.ScriptRegExp) {
250 this.script_regexp_object_ = new RegExp(script_id_or_name); 275 this.script_regexp_object_ = new GlobalRegExp(script_id_or_name);
251 } else { 276 } else {
252 throw new Error("Unexpected breakpoint type " + type); 277 throw MakeError(kDebugger, "Unexpected breakpoint type " + type);
253 } 278 }
254 this.line_ = opt_line || 0; 279 this.line_ = opt_line || 0;
255 this.column_ = opt_column; 280 this.column_ = opt_column;
256 this.groupId_ = opt_groupId; 281 this.groupId_ = opt_groupId;
257 this.position_alignment_ = IS_UNDEFINED(opt_position_alignment) 282 this.position_alignment_ = IS_UNDEFINED(opt_position_alignment)
258 ? Debug.BreakPositionAlignment.Statement : opt_position_alignment; 283 ? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
259 this.hit_count_ = 0; 284 this.hit_count_ = 0;
260 this.active_ = true; 285 this.active_ = true;
261 this.condition_ = null; 286 this.condition_ = null;
262 this.ignoreCount_ = 0; 287 this.ignoreCount_ = 0;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // We might want to account columns here as well. 414 // We might want to account columns here as well.
390 if (!(script.line_offset <= this.line_ && 415 if (!(script.line_offset <= this.line_ &&
391 this.line_ < script.line_offset + script.lineCount())) { 416 this.line_ < script.line_offset + script.lineCount())) {
392 return false; 417 return false;
393 } 418 }
394 if (this.type_ == Debug.ScriptBreakPointType.ScriptName) { 419 if (this.type_ == Debug.ScriptBreakPointType.ScriptName) {
395 return this.script_name_ == script.nameOrSourceURL(); 420 return this.script_name_ == script.nameOrSourceURL();
396 } else if (this.type_ == Debug.ScriptBreakPointType.ScriptRegExp) { 421 } else if (this.type_ == Debug.ScriptBreakPointType.ScriptRegExp) {
397 return this.script_regexp_object_.test(script.nameOrSourceURL()); 422 return this.script_regexp_object_.test(script.nameOrSourceURL());
398 } else { 423 } else {
399 throw new Error("Unexpected breakpoint type " + this.type_); 424 throw MakeError(kDebugger, "Unexpected breakpoint type " + this.type_);
400 } 425 }
401 } 426 }
402 }; 427 };
403 428
404 429
405 // Set the script break point in a script. 430 // Set the script break point in a script.
406 ScriptBreakPoint.prototype.set = function (script) { 431 ScriptBreakPoint.prototype.set = function (script) {
407 var column = this.column(); 432 var column = this.column();
408 var line = this.line(); 433 var line = this.line();
409 // If the column is undefined the break is on the line. To help locate the 434 // If the column is undefined the break is on the line. To help locate the
410 // first piece of breakable code on the line try to find the column on the 435 // first piece of breakable code on the line try to find the column on the
411 // line which contains some source. 436 // line which contains some source.
412 if (IS_UNDEFINED(column)) { 437 if (IS_UNDEFINED(column)) {
413 var source_line = script.sourceLine(this.line()); 438 var source_line = script.sourceLine(this.line());
414 439
415 // Allocate array for caching the columns where the actual source starts. 440 // Allocate array for caching the columns where the actual source starts.
416 if (!script.sourceColumnStart_) { 441 if (!script.sourceColumnStart_) {
417 script.sourceColumnStart_ = new Array(script.lineCount()); 442 script.sourceColumnStart_ = new GlobalArray(script.lineCount());
418 } 443 }
419 444
420 // Fill cache if needed and get column where the actual source starts. 445 // Fill cache if needed and get column where the actual source starts.
421 if (IS_UNDEFINED(script.sourceColumnStart_[line])) { 446 if (IS_UNDEFINED(script.sourceColumnStart_[line])) {
422 script.sourceColumnStart_[line] = 447 script.sourceColumnStart_[line] =
423 source_line.match(sourceLineBeginningSkip)[0].length; 448 source_line.match(sourceLineBeginningSkip)[0].length;
424 } 449 }
425 column = script.sourceColumnStart_[line]; 450 column = script.sourceColumnStart_[line];
426 } 451 }
427 452
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 if (script_break_points[i].matchesScript(script)) { 511 if (script_break_points[i].matchesScript(script)) {
487 result.push(script_break_points[i]); 512 result.push(script_break_points[i]);
488 } 513 }
489 } 514 }
490 return result; 515 return result;
491 } 516 }
492 517
493 518
494 Debug.setListener = function(listener, opt_data) { 519 Debug.setListener = function(listener, opt_data) {
495 if (!IS_FUNCTION(listener) && !IS_UNDEFINED(listener) && !IS_NULL(listener)) { 520 if (!IS_FUNCTION(listener) && !IS_UNDEFINED(listener) && !IS_NULL(listener)) {
496 throw new Error('Parameters have wrong types.'); 521 throw MakeTypeError(kDebuggerType);
497 } 522 }
498 %SetDebugEventListener(listener, opt_data); 523 %SetDebugEventListener(listener, opt_data);
499 }; 524 };
500 525
501 526
502 Debug.breakLocations = function(f, opt_position_aligment) { 527 Debug.breakLocations = function(f, opt_position_aligment) {
503 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); 528 if (!IS_FUNCTION(f)) throw MakeTypeError(kDebuggerType);
504 var position_aligment = IS_UNDEFINED(opt_position_aligment) 529 var position_aligment = IS_UNDEFINED(opt_position_aligment)
505 ? Debug.BreakPositionAlignment.Statement : opt_position_aligment; 530 ? Debug.BreakPositionAlignment.Statement : opt_position_aligment;
506 return %GetBreakLocations(f, position_aligment); 531 return %GetBreakLocations(f, position_aligment);
507 }; 532 };
508 533
509 // Returns a Script object. If the parameter is a function the return value 534 // Returns a Script object. If the parameter is a function the return value
510 // is the script in which the function is defined. If the parameter is a string 535 // is the script in which the function is defined. If the parameter is a string
511 // the return value is the script for which the script name has that string 536 // the return value is the script for which the script name has that string
512 // value. If it is a regexp and there is a unique script whose name matches 537 // value. If it is a regexp and there is a unique script whose name matches
513 // we return that, otherwise undefined. 538 // we return that, otherwise undefined.
(...skipping 12 matching lines...) Expand all
526 } 551 }
527 } 552 }
528 // Return the unique script matching the regexp. If there are more 553 // Return the unique script matching the regexp. If there are more
529 // than one we don't return a value since there is no good way to 554 // than one we don't return a value since there is no good way to
530 // decide which one to return. Returning a "random" one, say the 555 // decide which one to return. Returning a "random" one, say the
531 // first, would introduce nondeterminism (or something close to it) 556 // first, would introduce nondeterminism (or something close to it)
532 // because the order is the heap iteration order. 557 // because the order is the heap iteration order.
533 if (result_count == 1) { 558 if (result_count == 1) {
534 return last_result; 559 return last_result;
535 } else { 560 } else {
536 return undefined; 561 return UNDEFINED;
537 } 562 }
538 } else { 563 } else {
539 return %GetScript(func_or_script_name); 564 return %GetScript(func_or_script_name);
540 } 565 }
541 }; 566 };
542 567
543 // Returns the script source. If the parameter is a function the return value 568 // Returns the script source. If the parameter is a function the return value
544 // is the script source for the script in which the function is defined. If the 569 // is the script source for the script in which the function is defined. If the
545 // parameter is a string the return value is the script for which the script 570 // parameter is a string the return value is the script for which the script
546 // name has that string value. 571 // name has that string value.
547 Debug.scriptSource = function(func_or_script_name) { 572 Debug.scriptSource = function(func_or_script_name) {
548 return this.findScript(func_or_script_name).source; 573 return this.findScript(func_or_script_name).source;
549 }; 574 };
550 575
551 576
552 Debug.source = function(f) { 577 Debug.source = function(f) {
553 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); 578 if (!IS_FUNCTION(f)) throw MakeTypeError(kDebuggerType);
554 return %FunctionGetSourceCode(f); 579 return %FunctionGetSourceCode(f);
555 }; 580 };
556 581
557 582
558 Debug.sourcePosition = function(f) { 583 Debug.sourcePosition = function(f) {
559 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); 584 if (!IS_FUNCTION(f)) throw MakeTypeError(kDebuggerType);
560 return %FunctionGetScriptSourcePosition(f); 585 return %FunctionGetScriptSourcePosition(f);
561 }; 586 };
562 587
563 588
564 Debug.findFunctionSourceLocation = function(func, opt_line, opt_column) { 589 Debug.findFunctionSourceLocation = function(func, opt_line, opt_column) {
565 var script = %FunctionGetScript(func); 590 var script = %FunctionGetScript(func);
566 var script_offset = %FunctionGetScriptSourcePosition(func); 591 var script_offset = %FunctionGetScriptSourcePosition(func);
567 return script.locationFromLine(opt_line, opt_column, script_offset); 592 return script.locationFromLine(opt_line, opt_column, script_offset);
568 }; 593 };
569 594
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 } 628 }
604 for (var i = 0; i < break_points.length; i++) { 629 for (var i = 0; i < break_points.length; i++) {
605 if (break_points[i].number() == break_point_number) { 630 if (break_points[i].number() == break_point_number) {
606 return [break_points[i].actual_location]; 631 return [break_points[i].actual_location];
607 } 632 }
608 } 633 }
609 return []; 634 return [];
610 }; 635 };
611 636
612 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { 637 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
613 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); 638 if (!IS_FUNCTION(func)) throw MakeTypeError(kDebuggerType);
614 // Break points in API functions are not supported. 639 // Break points in API functions are not supported.
615 if (%FunctionIsAPIFunction(func)) { 640 if (%FunctionIsAPIFunction(func)) {
616 throw new Error('Cannot set break point in native code.'); 641 throw MakeError(kDebugger, 'Cannot set break point in native code.');
617 } 642 }
618 // Find source position relative to start of the function 643 // Find source position relative to start of the function
619 var break_position = 644 var break_position =
620 this.findFunctionSourceLocation(func, opt_line, opt_column).position; 645 this.findFunctionSourceLocation(func, opt_line, opt_column).position;
621 var source_position = break_position - this.sourcePosition(func); 646 var source_position = break_position - this.sourcePosition(func);
622 // Find the script for the function. 647 // Find the script for the function.
623 var script = %FunctionGetScript(func); 648 var script = %FunctionGetScript(func);
624 // Break in builtin JavaScript code is not supported. 649 // Break in builtin JavaScript code is not supported.
625 if (script.type == Debug.ScriptType.Native) { 650 if (script.type == Debug.ScriptType.Native) {
626 throw new Error('Cannot set break point in native code.'); 651 throw MakeError(kDebugger, 'Cannot set break point in native code.');
627 } 652 }
628 // If the script for the function has a name convert this to a script break 653 // If the script for the function has a name convert this to a script break
629 // point. 654 // point.
630 if (script && script.id) { 655 if (script && script.id) {
631 // Adjust the source position to be script relative. 656 // Adjust the source position to be script relative.
632 source_position += %FunctionGetScriptSourcePosition(func); 657 source_position += %FunctionGetScriptSourcePosition(func);
633 // Find line and column for the position in the script and set a script 658 // Find line and column for the position in the script and set a script
634 // break point from that. 659 // break point from that.
635 var location = script.locationFromPosition(source_position, false); 660 var location = script.locationFromPosition(source_position, false);
636 return this.setScriptBreakPointById(script.id, 661 return this.setScriptBreakPointById(script.id,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 }; 718 };
694 719
695 720
696 Debug.changeBreakPointCondition = function(break_point_number, condition) { 721 Debug.changeBreakPointCondition = function(break_point_number, condition) {
697 var break_point = this.findBreakPoint(break_point_number, false); 722 var break_point = this.findBreakPoint(break_point_number, false);
698 break_point.setCondition(condition); 723 break_point.setCondition(condition);
699 }; 724 };
700 725
701 726
702 Debug.changeBreakPointIgnoreCount = function(break_point_number, ignoreCount) { 727 Debug.changeBreakPointIgnoreCount = function(break_point_number, ignoreCount) {
703 if (ignoreCount < 0) { 728 if (ignoreCount < 0) throw MakeError(kDebugger, 'Invalid argument');
704 throw new Error('Invalid argument');
705 }
706 var break_point = this.findBreakPoint(break_point_number, false); 729 var break_point = this.findBreakPoint(break_point_number, false);
707 break_point.setIgnoreCount(ignoreCount); 730 break_point.setIgnoreCount(ignoreCount);
708 }; 731 };
709 732
710 733
711 Debug.clearBreakPoint = function(break_point_number) { 734 Debug.clearBreakPoint = function(break_point_number) {
712 var break_point = this.findBreakPoint(break_point_number, true); 735 var break_point = this.findBreakPoint(break_point_number, true);
713 if (break_point) { 736 if (break_point) {
714 return %ClearBreakPoint(break_point); 737 return %ClearBreakPoint(break_point);
715 } else { 738 } else {
716 break_point = this.findScriptBreakPoint(break_point_number, true); 739 break_point = this.findScriptBreakPoint(break_point_number, true);
717 if (!break_point) { 740 if (!break_point) throw MakeError(kDebugger, 'Invalid breakpoint');
718 throw new Error('Invalid breakpoint');
719 }
720 } 741 }
721 }; 742 };
722 743
723 744
724 Debug.clearAllBreakPoints = function() { 745 Debug.clearAllBreakPoints = function() {
725 for (var i = 0; i < break_points.length; i++) { 746 for (var i = 0; i < break_points.length; i++) {
726 var break_point = break_points[i]; 747 var break_point = break_points[i];
727 %ClearBreakPoint(break_point); 748 %ClearBreakPoint(break_point);
728 } 749 }
729 break_points = []; 750 break_points = [];
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 850
830 Debug.changeScriptBreakPointCondition = function( 851 Debug.changeScriptBreakPointCondition = function(
831 break_point_number, condition) { 852 break_point_number, condition) {
832 var script_break_point = this.findScriptBreakPoint(break_point_number, false); 853 var script_break_point = this.findScriptBreakPoint(break_point_number, false);
833 script_break_point.setCondition(condition); 854 script_break_point.setCondition(condition);
834 }; 855 };
835 856
836 857
837 Debug.changeScriptBreakPointIgnoreCount = function( 858 Debug.changeScriptBreakPointIgnoreCount = function(
838 break_point_number, ignoreCount) { 859 break_point_number, ignoreCount) {
839 if (ignoreCount < 0) { 860 if (ignoreCount < 0) throw MakeError(kDebugger, 'Invalid argument');
840 throw new Error('Invalid argument');
841 }
842 var script_break_point = this.findScriptBreakPoint(break_point_number, false); 861 var script_break_point = this.findScriptBreakPoint(break_point_number, false);
843 script_break_point.setIgnoreCount(ignoreCount); 862 script_break_point.setIgnoreCount(ignoreCount);
844 }; 863 };
845 864
846 865
847 Debug.scriptBreakPoints = function() { 866 Debug.scriptBreakPoints = function() {
848 return script_break_points; 867 return script_break_points;
849 }; 868 };
850 869
851 870
(...skipping 19 matching lines...) Expand all
871 890
872 Debug.clearBreakOnUncaughtException = function() { 891 Debug.clearBreakOnUncaughtException = function() {
873 return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, false); 892 return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, false);
874 }; 893 };
875 894
876 Debug.isBreakOnUncaughtException = function() { 895 Debug.isBreakOnUncaughtException = function() {
877 return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught); 896 return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught);
878 }; 897 };
879 898
880 Debug.showBreakPoints = function(f, full, opt_position_alignment) { 899 Debug.showBreakPoints = function(f, full, opt_position_alignment) {
881 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); 900 if (!IS_FUNCTION(f)) throw MakeError(kDebuggerType);
882 var source = full ? this.scriptSource(f) : this.source(f); 901 var source = full ? this.scriptSource(f) : this.source(f);
883 var offset = full ? this.sourcePosition(f) : 0; 902 var offset = full ? this.sourcePosition(f) : 0;
884 var locations = this.breakLocations(f, opt_position_alignment); 903 var locations = this.breakLocations(f, opt_position_alignment);
885 if (!locations) return source; 904 if (!locations) return source;
886 locations.sort(function(x, y) { return x - y; }); 905 locations.sort(function(x, y) { return x - y; });
887 var result = ""; 906 var result = "";
888 var prev_pos = 0; 907 var prev_pos = 0;
889 var pos; 908 var pos;
890 for (var i = 0; i < locations.length; i++) { 909 for (var i = 0; i < locations.length; i++) {
891 pos = locations[i] - offset; 910 pos = locations[i] - offset;
(...skipping 26 matching lines...) Expand all
918 } 937 }
919 938
920 function ExecutionState(break_id) { 939 function ExecutionState(break_id) {
921 this.break_id = break_id; 940 this.break_id = break_id;
922 this.selected_frame = 0; 941 this.selected_frame = 0;
923 } 942 }
924 943
925 ExecutionState.prototype.prepareStep = function(opt_action, opt_count, 944 ExecutionState.prototype.prepareStep = function(opt_action, opt_count,
926 opt_callframe) { 945 opt_callframe) {
927 var action = Debug.StepAction.StepIn; 946 var action = Debug.StepAction.StepIn;
928 if (!IS_UNDEFINED(opt_action)) action = builtins.$toNumber(opt_action); 947 if (!IS_UNDEFINED(opt_action)) action = $toNumber(opt_action);
929 var count = opt_count ? builtins.$toNumber(opt_count) : 1; 948 var count = opt_count ? $toNumber(opt_count) : 1;
930 var callFrameId = 0; 949 var callFrameId = 0;
931 if (!IS_UNDEFINED(opt_callframe)) { 950 if (!IS_UNDEFINED(opt_callframe)) {
932 callFrameId = opt_callframe.details_.frameId(); 951 callFrameId = opt_callframe.details_.frameId();
933 } 952 }
934 953
935 return %PrepareStep(this.break_id, action, count, callFrameId); 954 return %PrepareStep(this.break_id, action, count, callFrameId);
936 }; 955 };
937 956
938 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, 957 ExecutionState.prototype.evaluateGlobal = function(source, disable_break,
939 opt_additional_context) { 958 opt_additional_context) {
940 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source, 959 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source,
941 Boolean(disable_break), 960 $toBoolean(disable_break),
942 opt_additional_context)); 961 opt_additional_context));
943 }; 962 };
944 963
945 ExecutionState.prototype.frameCount = function() { 964 ExecutionState.prototype.frameCount = function() {
946 return %GetFrameCount(this.break_id); 965 return %GetFrameCount(this.break_id);
947 }; 966 };
948 967
949 ExecutionState.prototype.threadCount = function() { 968 ExecutionState.prototype.threadCount = function() {
950 return %GetThreadCount(this.break_id); 969 return %GetThreadCount(this.break_id);
951 }; 970 };
952 971
953 ExecutionState.prototype.frame = function(opt_index) { 972 ExecutionState.prototype.frame = function(opt_index) {
954 // If no index supplied return the selected frame. 973 // If no index supplied return the selected frame.
955 if (opt_index == null) opt_index = this.selected_frame; 974 if (opt_index == null) opt_index = this.selected_frame;
956 if (opt_index < 0 || opt_index >= this.frameCount()) { 975 if (opt_index < 0 || opt_index >= this.frameCount()) {
957 throw new Error('Illegal frame index.'); 976 throw MakeTypeError(kDebuggerFrame);
958 } 977 }
959 return new FrameMirror(this.break_id, opt_index); 978 return new FrameMirror(this.break_id, opt_index);
960 }; 979 };
961 980
962 ExecutionState.prototype.setSelectedFrame = function(index) { 981 ExecutionState.prototype.setSelectedFrame = function(index) {
963 var i = builtins.$toNumber(index); 982 var i = $toNumber(index);
964 if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.'); 983 if (i < 0 || i >= this.frameCount()) {
984 throw MakeTypeError(kDebuggerFrame);
985 }
965 this.selected_frame = i; 986 this.selected_frame = i;
966 }; 987 };
967 988
968 ExecutionState.prototype.selectedFrame = function() { 989 ExecutionState.prototype.selectedFrame = function() {
969 return this.selected_frame; 990 return this.selected_frame;
970 }; 991 };
971 992
972 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) { 993 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) {
973 return new DebugCommandProcessor(this, opt_is_running); 994 return new DebugCommandProcessor(this, opt_is_running);
974 }; 995 };
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 var script_break_point = breakpoint.script_break_point(); 1062 var script_break_point = breakpoint.script_break_point();
1042 var number; 1063 var number;
1043 if (script_break_point) { 1064 if (script_break_point) {
1044 number = script_break_point.number(); 1065 number = script_break_point.number();
1045 } else { 1066 } else {
1046 number = breakpoint.number(); 1067 number = breakpoint.number();
1047 } 1068 }
1048 o.body.breakpoints.push(number); 1069 o.body.breakpoints.push(number);
1049 } 1070 }
1050 } 1071 }
1051 return JSON.stringify(ObjectToProtocolObject_(o)); 1072 return JSONStringify(ObjectToProtocolObject_(o));
1052 }; 1073 };
1053 1074
1054 1075
1055 function MakeExceptionEvent(break_id, exception, uncaught, promise) { 1076 function MakeExceptionEvent(break_id, exception, uncaught, promise) {
1056 return new ExceptionEvent(break_id, exception, uncaught, promise); 1077 return new ExceptionEvent(break_id, exception, uncaught, promise);
1057 } 1078 }
1058 1079
1059 1080
1060 function ExceptionEvent(break_id, exception, uncaught, promise) { 1081 function ExceptionEvent(break_id, exception, uncaught, promise) {
1061 this.exec_state_ = new ExecutionState(break_id); 1082 this.exec_state_ = new ExecutionState(break_id);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 // response from the request. 1291 // response from the request.
1271 this.type = 'response'; 1292 this.type = 'response';
1272 this.request_seq = request.seq; 1293 this.request_seq = request.seq;
1273 this.command = request.command; 1294 this.command = request.command;
1274 } else { 1295 } else {
1275 // If message is not based on a request it is a dabugger generated event. 1296 // If message is not based on a request it is a dabugger generated event.
1276 this.type = 'event'; 1297 this.type = 'event';
1277 } 1298 }
1278 this.success = true; 1299 this.success = true;
1279 // Handler may set this field to control debugger state. 1300 // Handler may set this field to control debugger state.
1280 this.running = undefined; 1301 this.running = UNDEFINED;
1281 } 1302 }
1282 1303
1283 1304
1284 ProtocolMessage.prototype.setOption = function(name, value) { 1305 ProtocolMessage.prototype.setOption = function(name, value) {
1285 if (!this.options_) { 1306 if (!this.options_) {
1286 this.options_ = {}; 1307 this.options_ = {};
1287 } 1308 }
1288 this.options_[name] = value; 1309 this.options_[name] = value;
1289 }; 1310 };
1290 1311
(...skipping 25 matching lines...) Expand all
1316 json.success = this.success; 1337 json.success = this.success;
1317 } else { 1338 } else {
1318 json.success = false; 1339 json.success = false;
1319 } 1340 }
1320 if (this.body) { 1341 if (this.body) {
1321 // Encode the body part. 1342 // Encode the body part.
1322 var bodyJson; 1343 var bodyJson;
1323 var serializer = MakeMirrorSerializer(true, this.options_); 1344 var serializer = MakeMirrorSerializer(true, this.options_);
1324 if (this.body instanceof Mirror) { 1345 if (this.body instanceof Mirror) {
1325 bodyJson = serializer.serializeValue(this.body); 1346 bodyJson = serializer.serializeValue(this.body);
1326 } else if (this.body instanceof Array) { 1347 } else if (this.body instanceof GlobalArray) {
1327 bodyJson = []; 1348 bodyJson = [];
1328 for (var i = 0; i < this.body.length; i++) { 1349 for (var i = 0; i < this.body.length; i++) {
1329 if (this.body[i] instanceof Mirror) { 1350 if (this.body[i] instanceof Mirror) {
1330 bodyJson.push(serializer.serializeValue(this.body[i])); 1351 bodyJson.push(serializer.serializeValue(this.body[i]));
1331 } else { 1352 } else {
1332 bodyJson.push(ObjectToProtocolObject_(this.body[i], serializer)); 1353 bodyJson.push(ObjectToProtocolObject_(this.body[i], serializer));
1333 } 1354 }
1334 } 1355 }
1335 } else { 1356 } else {
1336 bodyJson = ObjectToProtocolObject_(this.body, serializer); 1357 bodyJson = ObjectToProtocolObject_(this.body, serializer);
1337 } 1358 }
1338 json.body = bodyJson; 1359 json.body = bodyJson;
1339 json.refs = serializer.serializeReferencedObjects(); 1360 json.refs = serializer.serializeReferencedObjects();
1340 } 1361 }
1341 if (this.message) { 1362 if (this.message) {
1342 json.message = this.message; 1363 json.message = this.message;
1343 } 1364 }
1344 if (this.error_details) { 1365 if (this.error_details) {
1345 json.error_details = this.error_details; 1366 json.error_details = this.error_details;
1346 } 1367 }
1347 json.running = this.running; 1368 json.running = this.running;
1348 return JSON.stringify(json); 1369 return JSONStringify(json);
1349 }; 1370 };
1350 1371
1351 1372
1352 DebugCommandProcessor.prototype.createResponse = function(request) { 1373 DebugCommandProcessor.prototype.createResponse = function(request) {
1353 return new ProtocolMessage(request); 1374 return new ProtocolMessage(request);
1354 }; 1375 };
1355 1376
1356 1377
1357 DebugCommandProcessor.prototype.processDebugJSONRequest = function( 1378 DebugCommandProcessor.prototype.processDebugJSONRequest = function(
1358 json_request) { 1379 json_request) {
1359 var request; // Current request. 1380 var request; // Current request.
1360 var response; // Generated response. 1381 var response; // Generated response.
1361 try { 1382 try {
1362 try { 1383 try {
1363 // Convert the JSON string to an object. 1384 // Convert the JSON string to an object.
1364 request = JSON.parse(json_request); 1385 request = JSONParse(json_request);
1365 1386
1366 // Create an initial response. 1387 // Create an initial response.
1367 response = this.createResponse(request); 1388 response = this.createResponse(request);
1368 1389
1369 if (!request.type) { 1390 if (!request.type) {
1370 throw new Error('Type not specified'); 1391 throw MakeError(kDebugger, 'Type not specified');
1371 } 1392 }
1372 1393
1373 if (request.type != 'request') { 1394 if (request.type != 'request') {
1374 throw new Error("Illegal type '" + request.type + "' in request"); 1395 throw MakeError(kDebugger,
1396 "Illegal type '" + request.type + "' in request");
1375 } 1397 }
1376 1398
1377 if (!request.command) { 1399 if (!request.command) {
1378 throw new Error('Command not specified'); 1400 throw MakeError(kDebugger, 'Command not specified');
1379 } 1401 }
1380 1402
1381 if (request.arguments) { 1403 if (request.arguments) {
1382 var args = request.arguments; 1404 var args = request.arguments;
1383 // TODO(yurys): remove request.arguments.compactFormat check once 1405 // TODO(yurys): remove request.arguments.compactFormat check once
1384 // ChromeDevTools are switched to 'inlineRefs' 1406 // ChromeDevTools are switched to 'inlineRefs'
1385 if (args.inlineRefs || args.compactFormat) { 1407 if (args.inlineRefs || args.compactFormat) {
1386 response.setOption('inlineRefs', true); 1408 response.setOption('inlineRefs', true);
1387 } 1409 }
1388 if (!IS_UNDEFINED(args.maxStringLength)) { 1410 if (!IS_UNDEFINED(args.maxStringLength)) {
1389 response.setOption('maxStringLength', args.maxStringLength); 1411 response.setOption('maxStringLength', args.maxStringLength);
1390 } 1412 }
1391 } 1413 }
1392 1414
1393 var key = request.command.toLowerCase(); 1415 var key = request.command.toLowerCase();
1394 var handler = DebugCommandProcessor.prototype.dispatch_[key]; 1416 var handler = DebugCommandProcessor.prototype.dispatch_[key];
1395 if (IS_FUNCTION(handler)) { 1417 if (IS_FUNCTION(handler)) {
1396 %_CallFunction(this, request, response, handler); 1418 %_CallFunction(this, request, response, handler);
1397 } else { 1419 } else {
1398 throw new Error('Unknown command "' + request.command + '" in request'); 1420 throw MakeError(kDebugger,
1421 'Unknown command "' + request.command + '" in request');
1399 } 1422 }
1400 } catch (e) { 1423 } catch (e) {
1401 // If there is no response object created one (without command). 1424 // If there is no response object created one (without command).
1402 if (!response) { 1425 if (!response) {
1403 response = this.createResponse(); 1426 response = this.createResponse();
1404 } 1427 }
1405 response.success = false; 1428 response.success = false;
1406 response.message = builtins.$toString(e); 1429 response.message = $toString(e);
1407 } 1430 }
1408 1431
1409 // Return the response as a JSON encoded string. 1432 // Return the response as a JSON encoded string.
1410 try { 1433 try {
1411 if (!IS_UNDEFINED(response.running)) { 1434 if (!IS_UNDEFINED(response.running)) {
1412 // Response controls running state. 1435 // Response controls running state.
1413 this.running_ = response.running; 1436 this.running_ = response.running;
1414 } 1437 }
1415 response.running = this.running_; 1438 response.running = this.running_;
1416 return response.toJSONProtocol(); 1439 return response.toJSONProtocol();
1417 } catch (e) { 1440 } catch (e) {
1418 // Failed to generate response - return generic error. 1441 // Failed to generate response - return generic error.
1419 return '{"seq":' + response.seq + ',' + 1442 return '{"seq":' + response.seq + ',' +
1420 '"request_seq":' + request.seq + ',' + 1443 '"request_seq":' + request.seq + ',' +
1421 '"type":"response",' + 1444 '"type":"response",' +
1422 '"success":false,' + 1445 '"success":false,' +
1423 '"message":"Internal error: ' + builtins.$toString(e) + '"}'; 1446 '"message":"Internal error: ' + $toString(e) + '"}';
1424 } 1447 }
1425 } catch (e) { 1448 } catch (e) {
1426 // Failed in one of the catch blocks above - most generic error. 1449 // Failed in one of the catch blocks above - most generic error.
1427 return '{"seq":0,"type":"response","success":false,"message":"Internal error "}'; 1450 return '{"seq":0,"type":"response","success":false,"message":"Internal error "}';
1428 } 1451 }
1429 }; 1452 };
1430 1453
1431 1454
1432 DebugCommandProcessor.prototype.continueRequest_ = function(request, response) { 1455 DebugCommandProcessor.prototype.continueRequest_ = function(request, response) {
1433 // Check for arguments for continue. 1456 // Check for arguments for continue.
1434 if (request.arguments) { 1457 if (request.arguments) {
1435 var count = 1; 1458 var count = 1;
1436 var action = Debug.StepAction.StepIn; 1459 var action = Debug.StepAction.StepIn;
1437 1460
1438 // Pull out arguments. 1461 // Pull out arguments.
1439 var stepaction = request.arguments.stepaction; 1462 var stepaction = request.arguments.stepaction;
1440 var stepcount = request.arguments.stepcount; 1463 var stepcount = request.arguments.stepcount;
1441 1464
1442 // Get the stepcount argument if any. 1465 // Get the stepcount argument if any.
1443 if (stepcount) { 1466 if (stepcount) {
1444 count = builtins.$toNumber(stepcount); 1467 count = $toNumber(stepcount);
1445 if (count < 0) { 1468 if (count < 0) {
1446 throw new Error('Invalid stepcount argument "' + stepcount + '".'); 1469 throw MakeError(kDebugger,
1470 'Invalid stepcount argument "' + stepcount + '".');
1447 } 1471 }
1448 } 1472 }
1449 1473
1450 // Get the stepaction argument. 1474 // Get the stepaction argument.
1451 if (stepaction) { 1475 if (stepaction) {
1452 if (stepaction == 'in') { 1476 if (stepaction == 'in') {
1453 action = Debug.StepAction.StepIn; 1477 action = Debug.StepAction.StepIn;
1454 } else if (stepaction == 'min') { 1478 } else if (stepaction == 'min') {
1455 action = Debug.StepAction.StepMin; 1479 action = Debug.StepAction.StepMin;
1456 } else if (stepaction == 'next') { 1480 } else if (stepaction == 'next') {
1457 action = Debug.StepAction.StepNext; 1481 action = Debug.StepAction.StepNext;
1458 } else if (stepaction == 'out') { 1482 } else if (stepaction == 'out') {
1459 action = Debug.StepAction.StepOut; 1483 action = Debug.StepAction.StepOut;
1460 } else { 1484 } else {
1461 throw new Error('Invalid stepaction argument "' + stepaction + '".'); 1485 throw MakeError(kDebugger,
1486 'Invalid stepaction argument "' + stepaction + '".');
1462 } 1487 }
1463 } 1488 }
1464 1489
1465 // Set up the VM for stepping. 1490 // Set up the VM for stepping.
1466 this.exec_state_.prepareStep(action, count); 1491 this.exec_state_.prepareStep(action, count);
1467 } 1492 }
1468 1493
1469 // VM should be running after executing this request. 1494 // VM should be running after executing this request.
1470 response.running = true; 1495 response.running = true;
1471 }; 1496 };
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 // Handle function break point. 1532 // Handle function break point.
1508 if (!IS_STRING(target)) { 1533 if (!IS_STRING(target)) {
1509 response.failed('Argument "target" is not a string value'); 1534 response.failed('Argument "target" is not a string value');
1510 return; 1535 return;
1511 } 1536 }
1512 var f; 1537 var f;
1513 try { 1538 try {
1514 // Find the function through a global evaluate. 1539 // Find the function through a global evaluate.
1515 f = this.exec_state_.evaluateGlobal(target).value(); 1540 f = this.exec_state_.evaluateGlobal(target).value();
1516 } catch (e) { 1541 } catch (e) {
1517 response.failed('Error: "' + builtins.$toString(e) + 1542 response.failed('Error: "' + $toString(e) +
1518 '" evaluating "' + target + '"'); 1543 '" evaluating "' + target + '"');
1519 return; 1544 return;
1520 } 1545 }
1521 if (!IS_FUNCTION(f)) { 1546 if (!IS_FUNCTION(f)) {
1522 response.failed('"' + target + '" does not evaluate to a function'); 1547 response.failed('"' + target + '" does not evaluate to a function');
1523 return; 1548 return;
1524 } 1549 }
1525 1550
1526 // Set function break point. 1551 // Set function break point.
1527 break_point_number = Debug.setBreakPoint(f, line, column, condition); 1552 break_point_number = Debug.setBreakPoint(f, line, column, condition);
1528 } else if (type == 'handle') { 1553 } else if (type == 'handle') {
1529 // Find the object pointed by the specified handle. 1554 // Find the object pointed by the specified handle.
1530 var handle = parseInt(target, 10); 1555 var handle = ParseInt(target, 10);
1531 var mirror = LookupMirror(handle); 1556 var mirror = LookupMirror(handle);
1532 if (!mirror) { 1557 if (!mirror) {
1533 return response.failed('Object #' + handle + '# not found'); 1558 return response.failed('Object #' + handle + '# not found');
1534 } 1559 }
1535 if (!mirror.isFunction()) { 1560 if (!mirror.isFunction()) {
1536 return response.failed('Object #' + handle + '# is not a function'); 1561 return response.failed('Object #' + handle + '# is not a function');
1537 } 1562 }
1538 1563
1539 // Set function break point. 1564 // Set function break point.
1540 break_point_number = Debug.setBreakPoint(mirror.value(), 1565 break_point_number = Debug.setBreakPoint(mirror.value(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { 1599 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
1575 response.body.type = 'scriptId'; 1600 response.body.type = 'scriptId';
1576 response.body.script_id = break_point.script_id(); 1601 response.body.script_id = break_point.script_id();
1577 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { 1602 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) {
1578 response.body.type = 'scriptName'; 1603 response.body.type = 'scriptName';
1579 response.body.script_name = break_point.script_name(); 1604 response.body.script_name = break_point.script_name();
1580 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { 1605 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) {
1581 response.body.type = 'scriptRegExp'; 1606 response.body.type = 'scriptRegExp';
1582 response.body.script_regexp = break_point.script_regexp_object().source; 1607 response.body.script_regexp = break_point.script_regexp_object().source;
1583 } else { 1608 } else {
1584 throw new Error("Internal error: Unexpected breakpoint type: " + 1609 throw MakeError(kDebugger,
1585 break_point.type()); 1610 "Unexpected breakpoint type: " + break_point.type());
1586 } 1611 }
1587 response.body.line = break_point.line(); 1612 response.body.line = break_point.line();
1588 response.body.column = break_point.column(); 1613 response.body.column = break_point.column();
1589 response.body.actual_locations = break_point.actual_locations(); 1614 response.body.actual_locations = break_point.actual_locations();
1590 } else { 1615 } else {
1591 response.body.type = 'function'; 1616 response.body.type = 'function';
1592 response.body.actual_locations = [break_point.actual_location]; 1617 response.body.actual_locations = [break_point.actual_location];
1593 } 1618 }
1594 }; 1619 };
1595 1620
1596 1621
1597 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function( 1622 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(
1598 request, response) { 1623 request, response) {
1599 // Check for legal request. 1624 // Check for legal request.
1600 if (!request.arguments) { 1625 if (!request.arguments) {
1601 response.failed('Missing arguments'); 1626 response.failed('Missing arguments');
1602 return; 1627 return;
1603 } 1628 }
1604 1629
1605 // Pull out arguments. 1630 // Pull out arguments.
1606 var break_point = builtins.$toNumber(request.arguments.breakpoint); 1631 var break_point = $toNumber(request.arguments.breakpoint);
1607 var enabled = request.arguments.enabled; 1632 var enabled = request.arguments.enabled;
1608 var condition = request.arguments.condition; 1633 var condition = request.arguments.condition;
1609 var ignoreCount = request.arguments.ignoreCount; 1634 var ignoreCount = request.arguments.ignoreCount;
1610 1635
1611 // Check for legal arguments. 1636 // Check for legal arguments.
1612 if (!break_point) { 1637 if (!break_point) {
1613 response.failed('Missing argument "breakpoint"'); 1638 response.failed('Missing argument "breakpoint"');
1614 return; 1639 return;
1615 } 1640 }
1616 1641
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 1697
1673 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function( 1698 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(
1674 request, response) { 1699 request, response) {
1675 // Check for legal request. 1700 // Check for legal request.
1676 if (!request.arguments) { 1701 if (!request.arguments) {
1677 response.failed('Missing arguments'); 1702 response.failed('Missing arguments');
1678 return; 1703 return;
1679 } 1704 }
1680 1705
1681 // Pull out arguments. 1706 // Pull out arguments.
1682 var break_point = builtins.$toNumber(request.arguments.breakpoint); 1707 var break_point = $toNumber(request.arguments.breakpoint);
1683 1708
1684 // Check for legal arguments. 1709 // Check for legal arguments.
1685 if (!break_point) { 1710 if (!break_point) {
1686 response.failed('Missing argument "breakpoint"'); 1711 response.failed('Missing argument "breakpoint"');
1687 return; 1712 return;
1688 } 1713 }
1689 1714
1690 // Clear break point. 1715 // Clear break point.
1691 Debug.clearBreakPoint(break_point); 1716 Debug.clearBreakPoint(break_point);
1692 1717
(...skipping 23 matching lines...) Expand all
1716 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { 1741 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
1717 description.type = 'scriptId'; 1742 description.type = 'scriptId';
1718 description.script_id = break_point.script_id(); 1743 description.script_id = break_point.script_id();
1719 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { 1744 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) {
1720 description.type = 'scriptName'; 1745 description.type = 'scriptName';
1721 description.script_name = break_point.script_name(); 1746 description.script_name = break_point.script_name();
1722 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { 1747 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) {
1723 description.type = 'scriptRegExp'; 1748 description.type = 'scriptRegExp';
1724 description.script_regexp = break_point.script_regexp_object().source; 1749 description.script_regexp = break_point.script_regexp_object().source;
1725 } else { 1750 } else {
1726 throw new Error("Internal error: Unexpected breakpoint type: " + 1751 throw MakeError(kDebugger,
1727 break_point.type()); 1752 "Unexpected breakpoint type: " + break_point.type());
1728 } 1753 }
1729 array.push(description); 1754 array.push(description);
1730 } 1755 }
1731 1756
1732 response.body = { 1757 response.body = {
1733 breakpoints: array, 1758 breakpoints: array,
1734 breakOnExceptions: Debug.isBreakOnException(), 1759 breakOnExceptions: Debug.isBreakOnException(),
1735 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException() 1760 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException()
1736 }; 1761 };
1737 }; 1762 };
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 var tmp_index = total_frames - from_index; 1843 var tmp_index = total_frames - from_index;
1819 from_index = total_frames - to_index; 1844 from_index = total_frames - to_index;
1820 to_index = tmp_index; 1845 to_index = tmp_index;
1821 } 1846 }
1822 if (from_index < 0 || to_index < 0) { 1847 if (from_index < 0 || to_index < 0) {
1823 return response.failed('Invalid frame number'); 1848 return response.failed('Invalid frame number');
1824 } 1849 }
1825 } 1850 }
1826 1851
1827 // Adjust the index. 1852 // Adjust the index.
1828 to_index = Math.min(total_frames, to_index); 1853 to_index = MathMin(total_frames, to_index);
1829 1854
1830 if (to_index <= from_index) { 1855 if (to_index <= from_index) {
1831 var error = 'Invalid frame range'; 1856 var error = 'Invalid frame range';
1832 return response.failed(error); 1857 return response.failed(error);
1833 } 1858 }
1834 1859
1835 // Create the response body. 1860 // Create the response body.
1836 var frames = []; 1861 var frames = [];
1837 for (var i = from_index; i < to_index; i++) { 1862 for (var i = from_index; i < to_index; i++) {
1838 frames.push(this.exec_state_.frame(i)); 1863 frames.push(this.exec_state_.frame(i));
(...skipping 26 matching lines...) Expand all
1865 }; 1890 };
1866 1891
1867 1892
1868 DebugCommandProcessor.prototype.resolveFrameFromScopeDescription_ = 1893 DebugCommandProcessor.prototype.resolveFrameFromScopeDescription_ =
1869 function(scope_description) { 1894 function(scope_description) {
1870 // Get the frame for which the scope or scopes are requested. 1895 // Get the frame for which the scope or scopes are requested.
1871 // With no frameNumber argument use the currently selected frame. 1896 // With no frameNumber argument use the currently selected frame.
1872 if (scope_description && !IS_UNDEFINED(scope_description.frameNumber)) { 1897 if (scope_description && !IS_UNDEFINED(scope_description.frameNumber)) {
1873 var frame_index = scope_description.frameNumber; 1898 var frame_index = scope_description.frameNumber;
1874 if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) { 1899 if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) {
1875 throw new Error('Invalid frame number'); 1900 throw MakeTypeError(kDebuggerFrame);
1876 } 1901 }
1877 return this.exec_state_.frame(frame_index); 1902 return this.exec_state_.frame(frame_index);
1878 } else { 1903 } else {
1879 return this.exec_state_.frame(); 1904 return this.exec_state_.frame();
1880 } 1905 }
1881 }; 1906 };
1882 1907
1883 1908
1884 // Gets scope host object from request. It is either a function 1909 // Gets scope host object from request. It is either a function
1885 // ('functionHandle' argument must be specified) or a stack frame 1910 // ('functionHandle' argument must be specified) or a stack frame
1886 // ('frameNumber' may be specified and the current frame is taken by default). 1911 // ('frameNumber' may be specified and the current frame is taken by default).
1887 DebugCommandProcessor.prototype.resolveScopeHolder_ = 1912 DebugCommandProcessor.prototype.resolveScopeHolder_ =
1888 function(scope_description) { 1913 function(scope_description) {
1889 if (scope_description && "functionHandle" in scope_description) { 1914 if (scope_description && "functionHandle" in scope_description) {
1890 if (!IS_NUMBER(scope_description.functionHandle)) { 1915 if (!IS_NUMBER(scope_description.functionHandle)) {
1891 throw new Error('Function handle must be a number'); 1916 throw MakeError(kDebugger, 'Function handle must be a number');
1892 } 1917 }
1893 var function_mirror = LookupMirror(scope_description.functionHandle); 1918 var function_mirror = LookupMirror(scope_description.functionHandle);
1894 if (!function_mirror) { 1919 if (!function_mirror) {
1895 throw new Error('Failed to find function object by handle'); 1920 throw MakeError(kDebugger, 'Failed to find function object by handle');
1896 } 1921 }
1897 if (!function_mirror.isFunction()) { 1922 if (!function_mirror.isFunction()) {
1898 throw new Error('Value of non-function type is found by handle'); 1923 throw MakeError(kDebugger,
1924 'Value of non-function type is found by handle');
1899 } 1925 }
1900 return function_mirror; 1926 return function_mirror;
1901 } else { 1927 } else {
1902 // No frames no scopes. 1928 // No frames no scopes.
1903 if (this.exec_state_.frameCount() == 0) { 1929 if (this.exec_state_.frameCount() == 0) {
1904 throw new Error('No scopes'); 1930 throw MakeError(kDebugger, 'No scopes');
1905 } 1931 }
1906 1932
1907 // Get the frame for which the scopes are requested. 1933 // Get the frame for which the scopes are requested.
1908 var frame = this.resolveFrameFromScopeDescription_(scope_description); 1934 var frame = this.resolveFrameFromScopeDescription_(scope_description);
1909 return frame; 1935 return frame;
1910 } 1936 }
1911 } 1937 }
1912 1938
1913 1939
1914 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) { 1940 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) {
(...skipping 14 matching lines...) Expand all
1929 }; 1955 };
1930 1956
1931 1957
1932 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { 1958 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) {
1933 // Get the frame or function for which the scope is requested. 1959 // Get the frame or function for which the scope is requested.
1934 var scope_holder = this.resolveScopeHolder_(request.arguments); 1960 var scope_holder = this.resolveScopeHolder_(request.arguments);
1935 1961
1936 // With no scope argument just return top scope. 1962 // With no scope argument just return top scope.
1937 var scope_index = 0; 1963 var scope_index = 0;
1938 if (request.arguments && !IS_UNDEFINED(request.arguments.number)) { 1964 if (request.arguments && !IS_UNDEFINED(request.arguments.number)) {
1939 scope_index = builtins.$toNumber(request.arguments.number); 1965 scope_index = $toNumber(request.arguments.number);
1940 if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) { 1966 if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) {
1941 return response.failed('Invalid scope number'); 1967 return response.failed('Invalid scope number');
1942 } 1968 }
1943 } 1969 }
1944 1970
1945 response.body = scope_holder.scope(scope_index); 1971 response.body = scope_holder.scope(scope_index);
1946 }; 1972 };
1947 1973
1948 1974
1949 // Reads value from protocol description. Description may be in form of type 1975 // Reads value from protocol description. Description may be in form of type
1950 // (for singletons), raw value (primitive types supported in JSON), 1976 // (for singletons), raw value (primitive types supported in JSON),
1951 // string value description plus type (for primitive values) or handle id. 1977 // string value description plus type (for primitive values) or handle id.
1952 // Returns raw value or throws exception. 1978 // Returns raw value or throws exception.
1953 DebugCommandProcessor.resolveValue_ = function(value_description) { 1979 DebugCommandProcessor.resolveValue_ = function(value_description) {
1954 if ("handle" in value_description) { 1980 if ("handle" in value_description) {
1955 var value_mirror = LookupMirror(value_description.handle); 1981 var value_mirror = LookupMirror(value_description.handle);
1956 if (!value_mirror) { 1982 if (!value_mirror) {
1957 throw new Error("Failed to resolve value by handle, ' #" + 1983 throw MakeError(kDebugger, "Failed to resolve value by handle, ' #" +
1958 value_description.handle + "# not found"); 1984 value_description.handle + "# not found");
1959 } 1985 }
1960 return value_mirror.value(); 1986 return value_mirror.value();
1961 } else if ("stringDescription" in value_description) { 1987 } else if ("stringDescription" in value_description) {
1962 if (value_description.type == BOOLEAN_TYPE) { 1988 if (value_description.type == MirrorType.BOOLEAN_TYPE) {
1963 return Boolean(value_description.stringDescription); 1989 return $toBoolean(value_description.stringDescription);
1964 } else if (value_description.type == NUMBER_TYPE) { 1990 } else if (value_description.type == MirrorType.NUMBER_TYPE) {
1965 return Number(value_description.stringDescription); 1991 return $toNumber(value_description.stringDescription);
1966 } if (value_description.type == STRING_TYPE) { 1992 } if (value_description.type == MirrorType.STRING_TYPE) {
1967 return String(value_description.stringDescription); 1993 return $toString(value_description.stringDescription);
1968 } else { 1994 } else {
1969 throw new Error("Unknown type"); 1995 throw MakeError(kDebugger, "Unknown type");
1970 } 1996 }
1971 } else if ("value" in value_description) { 1997 } else if ("value" in value_description) {
1972 return value_description.value; 1998 return value_description.value;
1973 } else if (value_description.type == UNDEFINED_TYPE) { 1999 } else if (value_description.type == MirrorType.UNDEFINED_TYPE) {
1974 return UNDEFINED; 2000 return UNDEFINED;
1975 } else if (value_description.type == NULL_TYPE) { 2001 } else if (value_description.type == MirrorType.NULL_TYPE) {
1976 return null; 2002 return null;
1977 } else { 2003 } else {
1978 throw new Error("Failed to parse value description"); 2004 throw MakeError(kDebugger, "Failed to parse value description");
1979 } 2005 }
1980 }; 2006 };
1981 2007
1982 2008
1983 DebugCommandProcessor.prototype.setVariableValueRequest_ = 2009 DebugCommandProcessor.prototype.setVariableValueRequest_ =
1984 function(request, response) { 2010 function(request, response) {
1985 if (!request.arguments) { 2011 if (!request.arguments) {
1986 response.failed('Missing arguments'); 2012 response.failed('Missing arguments');
1987 return; 2013 return;
1988 } 2014 }
1989 2015
1990 if (IS_UNDEFINED(request.arguments.name)) { 2016 if (IS_UNDEFINED(request.arguments.name)) {
1991 response.failed('Missing variable name'); 2017 response.failed('Missing variable name');
1992 } 2018 }
1993 var variable_name = request.arguments.name; 2019 var variable_name = request.arguments.name;
1994 2020
1995 var scope_description = request.arguments.scope; 2021 var scope_description = request.arguments.scope;
1996 2022
1997 // Get the frame or function for which the scope is requested. 2023 // Get the frame or function for which the scope is requested.
1998 var scope_holder = this.resolveScopeHolder_(scope_description); 2024 var scope_holder = this.resolveScopeHolder_(scope_description);
1999 2025
2000 if (IS_UNDEFINED(scope_description.number)) { 2026 if (IS_UNDEFINED(scope_description.number)) {
2001 response.failed('Missing scope number'); 2027 response.failed('Missing scope number');
2002 } 2028 }
2003 var scope_index = builtins.$toNumber(scope_description.number); 2029 var scope_index = $toNumber(scope_description.number);
2004 2030
2005 var scope = scope_holder.scope(scope_index); 2031 var scope = scope_holder.scope(scope_index);
2006 2032
2007 var new_value = 2033 var new_value =
2008 DebugCommandProcessor.resolveValue_(request.arguments.newValue); 2034 DebugCommandProcessor.resolveValue_(request.arguments.newValue);
2009 2035
2010 scope.setVariableValue(variable_name, new_value); 2036 scope.setVariableValue(variable_name, new_value);
2011 2037
2012 var new_value_mirror = MakeMirror(new_value); 2038 var new_value_mirror = MakeMirror(new_value);
2013 2039
(...skipping 11 matching lines...) Expand all
2025 // Pull out arguments. 2051 // Pull out arguments.
2026 var expression = request.arguments.expression; 2052 var expression = request.arguments.expression;
2027 var frame = request.arguments.frame; 2053 var frame = request.arguments.frame;
2028 var global = request.arguments.global; 2054 var global = request.arguments.global;
2029 var disable_break = request.arguments.disable_break; 2055 var disable_break = request.arguments.disable_break;
2030 var additional_context = request.arguments.additional_context; 2056 var additional_context = request.arguments.additional_context;
2031 2057
2032 // The expression argument could be an integer so we convert it to a 2058 // The expression argument could be an integer so we convert it to a
2033 // string. 2059 // string.
2034 try { 2060 try {
2035 expression = String(expression); 2061 expression = $toString(expression);
2036 } catch(e) { 2062 } catch(e) {
2037 return response.failed('Failed to convert expression argument to string'); 2063 return response.failed('Failed to convert expression argument to string');
2038 } 2064 }
2039 2065
2040 // Check for legal arguments. 2066 // Check for legal arguments.
2041 if (!IS_UNDEFINED(frame) && global) { 2067 if (!IS_UNDEFINED(frame) && global) {
2042 return response.failed('Arguments "frame" and "global" are exclusive'); 2068 return response.failed('Arguments "frame" and "global" are exclusive');
2043 } 2069 }
2044 2070
2045 var additional_context_object; 2071 var additional_context_object;
2046 if (additional_context) { 2072 if (additional_context) {
2047 additional_context_object = {}; 2073 additional_context_object = {};
2048 for (var i = 0; i < additional_context.length; i++) { 2074 for (var i = 0; i < additional_context.length; i++) {
2049 var mapping = additional_context[i]; 2075 var mapping = additional_context[i];
2050 2076
2051 if (!IS_STRING(mapping.name)) { 2077 if (!IS_STRING(mapping.name)) {
2052 return response.failed("Context element #" + i + 2078 return response.failed("Context element #" + i +
2053 " doesn't contain name:string property"); 2079 " doesn't contain name:string property");
2054 } 2080 }
2055 2081
2056 var raw_value = DebugCommandProcessor.resolveValue_(mapping); 2082 var raw_value = DebugCommandProcessor.resolveValue_(mapping);
2057 additional_context_object[mapping.name] = raw_value; 2083 additional_context_object[mapping.name] = raw_value;
2058 } 2084 }
2059 } 2085 }
2060 2086
2061 // Global evaluate. 2087 // Global evaluate.
2062 if (global) { 2088 if (global) {
2063 // Evaluate in the native context. 2089 // Evaluate in the native context.
2064 response.body = this.exec_state_.evaluateGlobal( 2090 response.body = this.exec_state_.evaluateGlobal(
2065 expression, Boolean(disable_break), additional_context_object); 2091 expression, $toBoolean(disable_break), additional_context_object);
2066 return; 2092 return;
2067 } 2093 }
2068 2094
2069 // Default value for disable_break is true. 2095 // Default value for disable_break is true.
2070 if (IS_UNDEFINED(disable_break)) { 2096 if (IS_UNDEFINED(disable_break)) {
2071 disable_break = true; 2097 disable_break = true;
2072 } 2098 }
2073 2099
2074 // No frames no evaluate in frame. 2100 // No frames no evaluate in frame.
2075 if (this.exec_state_.frameCount() == 0) { 2101 if (this.exec_state_.frameCount() == 0) {
2076 return response.failed('No frames'); 2102 return response.failed('No frames');
2077 } 2103 }
2078 2104
2079 // Check whether a frame was specified. 2105 // Check whether a frame was specified.
2080 if (!IS_UNDEFINED(frame)) { 2106 if (!IS_UNDEFINED(frame)) {
2081 var frame_number = builtins.$toNumber(frame); 2107 var frame_number = $toNumber(frame);
2082 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { 2108 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
2083 return response.failed('Invalid frame "' + frame + '"'); 2109 return response.failed('Invalid frame "' + frame + '"');
2084 } 2110 }
2085 // Evaluate in the specified frame. 2111 // Evaluate in the specified frame.
2086 response.body = this.exec_state_.frame(frame_number).evaluate( 2112 response.body = this.exec_state_.frame(frame_number).evaluate(
2087 expression, Boolean(disable_break), additional_context_object); 2113 expression, $toBoolean(disable_break), additional_context_object);
2088 return; 2114 return;
2089 } else { 2115 } else {
2090 // Evaluate in the selected frame. 2116 // Evaluate in the selected frame.
2091 response.body = this.exec_state_.frame().evaluate( 2117 response.body = this.exec_state_.frame().evaluate(
2092 expression, Boolean(disable_break), additional_context_object); 2118 expression, $toBoolean(disable_break), additional_context_object);
2093 return; 2119 return;
2094 } 2120 }
2095 }; 2121 };
2096 2122
2097 2123
2098 DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) { 2124 DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) {
2099 if (!request.arguments) { 2125 if (!request.arguments) {
2100 return response.failed('Missing arguments'); 2126 return response.failed('Missing arguments');
2101 } 2127 }
2102 2128
2103 // Pull out arguments. 2129 // Pull out arguments.
2104 var handles = request.arguments.handles; 2130 var handles = request.arguments.handles;
2105 2131
2106 // Check for legal arguments. 2132 // Check for legal arguments.
2107 if (IS_UNDEFINED(handles)) { 2133 if (IS_UNDEFINED(handles)) {
2108 return response.failed('Argument "handles" missing'); 2134 return response.failed('Argument "handles" missing');
2109 } 2135 }
2110 2136
2111 // Set 'includeSource' option for script lookup. 2137 // Set 'includeSource' option for script lookup.
2112 if (!IS_UNDEFINED(request.arguments.includeSource)) { 2138 if (!IS_UNDEFINED(request.arguments.includeSource)) {
2113 var includeSource = builtins.$toBoolean(request.arguments.includeSource); 2139 var includeSource = $toBoolean(request.arguments.includeSource);
2114 response.setOption('includeSource', includeSource); 2140 response.setOption('includeSource', includeSource);
2115 } 2141 }
2116 2142
2117 // Lookup handles. 2143 // Lookup handles.
2118 var mirrors = {}; 2144 var mirrors = {};
2119 for (var i = 0; i < handles.length; i++) { 2145 for (var i = 0; i < handles.length; i++) {
2120 var handle = handles[i]; 2146 var handle = handles[i];
2121 var mirror = LookupMirror(handle); 2147 var mirror = LookupMirror(handle);
2122 if (!mirror) { 2148 if (!mirror) {
2123 return response.failed('Object #' + handle + '# not found'); 2149 return response.failed('Object #' + handle + '# not found');
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 2197
2172 var from_line; 2198 var from_line;
2173 var to_line; 2199 var to_line;
2174 var frame = this.exec_state_.frame(); 2200 var frame = this.exec_state_.frame();
2175 if (request.arguments) { 2201 if (request.arguments) {
2176 // Pull out arguments. 2202 // Pull out arguments.
2177 from_line = request.arguments.fromLine; 2203 from_line = request.arguments.fromLine;
2178 to_line = request.arguments.toLine; 2204 to_line = request.arguments.toLine;
2179 2205
2180 if (!IS_UNDEFINED(request.arguments.frame)) { 2206 if (!IS_UNDEFINED(request.arguments.frame)) {
2181 var frame_number = builtins.$toNumber(request.arguments.frame); 2207 var frame_number = $toNumber(request.arguments.frame);
2182 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { 2208 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
2183 return response.failed('Invalid frame "' + frame + '"'); 2209 return response.failed('Invalid frame "' + frame + '"');
2184 } 2210 }
2185 frame = this.exec_state_.frame(frame_number); 2211 frame = this.exec_state_.frame(frame_number);
2186 } 2212 }
2187 } 2213 }
2188 2214
2189 // Get the script selected. 2215 // Get the script selected.
2190 var script = frame.func().script(); 2216 var script = frame.func().script();
2191 if (!script) { 2217 if (!script) {
(...skipping 15 matching lines...) Expand all
2207 }; 2233 };
2208 2234
2209 2235
2210 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { 2236 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {
2211 var types = ScriptTypeFlag(Debug.ScriptType.Normal); 2237 var types = ScriptTypeFlag(Debug.ScriptType.Normal);
2212 var includeSource = false; 2238 var includeSource = false;
2213 var idsToInclude = null; 2239 var idsToInclude = null;
2214 if (request.arguments) { 2240 if (request.arguments) {
2215 // Pull out arguments. 2241 // Pull out arguments.
2216 if (!IS_UNDEFINED(request.arguments.types)) { 2242 if (!IS_UNDEFINED(request.arguments.types)) {
2217 types = builtins.$toNumber(request.arguments.types); 2243 types = $toNumber(request.arguments.types);
2218 if (isNaN(types) || types < 0) { 2244 if (IsNaN(types) || types < 0) {
2219 return response.failed('Invalid types "' + 2245 return response.failed('Invalid types "' +
2220 request.arguments.types + '"'); 2246 request.arguments.types + '"');
2221 } 2247 }
2222 } 2248 }
2223 2249
2224 if (!IS_UNDEFINED(request.arguments.includeSource)) { 2250 if (!IS_UNDEFINED(request.arguments.includeSource)) {
2225 includeSource = builtins.$toBoolean(request.arguments.includeSource); 2251 includeSource = $toBoolean(request.arguments.includeSource);
2226 response.setOption('includeSource', includeSource); 2252 response.setOption('includeSource', includeSource);
2227 } 2253 }
2228 2254
2229 if (IS_ARRAY(request.arguments.ids)) { 2255 if (IS_ARRAY(request.arguments.ids)) {
2230 idsToInclude = {}; 2256 idsToInclude = {};
2231 var ids = request.arguments.ids; 2257 var ids = request.arguments.ids;
2232 for (var i = 0; i < ids.length; i++) { 2258 for (var i = 0; i < ids.length; i++) {
2233 idsToInclude[ids[i]] = true; 2259 idsToInclude[ids[i]] = true;
2234 } 2260 }
2235 } 2261 }
2236 2262
2237 var filterStr = null; 2263 var filterStr = null;
2238 var filterNum = null; 2264 var filterNum = null;
2239 if (!IS_UNDEFINED(request.arguments.filter)) { 2265 if (!IS_UNDEFINED(request.arguments.filter)) {
2240 var num = builtins.$toNumber(request.arguments.filter); 2266 var num = $toNumber(request.arguments.filter);
2241 if (!isNaN(num)) { 2267 if (!IsNaN(num)) {
2242 filterNum = num; 2268 filterNum = num;
2243 } 2269 }
2244 filterStr = request.arguments.filter; 2270 filterStr = request.arguments.filter;
2245 } 2271 }
2246 } 2272 }
2247 2273
2248 // Collect all scripts in the heap. 2274 // Collect all scripts in the heap.
2249 var scripts = %DebugGetLoadedScripts(); 2275 var scripts = %DebugGetLoadedScripts();
2250 2276
2251 response.body = []; 2277 response.body = [];
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 for (var i = 0; i < scripts.length; i++) { 2350 for (var i = 0; i < scripts.length; i++) {
2325 if (scripts[i].id == script_id) { 2351 if (scripts[i].id == script_id) {
2326 the_script = scripts[i]; 2352 the_script = scripts[i];
2327 } 2353 }
2328 } 2354 }
2329 if (!the_script) { 2355 if (!the_script) {
2330 response.failed('Script not found'); 2356 response.failed('Script not found');
2331 return; 2357 return;
2332 } 2358 }
2333 2359
2334 var change_log = new Array(); 2360 var change_log = new GlobalArray();
2335 2361
2336 if (!IS_STRING(request.arguments.new_source)) { 2362 if (!IS_STRING(request.arguments.new_source)) {
2337 throw "new_source argument expected"; 2363 throw "new_source argument expected";
2338 } 2364 }
2339 2365
2340 var new_source = request.arguments.new_source; 2366 var new_source = request.arguments.new_source;
2341 2367
2342 var result_description; 2368 var result_description;
2343 try { 2369 try {
2344 result_description = Debug.LiveEdit.SetScriptSource(the_script, 2370 result_description = Debug.LiveEdit.SetScriptSource(the_script,
(...skipping 21 matching lines...) Expand all
2366 var frame = request.arguments.frame; 2392 var frame = request.arguments.frame;
2367 2393
2368 // No frames to evaluate in frame. 2394 // No frames to evaluate in frame.
2369 if (this.exec_state_.frameCount() == 0) { 2395 if (this.exec_state_.frameCount() == 0) {
2370 return response.failed('No frames'); 2396 return response.failed('No frames');
2371 } 2397 }
2372 2398
2373 var frame_mirror; 2399 var frame_mirror;
2374 // Check whether a frame was specified. 2400 // Check whether a frame was specified.
2375 if (!IS_UNDEFINED(frame)) { 2401 if (!IS_UNDEFINED(frame)) {
2376 var frame_number = builtins.$toNumber(frame); 2402 var frame_number = $toNumber(frame);
2377 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) { 2403 if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
2378 return response.failed('Invalid frame "' + frame + '"'); 2404 return response.failed('Invalid frame "' + frame + '"');
2379 } 2405 }
2380 // Restart specified frame. 2406 // Restart specified frame.
2381 frame_mirror = this.exec_state_.frame(frame_number); 2407 frame_mirror = this.exec_state_.frame(frame_number);
2382 } else { 2408 } else {
2383 // Restart selected frame. 2409 // Restart selected frame.
2384 frame_mirror = this.exec_state_.frame(); 2410 frame_mirror = this.exec_state_.frame();
2385 } 2411 }
2386 2412
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 case 'string': 2586 case 'string':
2561 case 'number': 2587 case 'number':
2562 json = value; 2588 json = value;
2563 break; 2589 break;
2564 2590
2565 default: 2591 default:
2566 json = null; 2592 json = null;
2567 } 2593 }
2568 return json; 2594 return json;
2569 } 2595 }
2596
2597
2598 // -------------------------------------------------------------------
2599 // Exports
2600
2601 utils.InstallConstants(global, [
2602 "Debug", Debug,
2603 "DebugCommandProcessor", DebugCommandProcessor,
2604 ]);
2605
2606 // Functions needed by the debugger runtime.
2607 utils.InstallFunctions(utils, DONT_ENUM, [
2608 "MakeExecutionState", MakeExecutionState,
2609 "MakeExceptionEvent", MakeExceptionEvent,
2610 "MakeBreakEvent", MakeBreakEvent,
2611 "MakeCompileEvent", MakeCompileEvent,
2612 "MakePromiseEvent", MakePromiseEvent,
2613 "MakeAsyncTaskEvent", MakeAsyncTaskEvent,
2614 "IsBreakPointTriggered", IsBreakPointTriggered,
2615 "UpdateScriptBreakPoints", UpdateScriptBreakPoints,
2616 ]);
2617
2618 // Export to liveedit.js
2619 utils.Export(function(to) {
2620 to.GetScriptBreakPoints = GetScriptBreakPoints;
2621 });
2622
2623 })
OLDNEW
« no previous file with comments | « src/debug/debug.cc ('k') | src/debug/debug-evaluate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698