OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Default number of frames to include in the response to backtrace request. | 5 // Default number of frames to include in the response to backtrace request. |
6 var kDefaultBacktraceLength = 10; | 6 var kDefaultBacktraceLength = 10; |
7 | 7 |
8 var Debug = {}; | 8 var Debug = {}; |
9 | 9 |
10 // Regular expression to skip "crud" at the beginning of a source line which is | 10 // Regular expression to skip "crud" at the beginning of a source line which is |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 var result = []; | 479 var result = []; |
480 for (var i = 0; i < script_break_points.length; i++) { | 480 for (var i = 0; i < script_break_points.length; i++) { |
481 if (script_break_points[i].matchesScript(script)) { | 481 if (script_break_points[i].matchesScript(script)) { |
482 result.push(script_break_points[i]); | 482 result.push(script_break_points[i]); |
483 } | 483 } |
484 } | 484 } |
485 return result; | 485 return result; |
486 } | 486 } |
487 | 487 |
488 | 488 |
489 function GetLoadedScripts() { | |
490 ClearMirrorCache(); // The mirror cache may be holding onto scripts. | |
491 return %DebugGetLoadedScripts(); | |
492 } | |
493 | |
494 | |
495 Debug.setListener = function(listener, opt_data) { | 489 Debug.setListener = function(listener, opt_data) { |
496 if (!IS_FUNCTION(listener) && !IS_UNDEFINED(listener) && !IS_NULL(listener)) { | 490 if (!IS_FUNCTION(listener) && !IS_UNDEFINED(listener) && !IS_NULL(listener)) { |
497 throw new Error('Parameters have wrong types.'); | 491 throw new Error('Parameters have wrong types.'); |
498 } | 492 } |
499 %SetDebugEventListener(listener, opt_data); | 493 %SetDebugEventListener(listener, opt_data); |
500 }; | 494 }; |
501 | 495 |
502 | 496 |
503 Debug.breakExecution = function(f) { | 497 Debug.breakExecution = function(f) { |
504 %Break(); | 498 %Break(); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 pos = source.length; | 908 pos = source.length; |
915 result += source.substring(prev_pos, pos); | 909 result += source.substring(prev_pos, pos); |
916 return result; | 910 return result; |
917 }; | 911 }; |
918 | 912 |
919 | 913 |
920 // Get all the scripts currently loaded. Locating all the scripts is based on | 914 // Get all the scripts currently loaded. Locating all the scripts is based on |
921 // scanning the heap. | 915 // scanning the heap. |
922 Debug.scripts = function() { | 916 Debug.scripts = function() { |
923 // Collect all scripts in the heap. | 917 // Collect all scripts in the heap. |
924 return GetLoadedScripts(); | 918 return %DebugGetLoadedScripts(); |
925 }; | 919 }; |
926 | 920 |
927 | 921 |
928 Debug.debuggerFlags = function() { | 922 Debug.debuggerFlags = function() { |
929 return debugger_flags; | 923 return debugger_flags; |
930 }; | 924 }; |
931 | 925 |
932 Debug.MakeMirror = MakeMirror; | 926 Debug.MakeMirror = MakeMirror; |
933 | 927 |
934 function MakeExecutionState(break_id) { | 928 function MakeExecutionState(break_id) { |
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 if (!IS_UNDEFINED(request.arguments.filter)) { | 2237 if (!IS_UNDEFINED(request.arguments.filter)) { |
2244 var num = %ToNumber(request.arguments.filter); | 2238 var num = %ToNumber(request.arguments.filter); |
2245 if (!isNaN(num)) { | 2239 if (!isNaN(num)) { |
2246 filterNum = num; | 2240 filterNum = num; |
2247 } | 2241 } |
2248 filterStr = request.arguments.filter; | 2242 filterStr = request.arguments.filter; |
2249 } | 2243 } |
2250 } | 2244 } |
2251 | 2245 |
2252 // Collect all scripts in the heap. | 2246 // Collect all scripts in the heap. |
2253 var scripts = GetLoadedScripts(); | 2247 var scripts = %DebugGetLoadedScripts(); |
2254 | 2248 |
2255 response.body = []; | 2249 response.body = []; |
2256 | 2250 |
2257 for (var i = 0; i < scripts.length; i++) { | 2251 for (var i = 0; i < scripts.length; i++) { |
2258 if (idsToInclude && !idsToInclude[scripts[i].id]) { | 2252 if (idsToInclude && !idsToInclude[scripts[i].id]) { |
2259 continue; | 2253 continue; |
2260 } | 2254 } |
2261 if (filterStr || filterNum) { | 2255 if (filterStr || filterNum) { |
2262 var script = scripts[i]; | 2256 var script = scripts[i]; |
2263 var found = false; | 2257 var found = false; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 | 2309 |
2316 | 2310 |
2317 DebugCommandProcessor.prototype.changeLiveRequest_ = function( | 2311 DebugCommandProcessor.prototype.changeLiveRequest_ = function( |
2318 request, response) { | 2312 request, response) { |
2319 if (!request.arguments) { | 2313 if (!request.arguments) { |
2320 return response.failed('Missing arguments'); | 2314 return response.failed('Missing arguments'); |
2321 } | 2315 } |
2322 var script_id = request.arguments.script_id; | 2316 var script_id = request.arguments.script_id; |
2323 var preview_only = !!request.arguments.preview_only; | 2317 var preview_only = !!request.arguments.preview_only; |
2324 | 2318 |
2325 var scripts = GetLoadedScripts(); | 2319 var scripts = %DebugGetLoadedScripts(); |
2326 | 2320 |
2327 var the_script = null; | 2321 var the_script = null; |
2328 for (var i = 0; i < scripts.length; i++) { | 2322 for (var i = 0; i < scripts.length; i++) { |
2329 if (scripts[i].id == script_id) { | 2323 if (scripts[i].id == script_id) { |
2330 the_script = scripts[i]; | 2324 the_script = scripts[i]; |
2331 } | 2325 } |
2332 } | 2326 } |
2333 if (!the_script) { | 2327 if (!the_script) { |
2334 response.failed('Script not found'); | 2328 response.failed('Script not found'); |
2335 return; | 2329 return; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 | 2562 |
2569 default: | 2563 default: |
2570 json = null; | 2564 json = null; |
2571 } | 2565 } |
2572 return json; | 2566 return json; |
2573 } | 2567 } |
2574 | 2568 |
2575 Debug.TestApi = { | 2569 Debug.TestApi = { |
2576 CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_ | 2570 CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_ |
2577 }; | 2571 }; |
OLD | NEW |