Revision: 5148
Author: [email protected]
Date: Wed Jul 28 08:50:05 2010
Log: Add debugger protocol request for setting global flags.
Review URL: http://codereview.chromium.org/2880011
http://code.google.com/p/v8/source/detail?r=5148
Modified:
/branches/bleeding_edge/src/debug-debugger.js
/branches/bleeding_edge/src/debug.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/runtime.h
/branches/bleeding_edge/test/mjsunit/debug-enable-disable-breakpoints.js
=======================================
--- /branches/bleeding_edge/src/debug-debugger.js Fri Jul 2 13:46:04 2010
+++ /branches/bleeding_edge/src/debug-debugger.js Wed Jul 28 08:50:05 2010
@@ -79,6 +79,16 @@
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 @@
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.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 @@
} 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');
}
@@ -1616,6 +1634,7 @@
// Add the cleared break point number to the response.
response.body = { breakpoint: break_point }
}
+
DebugCommandProcessor.prototype.listBreakpointsRequest_ =
function(request, response) {
var array = [];
@@ -1633,7 +1652,7 @@
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 @@
}
array.push(description);
}
-
+
response.body = { breakpoints: array }
}
@@ -2086,7 +2105,7 @@
}
var change_log = new Array();
-
+
if (!IS_STRING(request.arguments.new_source)) {
throw "new_source argument expected";
}
@@ -2097,6 +2116,39 @@
new_source, preview_only, change_log);
response.body = {change_log: change_log, result: result_description};
};
+
+
+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
=======================================
--- /branches/bleeding_edge/src/debug.h Wed Jul 14 01:23:35 2010
+++ /branches/bleeding_edge/src/debug.h Wed Jul 28 08:50:05 2010
@@ -906,8 +906,6 @@
// Stack allocated class for disabling break.
class DisableBreak BASE_EMBEDDED {
public:
- // Enter the debugger by storing the previous top context and setting the
- // current top context to the debugger context.
explicit DisableBreak(bool disable_break) {
prev_disable_break_ = Debug::disable_break();
Debug::set_disable_break(disable_break);
=======================================
--- /branches/bleeding_edge/src/runtime.cc Wed Jul 28 06:02:03 2010
+++ /branches/bleeding_edge/src/runtime.cc Wed Jul 28 08:50:05 2010
@@ -9241,6 +9241,17 @@
// Convert to JS array and return.
return *Factory::NewJSArrayWithElements(details);
}
+
+
+// Sets the disable break state
+// args[0]: disable break state
+static Object* Runtime_SetDisableBreak(Arguments args) {
+ HandleScope scope;
+ ASSERT(args.length() == 1);
+ CONVERT_BOOLEAN_CHECKED(disable_break, args[0]);
+ Debug::set_disable_break(disable_break);
+ return Heap::undefined_value();
+}
static Object* Runtime_GetBreakLocations(Arguments args) {
=======================================
--- /branches/bleeding_edge/src/runtime.h Fri Jul 23 03:08:55 2010
+++ /branches/bleeding_edge/src/runtime.h Wed Jul 28 08:50:05 2010
@@ -322,6 +322,7 @@
F(GetCFrames, 1, 1) \
F(GetThreadCount, 1, 1) \
F(GetThreadDetails, 2, 1) \
+ F(SetDisableBreak, 1, 1) \
F(GetBreakLocations, 1, 1) \
F(SetFunctionBreakPoint, 3, 1) \
F(SetScriptBreakPoint, 3, 1) \
=======================================
---
/branches/bleeding_edge/test/mjsunit/debug-enable-disable-breakpoints.js
Mon Feb 2 23:59:12 2009
+++
/branches/bleeding_edge/test/mjsunit/debug-enable-disable-breakpoints.js
Wed Jul 28 08:50:05 2010
@@ -88,3 +88,18 @@
Debug.disableBreakPoint(bp1);
f();
assertEquals(6, break_point_hit_count);
+
+// Deactivate all breakpoints.
+Debug.debuggerFlags().breakPointsActive.setValue(false);
+f();
+assertEquals(6, break_point_hit_count);
+
+// Enable the first breakpoint.
+Debug.enableBreakPoint(bp1);
+f();
+assertEquals(6, break_point_hit_count);
+
+// Activate all breakpoints.
+Debug.debuggerFlags().breakPointsActive.setValue(true);
+f();
+assertEquals(7, break_point_hit_count);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev