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. ...@@ -3,40 +3,324 @@ Instantiating.
Waiting for wasm script (ignoring first non-wasm script). Waiting for wasm script (ignoring first non-wasm script).
Setting breakpoint at offset 38 on script wasm://wasm/0c10a5fe Setting breakpoint at offset 38 on script wasm://wasm/0c10a5fe
Calling main(4) Calling main(4)
Breaking on byte offset 38 Paused:
Setting breakpoint at offset 39 on script wasm://wasm/0c10a5fe Script wasm://wasm/0c10a5fe byte offset 38: Wasm opcode 0x1
Setting breakpoint at offset 54 on script wasm://wasm/0c10a5fe Scope:
Setting breakpoint at offset 53 on script wasm://wasm/0c10a5fe at wasm_A (0:38):
Setting breakpoint at offset 51 on script wasm://wasm/0c10a5fe - scope (global):
Setting breakpoint at offset 49 on script wasm://wasm/0c10a5fe - scope (local):
Setting breakpoint at offset 45 on script wasm://wasm/0c10a5fe stack:
Setting breakpoint at offset 47 on script wasm://wasm/0c10a5fe at wasm_B (0:56):
Breaking on byte offset 39 - scope (global):
Breaking on byte offset 45 - scope (local):
Breaking on byte offset 47 locals: "arg#0": 3 (number)
Breaking on byte offset 49 stack:
Breaking on byte offset 51 at (anonymous) (0:17):
Breaking on byte offset 53 -- skipped
Breaking on byte offset 54 Setting breakpoint at offset 39 on script v8://test/runWasm
Breaking on byte offset 38 Setting breakpoint at offset 54 on script v8://test/runWasm
Breaking on byte offset 39 Setting breakpoint at offset 53 on script v8://test/runWasm
Breaking on byte offset 45 Setting breakpoint at offset 51 on script v8://test/runWasm
Breaking on byte offset 47 Setting breakpoint at offset 49 on script v8://test/runWasm
Breaking on byte offset 49 Setting breakpoint at offset 45 on script v8://test/runWasm
Breaking on byte offset 51 Setting breakpoint at offset 47 on script v8://test/runWasm
Breaking on byte offset 53 Paused:
Breaking on byte offset 54 Script wasm://wasm/0c10a5fe byte offset 39: Wasm opcode 0x1
Breaking on byte offset 38 Scope:
Breaking on byte offset 39 at wasm_A (0:39):
Breaking on byte offset 45 - scope (global):
Breaking on byte offset 47 - scope (local):
Breaking on byte offset 49 stack:
Breaking on byte offset 51 at wasm_B (0:56):
Breaking on byte offset 53 - scope (global):
Breaking on byte offset 54 - scope (local):
Breaking on byte offset 38 locals: "arg#0": 3 (number)
Breaking on byte offset 39 stack:
Breaking on byte offset 45 at (anonymous) (0:17):
Breaking on byte offset 47 -- 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! exports.main returned!
Finished! Finished!
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
const {session, contextGroup, Protocol} = const {session, contextGroup, Protocol} =
InspectorTest.start('Tests stepping through wasm scripts.'); InspectorTest.start('Tests stepping through wasm scripts.');
session.setupScriptMap();
utils.load('test/mjsunit/wasm/wasm-module-builder.js'); utils.load('test/mjsunit/wasm/wasm-module-builder.js');
...@@ -65,13 +66,31 @@ function setBreakpoint(offset, scriptId, scriptUrl) { ...@@ -65,13 +66,31 @@ function setBreakpoint(offset, scriptId, scriptUrl) {
// Only set breakpoints during the first loop iteration. // Only set breakpoints during the first loop iteration.
var first_iteration = true; var first_iteration = true;
Protocol.Debugger.onPaused(pause_msg => { Protocol.Debugger.onPaused(async msg => {
let frame = pause_msg.params.callFrames[0]; let loc = msg.params.callFrames[0].location;
let loc = frame.location; InspectorTest.log('Paused:');
if (loc.lineNumber != 0) { await session.logSourceLocation(loc);
InspectorTest.log('Unexpected line number: ' + loc.lineNumber); 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;
} }
InspectorTest.log('Breaking on byte offset ' + loc.columnNumber); 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);
}
}
}
if (first_iteration && loc.columnNumber == func_a.body_offset) { if (first_iteration && loc.columnNumber == func_a.body_offset) {
// Check that setting breakpoints on active instances of A and B takes // Check that setting breakpoints on active instances of A and B takes
// effect immediately. // effect immediately.
...@@ -81,9 +100,23 @@ Protocol.Debugger.onPaused(pause_msg => { ...@@ -81,9 +100,23 @@ Protocol.Debugger.onPaused(pause_msg => {
} }
first_iteration = false; first_iteration = false;
} }
Protocol.Debugger.resume(); 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() { (async function test() {
await Protocol.Debugger.enable(); await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.'); 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