| Index: src/debug-delay.js
|
| diff --git a/src/debug-delay.js b/src/debug-delay.js
|
| index 754ac5d0480b1f3e249204edfc42244638e8ec44..55ccdae370a322829c31a6b9ac7c73322ec75ae6 100644
|
| --- a/src/debug-delay.js
|
| +++ b/src/debug-delay.js
|
| @@ -745,6 +745,13 @@ Debug.scripts = function() {
|
| return %DebugGetLoadedScripts();
|
| }
|
|
|
| +// Applies patch to existing script. All relevant functions get recompiled
|
| +// on the best effort basis.
|
| +Debug.change_script_live = function(script, change_pos, change_len, new_str) {
|
| + %DebugChangeScriptLive(script, change_pos, change_len, new_str);
|
| +}
|
| +
|
| +
|
| function MakeExecutionState(break_id) {
|
| return new ExecutionState(break_id);
|
| }
|
| @@ -1246,7 +1253,9 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request)
|
| } else if (request.command == 'version') {
|
| this.versionRequest_(request, response);
|
| } else if (request.command == 'profile') {
|
| - this.profileRequest_(request, response);
|
| + this.profileRequest_(request, response);
|
| + } else if (request.command == 'changelive') {
|
| + this.changeLiveRequest_(request, response);
|
| } else {
|
| throw new Error('Unknown command "' + request.command + '" in request');
|
| }
|
| @@ -1949,6 +1958,38 @@ DebugCommandProcessor.prototype.profileRequest_ = function(request, response) {
|
| };
|
|
|
|
|
| +DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response) {
|
| + if (!request.arguments) {
|
| + return response.failed('Missing arguments');
|
| + }
|
| + var script_id = request.arguments.script_id;
|
| + var change_pos = parseInt(request.arguments.change_pos);
|
| + var change_len = parseInt(request.arguments.change_len);
|
| + var new_string = request.arguments.new_string;
|
| + if (!IS_STRING(new_string)) {
|
| + response.failed('Argument "new_string" is not a string value');
|
| + return;
|
| + }
|
| +
|
| + var scripts = %DebugGetLoadedScripts();
|
| +
|
| + var the_script = null;
|
| + for (var i = 0; i < scripts.length; i++) {
|
| + if (scripts[i].id == script_id) {
|
| + the_script = scripts[i];
|
| + }
|
| + }
|
| + if (!the_script) {
|
| + response.failed('Script not found by id');
|
| + return;
|
| + }
|
| +
|
| + Debug.change_script_live(the_script, change_pos, change_len, new_string);
|
| +
|
| + response.body = {};
|
| +};
|
| +
|
| +
|
| // Check whether the previously processed command caused the VM to become
|
| // running.
|
| DebugCommandProcessor.prototype.isRunning = function() {
|
|
|