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