f10edd0900
BREAKING CHANGE: The values of Wasm locals, stack, and globals are now represented as objects instead of holding the (primitive) values directly, and SIMD128 values are no longer represented as Uint8Arrays. The DWARF extension has been prepared for this breaking change. The new `WasmValue` comes with `type` and `value` properties that hold its contents. The motivation here is that this is a more extensible approach. In case of SIMD128, the `value` property holds the canonical string representation, which has the additional advantage that these values can be compared with `===` (and `==`). This partially reverts https://crrev.com/c/2614428, the main difference here being that WasmValue is now a proper JSObject that can be exposed on the DebugEvaluate proxy API. Screenshot: https://imgur.com/rcahNKM.png Bug: chromium:1170282, chromium:1071432, chromium:1159402 Change-Id: Iea304e3680775123c41deb4c3d172ac949da1b98 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2643384 Reviewed-by: Philip Pfaffe <pfaffe@chromium.org> Reviewed-by: Zhi An Ng <zhin@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#72570}
66 lines
2.3 KiB
JavaScript
66 lines
2.3 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(
|
|
'Tests that Liftoff does not merge opcodes while stepping');
|
|
session.setupScriptMap();
|
|
|
|
let builder = new WasmModuleBuilder();
|
|
|
|
// i32.eqz and br_if are usually merged, so we wouldn't see any
|
|
// update on the operand stack after i32.eqz. For debugging,
|
|
// this is disabled, so we should see the result.
|
|
let body = [kExprLocalGet, 0, kExprI32Eqz, kExprBrIf, 0];
|
|
let fun = builder.addFunction('fun', kSig_v_i).addBody(body).exportFunc();
|
|
|
|
let module_bytes = builder.toArray();
|
|
|
|
let wasm_script_id = undefined;
|
|
Protocol.Debugger.onPaused(printPauseLocationAndStep);
|
|
|
|
InspectorTest.runAsyncTestSuite([
|
|
async function test() {
|
|
await Protocol.Debugger.enable();
|
|
WasmInspectorTest.instantiate(module_bytes);
|
|
[, {params: {scriptId: wasm_script_id}}] = await Protocol.Debugger.onceScriptParsed(2);
|
|
|
|
// Set a breakpoint at the beginning of 'fun'.
|
|
const offset = fun.body_offset;
|
|
InspectorTest.log(`Setting breakpoint at offset ${offset}.`);
|
|
let bpmsg = await Protocol.Debugger.setBreakpoint({
|
|
location: {scriptId: wasm_script_id, lineNumber: 0, columnNumber: offset}
|
|
});
|
|
|
|
for (let value of [0, -1, 13]) {
|
|
await Protocol.Runtime.evaluate(
|
|
{expression: `instance.exports.fun(${value})`});
|
|
}
|
|
}
|
|
]);
|
|
|
|
async function printPauseLocationAndStep(msg) {
|
|
// If we are outside of wasm, continue.
|
|
let loc = msg.params.callFrames[0].location;
|
|
if (loc.scriptId != wasm_script_id) {
|
|
Protocol.Debugger.resume();
|
|
return;
|
|
}
|
|
|
|
// Inspect only the top wasm frame.
|
|
let frame = msg.params.callFrames[0];
|
|
let scopes = {};
|
|
for (let scope of frame.scopeChain) {
|
|
if (scope.type == 'module') continue;
|
|
let scope_properties =
|
|
await Protocol.Runtime.getProperties({objectId: scope.object.objectId});
|
|
scopes[scope.type] = await Promise.all(scope_properties.result.result.map(
|
|
elem => WasmInspectorTest.getWasmValue(elem.value)));
|
|
}
|
|
let values = scopes['local'].concat(scopes['wasm-expression-stack']).join(', ');
|
|
InspectorTest.log(`Paused at offset ${loc.columnNumber}: [${values}]`);
|
|
Protocol.Debugger.stepOver();
|
|
}
|