summaryrefslogtreecommitdiff
path: root/deps/v8/test/inspector/debugger/wasm-set-breakpoint-liftoff.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/inspector/debugger/wasm-set-breakpoint-liftoff.js')
-rw-r--r--deps/v8/test/inspector/debugger/wasm-set-breakpoint-liftoff.js93
1 files changed, 69 insertions, 24 deletions
diff --git a/deps/v8/test/inspector/debugger/wasm-set-breakpoint-liftoff.js b/deps/v8/test/inspector/debugger/wasm-set-breakpoint-liftoff.js
index ce70f91921..3e8d783af6 100644
--- a/deps/v8/test/inspector/debugger/wasm-set-breakpoint-liftoff.js
+++ b/deps/v8/test/inspector/debugger/wasm-set-breakpoint-liftoff.js
@@ -6,29 +6,30 @@
const {session, contextGroup, Protocol} =
InspectorTest.start('Tests stepping through wasm scripts.');
+session.setupScriptMap();
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
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');
@@ -53,24 +54,68 @@ const evalWithUrl = (code, url) =>
.evaluate({'expression': code + '\n//# sourceURL=v8://test/' + url})
.then(getResult);
-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});
+ 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) {
+ // 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();
});
+async function getScopeValues(value) {
+ if (value.type == 'object') {
+ let msg = await Protocol.Runtime.getProperties({objectId: value.objectId});
+ const printProperty = function(elem) {
+ return `"${elem.name}": ${elem.value.value} (${elem.value.type})`;
+ }
+ return msg.result.result.map(printProperty).join(', ');
+ }
+ return value.value + ' (' + value.type + ')';
+}
+
(async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.');
@@ -82,9 +127,9 @@ Protocol.Debugger.onPaused(pause_msg => {
'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 evalWithUrl('instance.exports.main(4)', 'runWasm');
InspectorTest.log('exports.main returned!');