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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 BreakEvent.prototype.sourceLineText = function() { | 745 BreakEvent.prototype.sourceLineText = function() { |
746 return this.exec_state_.frame(0).sourceLineText(); | 746 return this.exec_state_.frame(0).sourceLineText(); |
747 }; | 747 }; |
748 | 748 |
749 | 749 |
750 BreakEvent.prototype.breakPointsHit = function() { | 750 BreakEvent.prototype.breakPointsHit = function() { |
751 return this.break_points_hit_; | 751 return this.break_points_hit_; |
752 }; | 752 }; |
753 | 753 |
754 | 754 |
755 BreakEvent.prototype.details = function() { | |
756 // Build the break details. | |
757 var details = ''; | |
758 if (this.breakPointsHit()) { | |
759 details += 'breakpoint'; | |
760 if (this.breakPointsHit().length > 1) { | |
761 details += 's'; | |
762 } | |
763 details += ' '; | |
764 for (var i = 0; i < this.breakPointsHit().length; i++) { | |
765 if (i > 0) { | |
766 details += ','; | |
767 } | |
768 details += this.breakPointsHit()[i].number(); | |
769 } | |
770 } else { | |
771 details += 'break'; | |
772 } | |
773 details += ' in '; | |
774 details += this.exec_state_.frame(0).invocationText(); | |
775 details += ' at '; | |
776 details += this.exec_state_.frame(0).sourceAndPositionText(); | |
777 details += '\n' | |
778 if (this.func().script()) { | |
779 details += FrameSourceUnderline(this.exec_state_.frame(0)); | |
780 } | |
781 return details; | |
782 }; | |
783 | |
784 | |
785 BreakEvent.prototype.debugPrompt = function() { | |
786 // Build the debug break prompt. | |
787 if (this.breakPointsHit()) { | |
788 return 'breakpoint'; | |
789 } else { | |
790 return 'break'; | |
791 } | |
792 }; | |
793 | |
794 | |
795 BreakEvent.prototype.toJSONProtocol = function() { | 755 BreakEvent.prototype.toJSONProtocol = function() { |
796 var o = { seq: next_response_seq++, | 756 var o = { seq: next_response_seq++, |
797 type: "event", | 757 type: "event", |
798 event: "break", | 758 event: "break", |
799 body: { invocationText: this.exec_state_.frame(0).invocationText(), | 759 body: { invocationText: this.exec_state_.frame(0).invocationText(), |
800 } | 760 } |
801 } | 761 } |
802 | 762 |
803 // Add script related information to the event if available. | 763 // Add script related information to the event if available. |
804 var script = this.func().script(); | 764 var script = this.func().script(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 ExceptionEvent.prototype.sourceColumn = function() { | 822 ExceptionEvent.prototype.sourceColumn = function() { |
863 return this.exec_state_.frame(0).sourceColumn(); | 823 return this.exec_state_.frame(0).sourceColumn(); |
864 }; | 824 }; |
865 | 825 |
866 | 826 |
867 ExceptionEvent.prototype.sourceLineText = function() { | 827 ExceptionEvent.prototype.sourceLineText = function() { |
868 return this.exec_state_.frame(0).sourceLineText(); | 828 return this.exec_state_.frame(0).sourceLineText(); |
869 }; | 829 }; |
870 | 830 |
871 | 831 |
872 ExceptionEvent.prototype.details = function() { | |
873 var details = ""; | |
874 if (this.uncaught_) { | |
875 details += "Uncaught: "; | |
876 } else { | |
877 details += "Exception: "; | |
878 } | |
879 | |
880 details += '"'; | |
881 details += MakeMirror(this.exception_).toText(); | |
882 details += '" at '; | |
883 details += this.exec_state_.frame(0).sourceAndPositionText(); | |
884 details += '\n'; | |
885 details += FrameSourceUnderline(this.exec_state_.frame(0)); | |
886 | |
887 return details; | |
888 }; | |
889 | |
890 ExceptionEvent.prototype.debugPrompt = function() { | |
891 if (this.uncaught_) { | |
892 return "uncaught exception"; | |
893 } else { | |
894 return "exception"; | |
895 } | |
896 }; | |
897 | |
898 ExceptionEvent.prototype.toJSONProtocol = function() { | 832 ExceptionEvent.prototype.toJSONProtocol = function() { |
899 var o = { seq: next_response_seq++, | 833 var o = { seq: next_response_seq++, |
900 type: "event", | 834 type: "event", |
901 event: "exception", | 835 event: "exception", |
902 body: { uncaught: this.uncaught_, | 836 body: { uncaught: this.uncaught_, |
903 exception: MakeMirror(this.exception_), | 837 exception: MakeMirror(this.exception_), |
904 sourceLine: this.sourceLine(), | 838 sourceLine: this.sourceLine(), |
905 sourceColumn: this.sourceColumn(), | 839 sourceColumn: this.sourceColumn(), |
906 sourceLineText: this.sourceLineText(), | 840 sourceLineText: this.sourceLineText(), |
907 } | 841 } |
908 } | 842 } |
909 | 843 |
910 // Add script information to the event if available. | 844 // Add script information to the event if available. |
911 var script = this.func().script(); | 845 var script = this.func().script(); |
912 if (script) { | 846 if (script) { |
913 o.body.script = { name: script.name(), | 847 o.body.script = { name: script.name(), |
914 lineOffset: script.lineOffset(), | 848 lineOffset: script.lineOffset(), |
915 columnOffset: script.columnOffset(), | 849 columnOffset: script.columnOffset(), |
916 lineCount: script.lineCount() | 850 lineCount: script.lineCount() |
917 }; | 851 }; |
918 } | 852 } |
919 | 853 |
920 return SimpleObjectToJSON_(o); | 854 return SimpleObjectToJSON_(o); |
921 }; | 855 }; |
922 | 856 |
| 857 |
923 function MakeCompileEvent(script_source, script_name, script_function) { | 858 function MakeCompileEvent(script_source, script_name, script_function) { |
924 return new CompileEvent(script_source, script_name, script_function); | 859 return new CompileEvent(script_source, script_name, script_function); |
925 } | 860 } |
926 | 861 |
| 862 |
927 function CompileEvent(script_source, script_name, script_function) { | 863 function CompileEvent(script_source, script_name, script_function) { |
928 this.scriptSource = script_source; | 864 this.scriptSource = script_source; |
929 this.scriptName = script_name; | 865 this.scriptName = script_name; |
930 this.scriptFunction = script_function; | 866 this.scriptFunction = script_function; |
931 } | 867 } |
932 | 868 |
933 CompileEvent.prototype.details = function() { | |
934 var result = ""; | |
935 result = "Script added" | |
936 if (this.scriptData) { | |
937 result += ": '"; | |
938 result += this.scriptData; | |
939 result += "'"; | |
940 } | |
941 return result; | |
942 }; | |
943 | |
944 CompileEvent.prototype.debugPrompt = function() { | |
945 var result = "source" | |
946 if (this.scriptData) { | |
947 result += " '"; | |
948 result += this.scriptData; | |
949 result += "'"; | |
950 } | |
951 if (this.func) { | |
952 result += " added"; | |
953 } else { | |
954 result += " compiled"; | |
955 } | |
956 return result; | |
957 }; | |
958 | 869 |
959 function MakeNewFunctionEvent(func) { | 870 function MakeNewFunctionEvent(func) { |
960 return new NewFunctionEvent(func); | 871 return new NewFunctionEvent(func); |
961 } | 872 } |
962 | 873 |
| 874 |
963 function NewFunctionEvent(func) { | 875 function NewFunctionEvent(func) { |
964 this.func = func; | 876 this.func = func; |
965 } | 877 } |
966 | 878 |
967 NewFunctionEvent.prototype.details = function() { | |
968 var result = ""; | |
969 result = "Function added: "; | |
970 result += this.func.name; | |
971 return result; | |
972 }; | |
973 | |
974 NewFunctionEvent.prototype.debugPrompt = function() { | |
975 var result = "function"; | |
976 if (this.func.name) { | |
977 result += " '"; | |
978 result += this.func.name; | |
979 result += "'"; | |
980 } | |
981 result += " added"; | |
982 return result; | |
983 }; | |
984 | |
985 NewFunctionEvent.prototype.name = function() { | 879 NewFunctionEvent.prototype.name = function() { |
986 return this.func.name; | 880 return this.func.name; |
987 }; | 881 }; |
988 | 882 |
| 883 |
989 NewFunctionEvent.prototype.setBreakPoint = function(p) { | 884 NewFunctionEvent.prototype.setBreakPoint = function(p) { |
990 Debug.setBreakPoint(this.func, p || 0); | 885 Debug.setBreakPoint(this.func, p || 0); |
991 }; | 886 }; |
992 | 887 |
| 888 |
993 function DebugCommandProcessor(exec_state) { | 889 function DebugCommandProcessor(exec_state) { |
994 this.exec_state_ = exec_state; | 890 this.exec_state_ = exec_state; |
995 }; | 891 }; |
996 | 892 |
997 | 893 |
998 // Convenience function for C debugger code to process a text command. This | 894 // Convenience function for C debugger code to process a text command. This |
999 // function converts the text command to a JSON request, performs the request | 895 // function converts the text command to a JSON request, performs the request |
1000 // and converts the request to a text result for display. The result is an | 896 // and converts the request to a text result for display. The result is an |
1001 // object containing the text result and the intermediate results. | 897 // object containing the text result and the intermediate results. |
1002 DebugCommandProcessor.prototype.processDebugCommand = function (command) { | 898 DebugCommandProcessor.prototype.processDebugCommand = function (command) { |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 json += NumberToJSON_(elem); | 1908 json += NumberToJSON_(elem); |
2013 } else if (IS_STRING(elem)) { | 1909 } else if (IS_STRING(elem)) { |
2014 json += StringToJSON_(elem); | 1910 json += StringToJSON_(elem); |
2015 } else { | 1911 } else { |
2016 json += elem; | 1912 json += elem; |
2017 } | 1913 } |
2018 } | 1914 } |
2019 json += ']'; | 1915 json += ']'; |
2020 return json; | 1916 return json; |
2021 } | 1917 } |
OLD | NEW |