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