Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Unified Diff: src/debug-debugger.js

Issue 2880011: Add debugger protocol request for setting global flags. (Closed)
Patch Set: After CR by Soren Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug.h ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug-debugger.js
diff --git a/src/debug-debugger.js b/src/debug-debugger.js
index c808c87b8ef9b3f93aca58ef8590b8d13d90039a..c2dbed08ab9f73909d78d9fe8921c2a90f567374 100644
--- a/src/debug-debugger.js
+++ b/src/debug-debugger.js
@@ -79,6 +79,16 @@ var next_response_seq = 0;
var next_break_point_number = 1;
var break_points = [];
var script_break_points = [];
+var debugger_flags = {
+ breakPointsActive: {
+ value: true,
+ getValue: function() { return this.value; },
+ setValue: function(value) {
+ this.value = !!value;
+ %SetDisableBreak(!this.value);
+ }
+ }
+};
// Create a new break point object and add it to the list of break points.
@@ -246,7 +256,7 @@ ScriptBreakPoint.prototype.cloneForOtherScript = function (other_script) {
other_script.id, this.line_, this.column_, this.groupId_);
copy.number_ = next_break_point_number++;
script_break_points.push(copy);
-
+
copy.hit_count_ = this.hit_count_;
copy.active_ = this.active_;
copy.condition_ = this.condition_;
@@ -813,7 +823,13 @@ Debug.showBreakPoints = function(f, full) {
Debug.scripts = function() {
// Collect all scripts in the heap.
return %DebugGetLoadedScripts();
-}
+};
+
+
+Debug.debuggerFlags = function() {
+ return debugger_flags;
+};
+
function MakeExecutionState(break_id) {
return new ExecutionState(break_id);
@@ -1325,9 +1341,11 @@ 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);
+ this.changeLiveRequest_(request, response);
+ } else if (request.command == 'flags') {
+ this.debuggerFlagsRequest_(request, response);
} else {
throw new Error('Unknown command "' + request.command + '" in request');
}
@@ -1617,6 +1635,7 @@ DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(request, resp
response.body = { breakpoint: break_point }
}
+
DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, response) {
var array = [];
for (var i = 0; i < script_break_points.length; i++) {
@@ -1633,7 +1652,7 @@ DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, resp
ignoreCount: break_point.ignoreCount(),
actual_locations: break_point.actual_locations()
}
-
+
if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
description.type = 'scriptId';
description.script_id = break_point.script_id();
@@ -1643,7 +1662,7 @@ DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, resp
}
array.push(description);
}
-
+
response.body = { breakpoints: array }
}
@@ -2070,7 +2089,7 @@ DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
return response.failed('Missing arguments');
}
var script_id = request.arguments.script_id;
-
+
var scripts = %DebugGetLoadedScripts();
var the_script = null;
@@ -2085,20 +2104,20 @@ DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
}
var change_log = new Array();
-
+
if (!IS_STRING(request.arguments.new_source)) {
throw "new_source argument expected";
}
var new_source = request.arguments.new_source;
-
+
try {
Debug.LiveEdit.SetScriptSource(the_script, new_source, change_log);
} catch (e) {
if (e instanceof Debug.LiveEdit.Failure) {
// Let's treat it as a "success" so that body with change_log will be
// sent back. "change_log" will have "failure" field set.
- change_log.push( { failure: true, message: e.toString() } );
+ change_log.push( { failure: true, message: e.toString() } );
} else {
throw e;
}
@@ -2107,6 +2126,39 @@ DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
};
+DebugCommandProcessor.prototype.debuggerFlagsRequest_ = function(request,
+ response) {
+ // Check for legal request.
+ if (!request.arguments) {
+ response.failed('Missing arguments');
+ return;
+ }
+
+ // Pull out arguments.
+ var flags = request.arguments.flags;
+
+ response.body = { flags: [] };
+ if (!IS_UNDEFINED(flags)) {
+ for (var i = 0; i < flags.length; i++) {
+ var name = flags[i].name;
+ var debugger_flag = debugger_flags[name];
+ if (!debugger_flag) {
+ continue;
+ }
+ if ('value' in flags[i]) {
+ debugger_flag.setValue(flags[i].value);
+ }
+ response.body.flags.push({ name: name, value: debugger_flag.getValue() });
+ }
+ } else {
+ for (var name in debugger_flags) {
+ var value = debugger_flags[name].getValue();
+ response.body.flags.push({ name: name, value: value });
+ }
+ }
+}
+
+
// Check whether the previously processed command caused the VM to become
// running.
DebugCommandProcessor.prototype.isRunning = function() {
« no previous file with comments | « src/debug.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698