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 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 this.command = request.command; | 1055 this.command = request.command; |
1056 } else { | 1056 } else { |
1057 // If message is not based on a request it is a dabugger generated event. | 1057 // If message is not based on a request it is a dabugger generated event. |
1058 this.type = 'event'; | 1058 this.type = 'event'; |
1059 } | 1059 } |
1060 this.success = true; | 1060 this.success = true; |
1061 this.running = false; | 1061 this.running = false; |
1062 } | 1062 } |
1063 | 1063 |
1064 | 1064 |
| 1065 ProtocolMessage.prototype.setOption = function(name, value) { |
| 1066 if (!this.options_) { |
| 1067 this.options_ = {}; |
| 1068 } |
| 1069 this.options_[name] = value; |
| 1070 } |
| 1071 |
| 1072 |
1065 ProtocolMessage.prototype.failed = function(message) { | 1073 ProtocolMessage.prototype.failed = function(message) { |
1066 this.success = false; | 1074 this.success = false; |
1067 this.message = message; | 1075 this.message = message; |
1068 } | 1076 } |
1069 | 1077 |
1070 | 1078 |
1071 ProtocolMessage.prototype.toJSONProtocol = function() { | 1079 ProtocolMessage.prototype.toJSONProtocol = function() { |
1072 // Encode the protocol header. | 1080 // Encode the protocol header. |
1073 var json = '{'; | 1081 var json = '{'; |
1074 json += '"seq":' + this.seq; | 1082 json += '"seq":' + this.seq; |
1075 if (this.request_seq) { | 1083 if (this.request_seq) { |
1076 json += ',"request_seq":' + this.request_seq; | 1084 json += ',"request_seq":' + this.request_seq; |
1077 } | 1085 } |
1078 json += ',"type":"' + this.type + '"'; | 1086 json += ',"type":"' + this.type + '"'; |
1079 if (this.event) { | 1087 if (this.event) { |
1080 json += ',"event":' + StringToJSON_(this.event); | 1088 json += ',"event":' + StringToJSON_(this.event); |
1081 } | 1089 } |
1082 if (this.command) { | 1090 if (this.command) { |
1083 json += ',"command":' + StringToJSON_(this.command); | 1091 json += ',"command":' + StringToJSON_(this.command); |
1084 } | 1092 } |
1085 if (this.success) { | 1093 if (this.success) { |
1086 json += ',"success":' + this.success; | 1094 json += ',"success":' + this.success; |
1087 } else { | 1095 } else { |
1088 json += ',"success":false'; | 1096 json += ',"success":false'; |
1089 } | 1097 } |
1090 if (this.body) { | 1098 if (this.body) { |
1091 json += ',"body":'; | 1099 json += ',"body":'; |
1092 // Encode the body part. | 1100 // Encode the body part. |
1093 var serializer = MakeMirrorSerializer(true); | 1101 var serializer = MakeMirrorSerializer(true, this.options_); |
1094 if (this.body instanceof Mirror) { | 1102 if (this.body instanceof Mirror) { |
1095 json += serializer.serializeValue(this.body); | 1103 json += serializer.serializeValue(this.body); |
1096 } else if (this.body instanceof Array) { | 1104 } else if (this.body instanceof Array) { |
1097 json += '['; | 1105 json += '['; |
1098 for (var i = 0; i < this.body.length; i++) { | 1106 for (var i = 0; i < this.body.length; i++) { |
1099 if (i != 0) json += ','; | 1107 if (i != 0) json += ','; |
1100 if (this.body[i] instanceof Mirror) { | 1108 if (this.body[i] instanceof Mirror) { |
1101 json += serializer.serializeValue(this.body[i]); | 1109 json += serializer.serializeValue(this.body[i]); |
1102 } else { | 1110 } else { |
1103 json += SimpleObjectToJSON_(this.body[i], serializer); | 1111 json += SimpleObjectToJSON_(this.body[i], serializer); |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 // Pull out arguments. | 1681 // Pull out arguments. |
1674 if (!IS_UNDEFINED(request.arguments.types)) { | 1682 if (!IS_UNDEFINED(request.arguments.types)) { |
1675 types = %ToNumber(request.arguments.types); | 1683 types = %ToNumber(request.arguments.types); |
1676 if (isNaN(types) || types < 0) { | 1684 if (isNaN(types) || types < 0) { |
1677 return response.failed('Invalid types "' + request.arguments.types + '"'
); | 1685 return response.failed('Invalid types "' + request.arguments.types + '"'
); |
1678 } | 1686 } |
1679 } | 1687 } |
1680 | 1688 |
1681 if (!IS_UNDEFINED(request.arguments.includeSource)) { | 1689 if (!IS_UNDEFINED(request.arguments.includeSource)) { |
1682 includeSource = %ToBoolean(request.arguments.includeSource); | 1690 includeSource = %ToBoolean(request.arguments.includeSource); |
| 1691 response.setOption('includeSource', includeSource); |
1683 } | 1692 } |
1684 } | 1693 } |
1685 | 1694 |
1686 // Collect all scripts in the heap. | 1695 // Collect all scripts in the heap. |
1687 var scripts = %DebugGetLoadedScripts(); | 1696 var scripts = %DebugGetLoadedScripts(); |
1688 | 1697 |
1689 response.body = []; | 1698 response.body = []; |
1690 | 1699 |
1691 for (var i = 0; i < scripts.length; i++) { | 1700 for (var i = 0; i < scripts.length; i++) { |
1692 if (types & ScriptTypeFlag(scripts[i].type)) { | 1701 if (types & ScriptTypeFlag(scripts[i].type)) { |
1693 var script = {}; | 1702 response.body.push(MakeMirror(scripts[i])); |
1694 if (scripts[i].name) { | |
1695 script.name = scripts[i].name; | |
1696 } | |
1697 script.id = scripts[i].id; | |
1698 script.lineOffset = scripts[i].line_offset; | |
1699 script.columnOffset = scripts[i].column_offset; | |
1700 script.lineCount = scripts[i].lineCount(); | |
1701 if (scripts[i].data) { | |
1702 script.data = scripts[i].data; | |
1703 } | |
1704 if (includeSource) { | |
1705 script.source = scripts[i].source; | |
1706 } else { | |
1707 script.sourceStart = scripts[i].source.substring(0, 80); | |
1708 } | |
1709 script.sourceLength = scripts[i].source.length; | |
1710 script.type = scripts[i].type; | |
1711 response.body.push(script); | |
1712 } | 1703 } |
1713 } | 1704 } |
1714 }; | 1705 }; |
1715 | 1706 |
1716 | 1707 |
1717 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { | 1708 DebugCommandProcessor.prototype.threadsRequest_ = function(request, response) { |
1718 // Get the number of threads. | 1709 // Get the number of threads. |
1719 var total_threads = this.exec_state_.threadCount(); | 1710 var total_threads = this.exec_state_.threadCount(); |
1720 | 1711 |
1721 // Get information for all threads. | 1712 // Get information for all threads. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 json += NumberToJSON_(elem); | 1861 json += NumberToJSON_(elem); |
1871 } else if (IS_STRING(elem)) { | 1862 } else if (IS_STRING(elem)) { |
1872 json += StringToJSON_(elem); | 1863 json += StringToJSON_(elem); |
1873 } else { | 1864 } else { |
1874 json += elem; | 1865 json += elem; |
1875 } | 1866 } |
1876 } | 1867 } |
1877 json += ']'; | 1868 json += ']'; |
1878 return json; | 1869 return json; |
1879 } | 1870 } |
OLD | NEW |