| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, | 279 var copy = new ScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, |
| 280 other_script.id, this.line_, this.column_, this.groupId_); | 280 other_script.id, this.line_, this.column_, this.groupId_); |
| 281 copy.number_ = next_break_point_number++; | 281 copy.number_ = next_break_point_number++; |
| 282 script_break_points.push(copy); | 282 script_break_points.push(copy); |
| 283 | 283 |
| 284 copy.hit_count_ = this.hit_count_; | 284 copy.hit_count_ = this.hit_count_; |
| 285 copy.active_ = this.active_; | 285 copy.active_ = this.active_; |
| 286 copy.condition_ = this.condition_; | 286 copy.condition_ = this.condition_; |
| 287 copy.ignoreCount_ = this.ignoreCount_; | 287 copy.ignoreCount_ = this.ignoreCount_; |
| 288 return copy; | 288 return copy; |
| 289 } | 289 }; |
| 290 | 290 |
| 291 | 291 |
| 292 ScriptBreakPoint.prototype.number = function() { | 292 ScriptBreakPoint.prototype.number = function() { |
| 293 return this.number_; | 293 return this.number_; |
| 294 }; | 294 }; |
| 295 | 295 |
| 296 | 296 |
| 297 ScriptBreakPoint.prototype.groupId = function() { | 297 ScriptBreakPoint.prototype.groupId = function() { |
| 298 return this.groupId_; | 298 return this.groupId_; |
| 299 }; | 299 }; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 328 return this.column_; | 328 return this.column_; |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 | 331 |
| 332 ScriptBreakPoint.prototype.actual_locations = function() { | 332 ScriptBreakPoint.prototype.actual_locations = function() { |
| 333 var locations = []; | 333 var locations = []; |
| 334 for (var i = 0; i < this.break_points_.length; i++) { | 334 for (var i = 0; i < this.break_points_.length; i++) { |
| 335 locations.push(this.break_points_[i].actual_location); | 335 locations.push(this.break_points_[i].actual_location); |
| 336 } | 336 } |
| 337 return locations; | 337 return locations; |
| 338 } | 338 }; |
| 339 | 339 |
| 340 | 340 |
| 341 ScriptBreakPoint.prototype.update_positions = function(line, column) { | 341 ScriptBreakPoint.prototype.update_positions = function(line, column) { |
| 342 this.line_ = line; | 342 this.line_ = line; |
| 343 this.column_ = column; | 343 this.column_ = column; |
| 344 } | 344 }; |
| 345 | 345 |
| 346 | 346 |
| 347 ScriptBreakPoint.prototype.hit_count = function() { | 347 ScriptBreakPoint.prototype.hit_count = function() { |
| 348 return this.hit_count_; | 348 return this.hit_count_; |
| 349 }; | 349 }; |
| 350 | 350 |
| 351 | 351 |
| 352 ScriptBreakPoint.prototype.active = function() { | 352 ScriptBreakPoint.prototype.active = function() { |
| 353 return this.active_; | 353 return this.active_; |
| 354 }; | 354 }; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 } | 470 } |
| 471 break_points = remaining_break_points; | 471 break_points = remaining_break_points; |
| 472 this.break_points_ = []; | 472 this.break_points_ = []; |
| 473 }; | 473 }; |
| 474 | 474 |
| 475 | 475 |
| 476 // Function called from runtime when a new script is compiled to set any script | 476 // Function called from runtime when a new script is compiled to set any script |
| 477 // break points set in this script. | 477 // break points set in this script. |
| 478 function UpdateScriptBreakPoints(script) { | 478 function UpdateScriptBreakPoints(script) { |
| 479 for (var i = 0; i < script_break_points.length; i++) { | 479 for (var i = 0; i < script_break_points.length; i++) { |
| 480 if (script_break_points[i].type() == Debug.ScriptBreakPointType.ScriptName &
& | 480 var break_point = script_break_points[i]; |
| 481 script_break_points[i].matchesScript(script)) { | 481 if ((break_point.type() == Debug.ScriptBreakPointType.ScriptName) && |
| 482 script_break_points[i].set(script); | 482 break_point.matchesScript(script)) { |
| 483 break_point.set(script); |
| 483 } | 484 } |
| 484 } | 485 } |
| 485 } | 486 } |
| 486 | 487 |
| 487 | 488 |
| 488 function GetScriptBreakPoints(script) { | 489 function GetScriptBreakPoints(script) { |
| 489 var result = []; | 490 var result = []; |
| 490 for (var i = 0; i < script_break_points.length; i++) { | 491 for (var i = 0; i < script_break_points.length; i++) { |
| 491 if (script_break_points[i].matchesScript(script)) { | 492 if (script_break_points[i].matchesScript(script)) { |
| 492 result.push(script_break_points[i]); | 493 result.push(script_break_points[i]); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 Debug.sourcePosition = function(f) { | 579 Debug.sourcePosition = function(f) { |
| 579 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); | 580 if (!IS_FUNCTION(f)) throw new Error('Parameters have wrong types.'); |
| 580 return %FunctionGetScriptSourcePosition(f); | 581 return %FunctionGetScriptSourcePosition(f); |
| 581 }; | 582 }; |
| 582 | 583 |
| 583 | 584 |
| 584 Debug.findFunctionSourceLocation = function(func, opt_line, opt_column) { | 585 Debug.findFunctionSourceLocation = function(func, opt_line, opt_column) { |
| 585 var script = %FunctionGetScript(func); | 586 var script = %FunctionGetScript(func); |
| 586 var script_offset = %FunctionGetScriptSourcePosition(func); | 587 var script_offset = %FunctionGetScriptSourcePosition(func); |
| 587 return script.locationFromLine(opt_line, opt_column, script_offset); | 588 return script.locationFromLine(opt_line, opt_column, script_offset); |
| 588 } | 589 }; |
| 589 | 590 |
| 590 | 591 |
| 591 // Returns the character position in a script based on a line number and an | 592 // Returns the character position in a script based on a line number and an |
| 592 // optional position within that line. | 593 // optional position within that line. |
| 593 Debug.findScriptSourcePosition = function(script, opt_line, opt_column) { | 594 Debug.findScriptSourcePosition = function(script, opt_line, opt_column) { |
| 594 var location = script.locationFromLine(opt_line, opt_column); | 595 var location = script.locationFromLine(opt_line, opt_column); |
| 595 return location ? location.position : null; | 596 return location ? location.position : null; |
| 596 } | 597 }; |
| 597 | 598 |
| 598 | 599 |
| 599 Debug.findBreakPoint = function(break_point_number, remove) { | 600 Debug.findBreakPoint = function(break_point_number, remove) { |
| 600 var break_point; | 601 var break_point; |
| 601 for (var i = 0; i < break_points.length; i++) { | 602 for (var i = 0; i < break_points.length; i++) { |
| 602 if (break_points[i].number() == break_point_number) { | 603 if (break_points[i].number() == break_point_number) { |
| 603 break_point = break_points[i]; | 604 break_point = break_points[i]; |
| 604 // Remove the break point from the list if requested. | 605 // Remove the break point from the list if requested. |
| 605 if (remove) { | 606 if (remove) { |
| 606 break_points.splice(i, 1); | 607 break_points.splice(i, 1); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 620 if (script_break_points[i].number() == break_point_number) { | 621 if (script_break_points[i].number() == break_point_number) { |
| 621 return script_break_points[i].actual_locations(); | 622 return script_break_points[i].actual_locations(); |
| 622 } | 623 } |
| 623 } | 624 } |
| 624 for (var i = 0; i < break_points.length; i++) { | 625 for (var i = 0; i < break_points.length; i++) { |
| 625 if (break_points[i].number() == break_point_number) { | 626 if (break_points[i].number() == break_point_number) { |
| 626 return [break_points[i].actual_location]; | 627 return [break_points[i].actual_location]; |
| 627 } | 628 } |
| 628 } | 629 } |
| 629 return []; | 630 return []; |
| 630 } | 631 }; |
| 631 | 632 |
| 632 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { | 633 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { |
| 633 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); | 634 if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.'); |
| 634 // Break points in API functions are not supported. | 635 // Break points in API functions are not supported. |
| 635 if (%FunctionIsAPIFunction(func)) { | 636 if (%FunctionIsAPIFunction(func)) { |
| 636 throw new Error('Cannot set break point in native code.'); | 637 throw new Error('Cannot set break point in native code.'); |
| 637 } | 638 } |
| 638 // Find source position relative to start of the function | 639 // Find source position relative to start of the function |
| 639 var break_position = | 640 var break_position = |
| 640 this.findFunctionSourceLocation(func, opt_line, opt_column).position; | 641 this.findFunctionSourceLocation(func, opt_line, opt_column).position; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 670 return break_point.number(); | 671 return break_point.number(); |
| 671 } | 672 } |
| 672 }; | 673 }; |
| 673 | 674 |
| 674 | 675 |
| 675 Debug.setBreakPointByScriptIdAndPosition = function(script_id, position, | 676 Debug.setBreakPointByScriptIdAndPosition = function(script_id, position, |
| 676 condition, enabled) | 677 condition, enabled) |
| 677 { | 678 { |
| 678 break_point = MakeBreakPoint(position); | 679 break_point = MakeBreakPoint(position); |
| 679 break_point.setCondition(condition); | 680 break_point.setCondition(condition); |
| 680 if (!enabled) | 681 if (!enabled) { |
| 681 break_point.disable(); | 682 break_point.disable(); |
| 683 } |
| 682 var scripts = this.scripts(); | 684 var scripts = this.scripts(); |
| 683 for (var i = 0; i < scripts.length; i++) { | 685 for (var i = 0; i < scripts.length; i++) { |
| 684 if (script_id == scripts[i].id) { | 686 if (script_id == scripts[i].id) { |
| 685 break_point.actual_position = %SetScriptBreakPoint(scripts[i], position, | 687 break_point.actual_position = %SetScriptBreakPoint(scripts[i], position, |
| 686 break_point); | 688 break_point); |
| 687 break; | 689 break; |
| 688 } | 690 } |
| 689 } | 691 } |
| 690 return break_point; | 692 return break_point; |
| 691 }; | 693 }; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 script_break_point = script_break_points[i]; | 766 script_break_point = script_break_points[i]; |
| 765 // Remove the break point from the list if requested. | 767 // Remove the break point from the list if requested. |
| 766 if (remove) { | 768 if (remove) { |
| 767 script_break_point.clear(); | 769 script_break_point.clear(); |
| 768 script_break_points.splice(i,1); | 770 script_break_points.splice(i,1); |
| 769 } | 771 } |
| 770 break; | 772 break; |
| 771 } | 773 } |
| 772 } | 774 } |
| 773 return script_break_point; | 775 return script_break_point; |
| 774 } | 776 }; |
| 775 | 777 |
| 776 | 778 |
| 777 // Sets a breakpoint in a script identified through id or name at the | 779 // Sets a breakpoint in a script identified through id or name at the |
| 778 // specified source line and column within that line. | 780 // specified source line and column within that line. |
| 779 Debug.setScriptBreakPoint = function(type, script_id_or_name, | 781 Debug.setScriptBreakPoint = function(type, script_id_or_name, |
| 780 opt_line, opt_column, opt_condition, | 782 opt_line, opt_column, opt_condition, |
| 781 opt_groupId) { | 783 opt_groupId) { |
| 782 // Create script break point object. | 784 // Create script break point object. |
| 783 var script_break_point = | 785 var script_break_point = |
| 784 new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, | 786 new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, |
| 785 opt_groupId); | 787 opt_groupId); |
| 786 | 788 |
| 787 // Assign number to the new script break point and add it. | 789 // Assign number to the new script break point and add it. |
| 788 script_break_point.number_ = next_break_point_number++; | 790 script_break_point.number_ = next_break_point_number++; |
| 789 script_break_point.setCondition(opt_condition); | 791 script_break_point.setCondition(opt_condition); |
| 790 script_break_points.push(script_break_point); | 792 script_break_points.push(script_break_point); |
| 791 | 793 |
| 792 // Run through all scripts to see if this script break point matches any | 794 // Run through all scripts to see if this script break point matches any |
| 793 // loaded scripts. | 795 // loaded scripts. |
| 794 var scripts = this.scripts(); | 796 var scripts = this.scripts(); |
| 795 for (var i = 0; i < scripts.length; i++) { | 797 for (var i = 0; i < scripts.length; i++) { |
| 796 if (script_break_point.matchesScript(scripts[i])) { | 798 if (script_break_point.matchesScript(scripts[i])) { |
| 797 script_break_point.set(scripts[i]); | 799 script_break_point.set(scripts[i]); |
| 798 } | 800 } |
| 799 } | 801 } |
| 800 | 802 |
| 801 return script_break_point.number(); | 803 return script_break_point.number(); |
| 802 } | 804 }; |
| 803 | 805 |
| 804 | 806 |
| 805 Debug.setScriptBreakPointById = function(script_id, | 807 Debug.setScriptBreakPointById = function(script_id, |
| 806 opt_line, opt_column, | 808 opt_line, opt_column, |
| 807 opt_condition, opt_groupId) { | 809 opt_condition, opt_groupId) { |
| 808 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, | 810 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, |
| 809 script_id, opt_line, opt_column, | 811 script_id, opt_line, opt_column, |
| 810 opt_condition, opt_groupId); | 812 opt_condition, opt_groupId); |
| 811 } | 813 }; |
| 812 | 814 |
| 813 | 815 |
| 814 Debug.setScriptBreakPointByName = function(script_name, | 816 Debug.setScriptBreakPointByName = function(script_name, |
| 815 opt_line, opt_column, | 817 opt_line, opt_column, |
| 816 opt_condition, opt_groupId) { | 818 opt_condition, opt_groupId) { |
| 817 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName, | 819 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName, |
| 818 script_name, opt_line, opt_column, | 820 script_name, opt_line, opt_column, |
| 819 opt_condition, opt_groupId); | 821 opt_condition, opt_groupId); |
| 820 } | 822 }; |
| 821 | 823 |
| 822 | 824 |
| 823 Debug.setScriptBreakPointByRegExp = function(script_regexp, | 825 Debug.setScriptBreakPointByRegExp = function(script_regexp, |
| 824 opt_line, opt_column, | 826 opt_line, opt_column, |
| 825 opt_condition, opt_groupId) { | 827 opt_condition, opt_groupId) { |
| 826 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptRegExp, | 828 return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptRegExp, |
| 827 script_regexp, opt_line, opt_column, | 829 script_regexp, opt_line, opt_column, |
| 828 opt_condition, opt_groupId); | 830 opt_condition, opt_groupId); |
| 829 } | 831 }; |
| 830 | 832 |
| 831 | 833 |
| 832 Debug.enableScriptBreakPoint = function(break_point_number) { | 834 Debug.enableScriptBreakPoint = function(break_point_number) { |
| 833 var script_break_point = this.findScriptBreakPoint(break_point_number, false); | 835 var script_break_point = this.findScriptBreakPoint(break_point_number, false); |
| 834 script_break_point.enable(); | 836 script_break_point.enable(); |
| 835 }; | 837 }; |
| 836 | 838 |
| 837 | 839 |
| 838 Debug.disableScriptBreakPoint = function(break_point_number) { | 840 Debug.disableScriptBreakPoint = function(break_point_number) { |
| 839 var script_break_point = this.findScriptBreakPoint(break_point_number, false); | 841 var script_break_point = this.findScriptBreakPoint(break_point_number, false); |
| 840 script_break_point.disable(); | 842 script_break_point.disable(); |
| 841 }; | 843 }; |
| 842 | 844 |
| 843 | 845 |
| 844 Debug.changeScriptBreakPointCondition = function(break_point_number, condition)
{ | 846 Debug.changeScriptBreakPointCondition = function( |
| 847 break_point_number, condition) { |
| 845 var script_break_point = this.findScriptBreakPoint(break_point_number, false); | 848 var script_break_point = this.findScriptBreakPoint(break_point_number, false); |
| 846 script_break_point.setCondition(condition); | 849 script_break_point.setCondition(condition); |
| 847 }; | 850 }; |
| 848 | 851 |
| 849 | 852 |
| 850 Debug.changeScriptBreakPointIgnoreCount = function(break_point_number, ignoreCou
nt) { | 853 Debug.changeScriptBreakPointIgnoreCount = function( |
| 854 break_point_number, ignoreCount) { |
| 851 if (ignoreCount < 0) { | 855 if (ignoreCount < 0) { |
| 852 throw new Error('Invalid argument'); | 856 throw new Error('Invalid argument'); |
| 853 } | 857 } |
| 854 var script_break_point = this.findScriptBreakPoint(break_point_number, false); | 858 var script_break_point = this.findScriptBreakPoint(break_point_number, false); |
| 855 script_break_point.setIgnoreCount(ignoreCount); | 859 script_break_point.setIgnoreCount(ignoreCount); |
| 856 }; | 860 }; |
| 857 | 861 |
| 858 | 862 |
| 859 Debug.scriptBreakPoints = function() { | 863 Debug.scriptBreakPoints = function() { |
| 860 return script_break_points; | 864 return script_break_points; |
| 861 } | 865 }; |
| 862 | 866 |
| 863 | 867 |
| 864 Debug.clearStepping = function() { | 868 Debug.clearStepping = function() { |
| 865 %ClearStepping(); | 869 %ClearStepping(); |
| 866 } | 870 }; |
| 867 | 871 |
| 868 Debug.setBreakOnException = function() { | 872 Debug.setBreakOnException = function() { |
| 869 return %ChangeBreakOnException(Debug.ExceptionBreak.Caught, true); | 873 return %ChangeBreakOnException(Debug.ExceptionBreak.Caught, true); |
| 870 }; | 874 }; |
| 871 | 875 |
| 872 Debug.clearBreakOnException = function() { | 876 Debug.clearBreakOnException = function() { |
| 873 return %ChangeBreakOnException(Debug.ExceptionBreak.Caught, false); | 877 return %ChangeBreakOnException(Debug.ExceptionBreak.Caught, false); |
| 874 }; | 878 }; |
| 875 | 879 |
| 876 Debug.isBreakOnException = function() { | 880 Debug.isBreakOnException = function() { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 this.break_id = break_id; | 937 this.break_id = break_id; |
| 934 this.selected_frame = 0; | 938 this.selected_frame = 0; |
| 935 } | 939 } |
| 936 | 940 |
| 937 ExecutionState.prototype.prepareStep = function(opt_action, opt_count) { | 941 ExecutionState.prototype.prepareStep = function(opt_action, opt_count) { |
| 938 var action = Debug.StepAction.StepIn; | 942 var action = Debug.StepAction.StepIn; |
| 939 if (!IS_UNDEFINED(opt_action)) action = %ToNumber(opt_action); | 943 if (!IS_UNDEFINED(opt_action)) action = %ToNumber(opt_action); |
| 940 var count = opt_count ? %ToNumber(opt_count) : 1; | 944 var count = opt_count ? %ToNumber(opt_count) : 1; |
| 941 | 945 |
| 942 return %PrepareStep(this.break_id, action, count); | 946 return %PrepareStep(this.break_id, action, count); |
| 943 } | 947 }; |
| 944 | 948 |
| 945 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, | 949 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, |
| 946 opt_additional_context) { | 950 opt_additional_context) { |
| 947 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source, | 951 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source, |
| 948 Boolean(disable_break), | 952 Boolean(disable_break), |
| 949 opt_additional_context)); | 953 opt_additional_context)); |
| 950 }; | 954 }; |
| 951 | 955 |
| 952 ExecutionState.prototype.frameCount = function() { | 956 ExecutionState.prototype.frameCount = function() { |
| 953 return %GetFrameCount(this.break_id); | 957 return %GetFrameCount(this.break_id); |
| 954 }; | 958 }; |
| 955 | 959 |
| 956 ExecutionState.prototype.threadCount = function() { | 960 ExecutionState.prototype.threadCount = function() { |
| 957 return %GetThreadCount(this.break_id); | 961 return %GetThreadCount(this.break_id); |
| 958 }; | 962 }; |
| 959 | 963 |
| 960 ExecutionState.prototype.frame = function(opt_index) { | 964 ExecutionState.prototype.frame = function(opt_index) { |
| 961 // If no index supplied return the selected frame. | 965 // If no index supplied return the selected frame. |
| 962 if (opt_index == null) opt_index = this.selected_frame; | 966 if (opt_index == null) opt_index = this.selected_frame; |
| 963 if (opt_index < 0 || opt_index >= this.frameCount()) | 967 if (opt_index < 0 || opt_index >= this.frameCount()) { |
| 964 throw new Error('Illegal frame index.'); | 968 throw new Error('Illegal frame index.'); |
| 969 } |
| 965 return new FrameMirror(this.break_id, opt_index); | 970 return new FrameMirror(this.break_id, opt_index); |
| 966 }; | 971 }; |
| 967 | 972 |
| 968 ExecutionState.prototype.setSelectedFrame = function(index) { | 973 ExecutionState.prototype.setSelectedFrame = function(index) { |
| 969 var i = %ToNumber(index); | 974 var i = %ToNumber(index); |
| 970 if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.'); | 975 if (i < 0 || i >= this.frameCount()) throw new Error('Illegal frame index.'); |
| 971 this.selected_frame = i; | 976 this.selected_frame = i; |
| 972 }; | 977 }; |
| 973 | 978 |
| 974 ExecutionState.prototype.selectedFrame = function() { | 979 ExecutionState.prototype.selectedFrame = function() { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 }; | 1086 }; |
| 1082 | 1087 |
| 1083 | 1088 |
| 1084 ExceptionEvent.prototype.eventType = function() { | 1089 ExceptionEvent.prototype.eventType = function() { |
| 1085 return Debug.DebugEvent.Exception; | 1090 return Debug.DebugEvent.Exception; |
| 1086 }; | 1091 }; |
| 1087 | 1092 |
| 1088 | 1093 |
| 1089 ExceptionEvent.prototype.exception = function() { | 1094 ExceptionEvent.prototype.exception = function() { |
| 1090 return this.exception_; | 1095 return this.exception_; |
| 1091 } | 1096 }; |
| 1092 | 1097 |
| 1093 | 1098 |
| 1094 ExceptionEvent.prototype.uncaught = function() { | 1099 ExceptionEvent.prototype.uncaught = function() { |
| 1095 return this.uncaught_; | 1100 return this.uncaught_; |
| 1096 } | 1101 }; |
| 1097 | 1102 |
| 1098 | 1103 |
| 1099 ExceptionEvent.prototype.func = function() { | 1104 ExceptionEvent.prototype.func = function() { |
| 1100 return this.exec_state_.frame(0).func(); | 1105 return this.exec_state_.frame(0).func(); |
| 1101 }; | 1106 }; |
| 1102 | 1107 |
| 1103 | 1108 |
| 1104 ExceptionEvent.prototype.sourceLine = function() { | 1109 ExceptionEvent.prototype.sourceLine = function() { |
| 1105 return this.exec_state_.frame(0).sourceLine(); | 1110 return this.exec_state_.frame(0).sourceLine(); |
| 1106 }; | 1111 }; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 o.running = true; | 1183 o.running = true; |
| 1179 if (this.before_) { | 1184 if (this.before_) { |
| 1180 o.event = "beforeCompile"; | 1185 o.event = "beforeCompile"; |
| 1181 } else { | 1186 } else { |
| 1182 o.event = "afterCompile"; | 1187 o.event = "afterCompile"; |
| 1183 } | 1188 } |
| 1184 o.body = {}; | 1189 o.body = {}; |
| 1185 o.body.script = this.script_; | 1190 o.body.script = this.script_; |
| 1186 | 1191 |
| 1187 return o.toJSONProtocol(); | 1192 return o.toJSONProtocol(); |
| 1188 } | 1193 }; |
| 1189 | 1194 |
| 1190 | 1195 |
| 1191 function MakeNewFunctionEvent(func) { | 1196 function MakeNewFunctionEvent(func) { |
| 1192 return new NewFunctionEvent(func); | 1197 return new NewFunctionEvent(func); |
| 1193 } | 1198 } |
| 1194 | 1199 |
| 1195 | 1200 |
| 1196 function NewFunctionEvent(func) { | 1201 function NewFunctionEvent(func) { |
| 1197 this.func = func; | 1202 this.func = func; |
| 1198 } | 1203 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 }; | 1239 }; |
| 1235 | 1240 |
| 1236 | 1241 |
| 1237 ScriptCollectedEvent.prototype.toJSONProtocol = function() { | 1242 ScriptCollectedEvent.prototype.toJSONProtocol = function() { |
| 1238 var o = new ProtocolMessage(); | 1243 var o = new ProtocolMessage(); |
| 1239 o.running = true; | 1244 o.running = true; |
| 1240 o.event = "scriptCollected"; | 1245 o.event = "scriptCollected"; |
| 1241 o.body = {}; | 1246 o.body = {}; |
| 1242 o.body.script = { id: this.id() }; | 1247 o.body.script = { id: this.id() }; |
| 1243 return o.toJSONProtocol(); | 1248 return o.toJSONProtocol(); |
| 1244 } | 1249 }; |
| 1245 | 1250 |
| 1246 | 1251 |
| 1247 function MakeScriptObject_(script, include_source) { | 1252 function MakeScriptObject_(script, include_source) { |
| 1248 var o = { id: script.id(), | 1253 var o = { id: script.id(), |
| 1249 name: script.name(), | 1254 name: script.name(), |
| 1250 lineOffset: script.lineOffset(), | 1255 lineOffset: script.lineOffset(), |
| 1251 columnOffset: script.columnOffset(), | 1256 columnOffset: script.columnOffset(), |
| 1252 lineCount: script.lineCount(), | 1257 lineCount: script.lineCount(), |
| 1253 }; | 1258 }; |
| 1254 if (!IS_UNDEFINED(script.data())) { | 1259 if (!IS_UNDEFINED(script.data())) { |
| 1255 o.data = script.data(); | 1260 o.data = script.data(); |
| 1256 } | 1261 } |
| 1257 if (include_source) { | 1262 if (include_source) { |
| 1258 o.source = script.source(); | 1263 o.source = script.source(); |
| 1259 } | 1264 } |
| 1260 return o; | 1265 return o; |
| 1261 }; | 1266 } |
| 1262 | 1267 |
| 1263 | 1268 |
| 1264 function DebugCommandProcessor(exec_state, opt_is_running) { | 1269 function DebugCommandProcessor(exec_state, opt_is_running) { |
| 1265 this.exec_state_ = exec_state; | 1270 this.exec_state_ = exec_state; |
| 1266 this.running_ = opt_is_running || false; | 1271 this.running_ = opt_is_running || false; |
| 1267 }; | 1272 } |
| 1268 | 1273 |
| 1269 | 1274 |
| 1270 DebugCommandProcessor.prototype.processDebugRequest = function (request) { | 1275 DebugCommandProcessor.prototype.processDebugRequest = function (request) { |
| 1271 return this.processDebugJSONRequest(request); | 1276 return this.processDebugJSONRequest(request); |
| 1272 } | 1277 }; |
| 1273 | 1278 |
| 1274 | 1279 |
| 1275 function ProtocolMessage(request) { | 1280 function ProtocolMessage(request) { |
| 1276 // Update sequence number. | 1281 // Update sequence number. |
| 1277 this.seq = next_response_seq++; | 1282 this.seq = next_response_seq++; |
| 1278 | 1283 |
| 1279 if (request) { | 1284 if (request) { |
| 1280 // If message is based on a request this is a response. Fill the initial | 1285 // If message is based on a request this is a response. Fill the initial |
| 1281 // response from the request. | 1286 // response from the request. |
| 1282 this.type = 'response'; | 1287 this.type = 'response'; |
| 1283 this.request_seq = request.seq; | 1288 this.request_seq = request.seq; |
| 1284 this.command = request.command; | 1289 this.command = request.command; |
| 1285 } else { | 1290 } else { |
| 1286 // If message is not based on a request it is a dabugger generated event. | 1291 // If message is not based on a request it is a dabugger generated event. |
| 1287 this.type = 'event'; | 1292 this.type = 'event'; |
| 1288 } | 1293 } |
| 1289 this.success = true; | 1294 this.success = true; |
| 1290 // Handler may set this field to control debugger state. | 1295 // Handler may set this field to control debugger state. |
| 1291 this.running = undefined; | 1296 this.running = undefined; |
| 1292 } | 1297 } |
| 1293 | 1298 |
| 1294 | 1299 |
| 1295 ProtocolMessage.prototype.setOption = function(name, value) { | 1300 ProtocolMessage.prototype.setOption = function(name, value) { |
| 1296 if (!this.options_) { | 1301 if (!this.options_) { |
| 1297 this.options_ = {}; | 1302 this.options_ = {}; |
| 1298 } | 1303 } |
| 1299 this.options_[name] = value; | 1304 this.options_[name] = value; |
| 1300 } | 1305 }; |
| 1301 | 1306 |
| 1302 | 1307 |
| 1303 ProtocolMessage.prototype.failed = function(message) { | 1308 ProtocolMessage.prototype.failed = function(message) { |
| 1304 this.success = false; | 1309 this.success = false; |
| 1305 this.message = message; | 1310 this.message = message; |
| 1306 } | 1311 }; |
| 1307 | 1312 |
| 1308 | 1313 |
| 1309 ProtocolMessage.prototype.toJSONProtocol = function() { | 1314 ProtocolMessage.prototype.toJSONProtocol = function() { |
| 1310 // Encode the protocol header. | 1315 // Encode the protocol header. |
| 1311 var json = {}; | 1316 var json = {}; |
| 1312 json.seq= this.seq; | 1317 json.seq= this.seq; |
| 1313 if (this.request_seq) { | 1318 if (this.request_seq) { |
| 1314 json.request_seq = this.request_seq; | 1319 json.request_seq = this.request_seq; |
| 1315 } | 1320 } |
| 1316 json.type = this.type; | 1321 json.type = this.type; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1344 bodyJson = ObjectToProtocolObject_(this.body, serializer); | 1349 bodyJson = ObjectToProtocolObject_(this.body, serializer); |
| 1345 } | 1350 } |
| 1346 json.body = bodyJson; | 1351 json.body = bodyJson; |
| 1347 json.refs = serializer.serializeReferencedObjects(); | 1352 json.refs = serializer.serializeReferencedObjects(); |
| 1348 } | 1353 } |
| 1349 if (this.message) { | 1354 if (this.message) { |
| 1350 json.message = this.message; | 1355 json.message = this.message; |
| 1351 } | 1356 } |
| 1352 json.running = this.running; | 1357 json.running = this.running; |
| 1353 return JSON.stringify(json); | 1358 return JSON.stringify(json); |
| 1354 } | 1359 }; |
| 1355 | 1360 |
| 1356 | 1361 |
| 1357 DebugCommandProcessor.prototype.createResponse = function(request) { | 1362 DebugCommandProcessor.prototype.createResponse = function(request) { |
| 1358 return new ProtocolMessage(request); | 1363 return new ProtocolMessage(request); |
| 1359 }; | 1364 }; |
| 1360 | 1365 |
| 1361 | 1366 |
| 1362 DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request)
{ | 1367 DebugCommandProcessor.prototype.processDebugJSONRequest = function( |
| 1368 json_request) { |
| 1363 var request; // Current request. | 1369 var request; // Current request. |
| 1364 var response; // Generated response. | 1370 var response; // Generated response. |
| 1365 try { | 1371 try { |
| 1366 try { | 1372 try { |
| 1367 // Convert the JSON string to an object. | 1373 // Convert the JSON string to an object. |
| 1368 request = JSON.parse(json_request); | 1374 request = JSON.parse(json_request); |
| 1369 | 1375 |
| 1370 // Create an initial response. | 1376 // Create an initial response. |
| 1371 response = this.createResponse(request); | 1377 response = this.createResponse(request); |
| 1372 | 1378 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 var break_point = Debug.findBreakPoint(break_point_number); | 1645 var break_point = Debug.findBreakPoint(break_point_number); |
| 1640 if (ignoreCount) { | 1646 if (ignoreCount) { |
| 1641 Debug.changeBreakPointIgnoreCount(break_point_number, ignoreCount); | 1647 Debug.changeBreakPointIgnoreCount(break_point_number, ignoreCount); |
| 1642 } | 1648 } |
| 1643 if (!enabled) { | 1649 if (!enabled) { |
| 1644 Debug.disableBreakPoint(break_point_number); | 1650 Debug.disableBreakPoint(break_point_number); |
| 1645 } | 1651 } |
| 1646 | 1652 |
| 1647 // Add the break point number to the response. | 1653 // Add the break point number to the response. |
| 1648 response.body = { type: type, | 1654 response.body = { type: type, |
| 1649 breakpoint: break_point_number } | 1655 breakpoint: break_point_number }; |
| 1650 | 1656 |
| 1651 // Add break point information to the response. | 1657 // Add break point information to the response. |
| 1652 if (break_point instanceof ScriptBreakPoint) { | 1658 if (break_point instanceof ScriptBreakPoint) { |
| 1653 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 1659 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
| 1654 response.body.type = 'scriptId'; | 1660 response.body.type = 'scriptId'; |
| 1655 response.body.script_id = break_point.script_id(); | 1661 response.body.script_id = break_point.script_id(); |
| 1656 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { | 1662 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { |
| 1657 response.body.type = 'scriptName'; | 1663 response.body.type = 'scriptName'; |
| 1658 response.body.script_name = break_point.script_name(); | 1664 response.body.script_name = break_point.script_name(); |
| 1659 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { | 1665 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { |
| 1660 response.body.type = 'scriptRegExp'; | 1666 response.body.type = 'scriptRegExp'; |
| 1661 response.body.script_regexp = break_point.script_regexp_object().source; | 1667 response.body.script_regexp = break_point.script_regexp_object().source; |
| 1662 } else { | 1668 } else { |
| 1663 throw new Error("Internal error: Unexpected breakpoint type: " + break_poi
nt.type()); | 1669 throw new Error("Internal error: Unexpected breakpoint type: " + |
| 1670 break_point.type()); |
| 1664 } | 1671 } |
| 1665 response.body.line = break_point.line(); | 1672 response.body.line = break_point.line(); |
| 1666 response.body.column = break_point.column(); | 1673 response.body.column = break_point.column(); |
| 1667 response.body.actual_locations = break_point.actual_locations(); | 1674 response.body.actual_locations = break_point.actual_locations(); |
| 1668 } else { | 1675 } else { |
| 1669 response.body.type = 'function'; | 1676 response.body.type = 'function'; |
| 1670 response.body.actual_locations = [break_point.actual_location]; | 1677 response.body.actual_locations = [break_point.actual_location]; |
| 1671 } | 1678 } |
| 1672 }; | 1679 }; |
| 1673 | 1680 |
| 1674 | 1681 |
| 1675 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(request, res
ponse) { | 1682 DebugCommandProcessor.prototype.changeBreakPointRequest_ = function( |
| 1683 request, response) { |
| 1676 // Check for legal request. | 1684 // Check for legal request. |
| 1677 if (!request.arguments) { | 1685 if (!request.arguments) { |
| 1678 response.failed('Missing arguments'); | 1686 response.failed('Missing arguments'); |
| 1679 return; | 1687 return; |
| 1680 } | 1688 } |
| 1681 | 1689 |
| 1682 // Pull out arguments. | 1690 // Pull out arguments. |
| 1683 var break_point = %ToNumber(request.arguments.breakpoint); | 1691 var break_point = %ToNumber(request.arguments.breakpoint); |
| 1684 var enabled = request.arguments.enabled; | 1692 var enabled = request.arguments.enabled; |
| 1685 var condition = request.arguments.condition; | 1693 var condition = request.arguments.condition; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1702 | 1710 |
| 1703 // Change condition if supplied | 1711 // Change condition if supplied |
| 1704 if (!IS_UNDEFINED(condition)) { | 1712 if (!IS_UNDEFINED(condition)) { |
| 1705 Debug.changeBreakPointCondition(break_point, condition); | 1713 Debug.changeBreakPointCondition(break_point, condition); |
| 1706 } | 1714 } |
| 1707 | 1715 |
| 1708 // Change ignore count if supplied | 1716 // Change ignore count if supplied |
| 1709 if (!IS_UNDEFINED(ignoreCount)) { | 1717 if (!IS_UNDEFINED(ignoreCount)) { |
| 1710 Debug.changeBreakPointIgnoreCount(break_point, ignoreCount); | 1718 Debug.changeBreakPointIgnoreCount(break_point, ignoreCount); |
| 1711 } | 1719 } |
| 1712 } | 1720 }; |
| 1713 | 1721 |
| 1714 | 1722 |
| 1715 DebugCommandProcessor.prototype.clearBreakPointGroupRequest_ = function(request,
response) { | 1723 DebugCommandProcessor.prototype.clearBreakPointGroupRequest_ = function( |
| 1724 request, response) { |
| 1716 // Check for legal request. | 1725 // Check for legal request. |
| 1717 if (!request.arguments) { | 1726 if (!request.arguments) { |
| 1718 response.failed('Missing arguments'); | 1727 response.failed('Missing arguments'); |
| 1719 return; | 1728 return; |
| 1720 } | 1729 } |
| 1721 | 1730 |
| 1722 // Pull out arguments. | 1731 // Pull out arguments. |
| 1723 var group_id = request.arguments.groupId; | 1732 var group_id = request.arguments.groupId; |
| 1724 | 1733 |
| 1725 // Check for legal arguments. | 1734 // Check for legal arguments. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1736 cleared_break_points.push(next_break_point.number()); | 1745 cleared_break_points.push(next_break_point.number()); |
| 1737 next_break_point.clear(); | 1746 next_break_point.clear(); |
| 1738 } else { | 1747 } else { |
| 1739 new_script_break_points.push(next_break_point); | 1748 new_script_break_points.push(next_break_point); |
| 1740 } | 1749 } |
| 1741 } | 1750 } |
| 1742 script_break_points = new_script_break_points; | 1751 script_break_points = new_script_break_points; |
| 1743 | 1752 |
| 1744 // Add the cleared break point numbers to the response. | 1753 // Add the cleared break point numbers to the response. |
| 1745 response.body = { breakpoints: cleared_break_points }; | 1754 response.body = { breakpoints: cleared_break_points }; |
| 1746 } | 1755 }; |
| 1747 | 1756 |
| 1748 | 1757 |
| 1749 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(request, resp
onse) { | 1758 DebugCommandProcessor.prototype.clearBreakPointRequest_ = function( |
| 1759 request, response) { |
| 1750 // Check for legal request. | 1760 // Check for legal request. |
| 1751 if (!request.arguments) { | 1761 if (!request.arguments) { |
| 1752 response.failed('Missing arguments'); | 1762 response.failed('Missing arguments'); |
| 1753 return; | 1763 return; |
| 1754 } | 1764 } |
| 1755 | 1765 |
| 1756 // Pull out arguments. | 1766 // Pull out arguments. |
| 1757 var break_point = %ToNumber(request.arguments.breakpoint); | 1767 var break_point = %ToNumber(request.arguments.breakpoint); |
| 1758 | 1768 |
| 1759 // Check for legal arguments. | 1769 // Check for legal arguments. |
| 1760 if (!break_point) { | 1770 if (!break_point) { |
| 1761 response.failed('Missing argument "breakpoint"'); | 1771 response.failed('Missing argument "breakpoint"'); |
| 1762 return; | 1772 return; |
| 1763 } | 1773 } |
| 1764 | 1774 |
| 1765 // Clear break point. | 1775 // Clear break point. |
| 1766 Debug.clearBreakPoint(break_point); | 1776 Debug.clearBreakPoint(break_point); |
| 1767 | 1777 |
| 1768 // Add the cleared break point number to the response. | 1778 // Add the cleared break point number to the response. |
| 1769 response.body = { breakpoint: break_point } | 1779 response.body = { breakpoint: break_point }; |
| 1770 } | 1780 }; |
| 1771 | 1781 |
| 1772 | 1782 |
| 1773 DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, resp
onse) { | 1783 DebugCommandProcessor.prototype.listBreakpointsRequest_ = function( |
| 1784 request, response) { |
| 1774 var array = []; | 1785 var array = []; |
| 1775 for (var i = 0; i < script_break_points.length; i++) { | 1786 for (var i = 0; i < script_break_points.length; i++) { |
| 1776 var break_point = script_break_points[i]; | 1787 var break_point = script_break_points[i]; |
| 1777 | 1788 |
| 1778 var description = { | 1789 var description = { |
| 1779 number: break_point.number(), | 1790 number: break_point.number(), |
| 1780 line: break_point.line(), | 1791 line: break_point.line(), |
| 1781 column: break_point.column(), | 1792 column: break_point.column(), |
| 1782 groupId: break_point.groupId(), | 1793 groupId: break_point.groupId(), |
| 1783 hit_count: break_point.hit_count(), | 1794 hit_count: break_point.hit_count(), |
| 1784 active: break_point.active(), | 1795 active: break_point.active(), |
| 1785 condition: break_point.condition(), | 1796 condition: break_point.condition(), |
| 1786 ignoreCount: break_point.ignoreCount(), | 1797 ignoreCount: break_point.ignoreCount(), |
| 1787 actual_locations: break_point.actual_locations() | 1798 actual_locations: break_point.actual_locations() |
| 1788 } | 1799 }; |
| 1789 | 1800 |
| 1790 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { | 1801 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { |
| 1791 description.type = 'scriptId'; | 1802 description.type = 'scriptId'; |
| 1792 description.script_id = break_point.script_id(); | 1803 description.script_id = break_point.script_id(); |
| 1793 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { | 1804 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { |
| 1794 description.type = 'scriptName'; | 1805 description.type = 'scriptName'; |
| 1795 description.script_name = break_point.script_name(); | 1806 description.script_name = break_point.script_name(); |
| 1796 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { | 1807 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { |
| 1797 description.type = 'scriptRegExp'; | 1808 description.type = 'scriptRegExp'; |
| 1798 description.script_regexp = break_point.script_regexp_object().source; | 1809 description.script_regexp = break_point.script_regexp_object().source; |
| 1799 } else { | 1810 } else { |
| 1800 throw new Error("Internal error: Unexpected breakpoint type: " + break_poi
nt.type()); | 1811 throw new Error("Internal error: Unexpected breakpoint type: " + |
| 1812 break_point.type()); |
| 1801 } | 1813 } |
| 1802 array.push(description); | 1814 array.push(description); |
| 1803 } | 1815 } |
| 1804 | 1816 |
| 1805 response.body = { | 1817 response.body = { |
| 1806 breakpoints: array, | 1818 breakpoints: array, |
| 1807 breakOnExceptions: Debug.isBreakOnException(), | 1819 breakOnExceptions: Debug.isBreakOnException(), |
| 1808 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException() | 1820 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException() |
| 1809 } | 1821 }; |
| 1810 } | 1822 }; |
| 1811 | 1823 |
| 1812 | 1824 |
| 1813 DebugCommandProcessor.prototype.disconnectRequest_ = | 1825 DebugCommandProcessor.prototype.disconnectRequest_ = |
| 1814 function(request, response) { | 1826 function(request, response) { |
| 1815 Debug.disableAllBreakPoints(); | 1827 Debug.disableAllBreakPoints(); |
| 1816 this.continueRequest_(request, response); | 1828 this.continueRequest_(request, response); |
| 1817 } | 1829 }; |
| 1818 | 1830 |
| 1819 | 1831 |
| 1820 DebugCommandProcessor.prototype.setExceptionBreakRequest_ = | 1832 DebugCommandProcessor.prototype.setExceptionBreakRequest_ = |
| 1821 function(request, response) { | 1833 function(request, response) { |
| 1822 // Check for legal request. | 1834 // Check for legal request. |
| 1823 if (!request.arguments) { | 1835 if (!request.arguments) { |
| 1824 response.failed('Missing arguments'); | 1836 response.failed('Missing arguments'); |
| 1825 return; | 1837 return; |
| 1826 } | 1838 } |
| 1827 | 1839 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1852 if (type == 'all') { | 1864 if (type == 'all') { |
| 1853 %ChangeBreakOnException(Debug.ExceptionBreak.Caught, enabled); | 1865 %ChangeBreakOnException(Debug.ExceptionBreak.Caught, enabled); |
| 1854 } else if (type == 'uncaught') { | 1866 } else if (type == 'uncaught') { |
| 1855 %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, enabled); | 1867 %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, enabled); |
| 1856 } else { | 1868 } else { |
| 1857 response.failed('Unknown "type":"' + type + '"'); | 1869 response.failed('Unknown "type":"' + type + '"'); |
| 1858 } | 1870 } |
| 1859 | 1871 |
| 1860 // Add the cleared break point number to the response. | 1872 // Add the cleared break point number to the response. |
| 1861 response.body = { 'type': type, 'enabled': enabled }; | 1873 response.body = { 'type': type, 'enabled': enabled }; |
| 1862 } | 1874 }; |
| 1863 | 1875 |
| 1864 | 1876 |
| 1865 DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response)
{ | 1877 DebugCommandProcessor.prototype.backtraceRequest_ = function( |
| 1878 request, response) { |
| 1866 // Get the number of frames. | 1879 // Get the number of frames. |
| 1867 var total_frames = this.exec_state_.frameCount(); | 1880 var total_frames = this.exec_state_.frameCount(); |
| 1868 | 1881 |
| 1869 // Create simple response if there are no frames. | 1882 // Create simple response if there are no frames. |
| 1870 if (total_frames == 0) { | 1883 if (total_frames == 0) { |
| 1871 response.body = { | 1884 response.body = { |
| 1872 totalFrames: total_frames | 1885 totalFrames: total_frames |
| 1873 } | 1886 }; |
| 1874 return; | 1887 return; |
| 1875 } | 1888 } |
| 1876 | 1889 |
| 1877 // Default frame range to include in backtrace. | 1890 // Default frame range to include in backtrace. |
| 1878 var from_index = 0 | 1891 var from_index = 0; |
| 1879 var to_index = kDefaultBacktraceLength; | 1892 var to_index = kDefaultBacktraceLength; |
| 1880 | 1893 |
| 1881 // Get the range from the arguments. | 1894 // Get the range from the arguments. |
| 1882 if (request.arguments) { | 1895 if (request.arguments) { |
| 1883 if (request.arguments.fromFrame) { | 1896 if (request.arguments.fromFrame) { |
| 1884 from_index = request.arguments.fromFrame; | 1897 from_index = request.arguments.fromFrame; |
| 1885 } | 1898 } |
| 1886 if (request.arguments.toFrame) { | 1899 if (request.arguments.toFrame) { |
| 1887 to_index = request.arguments.toFrame; | 1900 to_index = request.arguments.toFrame; |
| 1888 } | 1901 } |
| 1889 if (request.arguments.bottom) { | 1902 if (request.arguments.bottom) { |
| 1890 var tmp_index = total_frames - from_index; | 1903 var tmp_index = total_frames - from_index; |
| 1891 from_index = total_frames - to_index | 1904 from_index = total_frames - to_index; |
| 1892 to_index = tmp_index; | 1905 to_index = tmp_index; |
| 1893 } | 1906 } |
| 1894 if (from_index < 0 || to_index < 0) { | 1907 if (from_index < 0 || to_index < 0) { |
| 1895 return response.failed('Invalid frame number'); | 1908 return response.failed('Invalid frame number'); |
| 1896 } | 1909 } |
| 1897 } | 1910 } |
| 1898 | 1911 |
| 1899 // Adjust the index. | 1912 // Adjust the index. |
| 1900 to_index = Math.min(total_frames, to_index); | 1913 to_index = Math.min(total_frames, to_index); |
| 1901 | 1914 |
| 1902 if (to_index <= from_index) { | 1915 if (to_index <= from_index) { |
| 1903 var error = 'Invalid frame range'; | 1916 var error = 'Invalid frame range'; |
| 1904 return response.failed(error); | 1917 return response.failed(error); |
| 1905 } | 1918 } |
| 1906 | 1919 |
| 1907 // Create the response body. | 1920 // Create the response body. |
| 1908 var frames = []; | 1921 var frames = []; |
| 1909 for (var i = from_index; i < to_index; i++) { | 1922 for (var i = from_index; i < to_index; i++) { |
| 1910 frames.push(this.exec_state_.frame(i)); | 1923 frames.push(this.exec_state_.frame(i)); |
| 1911 } | 1924 } |
| 1912 response.body = { | 1925 response.body = { |
| 1913 fromFrame: from_index, | 1926 fromFrame: from_index, |
| 1914 toFrame: to_index, | 1927 toFrame: to_index, |
| 1915 totalFrames: total_frames, | 1928 totalFrames: total_frames, |
| 1916 frames: frames | 1929 frames: frames |
| 1917 } | 1930 }; |
| 1918 }; | 1931 }; |
| 1919 | 1932 |
| 1920 | 1933 |
| 1921 DebugCommandProcessor.prototype.frameRequest_ = function(request, response) { | 1934 DebugCommandProcessor.prototype.frameRequest_ = function(request, response) { |
| 1922 // No frames no source. | 1935 // No frames no source. |
| 1923 if (this.exec_state_.frameCount() == 0) { | 1936 if (this.exec_state_.frameCount() == 0) { |
| 1924 return response.failed('No frames'); | 1937 return response.failed('No frames'); |
| 1925 } | 1938 } |
| 1926 | 1939 |
| 1927 // With no arguments just keep the selected frame. | 1940 // With no arguments just keep the selected frame. |
| 1928 if (request.arguments) { | 1941 if (request.arguments) { |
| 1929 var index = request.arguments.number; | 1942 var index = request.arguments.number; |
| 1930 if (index < 0 || this.exec_state_.frameCount() <= index) { | 1943 if (index < 0 || this.exec_state_.frameCount() <= index) { |
| 1931 return response.failed('Invalid frame number'); | 1944 return response.failed('Invalid frame number'); |
| 1932 } | 1945 } |
| 1933 | 1946 |
| 1934 this.exec_state_.setSelectedFrame(request.arguments.number); | 1947 this.exec_state_.setSelectedFrame(request.arguments.number); |
| 1935 } | 1948 } |
| 1936 response.body = this.exec_state_.frame(); | 1949 response.body = this.exec_state_.frame(); |
| 1937 }; | 1950 }; |
| 1938 | 1951 |
| 1939 | 1952 |
| 1940 DebugCommandProcessor.prototype.frameForScopeRequest_ = function(request) { | 1953 DebugCommandProcessor.prototype.frameForScopeRequest_ = function(request) { |
| 1941 // Get the frame for which the scope or scopes are requested. With no frameNum
ber | 1954 // Get the frame for which the scope or scopes are requested. |
| 1942 // argument use the currently selected frame. | 1955 // With no frameNumber argument use the currently selected frame. |
| 1943 if (request.arguments && !IS_UNDEFINED(request.arguments.frameNumber)) { | 1956 if (request.arguments && !IS_UNDEFINED(request.arguments.frameNumber)) { |
| 1944 frame_index = request.arguments.frameNumber; | 1957 frame_index = request.arguments.frameNumber; |
| 1945 if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) { | 1958 if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) { |
| 1946 return response.failed('Invalid frame number'); | 1959 return response.failed('Invalid frame number'); |
| 1947 } | 1960 } |
| 1948 return this.exec_state_.frame(frame_index); | 1961 return this.exec_state_.frame(frame_index); |
| 1949 } else { | 1962 } else { |
| 1950 return this.exec_state_.frame(); | 1963 return this.exec_state_.frame(); |
| 1951 } | 1964 } |
| 1952 } | 1965 }; |
| 1953 | 1966 |
| 1954 | 1967 |
| 1955 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) { | 1968 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) { |
| 1956 // No frames no scopes. | 1969 // No frames no scopes. |
| 1957 if (this.exec_state_.frameCount() == 0) { | 1970 if (this.exec_state_.frameCount() == 0) { |
| 1958 return response.failed('No scopes'); | 1971 return response.failed('No scopes'); |
| 1959 } | 1972 } |
| 1960 | 1973 |
| 1961 // Get the frame for which the scopes are requested. | 1974 // Get the frame for which the scopes are requested. |
| 1962 var frame = this.frameForScopeRequest_(request); | 1975 var frame = this.frameForScopeRequest_(request); |
| 1963 | 1976 |
| 1964 // Fill all scopes for this frame. | 1977 // Fill all scopes for this frame. |
| 1965 var total_scopes = frame.scopeCount(); | 1978 var total_scopes = frame.scopeCount(); |
| 1966 var scopes = []; | 1979 var scopes = []; |
| 1967 for (var i = 0; i < total_scopes; i++) { | 1980 for (var i = 0; i < total_scopes; i++) { |
| 1968 scopes.push(frame.scope(i)); | 1981 scopes.push(frame.scope(i)); |
| 1969 } | 1982 } |
| 1970 response.body = { | 1983 response.body = { |
| 1971 fromScope: 0, | 1984 fromScope: 0, |
| 1972 toScope: total_scopes, | 1985 toScope: total_scopes, |
| 1973 totalScopes: total_scopes, | 1986 totalScopes: total_scopes, |
| 1974 scopes: scopes | 1987 scopes: scopes |
| 1975 } | 1988 }; |
| 1976 }; | 1989 }; |
| 1977 | 1990 |
| 1978 | 1991 |
| 1979 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { | 1992 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { |
| 1980 // No frames no scopes. | 1993 // No frames no scopes. |
| 1981 if (this.exec_state_.frameCount() == 0) { | 1994 if (this.exec_state_.frameCount() == 0) { |
| 1982 return response.failed('No scopes'); | 1995 return response.failed('No scopes'); |
| 1983 } | 1996 } |
| 1984 | 1997 |
| 1985 // Get the frame for which the scope is requested. | 1998 // Get the frame for which the scope is requested. |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 | 2223 |
| 2211 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { | 2224 DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) { |
| 2212 var types = ScriptTypeFlag(Debug.ScriptType.Normal); | 2225 var types = ScriptTypeFlag(Debug.ScriptType.Normal); |
| 2213 var includeSource = false; | 2226 var includeSource = false; |
| 2214 var idsToInclude = null; | 2227 var idsToInclude = null; |
| 2215 if (request.arguments) { | 2228 if (request.arguments) { |
| 2216 // Pull out arguments. | 2229 // Pull out arguments. |
| 2217 if (!IS_UNDEFINED(request.arguments.types)) { | 2230 if (!IS_UNDEFINED(request.arguments.types)) { |
| 2218 types = %ToNumber(request.arguments.types); | 2231 types = %ToNumber(request.arguments.types); |
| 2219 if (isNaN(types) || types < 0) { | 2232 if (isNaN(types) || types < 0) { |
| 2220 return response.failed('Invalid types "' + request.arguments.types + '"'
); | 2233 return response.failed('Invalid types "' + |
| 2234 request.arguments.types + '"'); |
| 2221 } | 2235 } |
| 2222 } | 2236 } |
| 2223 | 2237 |
| 2224 if (!IS_UNDEFINED(request.arguments.includeSource)) { | 2238 if (!IS_UNDEFINED(request.arguments.includeSource)) { |
| 2225 includeSource = %ToBoolean(request.arguments.includeSource); | 2239 includeSource = %ToBoolean(request.arguments.includeSource); |
| 2226 response.setOption('includeSource', includeSource); | 2240 response.setOption('includeSource', includeSource); |
| 2227 } | 2241 } |
| 2228 | 2242 |
| 2229 if (IS_ARRAY(request.arguments.ids)) { | 2243 if (IS_ARRAY(request.arguments.ids)) { |
| 2230 idsToInclude = {}; | 2244 idsToInclude = {}; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { | 2293 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { |
| 2280 // Get the number of threads. | 2294 // Get the number of threads. |
| 2281 var total_threads = this.exec_state_.threadCount(); | 2295 var total_threads = this.exec_state_.threadCount(); |
| 2282 | 2296 |
| 2283 // Get information for all threads. | 2297 // Get information for all threads. |
| 2284 var threads = []; | 2298 var threads = []; |
| 2285 for (var i = 0; i < total_threads; i++) { | 2299 for (var i = 0; i < total_threads; i++) { |
| 2286 var details = %GetThreadDetails(this.exec_state_.break_id, i); | 2300 var details = %GetThreadDetails(this.exec_state_.break_id, i); |
| 2287 var thread_info = { current: details[0], | 2301 var thread_info = { current: details[0], |
| 2288 id: details[1] | 2302 id: details[1] |
| 2289 } | 2303 }; |
| 2290 threads.push(thread_info); | 2304 threads.push(thread_info); |
| 2291 } | 2305 } |
| 2292 | 2306 |
| 2293 // Create the response body. | 2307 // Create the response body. |
| 2294 response.body = { | 2308 response.body = { |
| 2295 totalThreads: total_threads, | 2309 totalThreads: total_threads, |
| 2296 threads: threads | 2310 threads: threads |
| 2297 } | 2311 }; |
| 2298 }; | 2312 }; |
| 2299 | 2313 |
| 2300 | 2314 |
| 2301 DebugCommandProcessor.prototype.suspendRequest_ = function(request, response) { | 2315 DebugCommandProcessor.prototype.suspendRequest_ = function(request, response) { |
| 2302 response.running = false; | 2316 response.running = false; |
| 2303 }; | 2317 }; |
| 2304 | 2318 |
| 2305 | 2319 |
| 2306 DebugCommandProcessor.prototype.versionRequest_ = function(request, response) { | 2320 DebugCommandProcessor.prototype.versionRequest_ = function(request, response) { |
| 2307 response.body = { | 2321 response.body = { |
| 2308 V8Version: %GetV8Version() | 2322 V8Version: %GetV8Version() |
| 2309 } | 2323 }; |
| 2310 }; | 2324 }; |
| 2311 | 2325 |
| 2312 | 2326 |
| 2313 DebugCommandProcessor.prototype.profileRequest_ = function(request, response) { | 2327 DebugCommandProcessor.prototype.profileRequest_ = function(request, response) { |
| 2314 if (request.arguments.command == 'resume') { | 2328 if (request.arguments.command == 'resume') { |
| 2315 %ProfilerResume(); | 2329 %ProfilerResume(); |
| 2316 } else if (request.arguments.command == 'pause') { | 2330 } else if (request.arguments.command == 'pause') { |
| 2317 %ProfilerPause(); | 2331 %ProfilerPause(); |
| 2318 } else { | 2332 } else { |
| 2319 return response.failed('Unknown command'); | 2333 return response.failed('Unknown command'); |
| 2320 } | 2334 } |
| 2321 response.body = {}; | 2335 response.body = {}; |
| 2322 }; | 2336 }; |
| 2323 | 2337 |
| 2324 | 2338 |
| 2325 DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
{ | 2339 DebugCommandProcessor.prototype.changeLiveRequest_ = function( |
| 2340 request, response) { |
| 2326 if (!Debug.LiveEdit) { | 2341 if (!Debug.LiveEdit) { |
| 2327 return response.failed('LiveEdit feature is not supported'); | 2342 return response.failed('LiveEdit feature is not supported'); |
| 2328 } | 2343 } |
| 2329 if (!request.arguments) { | 2344 if (!request.arguments) { |
| 2330 return response.failed('Missing arguments'); | 2345 return response.failed('Missing arguments'); |
| 2331 } | 2346 } |
| 2332 var script_id = request.arguments.script_id; | 2347 var script_id = request.arguments.script_id; |
| 2333 var preview_only = !!request.arguments.preview_only; | 2348 var preview_only = !!request.arguments.preview_only; |
| 2334 | 2349 |
| 2335 var scripts = %DebugGetLoadedScripts(); | 2350 var scripts = %DebugGetLoadedScripts(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2386 debugger_flag.setValue(flags[i].value); | 2401 debugger_flag.setValue(flags[i].value); |
| 2387 } | 2402 } |
| 2388 response.body.flags.push({ name: name, value: debugger_flag.getValue() }); | 2403 response.body.flags.push({ name: name, value: debugger_flag.getValue() }); |
| 2389 } | 2404 } |
| 2390 } else { | 2405 } else { |
| 2391 for (var name in debugger_flags) { | 2406 for (var name in debugger_flags) { |
| 2392 var value = debugger_flags[name].getValue(); | 2407 var value = debugger_flags[name].getValue(); |
| 2393 response.body.flags.push({ name: name, value: value }); | 2408 response.body.flags.push({ name: name, value: value }); |
| 2394 } | 2409 } |
| 2395 } | 2410 } |
| 2396 } | 2411 }; |
| 2397 | 2412 |
| 2398 | 2413 |
| 2399 DebugCommandProcessor.prototype.v8FlagsRequest_ = function(request, response) { | 2414 DebugCommandProcessor.prototype.v8FlagsRequest_ = function(request, response) { |
| 2400 var flags = request.arguments.flags; | 2415 var flags = request.arguments.flags; |
| 2401 if (!flags) flags = ''; | 2416 if (!flags) flags = ''; |
| 2402 %SetFlags(flags); | 2417 %SetFlags(flags); |
| 2403 }; | 2418 }; |
| 2404 | 2419 |
| 2405 | 2420 |
| 2406 DebugCommandProcessor.prototype.gcRequest_ = function(request, response) { | 2421 DebugCommandProcessor.prototype.gcRequest_ = function(request, response) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 var id = request.arguments.id; | 2507 var id = request.arguments.id; |
| 2493 response.body = {}; | 2508 response.body = {}; |
| 2494 response.body.dump = %PrintLOLObj(id); | 2509 response.body.dump = %PrintLOLObj(id); |
| 2495 }; | 2510 }; |
| 2496 | 2511 |
| 2497 | 2512 |
| 2498 // Check whether the previously processed command caused the VM to become | 2513 // Check whether the previously processed command caused the VM to become |
| 2499 // running. | 2514 // running. |
| 2500 DebugCommandProcessor.prototype.isRunning = function() { | 2515 DebugCommandProcessor.prototype.isRunning = function() { |
| 2501 return this.running_; | 2516 return this.running_; |
| 2502 } | 2517 }; |
| 2503 | 2518 |
| 2504 | 2519 |
| 2505 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { | 2520 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { |
| 2506 return %SystemBreak(); | 2521 return %SystemBreak(); |
| 2507 }; | 2522 }; |
| 2508 | 2523 |
| 2509 | 2524 |
| 2510 function NumberToHex8Str(n) { | 2525 function NumberToHex8Str(n) { |
| 2511 var r = ""; | 2526 var r = ""; |
| 2512 for (var i = 0; i < 8; ++i) { | 2527 for (var i = 0; i < 8; ++i) { |
| 2513 var c = hexCharArray[n & 0x0F]; // hexCharArray is defined in uri.js | 2528 var c = hexCharArray[n & 0x0F]; // hexCharArray is defined in uri.js |
| 2514 r = c + r; | 2529 r = c + r; |
| 2515 n = n >>> 4; | 2530 n = n >>> 4; |
| 2516 } | 2531 } |
| 2517 return r; | 2532 return r; |
| 2518 }; | 2533 } |
| 2519 | 2534 |
| 2520 | 2535 |
| 2521 /** | 2536 /** |
| 2522 * Convert an Object to its debugger protocol representation. The representation | 2537 * Convert an Object to its debugger protocol representation. The representation |
| 2523 * may be serilized to a JSON object using JSON.stringify(). | 2538 * may be serilized to a JSON object using JSON.stringify(). |
| 2524 * This implementation simply runs through all string property names, converts | 2539 * This implementation simply runs through all string property names, converts |
| 2525 * each property value to a protocol value and adds the property to the result | 2540 * each property value to a protocol value and adds the property to the result |
| 2526 * object. For type "object" the function will be called recursively. Note that | 2541 * object. For type "object" the function will be called recursively. Note that |
| 2527 * circular structures will cause infinite recursion. | 2542 * circular structures will cause infinite recursion. |
| 2528 * @param {Object} object The object to format as protocol object. | 2543 * @param {Object} object The object to format as protocol object. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2584 json = ArrayToProtocolArray_(value, mirror_serializer); | 2599 json = ArrayToProtocolArray_(value, mirror_serializer); |
| 2585 } else { | 2600 } else { |
| 2586 json = ObjectToProtocolObject_(value, mirror_serializer); | 2601 json = ObjectToProtocolObject_(value, mirror_serializer); |
| 2587 } | 2602 } |
| 2588 break; | 2603 break; |
| 2589 | 2604 |
| 2590 case 'boolean': | 2605 case 'boolean': |
| 2591 case 'string': | 2606 case 'string': |
| 2592 case 'number': | 2607 case 'number': |
| 2593 json = value; | 2608 json = value; |
| 2594 break | 2609 break; |
| 2595 | 2610 |
| 2596 default: | 2611 default: |
| 2597 json = null; | 2612 json = null; |
| 2598 } | 2613 } |
| 2599 return json; | 2614 return json; |
| 2600 } | 2615 } |
| OLD | NEW |