OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Current debug state. | 115 // Current debug state. |
116 var kNoFrame = -1; | 116 var kNoFrame = -1; |
117 Debug.State = { | 117 Debug.State = { |
118 currentFrame: kNoFrame, | 118 currentFrame: kNoFrame, |
119 displaySourceStartLine: -1, | 119 displaySourceStartLine: -1, |
120 displaySourceEndLine: -1, | 120 displaySourceEndLine: -1, |
121 currentSourceLine: -1 | 121 currentSourceLine: -1 |
122 }; | 122 }; |
123 var trace_compile = false; // Tracing all compile events? | 123 var trace_compile = false; // Tracing all compile events? |
124 var trace_debug_json = false; // Tracing all debug json packets? | 124 var trace_debug_json = false; // Tracing all debug json packets? |
125 var last_cmd_line = ''; | 125 var last_cmd = ''; |
126 //var lol_is_enabled; // Set to true in d8.cc if LIVE_OBJECT_LIST is defined. | 126 //var lol_is_enabled; // Set to true in d8.cc if LIVE_OBJECT_LIST is defined. |
127 var lol_next_dump_index = 0; | 127 var lol_next_dump_index = 0; |
128 var kDefaultLolLinesToPrintAtATime = 10; | 128 var kDefaultLolLinesToPrintAtATime = 10; |
129 var kMaxLolLinesToPrintAtATime = 1000; | 129 var kMaxLolLinesToPrintAtATime = 1000; |
130 var repeat_cmd_line = ''; | 130 var repeat_cmd_line = ''; |
131 var is_running = true; | 131 var is_running = true; |
| 132 // Global variable used to store whether a handle was requested. |
| 133 var lookup_handle = null; |
132 | 134 |
133 // Copied from debug-delay.js. This is needed below: | 135 // Copied from debug-delay.js. This is needed below: |
134 function ScriptTypeFlag(type) { | 136 function ScriptTypeFlag(type) { |
135 return (1 << type); | 137 return (1 << type); |
136 } | 138 } |
137 | 139 |
138 | 140 |
139 // Process a debugger JSON message into a display text and a running status. | 141 // Process a debugger JSON message into a display text and a running status. |
140 // This function returns an object with properties "text" and "running" holding | 142 // This function returns an object with properties "text" and "running" holding |
141 // this information. | 143 // this information. |
142 function DebugMessageDetails(message) { | 144 function DebugMessageDetails(message) { |
143 if (trace_debug_json) { | 145 if (trace_debug_json) { |
144 print("received: '" + message + "'"); | 146 print("received: '" + message + "'"); |
145 } | 147 } |
146 // Convert the JSON string to an object. | 148 // Convert the JSON string to an object. |
147 var response = new ProtocolPackage(message); | 149 var response = new ProtocolPackage(message); |
148 is_running = response.running(); | 150 is_running = response.running(); |
149 | 151 |
150 if (response.type() == 'event') { | 152 if (response.type() == 'event') { |
151 return DebugEventDetails(response); | 153 return DebugEventDetails(response); |
152 } else { | 154 } else { |
153 return DebugResponseDetails(response); | 155 return DebugResponseDetails(response); |
154 } | 156 } |
155 } | 157 } |
156 | 158 |
157 function DebugEventDetails(response) { | 159 function DebugEventDetails(response) { |
158 details = {text:'', running:false}; | 160 var details = {text:'', running:false}; |
159 | 161 |
160 // Get the running state. | 162 // Get the running state. |
161 details.running = response.running(); | 163 details.running = response.running(); |
162 | 164 |
163 var body = response.body(); | 165 var body = response.body(); |
164 var result = ''; | 166 var result = ''; |
165 switch (response.event()) { | 167 switch (response.event()) { |
166 case 'break': | 168 case 'break': |
167 if (body.breakpoints) { | 169 if (body.breakpoints) { |
168 result += 'breakpoint'; | 170 result += 'breakpoint'; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 request.arguments = {}; | 583 request.arguments = {}; |
582 request.arguments.start = start_index; | 584 request.arguments.start = start_index; |
583 request.arguments.count = lines_to_dump; | 585 request.arguments.count = lines_to_dump; |
584 | 586 |
585 return request; | 587 return request; |
586 }; | 588 }; |
587 | 589 |
588 | 590 |
589 // Create a JSON request for the evaluation command. | 591 // Create a JSON request for the evaluation command. |
590 DebugRequest.prototype.makeEvaluateJSONRequest_ = function(expression) { | 592 DebugRequest.prototype.makeEvaluateJSONRequest_ = function(expression) { |
591 // Global varaible used to store whether a handle was requested. | |
592 lookup_handle = null; | 593 lookup_handle = null; |
593 | 594 |
594 if (lol_is_enabled) { | 595 if (lol_is_enabled) { |
595 // Check if the expression is a obj id in the form @<obj id>. | 596 // Check if the expression is a obj id in the form @<obj id>. |
596 var obj_id_match = expression.match(/^@([0-9]+)$/); | 597 var obj_id_match = expression.match(/^@([0-9]+)$/); |
597 if (obj_id_match) { | 598 if (obj_id_match) { |
598 var obj_id = parseInt(obj_id_match[1]); | 599 var obj_id = parseInt(obj_id_match[1]); |
599 // Build a dump request. | 600 // Build a dump request. |
600 var request = this.createRequest('getobj'); | 601 var request = this.createRequest('getobj'); |
601 request.arguments = {}; | 602 request.arguments = {}; |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 | 1942 |
1942 // Rounds number 'num' to 'length' decimal places. | 1943 // Rounds number 'num' to 'length' decimal places. |
1943 function roundNumber(num, length) { | 1944 function roundNumber(num, length) { |
1944 var factor = Math.pow(10, length); | 1945 var factor = Math.pow(10, length); |
1945 return Math.round(num * factor) / factor; | 1946 return Math.round(num * factor) / factor; |
1946 } | 1947 } |
1947 | 1948 |
1948 | 1949 |
1949 // Convert a JSON response to text for display in a text based debugger. | 1950 // Convert a JSON response to text for display in a text based debugger. |
1950 function DebugResponseDetails(response) { | 1951 function DebugResponseDetails(response) { |
1951 details = { text: '', running: false }; | 1952 var details = { text: '', running: false }; |
1952 | 1953 |
1953 try { | 1954 try { |
1954 if (!response.success()) { | 1955 if (!response.success()) { |
1955 details.text = response.message(); | 1956 details.text = response.message(); |
1956 return details; | 1957 return details; |
1957 } | 1958 } |
1958 | 1959 |
1959 // Get the running state. | 1960 // Get the running state. |
1960 details.running = response.running(); | 1961 details.running = response.running(); |
1961 | 1962 |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2803 json += NumberToJSON_(elem); | 2804 json += NumberToJSON_(elem); |
2804 } else if (typeof(elem) === 'string') { | 2805 } else if (typeof(elem) === 'string') { |
2805 json += StringToJSON_(elem); | 2806 json += StringToJSON_(elem); |
2806 } else { | 2807 } else { |
2807 json += elem; | 2808 json += elem; |
2808 } | 2809 } |
2809 } | 2810 } |
2810 json += ']'; | 2811 json += ']'; |
2811 return json; | 2812 return json; |
2812 } | 2813 } |
OLD | NEW |