Commit 8bee91a5 authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] remove step count parameter from prepare step.

And tons of changes to debugger tests.

R=bmeurer@chromium.org
BUG=chromium:569835
LOG=N

Review URL: https://codereview.chromium.org/1525173003

Cr-Commit-Position: refs/heads/master@{#32885}
parent 0a1e909f
......@@ -943,11 +943,14 @@ function ExecutionState(break_id) {
this.selected_frame = 0;
}
ExecutionState.prototype.prepareStep = function(opt_action, opt_count) {
var action = Debug.StepAction.StepIn;
if (!IS_UNDEFINED(opt_action)) action = TO_NUMBER(opt_action);
var count = opt_count ? TO_NUMBER(opt_count) : 1;
return %PrepareStep(this.break_id, action, count);
ExecutionState.prototype.prepareStep = function(action) {
if (action === Debug.StepAction.StepIn ||
action === Debug.StepAction.StepOut ||
action === Debug.StepAction.StepNext ||
action === Debug.StepAction.StepFrame) {
return %PrepareStep(this.break_id, action);
}
throw MakeTypeError(kDebuggerType);
};
ExecutionState.prototype.evaluateGlobal = function(source, disable_break,
......@@ -1451,21 +1454,10 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
DebugCommandProcessor.prototype.continueRequest_ = function(request, response) {
// Check for arguments for continue.
if (request.arguments) {
var count = 1;
var action = Debug.StepAction.StepIn;
// Pull out arguments.
var stepaction = request.arguments.stepaction;
var stepcount = request.arguments.stepcount;
// Get the stepcount argument if any.
if (stepcount) {
count = TO_NUMBER(stepcount);
if (count < 0) {
throw MakeError(kDebugger,
'Invalid stepcount argument "' + stepcount + '".');
}
}
// Get the stepaction argument.
if (stepaction) {
......@@ -1482,7 +1474,7 @@ DebugCommandProcessor.prototype.continueRequest_ = function(request, response) {
}
// Set up the VM for stepping.
this.exec_state_.prepareStep(action, count);
this.exec_state_.prepareStep(action);
}
// VM should be running after executing this request.
......
......@@ -1212,11 +1212,11 @@ RUNTIME_FUNCTION(Runtime_IsBreakOnException) {
// of frames to step down.
RUNTIME_FUNCTION(Runtime_PrepareStep) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
DCHECK(args.length() == 2);
CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id));
if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
if (!args[1]->IsNumber()) {
return isolate->Throw(isolate->heap()->illegal_argument_string());
}
......@@ -1227,18 +1227,11 @@ RUNTIME_FUNCTION(Runtime_PrepareStep) {
return isolate->Throw(isolate->heap()->illegal_argument_string());
}
// Get the number of steps.
int step_count = NumberToInt32(args[2]);
if (step_count < 1) {
return isolate->Throw(isolate->heap()->illegal_argument_string());
}
// Clear all current stepping setup.
isolate->debug()->ClearStepping();
// Prepare step.
isolate->debug()->PrepareStep(static_cast<StepAction>(step_action),
step_count);
isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), 1);
return isolate->heap()->undefined_value();
}
......
......@@ -183,7 +183,7 @@ namespace internal {
F(ClearBreakPoint, 1, 1) \
F(ChangeBreakOnException, 2, 1) \
F(IsBreakOnException, 1, 1) \
F(PrepareStep, 3, 1) \
F(PrepareStep, 2, 1) \
F(ClearStepping, 0, 1) \
F(DebugEvaluate, 6, 1) \
F(DebugEvaluateGlobal, 4, 1) \
......
......@@ -29,7 +29,7 @@ function listener(event, exec_state, event_data, data) {
++break_count;
if (break_count !== expected_breaks) {
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
print("Next step prepared");
}
}
......
......@@ -10,7 +10,7 @@ var exception = null;
function breakListener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
// Assert that the break happens at an intended location.
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// break") > 0);
} catch (e) {
......
......@@ -35,7 +35,7 @@ function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break)
{
call_graph += exec_state.frame().func().name();
exec_state.prepareStep();
exec_state.prepareStep(Debug.StepAction.StepIn);
}
};
......
......@@ -74,12 +74,14 @@ function listener(event, exec_state, event_data, data) {
// Test some illegal continue requests.
testArguments(exec_state, '{"stepaction":"maybe"}', false);
testArguments(exec_state, '{"stepcount":-1}', false);
// Test some legal continue requests.
testArguments(exec_state, '{"stepaction":"in"}', true);
testArguments(exec_state, '{"stepaction":"next"}', true);
testArguments(exec_state, '{"stepaction":"out"}', true);
// Step count argument is ignored.
testArguments(exec_state, '{"stepcount":-1}', true);
testArguments(exec_state, '{"stepcount":1}', true);
testArguments(exec_state, '{"stepcount":10}', true);
testArguments(exec_state, '{"stepcount":"10"}', true);
......
......@@ -34,7 +34,7 @@ function listener(event, exec_state, event_data, data) {
assertUnreachable();
}
}
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -98,7 +98,7 @@ function listener(event, exec_state, event_data, data) {
default:
fail("Unexpected");
}
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} else {
// Position at the end of the function.
assertEquals(debugger_source_position + 50,
......
......@@ -53,9 +53,7 @@ function h() {
}
}
function TestCase(step_count, expected_final_state) {
print("Test case, step count: " + step_count);
function TestCase(expected_final_state) {
var listener_exception = null;
var state_snapshot;
var listener_state;
......@@ -68,7 +66,7 @@ function TestCase(step_count, expected_final_state) {
if (event == Debug.DebugEvent.Break) {
if (listener_state == 0) {
Debug.clearBreakPoint(bp);
exec_state.prepareStep(Debug.StepAction.StepNext, step_count);
exec_state.prepareStep(Debug.StepAction.StepNext);
listener_state = 1;
} else if (listener_state == 1) {
state_snapshot = String(state);
......@@ -102,8 +100,4 @@ function TestCase(step_count, expected_final_state) {
// Warm-up -- make sure all is compiled and ready for breakpoint.
h();
TestCase(0, "0,0,-1");
TestCase(1, "0,0,-1");
TestCase(2, "0,0,0");
TestCase(5, "0,0,1");
TestCase(8, "0,0,2");
TestCase("0,0,-1");
......@@ -11,7 +11,7 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals(expected.shift(), exec_state.frame(0).sourceLineText());
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
......
......@@ -13,8 +13,9 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
print(event_data.sourceLineText());
assertTrue(event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
assertTrue(
event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -14,7 +14,7 @@ function listener(event, exec_state, event_data, data) {
try {
print(event_data.sourceLineText());
assertTrue(event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -33,7 +33,7 @@ var break_count = 0;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
print(exec_state.frame(0).sourceLineText());
var match = exec_state.frame(0).sourceLineText().match(/Break (\d)/);
assertNotNull(match);
......
......@@ -37,10 +37,10 @@ var bp1, bp2;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
if (state == 0) {
exec_state.prepareStep(Debug.StepAction.StepIn, 1000);
state = 1;
} else if (state == 1) {
if (step_count > 0) {
exec_state.prepareStep(Debug.StepAction.StepIn);
step_count--;
} else {
result = exec_state.frame().evaluate("i").value();
// Clear the break point on line 2 if set.
if (bp2) {
......@@ -65,19 +65,8 @@ function f() {
bp1 = Debug.setBreakPoint(f, 1);
// Check that performing 1000 steps will make i 499.
state = 0;
var step_count = 1000;
result = -1;
f();
assertEquals(332, result);
// Check that performing 1000 steps with a break point on the statement in the
// for loop (line 2) will only make i 0 as a real break point breaks even when
// multiple steps have been requested.
state = 0;
result = -1;
bp2 = Debug.setBreakPoint(f, 3);
f();
assertEquals(0, result);
// Get rid of the debug event listener.
Debug.setListener(null);
......@@ -48,7 +48,7 @@ function listener(event, exec_state, event_data, data) {
if (break_count >= 0 && break_count < 2) {
// 0, 1: Keep stepping through frames.
assertEquals(break_count, match_value);
exec_state.prepareStep(Debug.StepAction.StepFrame, 1);
exec_state.prepareStep(Debug.StepAction.StepFrame);
} else if (break_count === 2) {
// 2: let the code run to a breakpoint we set. The load should
// go monomorphic.
......@@ -58,7 +58,7 @@ function listener(event, exec_state, event_data, data) {
// call still have the ability to break like before?
assertEquals(break_count, match_value);
Debug.clearBreakPoint(bp_f1_line7);
exec_state.prepareStep(Debug.StepAction.StepFrame, 1);
exec_state.prepareStep(Debug.StepAction.StepFrame);
} else {
assertEquals(4, break_count);
assertEquals(2, match_value);
......
......@@ -82,7 +82,6 @@ Object.defineProperty(o, "set", { set : set });
Debug = debug.Debug;
var break_count = 0
var exception = null;
var step_size;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
......@@ -92,22 +91,20 @@ function listener(event, exec_state, event_data, data) {
var match = line.match(/\/\/ Break (\d+)$/);
assertEquals(2, match.length);
assertEquals(break_count, parseInt(match[1]));
break_count += step_size;
exec_state.prepareStep(Debug.StepAction.StepFrame, step_size);
break_count ++;
exec_state.prepareStep(Debug.StepAction.StepFrame);
} catch (e) {
print(e + e.stack);
exception = e;
}
}
for (step_size = 1; step_size < 6; step_size++) {
print("step size = " + step_size);
break_count = 0;
Debug.setListener(listener);
debugger; // Break 0
f0();
Debug.setListener(null); // Break 16
assertTrue(break_count > 14);
}
break_count = 0;
Debug.setListener(listener);
debugger; // Break 0
f0();
Debug.setListener(null); // Break 16
assertTrue(break_count > 14);
assertNull(exception);
......@@ -31,7 +31,7 @@ function listener(event, exec_state, event_data, data) {
try {
var source_line = exec_state.frame(0).sourceLineText();
assertTrue(source_line.indexOf("// Break") > 0);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
break_count++;
} catch (e) {
exception = e;
......
......@@ -41,14 +41,14 @@ var expected_function_name = null;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (state == 1) {
exec_state.prepareStep(Debug.StepAction.StepIn, 2);
state = 2;
} else if (state == 2) {
if (state == 3) {
assertEquals(expected_source_line_text,
event_data.sourceLineText());
assertEquals(expected_function_name, event_data.func().name());
state = 3;
state = 4;
} else {
exec_state.prepareStep(Debug.StepAction.StepIn);
state++;
}
}
} catch(e) {
......@@ -241,7 +241,7 @@ for (var n in this) {
state = 1;
this[n]();
assertNull(exception);
assertEquals(3, state);
assertEquals(4, state);
}
// Get rid of the debug event listener.
......
......@@ -15,7 +15,7 @@ function listener(event, exec_state, event_data, data) {
print(event_data.sourceLineText());
assertTrue(
event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -31,127 +31,114 @@
Debug = debug.Debug
var exception = false;
var exception = null;
function array_listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (breaks == 0) {
exec_state.prepareStep(Debug.StepAction.StepIn, 2);
breaks = 1;
} else if (breaks <= 3) {
breaks++;
// Check whether we break at the expected line.
print(event_data.sourceLineText());
assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0);
exec_state.prepareStep(Debug.StepAction.StepIn, 3);
}
print(event_data.sourceLineText(), breaks);
assertTrue(event_data.sourceLineText().indexOf(`B${breaks++}`) > 0);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
} catch (e) {
exception = true;
print(e);
quit();
exception = e;
}
};
function cb_false(num) {
print("element " + num); // Expected to step to this point.
return false;
}
print("element " + num); // B2 B5 B8
return false; // B3 B6 B9
} // B4 B7 B10
function cb_true(num) {
print("element " + num); // Expected to step to this point.
return true;
}
print("element " + num); // B2 B5 B8
return true; // B3 B6 B9
} // B4 B7 B10
function cb_reduce(a, b) {
print("elements " + a + " and " + b); // Expected to step to this point.
return a + b;
}
print("elements " + a + " and " + b); // B2 B5
return a + b; // B3 B6
} // B4 B7
var a = [1, 2, 3, 4];
Debug.setListener(array_listener);
var a = [1, 2, 3];
var breaks = 0;
debugger;
a.forEach(cb_true);
assertFalse(exception);
assertEquals(4, breaks);
Debug.setListener(array_listener);
debugger; // B0
a.forEach(cb_true); // B1
Debug.setListener(null); // B11
assertNull(exception);
assertEquals(12, breaks);
breaks = 0;
debugger;
a.some(cb_false);
assertFalse(exception);
assertEquals(4, breaks);
Debug.setListener(array_listener);
debugger; // B0
a.some(cb_false); // B1
Debug.setListener(null); // B11
assertNull(exception);
assertEquals(12, breaks);
breaks = 0;
debugger;
a.every(cb_true);
assertEquals(4, breaks);
assertFalse(exception);
Debug.setListener(array_listener);
debugger; // B0
a.every(cb_true); // B1
Debug.setListener(null); // B11
assertNull(exception);
assertEquals(12, breaks);
breaks = 0;
debugger;
a.map(cb_true);
assertFalse(exception);
assertEquals(4, breaks);
Debug.setListener(array_listener);
debugger; // B0
a.map(cb_true); // B1
Debug.setListener(null); // B11
assertNull(exception);
assertEquals(12, breaks);
breaks = 0;
debugger;
a.filter(cb_true);
assertFalse(exception);
assertEquals(4, breaks);
Debug.setListener(array_listener);
debugger; // B0
a.filter(cb_true); // B1
Debug.setListener(null); // B11
assertNull(exception);
assertEquals(12, breaks);
breaks = 0;
debugger;
a.reduce(cb_reduce);
assertFalse(exception);
assertEquals(4, breaks);
Debug.setListener(array_listener);
debugger; // B0
a.reduce(cb_reduce); // B1
Debug.setListener(null); // B8
assertNull(exception);
assertEquals(9, breaks);
breaks = 0;
debugger;
a.reduceRight(cb_reduce);
assertFalse(exception);
assertEquals(4, breaks);
Debug.setListener(null);
Debug.setListener(array_listener);
debugger; // B0
a.reduceRight(cb_reduce); // B1
Debug.setListener(null); // B8
assertNull(exception);
assertEquals(9, breaks);
// Test two levels of builtin callbacks:
// Array.forEach calls a callback function, which by itself uses
// Array.forEach with another callback function.
function second_level_listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (breaks == 0) {
exec_state.prepareStep(Debug.StepAction.StepIn, 3);
breaks = 1;
} else if (breaks <= 16) {
breaks++;
// Check whether we break at the expected line.
assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0);
// Step two steps further every four breaks to skip the
// forEach call in the first level of recurision.
var step = (breaks % 4 == 1) ? 6 : 3;
exec_state.prepareStep(Debug.StepAction.StepIn, step);
}
}
} catch (e) {
exception = true;
}
};
function cb_true_2(num) {
print("element " + num); // B3 B6 B9 B15 B18 B21 B27 B30 B33
return true; // B4 B7 B10 B16 B19 B22 B28 B31 B34
} // B5 B8 B11 B17 B20 B23 B29 B32 B35
function cb_foreach(num) {
a.forEach(cb_true);
print("back to the first level of recursion.");
}
Debug.setListener(second_level_listener);
a.forEach(cb_true_2); // B2 B14 B20 B26
print("back."); // B12 B18 B24 B36
} // B13 B19 B25 B37
breaks = 0;
debugger;
a.forEach(cb_foreach);
assertFalse(exception);
assertEquals(17, breaks);
Debug.setListener(null);
Debug.setListener(array_listener);
debugger; // B0
a.forEach(cb_foreach); // B1
Debug.setListener(null); // B38
assertNull(exception);
assertEquals(39, breaks);
......@@ -41,14 +41,14 @@ var expected_function_name = null;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (state == 1) {
exec_state.prepareStep(Debug.StepAction.StepIn, 2);
state = 2;
} else if (state == 2) {
if (state == 3) {
assertEquals(expected_function_name, event_data.func().name());
assertEquals(expected_source_line_text,
event_data.sourceLineText());
state = 3;
state = 4;
} else {
exec_state.prepareStep(Debug.StepAction.StepIn);
state++;
}
}
} catch(e) {
......@@ -72,7 +72,7 @@ function testStepInArraySlice() {
state = 1;
testStepInArraySlice();
assertNull(exception);
assertEquals(3, state);
assertEquals(4, state);
// Get rid of the debug event listener.
Debug.setListener(null);
......@@ -42,11 +42,11 @@ var step_in_count = 2;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (state == 0) {
if (state < step_in_count) {
// Step into f().
exec_state.prepareStep(Debug.StepAction.StepIn, step_in_count);
state = 2;
} else if (state == 2) {
exec_state.prepareStep(Debug.StepAction.StepIn);
state++;
} else {
assertEquals(expected_source_line_text,
event_data.sourceLineText());
assertEquals(expected_function_name, event_data.func().name());
......
......@@ -12,7 +12,7 @@ function listener(event, exec_state, event_data, data) {
try {
var source_line = exec_state.frame(0).sourceLineText();
print(source_line);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
break_count++;
} catch (e) {
exception = e;
......
......@@ -27,7 +27,7 @@ function listener(event, exec_state, event_data, data) {
"Expected: // Break " + break_count + ".");
++break_count;
if (break_count !== expected_breaks) {
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
} catch(e) {
......
......@@ -38,11 +38,11 @@ var state = 0;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (state == 0) {
if (state < 2) {
// Step into f2.call:
exec_state.prepareStep(Debug.StepAction.StepIn, 2);
state = 2;
} else if (state == 2) {
exec_state.prepareStep(Debug.StepAction.StepIn);
state++;
} else {
assertEquals('g', event_data.func().name());
assertEquals(' return t + 1; // expected line',
event_data.sourceLineText());
......
......@@ -38,13 +38,13 @@ var state = 1;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (state == 1) {
exec_state.prepareStep(Debug.StepAction.StepIn, 3);
state = 2;
} else if (state == 2) {
if (state < 4) {
exec_state.prepareStep(Debug.StepAction.StepIn);
state++;
} else {
assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0,
"source line: \"" + event_data.sourceLineText() + "\"");
state = 3;
state = 5;
}
}
} catch(e) {
......@@ -143,7 +143,7 @@ for (var n in this) {
this[n]();
++functionsCalled;
assertNull(exception, n);
assertEquals(3, state, n);
assertEquals(5, state, n);
assertEquals(functionsCalled, count, n);
}
......
......@@ -30,7 +30,6 @@
Debug = debug.Debug
var exception = null;
var step_out_count = 1;
// Simple debug event handler which counts the number of breaks hit and steps.
var break_point_hit_count = 0;
......@@ -40,7 +39,7 @@ function listener(event, exec_state, event_data, data) {
break_point_hit_count++;
// Continue stepping until returned to bottom frame.
if (exec_state.frameCount() > 1) {
exec_state.prepareStep(Debug.StepAction.StepOut, step_out_count);
exec_state.prepareStep(Debug.StepAction.StepOut);
}
}
......@@ -80,27 +79,23 @@ function fact(x) {
BeginTest('Test 1');
shouldBreak = function(x) { return x == 3; };
step_out_count = 1;
fact(3);
EndTest(2);
BeginTest('Test 2');
shouldBreak = function(x) { return x == 2; };
step_out_count = 1;
fact(3);
EndTest(3);
BeginTest('Test 3');
shouldBreak = function(x) { return x == 1; };
step_out_count = 2;
fact(3);
EndTest(2);
EndTest(4);
BeginTest('Test 4');
shouldBreak = function(x) { return x == 1 || x == 3; };
step_out_count = 2;
fact(3);
EndTest(3);
EndTest(5);
// Get rid of the debug event listener.
Debug.setListener(null);
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
// Do steps until we reach the global scope again.
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
......
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
// Do steps until we reach the global scope again.
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
......
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
// Do steps until we reach the global scope again.
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
......
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
// Do steps until we reach the global scope again.
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
......
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
// Do steps until we reach the global scope again.
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
......
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
// Do steps until we reach the global scope again.
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
......
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
// Do steps until we reach the global scope again.
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
......
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
}
// Do steps until we reach the global scope again.
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
......
......@@ -42,9 +42,9 @@ function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (state == 1) {
exec_state.prepareStep(Debug.StepAction.StepOut, 2);
state = 2;
} else if (state == 2) {
exec_state.prepareStep(Debug.StepAction.StepOut);
state++;
} else {
assertEquals(expected_function_name, event_data.func().name());
assertEquals(expected_source_line_text,
event_data.sourceLineText());
......
......@@ -14,7 +14,7 @@ var step_count = 0;
function listener(event, execState, eventData, data) {
if (event != Debug.DebugEvent.Break) return;
try {
execState.prepareStep(Debug.StepAction.StepInto);
execState.prepareStep(Debug.StepAction.StepIn);
var s = execState.frame().sourceLineText();
step_count++;
assertTrue(s.indexOf('// ' + step_count + '.') >= 0);
......
......@@ -12,7 +12,7 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
breaks.push(exec_state.frame(0).sourceLineText().trimLeft());
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -27,7 +27,7 @@ function listener(event, exec_state, event_data, data) {
"Expected: // Break " + break_count + ".");
++break_count;
if (break_count !== expected_breaks) {
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
}
} catch(e) {
......
......@@ -14,7 +14,7 @@ var stepCount = 0;
function listener(event, execState, eventData, data) {
if (event == Debug.DebugEvent.Break) {
if (!done) {
execState.prepareStep(Debug.StepAction.StepInto);
execState.prepareStep(Debug.StepAction.StepIn);
var s = execState.frame().sourceLineText();
assertTrue(s.indexOf('// ' + stepCount + '.') !== -1);
stepCount++;
......
......@@ -12,7 +12,7 @@ var done, stepCount;
function listener(event, execState, eventData, data) {
if (event == Debug.DebugEvent.Break) {
if (!done) {
execState.prepareStep(Debug.StepAction.StepInto);
execState.prepareStep(Debug.StepAction.StepIn);
var s = execState.frame().sourceLineText();
assertTrue(s.indexOf('// ' + stepCount + '.') !== -1);
stepCount++;
......
......@@ -15,7 +15,7 @@ function listener(event, exec_state, event_data, data) {
print(event_data.sourceLineText());
assertTrue(
event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -6,113 +6,95 @@
Debug = debug.Debug
var exception = false;
var exception = null;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (breaks == 0) {
exec_state.prepareStep(Debug.StepAction.StepIn, 2);
breaks = 1;
} else if (breaks <= 3) {
breaks++;
// Check whether we break at the expected line.
print(event_data.sourceLineText());
assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0);
exec_state.prepareStep(Debug.StepAction.StepIn, 3);
}
exec_state.prepareStep(Debug.StepAction.StepIn);
print(event_data.sourceLineText());
assertTrue(
event_data.sourceLineText().indexOf(`B${breaks++}`) > 0);
}
} catch (e) {
exception = true;
print(e);
quit();
exception = e;
}
}
function cb_set(num) {
print("element " + num); // Expected to step to this point.
return true;
}
print("element " + num); // B2 B5 B8
return true; // B3 B6 B9
} // B4 B7 B10
function cb_map(key, val) {
print("key " + key + ", value " + val); // Expected to step to this point.
return true;
}
print("key " + key + ", value " + val); // B2 B5 B8
return true; // B3 B6 B9
} // B4 B7 B10
var s = new Set();
s.add(1);
s.add(2);
s.add(3);
s.add(4);
var m = new Map();
m.set('foo', 1);
m.set('bar', 2);
m.set('baz', 3);
m.set('bat', 4);
Debug.setListener(listener);
var breaks = 0;
debugger;
s.forEach(cb_set);
assertFalse(exception);
assertEquals(4, breaks);
Debug.setListener(listener);
debugger; // B0
s.forEach(cb_set); // B1
Debug.setListener(null); // B11
assertNull(exception);
assertEquals(12, breaks);
breaks = 0;
debugger;
m.forEach(cb_map);
assertFalse(exception);
assertEquals(4, breaks);
Debug.setListener(null);
Debug.setListener(listener);
debugger; // B0
m.forEach(cb_map); // B1
Debug.setListener(null); // B11
assertNull(exception);
assertEquals(12, breaks);
// Test two levels of builtin callbacks:
// Array.forEach calls a callback function, which by itself uses
// Array.forEach with another callback function.
function second_level_listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
if (breaks == 0) {
exec_state.prepareStep(Debug.StepAction.StepIn, 3);
breaks = 1;
} else if (breaks <= 16) {
breaks++;
// Check whether we break at the expected line.
assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0);
// Step two steps further every four breaks to skip the
// forEach call in the first level of recurision.
var step = (breaks % 4 == 1) ? 6 : 3;
exec_state.prepareStep(Debug.StepAction.StepIn, step);
}
}
} catch (e) {
exception = true;
}
}
function cb_set_2(num) {
print("element " + num); // B3 B6 B9 B15 B18 B21 B27 B30 B33
return true; // B4 B7 B10 B16 B19 B22 B28 B31 B34
} // B5 B8 B11 B17 B20 B23 B29 B32 B35
function cb_map_2(k, v) {
print(`key ${k}, value ${v}`); // B3 B6 B9 B15 B18 B21 B27 B30 B33
return true; // B4 B7 B10 B16 B19 B22 B28 B31 B34
} // B5 B8 B11 B17 B20 B23 B29 B32 B35
function cb_set_foreach(num) {
s.forEach(cb_set);
print("back to the first level of recursion.");
}
s.forEach(cb_set_2); // B2 B14 B26
print("back."); // B12 B24 B36
} // B13 B25 B37
function cb_map_foreach(key, val) {
m.forEach(cb_set);
print("back to the first level of recursion.");
}
Debug.setListener(second_level_listener);
m.forEach(cb_map_2); // B2 B14 B26
print("back."); // B12 B24 B36
} // B13 B25 B37
breaks = 0;
debugger;
s.forEach(cb_set_foreach);
assertFalse(exception);
assertEquals(17, breaks);
Debug.setListener(listener);
debugger; // B0
s.forEach(cb_set_foreach); // B1
Debug.setListener(null); // B38
assertNull(exception);
assertEquals(39, breaks);
breaks = 0;
debugger;
m.forEach(cb_map_foreach);
assertFalse(exception);
assertEquals(17, breaks);
Debug.setListener(null);
Debug.setListener(listener);
debugger; // B0
m.forEach(cb_map_foreach); // B1
Debug.setListener(null); // B38
assertNull(exception);
assertEquals(39, breaks);
......@@ -15,7 +15,7 @@ function listener(event, exec_state, event_data, data) {
print(source);
if (/stop stepping/.test(source)) return;
if (/yield/.test(source)) yields++;
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
print(e, e.stack);
exception = e;
......
......@@ -26,9 +26,9 @@ function listener(event, exec_state, event_data, data) {
"Unexpected pause at: " + source + "\n" +
"Expected: // Break " + break_count + ".");
if (source.indexOf("StepOver.") !== -1) {
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
} else {
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
++break_count;
}
......
......@@ -19,7 +19,7 @@ function listener(event, exec_state, event_data, data) {
entry += exec_state.frame(i).sourceColumn();
}
log.push(entry);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -72,7 +72,7 @@ function listener(event, exec_state, event_data, data) {
var match = line.match(/\/\/ Break (\w)$/);
assertEquals(2, match.length);
log.push(match[1] + col);
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
break_count++;
} catch (e) {
exception = e;
......
......@@ -44,7 +44,7 @@ function listener(event, exec_state, event_data, data) {
++break_count;
if (break_count !== expected_breaks) {
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
print("Next step prepared");
}
}
......
......@@ -19,7 +19,7 @@ function listener(event, exec_state, event_data, data) {
entry += exec_state.frame(i).sourceColumn();
}
log.push(entry);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -19,7 +19,7 @@ function listener(event, exec_state, event_data, data) {
entry += exec_state.frame(i).sourceColumn();
}
log.push(entry);
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -30,7 +30,7 @@
Debug = debug.Debug
function breakListener(event, exec_state, event_data, data) {
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
Debug.setListener(breakListener);
......
......@@ -32,7 +32,7 @@ function listener(event, exec_state, event_data, data) {
for (var i = 0, n = exec_state.frameCount(); i < n; i++) {
exec_state.frame().scopeCount(i);
}
exec_state.prepareStep(Debug.StepAction.Continue, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
}
Debug.setListener(listener);
......
......@@ -31,7 +31,7 @@ Debug = debug.Debug;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
exec_state.prepareStep(Debug.StepAction.StepNext, 10);
exec_state.prepareStep(Debug.StepAction.StepNext);
}
};
......
......@@ -19,7 +19,7 @@ function listener(event, exec_state, event_data, data) {
try {
Debug.debuggerFlags().breakPointsActive.setValue(false);
breaks.push(exec_state.frame().sourceLineText().trimLeft());
exec_state.prepareStep(Debug.StepAction.StepIn, 1);
exec_state.prepareStep(Debug.StepAction.StepIn);
} catch (e) {
exception = e;
}
......
......@@ -5,13 +5,15 @@
// Flags: --allow-natives-syntax --expose-debug-as debug
Debug = debug.Debug
var exception = null;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
exec_state.prepareStep(Debug.StepAction.StepIn, 3);
exec_state.prepareStep(Debug.StepAction.StepIn);
}
} catch (e) {
exception = e;
}
}
......@@ -25,3 +27,4 @@ debugger;
f(2);
Debug.setListener(null);
assertNull(exception);
......@@ -10,7 +10,7 @@ var error_count = 0;
function f() {
return 0; // Break
}
} // Break
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
......@@ -18,7 +18,7 @@ function listener(event, exec_state, event_data, data) {
if (exec_state.frame(0).sourceLineText().indexOf("Break") <0) {
error_count++;
}
exec_state.prepareStep(Debug.StepAction.StepIn, 2);
exec_state.prepareStep(Debug.StepAction.StepIn);
f(); // We should not break in this call of f().
} catch (e) {
print(e + e.stack);
......@@ -29,7 +29,7 @@ function listener(event, exec_state, event_data, data) {
Debug.setListener(listener);
debugger; // Break
f();
f(); // Break
Debug.setListener(null); // Break
......
......@@ -20,7 +20,7 @@ function listener(event, exec_state, event_data, data) {
var label = +exec_state.frame(0).sourceLineText().substr(-1);
log.push(label);
if (label == 2) log.push(exec_state.frame(0).evaluate("i").value());
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
} catch (e) {
exception = e;
print("Caught something. " + e + " " + e.stack);
......
......@@ -12,7 +12,7 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
log.push(exec_state.frame(0).sourceLineText().trimLeft());
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
......
......@@ -16,7 +16,7 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals(expected.shift(), exec_state.frame(0).sourceLineText().trimLeft());
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
......
......@@ -12,7 +12,7 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
log.push(exec_state.frame(0).sourceLineText().trimLeft());
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
......
......@@ -13,7 +13,7 @@ function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
log.push(exec_state.frame(0).sourceLineText().trimLeft());
exec_state.prepareStep(Debug.StepAction.StepNext, 1);
exec_state.prepareStep(Debug.StepAction.StepNext);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
......
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