v8/test/inspector/debugger/wasm-step-from-non-breakable-position.js
Clemens Backes 10dbddd1e8 [wasm] Fix stepping from a non-breakable position
... at function start. Otherwise we run into a position mismatch:
In a non-flooded function, we add the function-entry breakpoint (for
"hook on function call") with the position of the first opcode.
In the flooded function though, we skip that special breakpoint because
we will stop at the first instruction anyway. But then the first
instruction is non-breakable, so we don't actually emit a breakpoint for
it.
Hence during OSR we do not find a corresponding position in the new
code.

This CL fixes this by postponing the function-entry breakpoint until the
first breakable opcode is found, and only emits it if that position does
not have a breakpoint anyway.
This way, we can also move the handling for function-entry breakpoints
from {StartFunctionBody} to {EmitDebuggingInfo}, where it fits much
better.

R=thibaudm@chromium.org

Bug: chromium:1137710
Change-Id: Idfa658fa0897cca89ba5ee3066cd414f68864d06
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2474774
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70529}
2020-10-15 11:35:43 +00:00

55 lines
2.0 KiB
JavaScript

// 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');
let {session, contextGroup, Protocol} = InspectorTest.start(
'Step into a function that starts with a non-breakable opcode (i.e. ' +
'block), then step from there. See https://crbug.com/1137710.');
session.setupScriptMap();
var builder = new WasmModuleBuilder();
var callee = builder.addFunction('callee', kSig_v_v)
.addBody([kExprBlock, kWasmStmt, kExprEnd])
.index;
var main = builder.addFunction('main', kSig_v_i)
.addBody([kExprCallFunction, callee])
.exportFunc();
var module_bytes = builder.toArray();
(async function test() {
InspectorTest.logProtocolCommandCalls('Debugger.stepInto');
InspectorTest.logProtocolCommandCalls('Debugger.resume');
await Protocol.Debugger.enable();
InspectorTest.log('Setting up global instance variable.');
WasmInspectorTest.instantiate(module_bytes);
const [, {params: wasmScript}] = await Protocol.Debugger.onceScriptParsed(2);
InspectorTest.log(`Got wasm script: ${wasmScript.url}`);
// Set a breakpoint in 'main', at the call.
InspectorTest.log(`Setting breakpoint on offset ${main.body_offset}`);
await Protocol.Debugger.setBreakpoint({
location: {
scriptId: wasmScript.scriptId,
lineNumber: 0,
columnNumber: main.body_offset
}
});
InspectorTest.log('Running main function.');
Protocol.Runtime.evaluate({ expression: 'instance.exports.main()' });
for (let action of ['stepInto', 'stepInto', 'resume']) {
const {params: {callFrames}} = await Protocol.Debugger.oncePaused();
await session.logSourceLocation(callFrames[0].location);
Protocol.Debugger[action]();
}
InspectorTest.log('exports.main returned.');
})().catch(reason => InspectorTest.log(`Failed: ${reason}`))
.finally(InspectorTest.completeTest);