Commit ee84d9f7 authored by yangguo's avatar yangguo Committed by Commit bot

[debug] remove debug command processor from regress tests.

BUG=v8:5510
R=jgruber@chromium.org

Review-Url: https://codereview.chromium.org/2535733002
Cr-Commit-Position: refs/heads/master@{#41312}
parent 0398e5d5
......@@ -34,57 +34,21 @@ Debug = debug.Debug
listenerCalled = false;
exception = false;
function ParsedResponse(json) {
this.response_ = eval('(' + json + ')');
this.refs_ = [];
if (this.response_.refs) {
for (var i = 0; i < this.response_.refs.length; i++) {
this.refs_[this.response_.refs[i].handle] = this.response_.refs[i];
}
}
}
ParsedResponse.prototype.response = function() {
return this.response_;
}
ParsedResponse.prototype.body = function() {
return this.response_.body;
}
ParsedResponse.prototype.lookup = function(handle) {
return this.refs_[handle];
}
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Exception)
{
if (event == Debug.DebugEvent.Exception) {
// The expected backtrace is
// 1: g
// 0: [anonymous]
// Get the debug command processor.
var dcp = exec_state.debugCommandProcessor(false);
// Get the backtrace.
var json;
json = '{"seq":0,"type":"request","command":"backtrace"}'
var response = new ParsedResponse(dcp.processDebugJSONRequest(json));
var backtrace = response.body();
assertEquals(2, backtrace.totalFrames);
assertEquals(2, backtrace.frames.length);
assertEquals("g", response.lookup(backtrace.frames[0].func.ref).name);
assertEquals("", response.lookup(backtrace.frames[1].func.ref).name);
assertEquals(2, exec_state.frameCount());
assertEquals("g", exec_state.frame(0).func().name());
assertEquals("", exec_state.frame(1).func().name());
listenerCalled = true;
}
} catch (e) {
print(e);
exception = e
};
};
......
......@@ -29,14 +29,6 @@
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
var exception = false;
function sendCommand(state, cmd) {
// Get the debug command processor in paused state.
var dcp = state.debugCommandProcessor(false);
var request = JSON.stringify(cmd);
var response = dcp.processDebugJSONRequest(request);
}
var state = 0;
function listener(event, exec_state, event_data, data) {
......@@ -44,8 +36,6 @@ function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
var line = event_data.sourceLineText();
print('break: ' + line);
print('event data: ' + event_data.toJSONProtocol());
print();
assertEquals('// BREAK', line.substr(-8),
"should not break outside evaluate");
......@@ -56,25 +46,13 @@ function listener(event, exec_state, event_data, data) {
// executed in the evaluate command, the stepping must stop at the end
// of the said set of instructions and not step further into native
// debugger code.
sendCommand(exec_state, {
seq : 0,
type : "request",
command : "evaluate",
arguments : {
'expression' : 'print("A"); debugger; print("B"); // BREAK',
'global' : true
}
});
exec_state.frame(0).evaluate(
"print('A');\n" +
"debugger; // BREAK\n" +
"print('B'); // BREAK");
break;
case 1:
sendCommand(exec_state, {
seq : 0,
type : "request",
command : "continue",
arguments : {
stepaction : "next"
}
});
exec_state.prepareStep(Debug.StepAction.StepNext);
break;
}
}
......
......@@ -31,13 +31,6 @@ Debug = debug.Debug
var breaks = 0;
var exception = false;
function sendCommand(state, cmd) {
// Get the debug command processor in paused state.
var dcp = state.debugCommandProcessor(false);
var request = JSON.stringify(cmd);
var response = dcp.processDebugJSONRequest(request);
}
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
......@@ -48,14 +41,7 @@ function listener(event, exec_state, event_data, data) {
"should not break on unexpected lines")
assertEquals('BREAK ' + breaks, line.substr(-7));
breaks++;
if (breaks < 4) {
sendCommand(exec_state, {
seq: 0,
type: "request",
command: "continue",
arguments: { stepaction: "next" }
});
}
if (breaks < 4) exec_state.prepareStep(Debug.StepAction.StepNext);
}
} catch (e) {
print(e);
......
......@@ -36,38 +36,22 @@ var break_count = 0;
var test_break_1 = false;
var test_break_2 = false;
function sendCommand(state, cmd) {
// Get the debug command processor in paused state.
var dcp = state.debugCommandProcessor(false);
var request = JSON.stringify(cmd);
var response = dcp.processDebugJSONRequest(request);
return JSON.parse(response);
}
function setBreakPointByName(state) {
sendCommand(state, {
seq: 0,
type: "request",
command: "setbreakpoint",
arguments: {
type: "script",
target: "testScriptOne",
line: 2
var scripts = Debug.scripts();
for (var script of scripts) {
if (script.source_url == "testScriptOne") {
Debug.setScriptBreakPointById(script.id, 2);
}
}
});
}
function setBreakPointByRegExp(state) {
sendCommand(state, {
seq: 0,
type: "request",
command: "setbreakpoint",
arguments: {
type: "scriptRegExp",
target: "Scrip.Two",
line: 2
var scripts = Debug.scripts();
for (var script of scripts) {
if (/Scrip.Two/.test(script.source_url)) {
Debug.setScriptBreakPointById(script.id, 2);
}
}
});
}
function listener(event, exec_state, event_data, data) {
......@@ -96,7 +80,6 @@ function listener(event, exec_state, event_data, data) {
}
Debug.setListener(listener);
debugger;
eval('function test1() { \n' +
' assertFalse(test_break_1); \n' +
......@@ -110,6 +93,8 @@ eval('function test2() { \n' +
'} \n' +
'//# sourceURL=testScriptTwo');
debugger;
test1();
test2();
assertEquals(3, break_count);
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