| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 if (IS_UNDEFINED(script.sourceColumnStart_[line])) { | 315 if (IS_UNDEFINED(script.sourceColumnStart_[line])) { |
| 316 script.sourceColumnStart_[line] = | 316 script.sourceColumnStart_[line] = |
| 317 source_line.match(sourceLineBeginningSkip)[0].length; | 317 source_line.match(sourceLineBeginningSkip)[0].length; |
| 318 } | 318 } |
| 319 column = script.sourceColumnStart_[line]; | 319 column = script.sourceColumnStart_[line]; |
| 320 } | 320 } |
| 321 | 321 |
| 322 // Convert the line and column into an absolute position within the script. | 322 // Convert the line and column into an absolute position within the script. |
| 323 var pos = Debug.findScriptSourcePosition(script, this.line(), column); | 323 var pos = Debug.findScriptSourcePosition(script, this.line(), column); |
| 324 | 324 |
| 325 // If the position is not found in the script (the script might be shorter |
| 326 // than it used to be) just ignore it. |
| 327 if (pos === null) return; |
| 328 |
| 325 // Create a break point object and set the break point. | 329 // Create a break point object and set the break point. |
| 326 break_point = MakeBreakPoint(pos, this.line(), this.column(), this); | 330 break_point = MakeBreakPoint(pos, this.line(), this.column(), this); |
| 327 break_point.setIgnoreCount(this.ignoreCount()); | 331 break_point.setIgnoreCount(this.ignoreCount()); |
| 328 %SetScriptBreakPoint(script, pos, break_point); | 332 %SetScriptBreakPoint(script, pos, break_point); |
| 329 | 333 |
| 330 return break_point; | 334 return break_point; |
| 331 }; | 335 }; |
| 332 | 336 |
| 333 | 337 |
| 334 // Clear all the break points created from this script break point | 338 // Clear all the break points created from this script break point |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 Debug.findFunctionSourcePosition = function(func, opt_line, opt_column) { | 440 Debug.findFunctionSourcePosition = function(func, opt_line, opt_column) { |
| 437 var script = %FunctionGetScript(func); | 441 var script = %FunctionGetScript(func); |
| 438 var script_offset = %FunctionGetScriptSourcePosition(func); | 442 var script_offset = %FunctionGetScriptSourcePosition(func); |
| 439 return script.locationFromLine(opt_line, opt_column, script_offset).position; | 443 return script.locationFromLine(opt_line, opt_column, script_offset).position; |
| 440 } | 444 } |
| 441 | 445 |
| 442 | 446 |
| 443 // Returns the character position in a script based on a line number and an | 447 // Returns the character position in a script based on a line number and an |
| 444 // optional position within that line. | 448 // optional position within that line. |
| 445 Debug.findScriptSourcePosition = function(script, opt_line, opt_column) { | 449 Debug.findScriptSourcePosition = function(script, opt_line, opt_column) { |
| 446 return script.locationFromLine(opt_line, opt_column).position; | 450 var location = script.locationFromLine(opt_line, opt_column); |
| 451 return location ? location.position : null; |
| 447 } | 452 } |
| 448 | 453 |
| 449 | 454 |
| 450 Debug.findBreakPoint = function(break_point_number, remove) { | 455 Debug.findBreakPoint = function(break_point_number, remove) { |
| 451 var break_point; | 456 var break_point; |
| 452 for (var i = 0; i < break_points.length; i++) { | 457 for (var i = 0; i < break_points.length; i++) { |
| 453 if (break_points[i].number() == break_point_number) { | 458 if (break_points[i].number() == break_point_number) { |
| 454 break_point = break_points[i]; | 459 break_point = break_points[i]; |
| 455 // Remove the break point from the list if requested. | 460 // Remove the break point from the list if requested. |
| 456 if (remove) { | 461 if (remove) { |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 return new BreakEvent(exec_state, break_points_hit); | 725 return new BreakEvent(exec_state, break_points_hit); |
| 721 } | 726 } |
| 722 | 727 |
| 723 | 728 |
| 724 function BreakEvent(exec_state, break_points_hit) { | 729 function BreakEvent(exec_state, break_points_hit) { |
| 725 this.exec_state_ = exec_state; | 730 this.exec_state_ = exec_state; |
| 726 this.break_points_hit_ = break_points_hit; | 731 this.break_points_hit_ = break_points_hit; |
| 727 } | 732 } |
| 728 | 733 |
| 729 | 734 |
| 735 BreakEvent.prototype.executionState = function() { |
| 736 return this.exec_state_; |
| 737 }; |
| 738 |
| 739 |
| 740 BreakEvent.prototype.eventType = function() { |
| 741 return Debug.DebugEvent.Break; |
| 742 }; |
| 743 |
| 744 |
| 730 BreakEvent.prototype.func = function() { | 745 BreakEvent.prototype.func = function() { |
| 731 return this.exec_state_.frame(0).func(); | 746 return this.exec_state_.frame(0).func(); |
| 732 }; | 747 }; |
| 733 | 748 |
| 734 | 749 |
| 735 BreakEvent.prototype.sourceLine = function() { | 750 BreakEvent.prototype.sourceLine = function() { |
| 736 return this.exec_state_.frame(0).sourceLine(); | 751 return this.exec_state_.frame(0).sourceLine(); |
| 737 }; | 752 }; |
| 738 | 753 |
| 739 | 754 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 } | 807 } |
| 793 | 808 |
| 794 return SimpleObjectToJSON_(o); | 809 return SimpleObjectToJSON_(o); |
| 795 }; | 810 }; |
| 796 | 811 |
| 797 | 812 |
| 798 function MakeExceptionEvent(exec_state, exception, uncaught) { | 813 function MakeExceptionEvent(exec_state, exception, uncaught) { |
| 799 return new ExceptionEvent(exec_state, exception, uncaught); | 814 return new ExceptionEvent(exec_state, exception, uncaught); |
| 800 } | 815 } |
| 801 | 816 |
| 817 |
| 802 function ExceptionEvent(exec_state, exception, uncaught) { | 818 function ExceptionEvent(exec_state, exception, uncaught) { |
| 803 this.exec_state_ = exec_state; | 819 this.exec_state_ = exec_state; |
| 804 this.exception_ = exception; | 820 this.exception_ = exception; |
| 805 this.uncaught_ = uncaught; | 821 this.uncaught_ = uncaught; |
| 806 } | 822 } |
| 807 | 823 |
| 824 |
| 825 ExceptionEvent.prototype.executionState = function() { |
| 826 return this.exec_state_; |
| 827 }; |
| 828 |
| 829 |
| 830 ExceptionEvent.prototype.eventType = function() { |
| 831 return Debug.DebugEvent.Exception; |
| 832 }; |
| 833 |
| 834 |
| 808 ExceptionEvent.prototype.uncaught = function() { | 835 ExceptionEvent.prototype.uncaught = function() { |
| 809 return this.uncaught_; | 836 return this.uncaught_; |
| 810 } | 837 } |
| 811 | 838 |
| 812 ExceptionEvent.prototype.func = function() { | 839 ExceptionEvent.prototype.func = function() { |
| 813 return this.exec_state_.frame(0).func(); | 840 return this.exec_state_.frame(0).func(); |
| 814 }; | 841 }; |
| 815 | 842 |
| 816 | 843 |
| 817 ExceptionEvent.prototype.sourceLine = function() { | 844 ExceptionEvent.prototype.sourceLine = function() { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 848 lineOffset: script.lineOffset(), | 875 lineOffset: script.lineOffset(), |
| 849 columnOffset: script.columnOffset(), | 876 columnOffset: script.columnOffset(), |
| 850 lineCount: script.lineCount() | 877 lineCount: script.lineCount() |
| 851 }; | 878 }; |
| 852 } | 879 } |
| 853 | 880 |
| 854 return SimpleObjectToJSON_(o); | 881 return SimpleObjectToJSON_(o); |
| 855 }; | 882 }; |
| 856 | 883 |
| 857 | 884 |
| 858 function MakeCompileEvent(script_source, script_name, script_function) { | 885 function MakeCompileEvent(script_source, script_name, script_function, before) { |
| 859 return new CompileEvent(script_source, script_name, script_function); | 886 return new CompileEvent(script_source, script_name, script_function, before); |
| 860 } | 887 } |
| 861 | 888 |
| 862 | 889 |
| 863 function CompileEvent(script_source, script_name, script_function) { | 890 function CompileEvent(script_source, script_name, script_function, before) { |
| 864 this.scriptSource = script_source; | 891 this.scriptSource = script_source; |
| 865 this.scriptName = script_name; | 892 this.scriptName = script_name; |
| 866 this.scriptFunction = script_function; | 893 this.scriptFunction = script_function; |
| 894 this.before = before; |
| 867 } | 895 } |
| 868 | 896 |
| 869 | 897 |
| 898 CompileEvent.prototype.eventType = function() { |
| 899 if (this.before) { |
| 900 return Debug.DebugEvent.BeforeComplie; |
| 901 } else { |
| 902 return Debug.DebugEvent.AfterComplie; |
| 903 } |
| 904 }; |
| 905 |
| 906 |
| 870 function MakeNewFunctionEvent(func) { | 907 function MakeNewFunctionEvent(func) { |
| 871 return new NewFunctionEvent(func); | 908 return new NewFunctionEvent(func); |
| 872 } | 909 } |
| 873 | 910 |
| 874 | 911 |
| 875 function NewFunctionEvent(func) { | 912 function NewFunctionEvent(func) { |
| 876 this.func = func; | 913 this.func = func; |
| 877 } | 914 } |
| 878 | 915 |
| 916 |
| 917 NewFunctionEvent.prototype.eventType = function() { |
| 918 return Debug.DebugEvent.NewFunction; |
| 919 }; |
| 920 |
| 921 |
| 879 NewFunctionEvent.prototype.name = function() { | 922 NewFunctionEvent.prototype.name = function() { |
| 880 return this.func.name; | 923 return this.func.name; |
| 881 }; | 924 }; |
| 882 | 925 |
| 883 | 926 |
| 884 NewFunctionEvent.prototype.setBreakPoint = function(p) { | 927 NewFunctionEvent.prototype.setBreakPoint = function(p) { |
| 885 Debug.setBreakPoint(this.func, p || 0); | 928 Debug.setBreakPoint(this.func, p || 0); |
| 886 }; | 929 }; |
| 887 | 930 |
| 888 | 931 |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1597 json += NumberToJSON_(elem); | 1640 json += NumberToJSON_(elem); |
| 1598 } else if (IS_STRING(elem)) { | 1641 } else if (IS_STRING(elem)) { |
| 1599 json += StringToJSON_(elem); | 1642 json += StringToJSON_(elem); |
| 1600 } else { | 1643 } else { |
| 1601 json += elem; | 1644 json += elem; |
| 1602 } | 1645 } |
| 1603 } | 1646 } |
| 1604 json += ']'; | 1647 json += ']'; |
| 1605 return json; | 1648 return json; |
| 1606 } | 1649 } |
| OLD | NEW |