Commit adea008b authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[inspector] Remove redundant tests.

The wasm-scope-info-liftoff.js and wasm-set-breakpoint-liftoff.js tests
were originally testing the Liftoff path (when we still had the Wasm
interpreter), and have received some updates along the way. Nowadays the
interpreter is going and the non-liftoff versions of these tests don't
provide any additional test coverage, but are merely a slightly less
updated version of the liftoff test.

Bug: chromium:1162229
Change-Id: Ifc9933d47f33674a83b99425ef9d0e4bc5550323
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2609415
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71909}
parent 6f448efb
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --experimental-wasm-type-reflection --experimental-wasm-simd
// SIMD in Liftoff only works with these cpu features, force them on.
// Flags: --enable-sse3 --enable-ssse3 --enable-sse4-1
utils.load('test/inspector/wasm-inspector-test.js');
let {session, contextGroup, Protocol} = InspectorTest.start(
'Test retrieving scope information from compiled Liftoff frames');
session.setupScriptMap();
Protocol.Debugger.enable();
Protocol.Debugger.onPaused(printPauseLocationsAndContinue);
let breakpointLocation = -1;
InspectorTest.runAsyncTestSuite([
async function test() {
// Instantiate wasm and wait for three wasm scripts for the three functions.
instantiateWasm();
let scriptIds = await waitForWasmScripts();
// Set a breakpoint.
InspectorTest.log(
'Setting breakpoint on line 2 (first instruction) of third function');
let breakpoint = await Protocol.Debugger.setBreakpoint(
{'location': {'scriptId': scriptIds[0], 'lineNumber': 0, 'columnNumber': breakpointLocation}});
printIfFailure(breakpoint);
InspectorTest.logMessage(breakpoint.result.actualLocation);
// Now run the wasm code.
await WasmInspectorTest.evalWithUrl('instance.exports.main(42)', 'runWasm');
InspectorTest.log('exports.main returned. Test finished.');
}
]);
async function printPauseLocationsAndContinue(msg) {
let loc = msg.params.callFrames[0].location;
InspectorTest.log('Paused:');
await session.logSourceLocation(loc);
InspectorTest.log('Scope:');
for (var frame of msg.params.callFrames) {
var isWasmFrame = /^wasm/.test(frame.url);
var functionName = frame.functionName || '(anonymous)';
var lineNumber = frame.location.lineNumber;
var columnNumber = frame.location.columnNumber;
InspectorTest.log(`at ${functionName} (${lineNumber}:${columnNumber}):`);
for (var scope of frame.scopeChain) {
InspectorTest.logObject(' - scope (' + scope.type + '):');
if (!isWasmFrame && scope.type == 'global') {
// Skip global scope for non wasm-functions.
InspectorTest.logObject(' -- skipped globals');
continue;
}
var properties = await Protocol.Runtime.getProperties(
{'objectId': scope.object.objectId});
await WasmInspectorTest.dumpScopeProperties(properties);
}
}
InspectorTest.log();
Protocol.Debugger.stepOver();
}
async function instantiateWasm() {
var builder = new WasmModuleBuilder();
// Add a global, memory and exports to populate the module scope.
builder.addGlobal(kWasmI32, true).exportAs('exported_global');
builder.addMemory(1,1).exportMemoryAs('exported_memory');
builder.addTable(kWasmAnyFunc, 3).exportAs('exported_table');
// Add two functions without breakpoint, to check that locals and operand
// stack values are shown correctly in Liftoff code.
// Function A will have its parameter spilled to the stack, because it calls
// function B.
// Function B has a local with a constant value (not using a register), the
// parameter will be held in a register.
const main = builder.addFunction('A (liftoff)', kSig_v_i)
.addBody([
// Call function 'B', forwarding param 0.
kExprLocalGet, 0, kExprCallFunction, 1
])
.exportAs('main');
builder.addFunction('B (liftoff)', kSig_v_i, ['i32_arg'])
.addLocals(kWasmI32, 1, ['i32_local'])
.addLocals(kWasmF32, 4, ['f32_local', '0', '0'])
.addLocals(kWasmS128, 1, ['v128_local'])
.addBody([
// Load a parameter and a constant onto the operand stack.
kExprLocalGet, 0, kExprI32Const, 3,
// Set local 6 to v128 i32.x4 23, 23, 23, 23.
kExprI32Const, 23,
kSimdPrefix, kExprI32x4Splat,
kExprLocalSet, 6,
// Set local 2 to 7.2.
...wasmF32Const(7.2), kExprLocalSet, 2,
// Call function 'C', forwarding param 0.
kExprLocalGet, 0, kExprCallFunction, 2,
// Drop the two operand stack values.
kExprDrop, kExprDrop
]);
// A third function which will be stepped through.
let func = builder.addFunction('C (interpreted)', kSig_v_i, ['i32_arg'])
.addLocals(kWasmI32, 1, ['i32_local'])
.addLocals(kWasmF32, 1, [''])
.addBody([
// Set global 0 to param 0.
kExprLocalGet, 0, kExprGlobalSet, 0,
// Set local 1 to 47.
kExprI32Const, 47, kExprLocalSet, 1,
]);
// Append function to table to test function table output.
builder.appendToTable([main.index]);
var module_bytes = builder.toArray();
breakpointLocation = func.body_offset;
function addWasmJSToTable() {
// Create WasmJS functions to test the function tables output.
const js_func = function js_func() { return 7; };
const wasmjs_func = new WebAssembly.Function({parameters:[], results:['i32']}, js_func);
const wasmjs_anonymous_func = new WebAssembly.Function({parameters:[], results:['i32']}, _ => 7);
instance.exports.exported_table.set(0, wasmjs_func);
instance.exports.exported_table.set(1, wasmjs_anonymous_func);
}
InspectorTest.log('Calling instantiate function.');
await WasmInspectorTest.instantiate(module_bytes);
await WasmInspectorTest.evalWithUrl(`(${addWasmJSToTable})()`, 'populateTable');
}
function printIfFailure(message) {
if (!message.result) {
InspectorTest.logMessage(message);
}
return message;
}
async function waitForWasmScripts() {
InspectorTest.log('Waiting for wasm script to be parsed.');
let wasm_script_ids = [];
while (wasm_script_ids.length < 1) {
let script_msg = await Protocol.Debugger.onceScriptParsed();
let url = script_msg.params.url;
if (url.startsWith('wasm://')) {
InspectorTest.log('Got wasm script!');
wasm_script_ids.push(script_msg.params.scriptId);
}
}
return wasm_script_ids;
}
// Copyright 2017 the V8 project authors. All rights reserved.
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -9,12 +9,12 @@
utils.load('test/inspector/wasm-inspector-test.js');
let {session, contextGroup, Protocol} = InspectorTest.start(
'Test retrieving scope information when pausing in wasm functions');
'Test retrieving scope information from compiled Liftoff frames');
session.setupScriptMap();
Protocol.Debugger.enable();
Protocol.Debugger.onPaused(printPauseLocationsAndContinue);
let breakpointLocation = undefined; // Will be set by {instantiateWasm}.
let breakpointLocation = -1;
InspectorTest.runAsyncTestSuite([
async function test() {
......@@ -24,19 +24,14 @@ InspectorTest.runAsyncTestSuite([
// Set a breakpoint.
InspectorTest.log(
'Setting breakpoint on first instruction of second function');
let breakpoint = await Protocol.Debugger.setBreakpoint({
'location' : {
'scriptId' : scriptIds[0],
'lineNumber' : 0,
'columnNumber' : breakpointLocation
}
});
'Setting breakpoint on line 2 (first instruction) of third function');
let breakpoint = await Protocol.Debugger.setBreakpoint(
{'location': {'scriptId': scriptIds[0], 'lineNumber': 0, 'columnNumber': breakpointLocation}});
printIfFailure(breakpoint);
InspectorTest.logMessage(breakpoint.result.actualLocation);
// Now run the wasm code.
await WasmInspectorTest.evalWithUrl('instance.exports.main(4)', 'runWasm');
await WasmInspectorTest.evalWithUrl('instance.exports.main(42)', 'runWasm');
InspectorTest.log('exports.main returned. Test finished.');
}
]);
......@@ -75,71 +70,69 @@ async function instantiateWasm() {
builder.addMemory(1,1).exportMemoryAs('exported_memory');
builder.addTable(kWasmAnyFunc, 3).exportAs('exported_table');
// Add a function without breakpoint, to check that locals are shown
// correctly in compiled code.
const main = builder.addFunction('call_func', kSig_v_i).addLocals(kWasmF32, 1)
.addBody([
// Set local 1 to 7.2.
...wasmF32Const(7.2), kExprLocalSet, 1,
// Call function 'func', forwarding param 0.
kExprLocalGet, 0, kExprCallFunction, 1
]).exportAs('main');
// A second function which will be stepped through.
const func = builder.addFunction('func', kSig_v_i, ['i32Arg'])
.addLocals(kWasmI32, 1)
.addLocals(kWasmI64, 1, ['i64_local'])
.addLocals(kWasmF64, 3, ['unicode☼f64', '0', '0'])
.addLocals(kWasmS128, 1)
.addLocals(kWasmF32, 1, [''])
.addBody([
// Set param 0 to 11.
kExprI32Const, 11, kExprLocalSet, 0,
// Set local 1 to 47.
kExprI32Const, 47, kExprLocalSet, 1,
// Set local 2 to 0x7FFFFFFFFFFFFFFF (max i64).
kExprI64Const, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0,
kExprLocalSet, 2,
// Set local 2 to 0x8000000000000000 (min i64).
kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7f,
kExprLocalSet, 2,
// Set local 3 to 1/7.
kExprI32Const, 1, kExprF64UConvertI32, kExprI32Const, 7,
kExprF64UConvertI32, kExprF64Div, kExprLocalSet, 3,
// Set local 6 to [23, 23, 23, 23]
kExprI32Const, 23,
kSimdPrefix, kExprI32x4Splat,
kExprLocalSet, 6,
// Set local 7 to 21
kExprI32Const, 21, kExprF32UConvertI32,
kExprLocalSet, 7,
// Set global 0 to 15
kExprI32Const, 15, kExprGlobalSet, 0,
]);
// Add two functions without breakpoint, to check that locals and operand
// stack values are shown correctly in Liftoff code.
// Function A will have its parameter spilled to the stack, because it calls
// function B.
// Function B has a local with a constant value (not using a register), the
// parameter will be held in a register.
const main = builder.addFunction('A (liftoff)', kSig_v_i)
.addBody([
// Call function 'B', forwarding param 0.
kExprLocalGet, 0, kExprCallFunction, 1
])
.exportAs('main');
builder.addFunction('B (liftoff)', kSig_v_i, ['i32_arg'])
.addLocals(kWasmI32, 1, ['i32_local'])
.addLocals(kWasmF32, 4, ['f32_local', '0', '0'])
.addLocals(kWasmS128, 1, ['v128_local'])
.addBody([
// Load a parameter and a constant onto the operand stack.
kExprLocalGet, 0, kExprI32Const, 3,
// Set local 6 to v128 i32.x4 23, 23, 23, 23.
kExprI32Const, 23,
kSimdPrefix, kExprI32x4Splat,
kExprLocalSet, 6,
// Set local 2 to 7.2.
...wasmF32Const(7.2), kExprLocalSet, 2,
// Call function 'C', forwarding param 0.
kExprLocalGet, 0, kExprCallFunction, 2,
// Drop the two operand stack values.
kExprDrop, kExprDrop
]);
// A third function which will be stepped through.
let func = builder.addFunction('C (interpreted)', kSig_v_i, ['i32_arg'])
.addLocals(kWasmI32, 1, ['i32_local'])
.addLocals(kWasmF32, 1, [''])
.addBody([
// Set global 0 to param 0.
kExprLocalGet, 0, kExprGlobalSet, 0,
// Set local 1 to 47.
kExprI32Const, 47, kExprLocalSet, 1,
]);
// Append function to table to test function table output.
builder.appendToTable([main.index]);
let moduleBytes = builder.toArray();
var module_bytes = builder.toArray();
breakpointLocation = func.body_offset;
function addWasmJSToTable() {
// Create WasmJS functions to test the function tables output.
const js_func = function js_func() { return 7; };
const wasmjs_func = new WebAssembly.Function(
{parameters:[], results:['i32']}, js_func);
const wasmjs_anonymous_func = new WebAssembly.Function(
{parameters:[], results:['i32']}, _ => 7);
const wasmjs_func = new WebAssembly.Function({parameters:[], results:['i32']}, js_func);
const wasmjs_anonymous_func = new WebAssembly.Function({parameters:[], results:['i32']}, _ => 7);
instance.exports.exported_table.set(0, wasmjs_func);
instance.exports.exported_table.set(1, wasmjs_anonymous_func);
}
InspectorTest.log('Calling instantiate function.');
await WasmInspectorTest.instantiate(moduleBytes);
await WasmInspectorTest.evalWithUrl(`(${addWasmJSToTable})()`,
'populateTable');
await WasmInspectorTest.instantiate(module_bytes);
await WasmInspectorTest.evalWithUrl(`(${addWasmJSToTable})()`, 'populateTable');
}
function printIfFailure(message) {
......
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
utils.load('test/inspector/wasm-inspector-test.js');
const {session, contextGroup, Protocol} =
InspectorTest.start('Tests stepping through wasm scripts.');
session.setupScriptMap();
const builder = new WasmModuleBuilder();
const func_a =
builder.addFunction('wasm_A', kSig_v_v).addBody([kExprNop, kExprNop]);
// wasm_B calls wasm_A <param0> times.
const func_b = builder.addFunction('wasm_B', kSig_v_i)
.addBody([
// clang-format off
kExprLoop, kWasmStmt, // while
kExprLocalGet, 0, // -
kExprIf, kWasmStmt, // if <param0> != 0
kExprLocalGet, 0, // -
kExprI32Const, 1, // -
kExprI32Sub, // -
kExprLocalSet, 0, // decrease <param0>
kExprCallFunction, func_a.index, // -
kExprBr, 1, // continue
kExprEnd, // -
kExprEnd, // break
// clang-format on
])
.exportAs('main');
const module_bytes = builder.toArray();
const getResult = msg => msg.result || InspectorTest.logMessage(msg);
function setBreakpoint(offset, scriptId, scriptUrl) {
InspectorTest.log(
'Setting breakpoint at offset ' + offset + ' on script ' + scriptUrl);
return Protocol.Debugger
.setBreakpoint(
{'location': {'scriptId': scriptId, 'lineNumber': 0, 'columnNumber': offset}})
.then(getResult);
}
// Only set breakpoints during the first loop iteration.
var first_iteration = true;
Protocol.Debugger.onPaused(async msg => {
let loc = msg.params.callFrames[0].location;
InspectorTest.log('Paused:');
await session.logSourceLocation(loc);
InspectorTest.log('Scope:');
for (var frame of msg.params.callFrames) {
var functionName = frame.functionName || '(anonymous)';
var lineNumber = frame.location.lineNumber;
var columnNumber = frame.location.columnNumber;
InspectorTest.log(`at ${functionName} (${lineNumber}:${columnNumber}):`);
if (!/^wasm/.test(frame.url)) {
InspectorTest.log(' -- skipped');
continue;
}
for (var scope of frame.scopeChain) {
InspectorTest.logObject(' - scope (' + scope.type + '):');
var properties = await Protocol.Runtime.getProperties(
{'objectId': scope.object.objectId});
await WasmInspectorTest.dumpScopeProperties(properties);
}
}
if (first_iteration && loc.columnNumber == func_a.body_offset) {
// Check that setting breakpoints on active instances of A and B takes
// effect immediately.
setBreakpoint(func_a.body_offset + 1, loc.scriptId, frame.url);
// All of the following breakpoints are in reachable code, except offset 17.
for (offset of [18, 17, 11, 10, 8, 6, 2, 4]) {
setBreakpoint(func_b.body_offset + offset, loc.scriptId, frame.url);
}
first_iteration = false;
}
Protocol.Debugger.resume();
});
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.');
// Spawn asynchronously:
WasmInspectorTest.instantiate(module_bytes);
InspectorTest.log(
'Waiting for wasm script (ignoring first non-wasm script).');
// Ignore javascript and full module wasm script, get scripts for functions.
const [, {params: wasm_script}] = await Protocol.Debugger.onceScriptParsed(2);
// Set a breakpoint in function A at offset 0. When the debugger hits this
// breakpoint, new ones will be added.
await setBreakpoint(func_a.body_offset, wasm_script.scriptId, wasm_script.url);
InspectorTest.log('Calling main(4)');
await WasmInspectorTest.evalWithUrl('instance.exports.main(4)', 'runWasm');
InspectorTest.log('exports.main returned!');
}
]);
// Copyright 2018 the V8 project authors. All rights reserved.
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -6,27 +6,28 @@ utils.load('test/inspector/wasm-inspector-test.js');
const {session, contextGroup, Protocol} =
InspectorTest.start('Tests stepping through wasm scripts.');
session.setupScriptMap();
const builder = new WasmModuleBuilder();
const func_a_idx =
builder.addFunction('wasm_A', kSig_v_v).addBody([kExprNop, kExprNop]).index;
const func_a =
builder.addFunction('wasm_A', kSig_v_v).addBody([kExprNop, kExprNop]);
// wasm_B calls wasm_A <param0> times.
const func_b = builder.addFunction('wasm_B', kSig_v_i)
.addBody([
// clang-format off
kExprLoop, kWasmStmt, // while
kExprLocalGet, 0, // -
kExprIf, kWasmStmt, // if <param0> != 0
kExprLocalGet, 0, // -
kExprI32Const, 1, // -
kExprI32Sub, // -
kExprLocalSet, 0, // decrease <param0>
kExprCallFunction, func_a_idx, // -
kExprBr, 1, // continue
kExprEnd, // -
kExprEnd, // break
kExprLoop, kWasmStmt, // while
kExprLocalGet, 0, // -
kExprIf, kWasmStmt, // if <param0> != 0
kExprLocalGet, 0, // -
kExprI32Const, 1, // -
kExprI32Sub, // -
kExprLocalSet, 0, // decrease <param0>
kExprCallFunction, func_a.index, // -
kExprBr, 1, // continue
kExprEnd, // -
kExprEnd, // break
// clang-format on
])
.exportAs('main');
......@@ -35,21 +36,51 @@ const module_bytes = builder.toArray();
const getResult = msg => msg.result || InspectorTest.logMessage(msg);
function setBreakpoint(offset, script) {
function setBreakpoint(offset, scriptId, scriptUrl) {
InspectorTest.log(
'Setting breakpoint at offset ' + offset + ' on script ' + script.url);
'Setting breakpoint at offset ' + offset + ' on script ' + scriptUrl);
return Protocol.Debugger
.setBreakpoint(
{'location': {'scriptId': script.scriptId, 'lineNumber': 0, 'columnNumber': offset}})
{'location': {'scriptId': scriptId, 'lineNumber': 0, 'columnNumber': offset}})
.then(getResult);
}
Protocol.Debugger.onPaused(pause_msg => {
let loc = pause_msg.params.callFrames[0].location;
if (loc.lineNumber != 0) {
InspectorTest.log('Unexpected line number: ' + loc.lineNumber);
// Only set breakpoints during the first loop iteration.
var first_iteration = true;
Protocol.Debugger.onPaused(async msg => {
let loc = msg.params.callFrames[0].location;
InspectorTest.log('Paused:');
await session.logSourceLocation(loc);
InspectorTest.log('Scope:');
for (var frame of msg.params.callFrames) {
var functionName = frame.functionName || '(anonymous)';
var lineNumber = frame.location.lineNumber;
var columnNumber = frame.location.columnNumber;
InspectorTest.log(`at ${functionName} (${lineNumber}:${columnNumber}):`);
if (!/^wasm/.test(frame.url)) {
InspectorTest.log(' -- skipped');
continue;
}
for (var scope of frame.scopeChain) {
InspectorTest.logObject(' - scope (' + scope.type + '):');
var properties = await Protocol.Runtime.getProperties(
{'objectId': scope.object.objectId});
await WasmInspectorTest.dumpScopeProperties(properties);
}
}
if (first_iteration && loc.columnNumber == func_a.body_offset) {
// Check that setting breakpoints on active instances of A and B takes
// effect immediately.
setBreakpoint(func_a.body_offset + 1, loc.scriptId, frame.url);
// All of the following breakpoints are in reachable code, except offset 17.
for (offset of [18, 17, 11, 10, 8, 6, 2, 4]) {
setBreakpoint(func_b.body_offset + offset, loc.scriptId, frame.url);
}
first_iteration = false;
}
InspectorTest.log('Breaking on byte offset ' + loc.columnNumber);
Protocol.Debugger.resume();
});
......@@ -63,9 +94,9 @@ InspectorTest.runAsyncTestSuite([
'Waiting for wasm script (ignoring first non-wasm script).');
// Ignore javascript and full module wasm script, get scripts for functions.
const [, {params: wasm_script}] = await Protocol.Debugger.onceScriptParsed(2);
for (offset of [11, 10, 8, 6, 2, 4]) {
await setBreakpoint(func_b.body_offset + offset, wasm_script);
}
// Set a breakpoint in function A at offset 0. When the debugger hits this
// breakpoint, new ones will be added.
await setBreakpoint(func_a.body_offset, wasm_script.scriptId, wasm_script.url);
InspectorTest.log('Calling main(4)');
await WasmInspectorTest.evalWithUrl('instance.exports.main(4)', 'runWasm');
InspectorTest.log('exports.main returned!');
......
......@@ -152,7 +152,7 @@
# Skip tests that fail with GC stress: https://crbug.com/v8/10748
'debugger/wasm-debug-command': [SKIP],
'debugger/wasm-global-names': [SKIP],
'debugger/wasm-set-breakpoint-liftoff': [SKIP],
'debugger/wasm-set-breakpoint': [SKIP],
'debugger/wasm-source': [SKIP],
'debugger/wasm-stepping-with-skiplist': [SKIP],
}], # stress_js_bg_compile_wasm_code_gc
......
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