Commit 4828af82 authored by Kim-Anh Tran's avatar Kim-Anh Tran Committed by Commit Bot

[debug] Add support for skipping locations on stepping into

This extends the skip list feature from step over to step into.
On a step into we can pass a skipList, which contains locations
that we do not want to stop at.

Bug: chromium:1105765
Change-Id: I70a4ded3f6a7eada14f54ae9c2f994c155c7305b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2345224Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69376}
parent 9c8ebcbb
......@@ -1891,9 +1891,9 @@ void Debug::OnDebugBreak(Handle<FixedArray> break_points_hit,
HandleScope scope(isolate_);
DisableBreak no_recursive_break(this);
// Only check if we should skip this location if we
// paused because of a step over.
if (lastStepAction == StepAction::StepNext && ShouldBeSkipped()) {
if ((lastStepAction == StepAction::StepNext ||
lastStepAction == StepAction::StepIn) &&
ShouldBeSkipped()) {
PrepareStep(lastStepAction);
return;
}
......
......@@ -1146,6 +1146,14 @@ Response V8DebuggerAgentImpl::stepInto(
Maybe<bool> inBreakOnAsyncCall,
Maybe<protocol::Array<protocol::Debugger::LocationRange>> inSkipList) {
if (!isPaused()) return Response::ServerError(kDebuggerNotPaused);
if (inSkipList.isJust()) {
const Response res = processSkipList(inSkipList.fromJust());
if (res.IsError()) return res;
} else {
m_skipList.clear();
}
m_session->releaseObjectGroup(kBacktraceObjectGroup);
m_debugger->stepIntoStatement(m_session->contextGroupId(),
inBreakOnAsyncCall.fromMaybe(false));
......
Tests that stepOver and stepInto correctly handle skipLists.
Test: No skip list
Testing step over with skipList: []
Test: Stepping over without skip list
Testing stepOver with skipList: []
test: 1:2
test: 2:10
test: 3:12
......@@ -9,15 +9,15 @@ test: 5:4
test: 7:10
test: 8:2
test: 9:13
Test: Skip lines
Testing step over with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":4,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":8,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}}]
Test: Stepping over with skip list
Testing stepOver with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":4,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":8,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}}]
test: 1:2
test: 4:2
test: 5:4
test: 7:10
test: 9:13
Test: Start location is inclusive
Testing step over with skipList: [{"scriptId":"3","start":{"lineNumber":8,"columnNumber":2},"end":{"lineNumber":9,"columnNumber":0}}]
Test: Stepping over start location is inclusive
Testing stepOver with skipList: [{"scriptId":"3","start":{"lineNumber":8,"columnNumber":2},"end":{"lineNumber":9,"columnNumber":0}}]
test: 1:2
test: 2:10
test: 3:12
......@@ -25,28 +25,87 @@ test: 4:2
test: 5:4
test: 7:10
test: 9:13
Test: End location is exclusive
Testing step over with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":8,"columnNumber":2}}]
Test: Stepping over end location is exclusive
Testing stepOver with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":8,"columnNumber":2}}]
test: 1:2
test: 8:2
test: 9:13
Test: Stepping into without skip list
Testing stepInto with skipList: []
test: 1:2
test: 2:10
test: 3:12
test: 4:2
test: 5:4
test: 7:10
test: 8:2
add: 1:12
add: 2:13
test: 9:13
Test: Stepping into with skip list, while call itself is skipped
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":1,"columnNumber":0},"end":{"lineNumber":2,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}}]
test: 1:2
add: 2:13
test: 9:13
Test: Stepping into start location is inclusive
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":2,"columnNumber":13},"end":{"lineNumber":3,"columnNumber":0}}]
test: 1:2
test: 2:10
test: 3:12
test: 4:2
test: 5:4
test: 7:10
test: 8:2
add: 1:12
test: 9:13
Test: Stepping into end location is exclusive
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":1,"columnNumber":0},"end":{"lineNumber":2,"columnNumber":13}}]
test: 1:2
test: 2:10
test: 3:12
test: 4:2
test: 5:4
test: 7:10
test: 8:2
add: 2:13
test: 9:13
Test: start position has invalid column number
Testing stepOver with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":-1},"end":{"lineNumber":9,"columnNumber":0}}]
test: 1:2
Position missing 'column' or 'column' < 0.
Test: start position has invalid line number
Testing stepOver with skipList: [{"scriptId":"3","start":{"lineNumber":-1,"columnNumber":0},"end":{"lineNumber":2,"columnNumber":0}}]
test: 1:2
Position missing 'line' or 'line' < 0.
Test: end position smaller than start position
Testing stepOver with skipList: [{"scriptId":"3","start":{"lineNumber":4,"columnNumber":0},"end":{"lineNumber":2,"columnNumber":0}}]
test: 1:2
Input positions array is not sorted or contains duplicate values.
Test: skip list is not maximally merged
Testing stepOver with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":4,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":4,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}}]
test: 1:2
Input positions array is not sorted or contains duplicate values.
Test: skip list is not sorted
Testing stepOver with skipList: [{"scriptId":"3","start":{"lineNumber":8,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":4,"columnNumber":0}}]
test: 1:2
Input positions array is not sorted or contains duplicate values.
Test: start position has invalid column number
Testing step over with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":-1},"end":{"lineNumber":9,"columnNumber":0}}]
Testing stepInto with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":-1},"end":{"lineNumber":9,"columnNumber":0}}]
test: 1:2
Position missing 'column' or 'column' < 0.
Test: start position has invalid line number
Testing step over with skipList: [{"scriptId":"3","start":{"lineNumber":-1,"columnNumber":0},"end":{"lineNumber":2,"columnNumber":0}}]
Testing stepInto with skipList: [{"scriptId":"3","start":{"lineNumber":-1,"columnNumber":0},"end":{"lineNumber":2,"columnNumber":0}}]
test: 1:2
Position missing 'line' or 'line' < 0.
Test: end position smaller than start position
Testing step over with skipList: [{"scriptId":"3","start":{"lineNumber":4,"columnNumber":0},"end":{"lineNumber":2,"columnNumber":0}}]
Testing stepInto with skipList: [{"scriptId":"3","start":{"lineNumber":4,"columnNumber":0},"end":{"lineNumber":2,"columnNumber":0}}]
test: 1:2
Input positions array is not sorted or contains duplicate values.
Test: skip list is not maximally merged
Testing step over with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":4,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":4,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}}]
Testing stepInto with skipList: [{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":4,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":4,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}}]
test: 1:2
Input positions array is not sorted or contains duplicate values.
Test: skip list is not sorted
Testing step over with skipList: [{"scriptId":"3","start":{"lineNumber":8,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":4,"columnNumber":0}}]
Testing stepInto with skipList: [{"scriptId":"3","start":{"lineNumber":8,"columnNumber":0},"end":{"lineNumber":9,"columnNumber":0}},{"scriptId":"3","start":{"lineNumber":2,"columnNumber":0},"end":{"lineNumber":4,"columnNumber":0}}]
test: 1:2
Input positions array is not sorted or contains duplicate values.
......@@ -18,7 +18,8 @@ function test(input) {
}
function add(a, b) {
return a + b;
var res = a + b;
return res;
}
contextGroup.addScript(`${test} //# sourceURL=test.js`);
......@@ -30,83 +31,122 @@ const function_call_line_offset = 8;
const function_call_column_offset = 2;
const if_case_line_offset = 4;
const add_first_line_line_offset = 1;
const add_last_line_line_offset = 2;
const add_last_line_column_offset = 13;
Protocol.Debugger.enable();
runTest()
.catch(reason => InspectorTest.log(`Failed: ${reason}`))
.then(InspectorTest.completeTest);
async function runTest() {
const response = await Protocol.Debugger.onceScriptParsed();
const scriptId = response.params.scriptId;
const response = await Protocol.Debugger.onceScriptParsed(2);
const scriptIds = response.map(msg => msg.params.scriptId);
await checkValidSkipLists(scriptId);
await checkInvalidSkipLists(scriptId);
await checkValidSkipLists(scriptIds[0], scriptIds[1]);
await checkInvalidSkipLists(scriptIds[0]);
}
async function checkInvalidSkipLists(scriptId) {
InspectorTest.log('Test: start position has invalid column number');
let skipList = [createLocationRange(
scriptId, first_non_debug_line_offset, -1, last_line_line_offset, 0)];
await testStepOver(skipList);
const actions = ['stepOver', 'stepInto'];
for (let action of actions) {
InspectorTest.log('Test: start position has invalid column number');
let skipList = [createLocationRange(
scriptId, first_non_debug_line_offset, -1, last_line_line_offset, 0)];
await testStep(skipList, action);
InspectorTest.log('Test: start position has invalid line number');
skipList =
[createLocationRange(scriptId, -1, 0, first_non_debug_line_offset, 0)];
await testStep(skipList, action);
InspectorTest.log('Test: end position smaller than start position');
skipList = [createLocationRange(
scriptId, if_case_line_offset, 0, first_non_debug_line_offset, 0)];
await testStep(skipList, action);
InspectorTest.log('Test: skip list is not maximally merged');
skipList = [
createLocationRange(
scriptId, first_non_debug_line_offset, 0, if_case_line_offset, 0),
createLocationRange(
scriptId, if_case_line_offset, 0, last_line_line_offset, 0)
];
await testStep(skipList, action);
InspectorTest.log('Test: skip list is not sorted');
skipList = [
createLocationRange(
scriptId, function_call_line_offset, 0, last_line_line_offset, 0),
createLocationRange(
scriptId, first_non_debug_line_offset, 0, if_case_line_offset, 0)
];
await testStep(skipList, action);
}
}
InspectorTest.log('Test: start position has invalid line number');
skipList =
[createLocationRange(scriptId, -1, 0, first_non_debug_line_offset, 0)];
await testStepOver(skipList);
async function checkValidSkipLists(testScriptId, addScriptId) {
InspectorTest.log('Test: Stepping over without skip list');
await testStep([], 'stepOver');
InspectorTest.log('Test: end position smaller than start position');
InspectorTest.log('Test: Stepping over with skip list');
let skipList = [
createLocationRange(
testScriptId, first_non_debug_line_offset, 0, if_case_line_offset, 0),
createLocationRange(
testScriptId, function_call_line_offset, 0, last_line_line_offset, 0)
];
await testStep(skipList, 'stepOver');
InspectorTest.log('Test: Stepping over start location is inclusive');
skipList = [createLocationRange(
testScriptId, function_call_line_offset, function_call_column_offset,
last_line_line_offset, 0)];
await testStep(skipList, 'stepOver');
InspectorTest.log('Test: Stepping over end location is exclusive');
skipList = [createLocationRange(
scriptId, if_case_line_offset, 0, first_non_debug_line_offset, 0)];
await testStepOver(skipList);
testScriptId, first_non_debug_line_offset, 0, function_call_line_offset,
function_call_column_offset)];
await testStep(skipList, 'stepOver');
InspectorTest.log('Test: Stepping into without skip list');
skipList = [];
await testStep(skipList, 'stepInto');
InspectorTest.log('Test: skip list is not maximally merged');
InspectorTest.log(
'Test: Stepping into with skip list, while call itself is skipped');
skipList = [
createLocationRange(
scriptId, first_non_debug_line_offset, 0, if_case_line_offset, 0),
addScriptId, add_first_line_line_offset, 0, add_last_line_line_offset,
0),
createLocationRange(
scriptId, if_case_line_offset, 0, last_line_line_offset, 0)
testScriptId, first_non_debug_line_offset, 0,
function_call_line_offset + 1, 0),
];
await testStepOver(skipList);
await testStep(skipList, 'stepInto');
InspectorTest.log('Test: skip list is not sorted');
InspectorTest.log('Test: Stepping into start location is inclusive');
skipList = [
createLocationRange(
scriptId, function_call_line_offset, 0, last_line_line_offset, 0),
createLocationRange(
scriptId, first_non_debug_line_offset, 0, if_case_line_offset, 0)
addScriptId, add_last_line_line_offset, add_last_line_column_offset,
add_last_line_line_offset + 1, 0),
];
await testStepOver(skipList);
}
async function checkValidSkipLists(scriptId) {
InspectorTest.log('Test: No skip list');
await testStepOver([]);
await testStep(skipList, 'stepInto');
InspectorTest.log('Test: Skip lines');
let skipList = [
createLocationRange(
scriptId, first_non_debug_line_offset, 0, if_case_line_offset, 0),
InspectorTest.log('Test: Stepping into end location is exclusive');
skipList = [
createLocationRange(
scriptId, function_call_line_offset, 0, last_line_line_offset, 0)
addScriptId, add_last_line_line_offset - 1, 0,
add_last_line_line_offset, add_last_line_column_offset),
];
await testStepOver(skipList);
InspectorTest.log('Test: Start location is inclusive');
skipList = [createLocationRange(
scriptId, function_call_line_offset, function_call_column_offset,
last_line_line_offset, 0)];
await testStepOver(skipList);
InspectorTest.log('Test: End location is exclusive');
skipList = [createLocationRange(
scriptId, first_non_debug_line_offset, 0, function_call_line_offset,
function_call_column_offset)];
await testStepOver(skipList);
await testStep(skipList, 'stepInto');
}
async function testStepOver(skipList) {
async function testStep(skipList, stepAction) {
InspectorTest.log(
`Testing step over with skipList: ${JSON.stringify(skipList)}`);
`Testing ${stepAction} with skipList: ${JSON.stringify(skipList)}`);
Protocol.Runtime.evaluate({expression: 'test(5);'});
while (true) {
const pausedMsg = await Protocol.Debugger.oncePaused();
......@@ -114,7 +154,7 @@ async function testStepOver(skipList) {
printCallFrame(topCallFrame);
if (topCallFrame.location.lineNumber == last_line_line_offset) break;
const stepOverMsg = await Protocol.Debugger.stepOver({skipList});
const stepOverMsg = await Protocol.Debugger[stepAction]({skipList});
if (stepOverMsg.error) {
InspectorTest.log(stepOverMsg.error.message);
Protocol.Debugger.resume();
......
......@@ -8,8 +8,8 @@ Got wasm script: wasm://wasm/befe41aa
}
Test with valid skip lists
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: No skip list
Testing step over with skipList: []
Test: Stepping over without skip list
Testing stepOver with skipList: []
Script wasm://wasm/befe41aa byte offset 48: Wasm opcode 0x04
Script wasm://wasm/befe41aa byte offset 50: Wasm opcode 0x20
Script wasm://wasm/befe41aa byte offset 52: Wasm opcode 0x41
......@@ -19,8 +19,8 @@ Script wasm://wasm/befe41aa byte offset 57: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 60: Wasm opcode 0x10
Script wasm://wasm/befe41aa byte offset 62: Wasm opcode 0x0c
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: Skip lines
Testing step over with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":50}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":60},"end":{"lineNumber":0,"columnNumber":62}}]
Test: Stepping over with skip list
Testing stepOver with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":50}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":60},"end":{"lineNumber":0,"columnNumber":62}}]
Script wasm://wasm/befe41aa byte offset 50: Wasm opcode 0x20
Script wasm://wasm/befe41aa byte offset 52: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 54: Wasm opcode 0x6b
......@@ -28,30 +28,90 @@ Script wasm://wasm/befe41aa byte offset 55: Wasm opcode 0x21
Script wasm://wasm/befe41aa byte offset 57: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 62: Wasm opcode 0x0c
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: Start location is inclusive
Testing step over with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":61}}]
Test: Stepping over start location is inclusive
Testing stepOver with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":61}}]
Script wasm://wasm/befe41aa byte offset 62: Wasm opcode 0x0c
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: End location is exclusive
Testing step over with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":49},"end":{"lineNumber":0,"columnNumber":62}}]
Test: Stepping over end location is exclusive
Testing stepOver with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":49},"end":{"lineNumber":0,"columnNumber":62}}]
Script wasm://wasm/befe41aa byte offset 48: Wasm opcode 0x04
Script wasm://wasm/befe41aa byte offset 62: Wasm opcode 0x0c
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: Stepping into without skip list
Testing stepInto with skipList: []
Script wasm://wasm/befe41aa byte offset 48: Wasm opcode 0x04
Script wasm://wasm/befe41aa byte offset 50: Wasm opcode 0x20
Script wasm://wasm/befe41aa byte offset 52: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 54: Wasm opcode 0x6b
Script wasm://wasm/befe41aa byte offset 55: Wasm opcode 0x21
Script wasm://wasm/befe41aa byte offset 57: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 60: Wasm opcode 0x10
Script wasm://wasm/befe41aa byte offset 39: Wasm opcode 0x01
Script wasm://wasm/befe41aa byte offset 40: Wasm opcode 0x01
Script wasm://wasm/befe41aa byte offset 41: Wasm opcode 0x0b
Script wasm://wasm/befe41aa byte offset 62: Wasm opcode 0x0c
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: Stepping into with skip list, while call itself is skipped
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":39},"end":{"lineNumber":0,"columnNumber":41}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":50},"end":{"lineNumber":0,"columnNumber":62}}]
Script wasm://wasm/befe41aa byte offset 48: Wasm opcode 0x04
Script wasm://wasm/befe41aa byte offset 41: Wasm opcode 0x0b
Script wasm://wasm/befe41aa byte offset 62: Wasm opcode 0x0c
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: Stepping into start location is inclusive
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":39},"end":{"lineNumber":0,"columnNumber":40}}]
Script wasm://wasm/befe41aa byte offset 48: Wasm opcode 0x04
Script wasm://wasm/befe41aa byte offset 50: Wasm opcode 0x20
Script wasm://wasm/befe41aa byte offset 52: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 54: Wasm opcode 0x6b
Script wasm://wasm/befe41aa byte offset 55: Wasm opcode 0x21
Script wasm://wasm/befe41aa byte offset 57: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 60: Wasm opcode 0x10
Script wasm://wasm/befe41aa byte offset 40: Wasm opcode 0x01
Script wasm://wasm/befe41aa byte offset 41: Wasm opcode 0x0b
Script wasm://wasm/befe41aa byte offset 62: Wasm opcode 0x0c
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: Stepping into end location is exclusive
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":38},"end":{"lineNumber":0,"columnNumber":41}}]
Script wasm://wasm/befe41aa byte offset 48: Wasm opcode 0x04
Script wasm://wasm/befe41aa byte offset 50: Wasm opcode 0x20
Script wasm://wasm/befe41aa byte offset 52: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 54: Wasm opcode 0x6b
Script wasm://wasm/befe41aa byte offset 55: Wasm opcode 0x21
Script wasm://wasm/befe41aa byte offset 57: Wasm opcode 0x41
Script wasm://wasm/befe41aa byte offset 60: Wasm opcode 0x10
Script wasm://wasm/befe41aa byte offset 41: Wasm opcode 0x0b
Script wasm://wasm/befe41aa byte offset 62: Wasm opcode 0x0c
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test with invalid skip lists
Script wasm://wasm/befe41aa byte offset 46: Wasm opcode 0x20
Test: start position has invalid column number
Testing step over with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":-1},"end":{"lineNumber":0,"columnNumber":62}}]
Testing stepOver with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":-1},"end":{"lineNumber":0,"columnNumber":62}}]
Position missing 'column' or 'column' < 0.
Test: start position has invalid line number
Testing stepOver with skipList: [{"scriptId":"4","start":{"lineNumber":-1,"columnNumber":0},"end":{"lineNumber":0,"columnNumber":62}}]
Position missing 'line' or 'line' < 0.
Test: end position smaller than start position
Testing stepOver with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":62},"end":{"lineNumber":0,"columnNumber":48}}]
Input positions array is not sorted or contains duplicate values.
Test: skip list is not maximally merged
Testing stepOver with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":50}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":50},"end":{"lineNumber":0,"columnNumber":62}}]
Input positions array is not sorted or contains duplicate values.
Test: skip list is not sorted
Testing stepOver with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":50},"end":{"lineNumber":0,"columnNumber":62}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":62}}]
Input positions array is not sorted or contains duplicate values.
Test: start position has invalid column number
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":-1},"end":{"lineNumber":0,"columnNumber":62}}]
Position missing 'column' or 'column' < 0.
Test: start position has invalid line number
Testing step over with skipList: [{"scriptId":"4","start":{"lineNumber":-1,"columnNumber":0},"end":{"lineNumber":0,"columnNumber":62}}]
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":-1,"columnNumber":0},"end":{"lineNumber":0,"columnNumber":62}}]
Position missing 'line' or 'line' < 0.
Test: end position smaller than start position
Testing step over with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":62},"end":{"lineNumber":0,"columnNumber":48}}]
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":62},"end":{"lineNumber":0,"columnNumber":48}}]
Input positions array is not sorted or contains duplicate values.
Test: skip list is not maximally merged
Testing step over with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":50}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":50},"end":{"lineNumber":0,"columnNumber":62}}]
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":50}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":50},"end":{"lineNumber":0,"columnNumber":62}}]
Input positions array is not sorted or contains duplicate values.
Test: skip list is not sorted
Testing step over with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":50},"end":{"lineNumber":0,"columnNumber":62}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":62}}]
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":50},"end":{"lineNumber":0,"columnNumber":62}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":62}}]
Input positions array is not sorted or contains duplicate values.
Finished!
......@@ -8,13 +8,14 @@ let {session, contextGroup, Protocol} =
InspectorTest.start('Tests stepping through wasm scripts by byte offsets');
session.setupScriptMap();
var builder = new WasmModuleBuilder();
const builder = new WasmModuleBuilder();
var func_a_idx =
builder.addFunction('wasm_A', kSig_v_i).addBody([kExprNop, kExprNop]).index;
const func_a =
builder.addFunction('wasm_A', kSig_v_i).addBody([kExprNop, kExprNop]);
const func_a_idx = func_a.index;
// wasm_B calls wasm_A <param0> times.
var func_b = builder.addFunction('wasm_B', kSig_v_i)
const func_b = builder.addFunction('wasm_B', kSig_v_i)
.addBody([
// clang-format off
kExprLoop, kWasmStmt, // while
......@@ -40,6 +41,9 @@ const loop_body_end_offset = loop_body_start_offset + 14;
const if_statement_offset = loop_body_start_offset + 2
const call_function_offset = loop_body_start_offset + 12;
const func_a_start_offset = func_a.body_offset;
const func_a_end_offset = func_a_start_offset + 2;
runTest()
.catch(reason => InspectorTest.log(`Failed: ${reason}`))
.then(InspectorTest.completeTest);
......@@ -67,83 +71,113 @@ async function runTest() {
async function checkValidSkipLists(scriptId) {
InspectorTest.log('Test with valid skip lists');
Protocol.Runtime.evaluate({expression: 'instance.exports.main(5)'});
Protocol.Runtime.evaluate({expression: 'instance.exports.main(8)'});
const {params: {callFrames}} = await Protocol.Debugger.oncePaused();
await session.logSourceLocation(callFrames[0].location);
InspectorTest.log('Test: No skip list');
InspectorTest.log('Test: Stepping over without skip list');
let skipList = [];
await stepThroughOneLoopIteration(skipList);
await stepThroughOneLoopIteration(skipList, 'stepOver');
InspectorTest.log('Test: Skip lines');
InspectorTest.log('Test: Stepping over with skip list');
skipList = [
createLocationRange(scriptId, loop_body_start_offset, if_statement_offset),
createLocationRange(scriptId, call_function_offset, loop_body_end_offset)
];
await stepThroughOneLoopIteration(skipList);
await stepThroughOneLoopIteration(skipList, 'stepOver');
InspectorTest.log('Test: Start location is inclusive');
InspectorTest.log('Test: Stepping over start location is inclusive');
skipList = [
createLocationRange(
scriptId, loop_body_start_offset, loop_body_end_offset - 1),
];
await stepThroughOneLoopIteration(skipList);
await stepThroughOneLoopIteration(skipList, 'stepOver');
InspectorTest.log('Test: End location is exclusive');
InspectorTest.log('Test: Stepping over end location is exclusive');
skipList = [
createLocationRange(
scriptId, loop_body_start_offset + 1, loop_body_end_offset),
];
await stepThroughOneLoopIteration(skipList);
await Protocol.Debugger.resume();
}
await stepThroughOneLoopIteration(skipList, 'stepOver');
async function checkInvalidSkipLists(scriptId) {
InspectorTest.log('Test with invalid skip lists');
Protocol.Runtime.evaluate({expression: 'instance.exports.main(5)'});
const {params: {callFrames}} = await Protocol.Debugger.oncePaused();
await session.logSourceLocation(callFrames[0].location);
InspectorTest.log('Test: Stepping into without skip list');
skipList = [];
await stepThroughOneLoopIteration(skipList, 'stepInto');
InspectorTest.log('Test: start position has invalid column number');
let skipList = [
createLocationRange(scriptId, -1, loop_body_end_offset),
];
await stepThroughOneLoopIteration(skipList);
InspectorTest.log('Test: start position has invalid line number');
skipList = [{
scriptId: scriptId,
start: {lineNumber: -1, columnNumber: 0},
end: {lineNumber: 0, columnNumber: loop_body_end_offset}
}];
await stepThroughOneLoopIteration(skipList);
InspectorTest.log('Test: end position smaller than start position');
skipList = [createLocationRange(
scriptId, loop_body_end_offset, loop_body_start_offset)];
await stepThroughOneLoopIteration(skipList);
InspectorTest.log('Test: skip list is not maximally merged');
InspectorTest.log(
'Test: Stepping into with skip list, while call itself is skipped');
skipList = [
createLocationRange(scriptId, loop_body_start_offset, if_statement_offset),
createLocationRange(scriptId, func_a_start_offset, func_a_end_offset),
createLocationRange(scriptId, if_statement_offset, loop_body_end_offset)
];
await stepThroughOneLoopIteration(skipList);
await stepThroughOneLoopIteration(skipList, 'stepInto');
InspectorTest.log('Test: skip list is not sorted');
InspectorTest.log('Test: Stepping into start location is inclusive');
skipList = [
createLocationRange(scriptId, if_statement_offset, loop_body_end_offset),
createLocationRange(scriptId, loop_body_start_offset, loop_body_end_offset)
createLocationRange(scriptId, func_a_start_offset, func_a_end_offset - 1),
];
await stepThroughOneLoopIteration(skipList);
await stepThroughOneLoopIteration(skipList, 'stepInto');
InspectorTest.log('Test: Stepping into end location is exclusive');
skipList = [
createLocationRange(scriptId, func_a_start_offset - 1, func_a_end_offset),
];
await stepThroughOneLoopIteration(skipList, 'stepInto');
await Protocol.Debugger.resume();
}
async function checkInvalidSkipLists(scriptId) {
InspectorTest.log('Test with invalid skip lists');
Protocol.Runtime.evaluate({expression: 'instance.exports.main(8)'});
const {params: {callFrames}} = await Protocol.Debugger.oncePaused();
await session.logSourceLocation(callFrames[0].location);
const actions = ['stepOver', 'stepInto'];
for (let action of actions) {
InspectorTest.log('Test: start position has invalid column number');
let skipList = [
createLocationRange(scriptId, -1, loop_body_end_offset),
];
await stepThroughOneLoopIteration(skipList, action);
InspectorTest.log('Test: start position has invalid line number');
skipList = [{
scriptId: scriptId,
start: {lineNumber: -1, columnNumber: 0},
end: {lineNumber: 0, columnNumber: loop_body_end_offset}
}];
await stepThroughOneLoopIteration(skipList, action);
InspectorTest.log('Test: end position smaller than start position');
skipList = [createLocationRange(
scriptId, loop_body_end_offset, loop_body_start_offset)];
await stepThroughOneLoopIteration(skipList, action);
InspectorTest.log('Test: skip list is not maximally merged');
skipList = [
createLocationRange(
scriptId, loop_body_start_offset, if_statement_offset),
createLocationRange(scriptId, if_statement_offset, loop_body_end_offset)
];
await stepThroughOneLoopIteration(skipList, action);
InspectorTest.log('Test: skip list is not sorted');
skipList = [
createLocationRange(scriptId, if_statement_offset, loop_body_end_offset),
createLocationRange(
scriptId, loop_body_start_offset, loop_body_end_offset)
];
await stepThroughOneLoopIteration(skipList, action);
}
}
async function stepThroughOneLoopIteration(skipList) {
async function stepThroughOneLoopIteration(skipList, stepAction) {
InspectorTest.log(
`Testing step over with skipList: ${JSON.stringify(skipList)}`);
`Testing ${stepAction} with skipList: ${JSON.stringify(skipList)}`);
let topFrameLocation = -1;
while (topFrameLocation.columnNumber != loop_start_offset) {
const stepOverMsg = await Protocol.Debugger.stepOver({skipList});
const stepOverMsg = await Protocol.Debugger[stepAction]({skipList});
if (stepOverMsg.error) {
InspectorTest.log(stepOverMsg.error.message);
return;
......
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