Commit 2c8a4155 authored by jgruber's avatar jgruber Committed by Commit bot

[debug-wrapper] clearAllBreakPoints and several scripts functions

This adds clearAllBreakPoints functionality (which requires tracking set
breakpoints internally), and several script-related functions that rely
on runtime functions.

BUG=v8:5530

Review-Url: https://codereview.chromium.org/2508853003
Cr-Commit-Position: refs/heads/master@{#41064}
parent 28777644
......@@ -25,7 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
function a() { b(); };
function b() {
c(true);
......@@ -55,23 +54,22 @@ function d(x) {
x = 15;
}
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
// This is the number of comment lines above the first test function.
var comment_lines = 28;
var comment_lines = 27;
// This is the last position in the entire file (note: this equals
// file size of <debug-sourceinfo.js> - 1, since starting at 0).
var last_position = 8126;
var last_position = 8022;
// This is the last line of entire file (note: starting at 0).
var last_line = 200;
var last_line = 198;
// This is the last column of last line (note: starting at 0).
var last_column = 71;
// This magic number is the length or the first line comment (actually number
// of characters before 'function a(...'.
var comment_line_length = 1633;
var comment_line_length = 1599;
var start_a = 9 + comment_line_length;
var start_b = 35 + comment_line_length;
var start_c = 66 + comment_line_length;
......@@ -80,7 +78,7 @@ var start_d = 151 + comment_line_length;
// The position of the first line of d(), i.e. "x = 1 ;".
var start_code_d = start_d + 6;
// The line # of the first line of d() (note: starting at 0).
var start_line_d = 40;
var start_line_d = 39;
var line_length_d = 10;
var num_lines_d = 15;
......
......@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
// Check that the script source for all functions in a script is the same.
......
......@@ -25,7 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --allow-natives-syntax
// Flags: --concurrent-recompilation --block-concurrent-recompilation
if (!%IsConcurrentRecompilationSupported()) {
......
......@@ -45,6 +45,12 @@ class DebugWrapper {
StepFrame: 3,
};
// The different types of scripts matching enum ScriptType in objects.h.
this.ScriptType = { Native: 0,
Extension: 1,
Normal: 2,
Wasm: 3};
// A copy of the scope types from runtime-debug.cc.
// NOTE: these constants should be backward-compatible, so
// add new ones to the end of this list.
......@@ -78,6 +84,9 @@ class DebugWrapper {
// Store the current script id so we can skip corresponding break events.
this.thisScriptId = %FunctionGetScriptId(receive);
// Stores all set breakpoints.
this.breakpoints = new Set();
// Register as the active wrapper.
assertTrue(activeWrapper === undefined);
activeWrapper = this;
......@@ -136,25 +145,7 @@ class DebugWrapper {
const offset = %FunctionGetScriptSourcePosition(func);
const loc =
%ScriptLocationFromLine2(scriptid, opt_line, opt_column, offset);
const params = { location :
{ scriptId : scriptid.toString(),
lineNumber : loc.line,
columnNumber : loc.column,
}};
if (!!opt_condition) {
params.condition = opt_condition;
}
const {msgid, msg} = this.createMessage("Debugger.setBreakpoint", params);
this.sendMessage(msg);
const reply = this.takeReplyChecked(msgid);
assertTrue(reply.result !== undefined);
const breakid = reply.result.breakpointId;
assertTrue(breakid !== undefined);
return breakid;
return this.setBreakPointAtLocation(scriptid, loc, opt_condition);
}
setScriptBreakPoint(type, scriptid, opt_line, opt_column, opt_condition) {
......@@ -166,32 +157,23 @@ class DebugWrapper {
setScriptBreakPointById(scriptid, opt_line, opt_column, opt_condition) {
const loc = %ScriptLocationFromLine2(scriptid, opt_line, opt_column, 0);
const params = { location :
{ scriptId : scriptid.toString(),
lineNumber : loc.line,
columnNumber : loc.column,
}};
if (!!opt_condition) {
params.condition = opt_condition;
}
const {msgid, msg} = this.createMessage("Debugger.setBreakpoint", params);
this.sendMessage(msg);
const reply = this.takeReplyChecked(msgid);
assertTrue(reply.result !== undefined);
const breakid = reply.result.breakpointId;
assertTrue(breakid !== undefined);
return breakid;
return this.setBreakPointAtLocation(scriptid, loc, opt_condition);
}
clearBreakPoint(breakid) {
assertTrue(this.breakpoints.has(breakid));
const {msgid, msg} = this.createMessage(
"Debugger.removeBreakpoint", { breakpointId : breakid });
this.sendMessage(msg);
this.takeReplyChecked(msgid);
this.breakpoints.delete(breakid);
}
clearAllBreakPoints() {
for (let breakid of this.breakpoints) {
this.clearBreakPoint(breakid);
}
this.breakpoints.clear();
}
showBreakPoints(f, opt_position_alignment) {
......@@ -236,10 +218,10 @@ class DebugWrapper {
}
// Returns a Script object. If the parameter is a function the return value
// is the script in which the function is defined. If the parameter is a string
// the return value is the script for which the script name has that string
// value. If it is a regexp and there is a unique script whose name matches
// we return that, otherwise undefined.
// is the script in which the function is defined. If the parameter is a
// string the return value is the script for which the script name has that
// string value. If it is a regexp and there is a unique script whose name
// matches we return that, otherwise undefined.
findScript(func_or_script_name) {
if (%IsFunction(func_or_script_name)) {
return %FunctionGetScript(func_or_script_name);
......@@ -269,11 +251,32 @@ class DebugWrapper {
}
}
// Returns the script source. If the parameter is a function the return value
// is the script source for the script in which the function is defined. If the
// parameter is a string the return value is the script for which the script
// name has that string value.
scriptSource(func_or_script_name) {
return this.findScript(func_or_script_name).source;
};
sourcePosition(f) {
if (!%IsFunction(f)) throw new Error("Not passed a Function");
return %FunctionGetScriptSourcePosition(f);
};
// Returns the character position in a script based on a line number and an
// optional position within that line.
findScriptSourcePosition(script, opt_line, opt_column) {
var location = %ScriptLocationFromLine(script, opt_line, opt_column, 0);
return location ? location.position : null;
};
findFunctionSourceLocation(func, opt_line, opt_column) {
var script = %FunctionGetScript(func);
var script_offset = %FunctionGetScriptSourcePosition(func);
return %ScriptLocationFromLine(script, opt_line, opt_column, script_offset);
}
setBreakPointsActive(enabled) {
const {msgid, msg} = this.createMessage(
"Debugger.setBreakpointsActive", { active : enabled });
......@@ -331,6 +334,28 @@ class DebugWrapper {
return reply;
}
setBreakPointAtLocation(scriptid, loc, opt_condition) {
const params = { location :
{ scriptId : scriptid.toString(),
lineNumber : loc.line,
columnNumber : loc.column,
},
condition : opt_condition,
};
const {msgid, msg} = this.createMessage("Debugger.setBreakpoint", params);
this.sendMessage(msg);
const reply = this.takeReplyChecked(msgid);
assertTrue(reply.result !== undefined);
const breakid = reply.result.breakpointId;
assertTrue(breakid !== undefined);
this.breakpoints.add(breakid);
return breakid;
}
execStatePrepareStep(action) {
switch(action) {
case this.StepAction.StepOut: this.stepOut(); break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment