summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/wasm-07.js
blob: a6977198e8a98d8916a2bae1b01f0f9e750f11a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// |jit-test| test-also=--wasm-compiler=optimizing; skip-if: !wasmDebuggingEnabled()

// Checking existence of all frame.offset references during onEnterFrame,
// onLeaveFrame and onStep events in the source code, and that we can
// potentially resolve offset back to the line/column.

load(libdir + "wasm.js");

var offsets;
wasmRunWithDebugger(
    '(module (func (nop) (nop)) (export "test" (func 0)))',
    undefined,
    function ({dbg}) {
        offsets = [];
        dbg.onEnterFrame = function (frame) {
            if (frame.type != 'wasmcall') {
                return;
            }
            offsets.push(frame.offset);
            frame.onStep = function () {
                offsets.push(frame.offset);
            };
            frame.onPop = function () {
                offsets.push(frame.offset);
            };
        };
    },
    function ({wasmScript, error}) {
        assertEq(error, undefined);
        assertEq(offsets.length, 4);
        offsets.forEach(offset => {
            var loc = wasmScript.getOffsetLocation(offset);
            assertEq(loc.isEntryPoint, true);
            assertEq(loc.lineNumber > 0, true);
            assertEq(loc.columnNumber > 0, true);
            assertEq(wasmScript.getLineOffsets(loc.lineNumber).length, 1);
        });
    }
);