Commit fc55d733 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Extend liftoff breakpoint test for scope inspection

This extends the existing test to also print scope information on every
break. Note that the currently printed information is not correct, since
register values are not reconstructed yet. We just always print {-11}
for register values.
Thus the expected output will change with follow-up CL.

R=thibaudm@chromium.org

Bug: v8:10222
Change-Id: I7be13ecb02957454c875a4280cec154a08c2deb7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2062403Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66433}
parent 4717c9a2
......@@ -3,40 +3,324 @@ Instantiating.
Waiting for wasm script (ignoring first non-wasm script).
Setting breakpoint at offset 38 on script wasm://wasm/0c10a5fe
Calling main(4)
Breaking on byte offset 38
Setting breakpoint at offset 39 on script wasm://wasm/0c10a5fe
Setting breakpoint at offset 54 on script wasm://wasm/0c10a5fe
Setting breakpoint at offset 53 on script wasm://wasm/0c10a5fe
Setting breakpoint at offset 51 on script wasm://wasm/0c10a5fe
Setting breakpoint at offset 49 on script wasm://wasm/0c10a5fe
Setting breakpoint at offset 45 on script wasm://wasm/0c10a5fe
Setting breakpoint at offset 47 on script wasm://wasm/0c10a5fe
Breaking on byte offset 39
Breaking on byte offset 45
Breaking on byte offset 47
Breaking on byte offset 49
Breaking on byte offset 51
Breaking on byte offset 53
Breaking on byte offset 54
Breaking on byte offset 38
Breaking on byte offset 39
Breaking on byte offset 45
Breaking on byte offset 47
Breaking on byte offset 49
Breaking on byte offset 51
Breaking on byte offset 53
Breaking on byte offset 54
Breaking on byte offset 38
Breaking on byte offset 39
Breaking on byte offset 45
Breaking on byte offset 47
Breaking on byte offset 49
Breaking on byte offset 51
Breaking on byte offset 53
Breaking on byte offset 54
Breaking on byte offset 38
Breaking on byte offset 39
Breaking on byte offset 45
Breaking on byte offset 47
Paused:
Script wasm://wasm/0c10a5fe byte offset 38: Wasm opcode 0x1
Scope:
at wasm_A (0:38):
- scope (global):
- scope (local):
stack:
at wasm_B (0:56):
- scope (global):
- scope (local):
locals: "arg#0": 3 (number)
stack:
at (anonymous) (0:17):
-- skipped
Setting breakpoint at offset 39 on script v8://test/runWasm
Setting breakpoint at offset 54 on script v8://test/runWasm
Setting breakpoint at offset 53 on script v8://test/runWasm
Setting breakpoint at offset 51 on script v8://test/runWasm
Setting breakpoint at offset 49 on script v8://test/runWasm
Setting breakpoint at offset 45 on script v8://test/runWasm
Setting breakpoint at offset 47 on script v8://test/runWasm
Paused:
Script wasm://wasm/0c10a5fe byte offset 39: Wasm opcode 0x1
Scope:
at wasm_A (0:39):
- scope (global):
- scope (local):
stack:
at wasm_B (0:56):
- scope (global):
- scope (local):
locals: "arg#0": 3 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 45: Wasm opcode 0x20
Scope:
at wasm_B (0:45):
- scope (global):
- scope (local):
locals: "arg#0": 3 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 47: Wasm opcode 0x4
Scope:
at wasm_B (0:47):
- scope (global):
- scope (local):
locals: "arg#0": 3 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 49: Wasm opcode 0x20
Scope:
at wasm_B (0:49):
- scope (global):
- scope (local):
locals: "arg#0": 3 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 51: Wasm opcode 0x41
Scope:
at wasm_B (0:51):
- scope (global):
- scope (local):
locals: "arg#0": 3 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 53: Wasm opcode 0x6b
Scope:
at wasm_B (0:53):
- scope (global):
- scope (local):
locals: "arg#0": 3 (number)
stack: "0": -11 (number), "1": 1 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 54: Wasm opcode 0x21
Scope:
at wasm_B (0:54):
- scope (global):
- scope (local):
locals: "arg#0": 3 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 38: Wasm opcode 0x1
Scope:
at wasm_A (0:38):
- scope (global):
- scope (local):
stack:
at wasm_B (0:56):
- scope (global):
- scope (local):
locals: "arg#0": 2 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 39: Wasm opcode 0x1
Scope:
at wasm_A (0:39):
- scope (global):
- scope (local):
stack:
at wasm_B (0:56):
- scope (global):
- scope (local):
locals: "arg#0": 2 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 45: Wasm opcode 0x20
Scope:
at wasm_B (0:45):
- scope (global):
- scope (local):
locals: "arg#0": 2 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 47: Wasm opcode 0x4
Scope:
at wasm_B (0:47):
- scope (global):
- scope (local):
locals: "arg#0": 2 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 49: Wasm opcode 0x20
Scope:
at wasm_B (0:49):
- scope (global):
- scope (local):
locals: "arg#0": 2 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 51: Wasm opcode 0x41
Scope:
at wasm_B (0:51):
- scope (global):
- scope (local):
locals: "arg#0": 2 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 53: Wasm opcode 0x6b
Scope:
at wasm_B (0:53):
- scope (global):
- scope (local):
locals: "arg#0": 2 (number)
stack: "0": -11 (number), "1": 1 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 54: Wasm opcode 0x21
Scope:
at wasm_B (0:54):
- scope (global):
- scope (local):
locals: "arg#0": 2 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 38: Wasm opcode 0x1
Scope:
at wasm_A (0:38):
- scope (global):
- scope (local):
stack:
at wasm_B (0:56):
- scope (global):
- scope (local):
locals: "arg#0": 1 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 39: Wasm opcode 0x1
Scope:
at wasm_A (0:39):
- scope (global):
- scope (local):
stack:
at wasm_B (0:56):
- scope (global):
- scope (local):
locals: "arg#0": 1 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 45: Wasm opcode 0x20
Scope:
at wasm_B (0:45):
- scope (global):
- scope (local):
locals: "arg#0": 1 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 47: Wasm opcode 0x4
Scope:
at wasm_B (0:47):
- scope (global):
- scope (local):
locals: "arg#0": 1 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 49: Wasm opcode 0x20
Scope:
at wasm_B (0:49):
- scope (global):
- scope (local):
locals: "arg#0": 1 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 51: Wasm opcode 0x41
Scope:
at wasm_B (0:51):
- scope (global):
- scope (local):
locals: "arg#0": 1 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 53: Wasm opcode 0x6b
Scope:
at wasm_B (0:53):
- scope (global):
- scope (local):
locals: "arg#0": 1 (number)
stack: "0": -11 (number), "1": 1 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 54: Wasm opcode 0x21
Scope:
at wasm_B (0:54):
- scope (global):
- scope (local):
locals: "arg#0": 1 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 38: Wasm opcode 0x1
Scope:
at wasm_A (0:38):
- scope (global):
- scope (local):
stack:
at wasm_B (0:56):
- scope (global):
- scope (local):
locals: "arg#0": 0 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 39: Wasm opcode 0x1
Scope:
at wasm_A (0:39):
- scope (global):
- scope (local):
stack:
at wasm_B (0:56):
- scope (global):
- scope (local):
locals: "arg#0": 0 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 45: Wasm opcode 0x20
Scope:
at wasm_B (0:45):
- scope (global):
- scope (local):
locals: "arg#0": 0 (number)
stack:
at (anonymous) (0:17):
-- skipped
Paused:
Script wasm://wasm/0c10a5fe byte offset 47: Wasm opcode 0x4
Scope:
at wasm_B (0:47):
- scope (global):
- scope (local):
locals: "arg#0": 0 (number)
stack: "0": -11 (number)
at (anonymous) (0:17):
-- skipped
exports.main returned!
Finished!
......@@ -6,6 +6,7 @@
const {session, contextGroup, Protocol} =
InspectorTest.start('Tests stepping through wasm scripts.');
session.setupScriptMap();
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
......@@ -65,13 +66,31 @@ function setBreakpoint(offset, scriptId, scriptUrl) {
// Only set breakpoints during the first loop iteration.
var first_iteration = true;
Protocol.Debugger.onPaused(pause_msg => {
let frame = pause_msg.params.callFrames[0];
let loc = frame.location;
if (loc.lineNumber != 0) {
InspectorTest.log('Unexpected line number: ' + loc.lineNumber);
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});
for (var value of properties.result.result) {
var value_str = await getScopeValues(value.value);
InspectorTest.log(' ' + value.name + ': ' + value_str);
}
}
}
InspectorTest.log('Breaking on byte offset ' + loc.columnNumber);
if (first_iteration && loc.columnNumber == func_a.body_offset) {
// Check that setting breakpoints on active instances of A and B takes
// effect immediately.
......@@ -81,9 +100,23 @@ Protocol.Debugger.onPaused(pause_msg => {
}
first_iteration = false;
}
Protocol.Debugger.resume();
});
async function getScopeValues(value) {
if (value.type != 'object') {
InspectorTest.log('Expected object. Found:');
InspectorTest.logObject(value);
return;
}
let msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
let printProperty = elem => '"' + elem.name + '"' +
': ' + elem.value.value + ' (' + elem.value.type + ')';
return msg.result.result.map(printProperty).join(', ');
}
(async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.');
......
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