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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Verify that wasm frame(s) can be requested from the client.
*/
add_task(
threadFrontTest(async ({ threadFront, debuggee }) => {
await threadFront.reconfigure({
observeAsmJS: true,
});
await executeOnNextTickAndWaitForPause(
() => evalCode(debuggee),
threadFront
);
const frameResponse = await threadFront.getFrames(0, null);
Assert.equal(frameResponse.frames.length, 4);
const wasmFrame = frameResponse.frames[1];
Assert.equal(wasmFrame.type, "wasmcall");
Assert.equal(wasmFrame.this, undefined);
const location = wasmFrame.where;
const source = await getSourceById(threadFront, location.actor);
Assert.equal(location.line > 0, true);
Assert.equal(location.column > 0, true);
Assert.equal(/^wasm:(?:[^:]*:)*?[0-9a-f]{16}$/.test(source.url), true);
threadFront.resume();
})
);
function evalCode(debuggee) {
/* eslint-disable comma-spacing, max-len */
debuggee.eval(
"(" +
function() {
// WebAssembly bytecode was generated by running:
// js -e 'print(wasmTextToBinary("(module(import \"a\" \"b\")(func(export \"c\")call 0))"))'
const m = new WebAssembly.Module(
new Uint8Array([
0,
97,
115,
109,
1,
0,
0,
0,
1,
132,
128,
128,
128,
0,
1,
96,
0,
0,
2,
135,
128,
128,
128,
0,
1,
1,
97,
1,
98,
0,
0,
3,
130,
128,
128,
128,
0,
1,
0,
6,
129,
128,
128,
128,
0,
0,
7,
133,
128,
128,
128,
0,
1,
1,
99,
0,
1,
10,
138,
128,
128,
128,
0,
1,
132,
128,
128,
128,
0,
0,
16,
0,
11,
])
);
const i = new WebAssembly.Instance(m, {
a: {
b: () => {
debugger;
},
},
});
i.exports.c();
} +
")()"
);
}
|