| 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 }; | 738 }; |
| 739 | 739 |
| 740 | 740 |
| 741 // Get all the scripts currently loaded. Locating all the scripts is based on | 741 // Get all the scripts currently loaded. Locating all the scripts is based on |
| 742 // scanning the heap. | 742 // scanning the heap. |
| 743 Debug.scripts = function() { | 743 Debug.scripts = function() { |
| 744 // Collect all scripts in the heap. | 744 // Collect all scripts in the heap. |
| 745 return %DebugGetLoadedScripts(); | 745 return %DebugGetLoadedScripts(); |
| 746 } | 746 } |
| 747 | 747 |
| 748 // Applies patch to existing script. All relevant functions get recompiled |
| 749 // on the best effort basis. |
| 750 Debug.change_script_live = function(script, change_pos, change_len, new_str) { |
| 751 %DebugChangeScriptLive(script, change_pos, change_len, new_str); |
| 752 } |
| 753 |
| 754 |
| 748 function MakeExecutionState(break_id) { | 755 function MakeExecutionState(break_id) { |
| 749 return new ExecutionState(break_id); | 756 return new ExecutionState(break_id); |
| 750 } | 757 } |
| 751 | 758 |
| 752 function ExecutionState(break_id) { | 759 function ExecutionState(break_id) { |
| 753 this.break_id = break_id; | 760 this.break_id = break_id; |
| 754 this.selected_frame = 0; | 761 this.selected_frame = 0; |
| 755 } | 762 } |
| 756 | 763 |
| 757 ExecutionState.prototype.prepareStep = function(opt_action, opt_count) { | 764 ExecutionState.prototype.prepareStep = function(opt_action, opt_count) { |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 this.sourceRequest_(request, response); | 1246 this.sourceRequest_(request, response); |
| 1240 } else if (request.command == 'scripts') { | 1247 } else if (request.command == 'scripts') { |
| 1241 this.scriptsRequest_(request, response); | 1248 this.scriptsRequest_(request, response); |
| 1242 } else if (request.command == 'threads') { | 1249 } else if (request.command == 'threads') { |
| 1243 this.threadsRequest_(request, response); | 1250 this.threadsRequest_(request, response); |
| 1244 } else if (request.command == 'suspend') { | 1251 } else if (request.command == 'suspend') { |
| 1245 this.suspendRequest_(request, response); | 1252 this.suspendRequest_(request, response); |
| 1246 } else if (request.command == 'version') { | 1253 } else if (request.command == 'version') { |
| 1247 this.versionRequest_(request, response); | 1254 this.versionRequest_(request, response); |
| 1248 } else if (request.command == 'profile') { | 1255 } else if (request.command == 'profile') { |
| 1249 this.profileRequest_(request, response); | 1256 this.profileRequest_(request, response); |
| 1257 } else if (request.command == 'changelive') { |
| 1258 this.changeLiveRequest_(request, response); |
| 1250 } else { | 1259 } else { |
| 1251 throw new Error('Unknown command "' + request.command + '" in request'); | 1260 throw new Error('Unknown command "' + request.command + '" in request'); |
| 1252 } | 1261 } |
| 1253 } catch (e) { | 1262 } catch (e) { |
| 1254 // If there is no response object created one (without command). | 1263 // If there is no response object created one (without command). |
| 1255 if (!response) { | 1264 if (!response) { |
| 1256 response = this.createResponse(); | 1265 response = this.createResponse(); |
| 1257 } | 1266 } |
| 1258 response.success = false; | 1267 response.success = false; |
| 1259 response.message = %ToString(e); | 1268 response.message = %ToString(e); |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1942 %ProfilerResume(modules, tag); | 1951 %ProfilerResume(modules, tag); |
| 1943 } else if (request.arguments.command == 'pause') { | 1952 } else if (request.arguments.command == 'pause') { |
| 1944 %ProfilerPause(modules, tag); | 1953 %ProfilerPause(modules, tag); |
| 1945 } else { | 1954 } else { |
| 1946 return response.failed('Unknown command'); | 1955 return response.failed('Unknown command'); |
| 1947 } | 1956 } |
| 1948 response.body = {}; | 1957 response.body = {}; |
| 1949 }; | 1958 }; |
| 1950 | 1959 |
| 1951 | 1960 |
| 1961 DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
{ |
| 1962 if (!request.arguments) { |
| 1963 return response.failed('Missing arguments'); |
| 1964 } |
| 1965 var script_id = request.arguments.script_id; |
| 1966 var change_pos = parseInt(request.arguments.change_pos); |
| 1967 var change_len = parseInt(request.arguments.change_len); |
| 1968 var new_string = request.arguments.new_string; |
| 1969 if (!IS_STRING(new_string)) { |
| 1970 response.failed('Argument "new_string" is not a string value'); |
| 1971 return; |
| 1972 } |
| 1973 |
| 1974 var scripts = %DebugGetLoadedScripts(); |
| 1975 |
| 1976 var the_script = null; |
| 1977 for (var i = 0; i < scripts.length; i++) { |
| 1978 if (scripts[i].id == script_id) { |
| 1979 the_script = scripts[i]; |
| 1980 } |
| 1981 } |
| 1982 if (!the_script) { |
| 1983 response.failed('Script not found by id'); |
| 1984 return; |
| 1985 } |
| 1986 |
| 1987 Debug.change_script_live(the_script, change_pos, change_len, new_string); |
| 1988 |
| 1989 response.body = {}; |
| 1990 }; |
| 1991 |
| 1992 |
| 1952 // Check whether the previously processed command caused the VM to become | 1993 // Check whether the previously processed command caused the VM to become |
| 1953 // running. | 1994 // running. |
| 1954 DebugCommandProcessor.prototype.isRunning = function() { | 1995 DebugCommandProcessor.prototype.isRunning = function() { |
| 1955 return this.running_; | 1996 return this.running_; |
| 1956 } | 1997 } |
| 1957 | 1998 |
| 1958 | 1999 |
| 1959 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { | 2000 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { |
| 1960 return %SystemBreak(); | 2001 return %SystemBreak(); |
| 1961 }; | 2002 }; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 case 'string': | 2109 case 'string': |
| 2069 case 'number': | 2110 case 'number': |
| 2070 json = value; | 2111 json = value; |
| 2071 break | 2112 break |
| 2072 | 2113 |
| 2073 default: | 2114 default: |
| 2074 json = null; | 2115 json = null; |
| 2075 } | 2116 } |
| 2076 return json; | 2117 return json; |
| 2077 } | 2118 } |
| OLD | NEW |