warpo 3.1.3 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assemblyscript/std/README.md +5 -0
- package/assemblyscript/std/assembly/array.ts +542 -0
- package/assemblyscript/std/assembly/arraybuffer.ts +72 -0
- package/assemblyscript/std/assembly/builtins.ts +2312 -0
- package/assemblyscript/std/assembly/compat.ts +2 -0
- package/assemblyscript/std/assembly/dataview.ts +144 -0
- package/assemblyscript/std/assembly/date.ts +383 -0
- package/assemblyscript/std/assembly/diagnostics.ts +11 -0
- package/assemblyscript/std/assembly/error.ts +39 -0
- package/assemblyscript/std/assembly/function.ts +44 -0
- package/assemblyscript/std/assembly/iterator.ts +24 -0
- package/assemblyscript/std/assembly/map.ts +304 -0
- package/assemblyscript/std/assembly/math.ts +3401 -0
- package/assemblyscript/std/assembly/memory.ts +110 -0
- package/assemblyscript/std/assembly/number.ts +388 -0
- package/assemblyscript/std/assembly/object.ts +30 -0
- package/assemblyscript/std/assembly/polyfills.ts +24 -0
- package/assemblyscript/std/assembly/process.ts +7 -0
- package/assemblyscript/std/assembly/promise.ts +172 -0
- package/assemblyscript/std/assembly/reference.ts +48 -0
- package/assemblyscript/std/assembly/regexp.ts +16 -0
- package/assemblyscript/std/assembly/rt/common.ts +79 -0
- package/assemblyscript/std/assembly/rt/index-incremental.ts +4 -0
- package/assemblyscript/std/assembly/rt/index-radical.ts +4 -0
- package/assemblyscript/std/assembly/rt/index.d.ts +37 -0
- package/assemblyscript/std/assembly/rt/itcms.ts +415 -0
- package/assemblyscript/std/assembly/rt/tcms.ts +276 -0
- package/assemblyscript/std/assembly/rt/tlsf.ts +564 -0
- package/assemblyscript/std/assembly/rt.ts +71 -0
- package/assemblyscript/std/assembly/set.ts +261 -0
- package/assemblyscript/std/assembly/shared/feature.ts +69 -0
- package/assemblyscript/std/assembly/shared/host.ts +12 -0
- package/assemblyscript/std/assembly/shared/runtime.ts +9 -0
- package/assemblyscript/std/assembly/shared/target.ts +9 -0
- package/assemblyscript/std/assembly/shared/tsconfig.json +9 -0
- package/assemblyscript/std/assembly/shared/typeinfo.ts +72 -0
- package/assemblyscript/std/assembly/staticarray.ts +446 -0
- package/assemblyscript/std/assembly/string.ts +892 -0
- package/assemblyscript/std/assembly/symbol.ts +61 -0
- package/assemblyscript/std/assembly/table.ts +15 -0
- package/assemblyscript/std/assembly/tsconfig.json +4 -0
- package/assemblyscript/std/assembly/tuple.ts +36 -0
- package/assemblyscript/std/assembly/typedarray.ts +2000 -0
- package/assemblyscript/std/assembly/uri.ts +17 -0
- package/assemblyscript/std/assembly/util/bytes.ts +90 -0
- package/assemblyscript/std/assembly/util/casemap.ts +264 -0
- package/assemblyscript/std/assembly/util/error.ts +54 -0
- package/assemblyscript/std/assembly/util/hash.ts +117 -0
- package/assemblyscript/std/assembly/util/math.ts +1922 -0
- package/assemblyscript/std/assembly/util/memory.ts +309 -0
- package/assemblyscript/std/assembly/util/number.ts +884 -0
- package/assemblyscript/std/assembly/util/sort.ts +282 -0
- package/assemblyscript/std/assembly/util/string.ts +1075 -0
- package/assemblyscript/std/assembly/util/uri.ts +251 -0
- package/assemblyscript/std/assembly/vector.ts +3 -0
- package/dist/common/leb128.d.ts +5 -0
- package/dist/common/leb128.js +17 -0
- package/dist/common/leb128.js.map +1 -0
- package/dist/debug_server/debugSession.d.ts +31 -1
- package/dist/debug_server/debugSession.js +477 -99
- package/dist/debug_server/debugSession.js.map +1 -1
- package/dist/debug_server/debugTrace.d.ts +2 -0
- package/dist/debug_server/debugTrace.js +38 -0
- package/dist/debug_server/debugTrace.js.map +1 -0
- package/dist/debug_server/debugger.d.ts +5 -1
- package/dist/debug_server/debuggerWasmModule.d.ts +9 -0
- package/dist/debug_server/debuggerWasmModule.js +182 -4
- package/dist/debug_server/debuggerWasmModule.js.map +1 -1
- package/dist/debug_server/nodeDebugger.d.ts +12 -1
- package/dist/debug_server/nodeDebugger.js +74 -28
- package/dist/debug_server/nodeDebugger.js.map +1 -1
- package/dist/debug_server/tests/debugSession.test.js +556 -22
- package/dist/debug_server/tests/debugSession.test.js.map +1 -1
- package/dist/debug_server/tests/testModule/debugger_breakpoint_validation.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_breakpoint_validation.js +12 -0
- package/dist/debug_server/tests/testModule/debugger_breakpoint_validation.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_closure_stepping.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_closure_stepping.js +12 -0
- package/dist/debug_server/tests/testModule/debugger_closure_stepping.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_function_closure.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_function_closure.js +24 -0
- package/dist/debug_server/tests/testModule/debugger_function_closure.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_import.case.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_import.case.js +9 -0
- package/dist/debug_server/tests/testModule/debugger_import.case.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_import.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_import.js +6 -0
- package/dist/debug_server/tests/testModule/debugger_import.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_pause.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_pause.js +9 -0
- package/dist/debug_server/tests/testModule/debugger_pause.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_std_array.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_std_array.js +6 -0
- package/dist/debug_server/tests/testModule/debugger_std_array.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_stepping.d.ts +3 -0
- package/dist/debug_server/tests/testModule/debugger_stepping.js +28 -0
- package/dist/debug_server/tests/testModule/debugger_stepping.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_string_stepping.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_string_stepping.js +9 -0
- package/dist/debug_server/tests/testModule/debugger_string_stepping.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_typed_array.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_typed_array.js +52 -0
- package/dist/debug_server/tests/testModule/debugger_typed_array.js.map +1 -0
- package/dist/debug_server/tests/testModule/debugger_utf8_const_str.d.ts +1 -0
- package/dist/debug_server/tests/testModule/debugger_utf8_const_str.js +10 -0
- package/dist/debug_server/tests/testModule/debugger_utf8_const_str.js.map +1 -0
- package/dist/dwarf/dwarfParser.js +6 -13
- package/dist/dwarf/dwarfParser.js.map +1 -1
- package/dist/dwarf/functionDebugInfo.d.ts +3 -0
- package/dist/dwarf/functionDebugInfo.js +24 -0
- package/dist/dwarf/functionDebugInfo.js.map +1 -1
- package/package.json +7 -7
- package/warpo_extension/std/tsconfig.json +4 -0
- package/warpo_extension/std/warpo/ffi.ts +16 -0
- package/warpo_extension/std/warpo/test/comparison.ts +122 -0
- package/warpo_extension/std/warpo/test/env.ts +33 -0
- package/warpo_extension/std/warpo/test/expect.ts +101 -0
- package/warpo_extension/std/warpo/test/formatPrint.ts +99 -0
- package/warpo_extension/std/warpo/test/implement.ts +41 -0
- package/warpo_extension/std/warpo/test/index.d.ts +0 -0
- package/warpo_extension/std/warpo/test/index.ts +39 -0
- package/warpo_extension/std/warpo/test/mockInstrument.ts +26 -0
- package/warpo_extension/std/warpo/utf8/const_str.ts +17 -0
- package/warpo_extension/std/wasi_snapshot_preview1/LICENSE +202 -0
- package/warpo_extension/std/wasi_snapshot_preview1/README.md +1 -0
- package/warpo_extension/std/wasi_snapshot_preview1/bindings/wasi_snapshot_preview1.ts +1731 -0
- package/warpo_extension/std/wasi_snapshot_preview1/wasi_console.ts +96 -0
- package/warpo_extension/std/wasi_snapshot_preview1/wasi_crypto.ts +8 -0
- package/warpo_extension/std/wasi_snapshot_preview1/wasi_date.ts +13 -0
- package/warpo_extension/std/wasi_snapshot_preview1/wasi_internal.ts +119 -0
- package/warpo_extension/std/wasi_snapshot_preview1/wasi_performance.ts +11 -0
- package/warpo_extension/std/wasi_snapshot_preview1/wasi_process.ts +191 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { DebugClient } from "@vscode/debugadapter-testsupport";
|
|
4
4
|
import * as assert from "node:assert/strict";
|
|
5
|
+
import * as fs from "node:fs";
|
|
5
6
|
import * as path from "node:path";
|
|
6
7
|
import { describe, it, beforeEach, afterEach } from "node:test";
|
|
7
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -73,8 +74,13 @@ function findVariable(variables, name) {
|
|
|
73
74
|
async function launchAndWaitForBreakpoint(dc, launchArgs) {
|
|
74
75
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
75
76
|
await dc.launchRequest(launchArgs);
|
|
77
|
+
await dc.configurationDoneRequest({});
|
|
76
78
|
await stoppedPromise;
|
|
77
79
|
}
|
|
80
|
+
async function launchAndConfigure(dc, launchArgs) {
|
|
81
|
+
await dc.launchRequest(launchArgs);
|
|
82
|
+
await dc.configurationDoneRequest({});
|
|
83
|
+
}
|
|
78
84
|
async function readFrameLocals(dc, frame) {
|
|
79
85
|
const scopesResponse = await dc.scopesRequest({ frameId: frame.id });
|
|
80
86
|
const localsScope = assertDefined(scopesResponse.body.scopes.find((scope) => scope.name.startsWith("Local:")));
|
|
@@ -132,18 +138,49 @@ void describe("WarpoDebugSession", () => {
|
|
|
132
138
|
await waitForExit(serverChild, 1000);
|
|
133
139
|
}
|
|
134
140
|
});
|
|
135
|
-
void it("should
|
|
141
|
+
void it("should return breakpoints unverified before a wasm module is loaded", async () => {
|
|
136
142
|
await dc.initializeRequest();
|
|
137
143
|
const response = await dc.setBreakpointsRequest({
|
|
138
144
|
source: { path: "test.ts" },
|
|
139
145
|
breakpoints: [{ line: 5 }, { line: 10 }],
|
|
140
146
|
});
|
|
141
147
|
assert.equal(response.body.breakpoints.length, 2);
|
|
142
|
-
assert.equal(response.body.breakpoints[0].verified,
|
|
148
|
+
assert.equal(response.body.breakpoints[0].verified, false);
|
|
143
149
|
assert.equal(response.body.breakpoints[0].line, 5);
|
|
144
|
-
assert.equal(response.body.breakpoints[1].verified,
|
|
150
|
+
assert.equal(response.body.breakpoints[1].verified, false);
|
|
145
151
|
assert.equal(response.body.breakpoints[1].line, 10);
|
|
146
152
|
});
|
|
153
|
+
void it("should reject breakpoints without wasm bytecode mappings", { timeout: 10000 }, async () => {
|
|
154
|
+
const source = sourcePath("debugger_breakpoint_validation.ts");
|
|
155
|
+
const output = await buildModule(source);
|
|
156
|
+
const validLine = 7;
|
|
157
|
+
await dc.initializeRequest();
|
|
158
|
+
const initialResponse = await dc.setBreakpointsRequest({
|
|
159
|
+
source: { path: source },
|
|
160
|
+
breakpoints: [{ line: validLine }],
|
|
161
|
+
});
|
|
162
|
+
assert.equal(initialResponse.body.breakpoints[0].verified, false);
|
|
163
|
+
const breakpointChangedPromise = dc.waitForEvent("breakpoint");
|
|
164
|
+
const launchArgs = {
|
|
165
|
+
program: output,
|
|
166
|
+
launchType: "wasm file",
|
|
167
|
+
runtime: "node",
|
|
168
|
+
entryFunctionName: "_start",
|
|
169
|
+
};
|
|
170
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
171
|
+
const breakpointChangedEvent = await breakpointChangedPromise;
|
|
172
|
+
const breakpointChangedBody = breakpointChangedEvent.body;
|
|
173
|
+
assert.equal(breakpointChangedBody?.reason, "changed");
|
|
174
|
+
assert.equal(breakpointChangedBody?.breakpoint?.verified, true);
|
|
175
|
+
const response = await dc.setBreakpointsRequest({
|
|
176
|
+
source: { path: source },
|
|
177
|
+
breakpoints: [{ line: 5 }, { line: 6 }, { line: validLine }],
|
|
178
|
+
});
|
|
179
|
+
assert.equal(response.body.breakpoints[0].verified, false);
|
|
180
|
+
assert.equal(response.body.breakpoints[1].verified, false);
|
|
181
|
+
assert.equal(response.body.breakpoints[2].verified, true);
|
|
182
|
+
await dc.disconnectRequest({ terminateDebuggee: true });
|
|
183
|
+
});
|
|
147
184
|
void it("should stop in a unit test after returning from main", { timeout: 15000 }, async () => {
|
|
148
185
|
const testSource = sourcePath("unittest_debug.case.ts");
|
|
149
186
|
const implementationSource = sourcePath("unittest_debug.ts");
|
|
@@ -173,33 +210,128 @@ void describe("WarpoDebugSession", () => {
|
|
|
173
210
|
assert.equal(assertDefined(stackTraceResponse.body.stackFrames[0]).source?.path, normalizeDebugPath(testSource));
|
|
174
211
|
assert.equal(stackTraceResponse.body.stackFrames[0].line, 9);
|
|
175
212
|
});
|
|
213
|
+
void it("should step over a JavaScript import during step into", { timeout: 15000 }, async () => {
|
|
214
|
+
const implementationSource = sourcePath("debugger_import.ts");
|
|
215
|
+
await dc.initializeRequest();
|
|
216
|
+
await dc.setBreakpointsRequest({
|
|
217
|
+
source: { path: implementationSource },
|
|
218
|
+
breakpoints: [{ line: 7 }],
|
|
219
|
+
});
|
|
220
|
+
const launchArgs = {
|
|
221
|
+
launchType: "unittest",
|
|
222
|
+
runtime: "node",
|
|
223
|
+
cwd: TEST_MODULE_DIR,
|
|
224
|
+
warpoPath: WARPO_CLI,
|
|
225
|
+
};
|
|
226
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
227
|
+
const stoppedPromise = dc.waitForEvent("stopped");
|
|
228
|
+
await dc.stepInRequest({ threadId: 1 });
|
|
229
|
+
await stoppedPromise;
|
|
230
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
231
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
232
|
+
assert.equal(frame.source?.path, normalizeDebugPath(implementationSource));
|
|
233
|
+
assert.equal(frame.line, 8);
|
|
234
|
+
});
|
|
176
235
|
void it("should report the built wasm as a loaded source on launch", { timeout: 5000 }, async () => {
|
|
177
236
|
const source = sourcePath("debugger_basic.ts");
|
|
178
237
|
const output = await buildModule(source);
|
|
179
238
|
const breakpointLine = 13;
|
|
239
|
+
const traceFile = path.join(TEST_MODULE_DIR, "build", "test_debug_trace.log");
|
|
240
|
+
if (fs.existsSync(traceFile)) {
|
|
241
|
+
fs.unlinkSync(traceFile);
|
|
242
|
+
}
|
|
180
243
|
await dc.initializeRequest();
|
|
181
244
|
const breakpointResponse = await dc.setBreakpointsRequest({
|
|
182
245
|
source: { path: source },
|
|
183
246
|
breakpoints: [{ line: breakpointLine }],
|
|
184
247
|
});
|
|
185
248
|
assert.equal(breakpointResponse.body.breakpoints.length, 1);
|
|
186
|
-
assert.equal(breakpointResponse.body.breakpoints[0].verified,
|
|
249
|
+
assert.equal(breakpointResponse.body.breakpoints[0].verified, false);
|
|
187
250
|
assert.equal(breakpointResponse.body.breakpoints[0].line, breakpointLine);
|
|
188
251
|
const launchArgs = {
|
|
189
252
|
program: output,
|
|
190
253
|
launchType: "wasm file",
|
|
191
254
|
runtime: "node",
|
|
192
255
|
entryFunctionName: "_start",
|
|
256
|
+
debugSessionLogFile: traceFile,
|
|
193
257
|
};
|
|
194
258
|
const loadedSourcePromise = waitForLoadedWasmSource(dc, output);
|
|
195
259
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
196
|
-
await dc
|
|
260
|
+
await launchAndConfigure(dc, launchArgs);
|
|
197
261
|
const loadedSourceEvent = await loadedSourcePromise;
|
|
198
262
|
const loadedSourceBody = loadedSourceEvent.body;
|
|
199
263
|
await stoppedPromise;
|
|
200
264
|
assert.equal(loadedSourceBody?.reason, "new");
|
|
201
265
|
assert.equal(loadedSourceBody?.source?.path, path.resolve(output));
|
|
202
266
|
assert.equal(loadedSourceBody?.source?.name, path.basename(output));
|
|
267
|
+
assert.equal(fs.existsSync(traceFile), true, "debugSessionLogFile should be created on launch");
|
|
268
|
+
if (fs.existsSync(traceFile)) {
|
|
269
|
+
fs.unlinkSync(traceFile);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
void it("should stop at a breakpoint in the AssemblyScript standard library", { timeout: 15000 }, async () => {
|
|
273
|
+
const source = sourcePath("debugger_std_array.ts");
|
|
274
|
+
const stdSource = path.resolve(DIRNAME, "..", "..", "..", "assemblyscript", "std", "assembly", "array.ts");
|
|
275
|
+
const output = await buildModule(source);
|
|
276
|
+
const breakpointLine = 101;
|
|
277
|
+
const traceFile = path.join(TEST_MODULE_DIR, "build", "test_std_breakpoint_trace.log");
|
|
278
|
+
if (fs.existsSync(traceFile)) {
|
|
279
|
+
fs.unlinkSync(traceFile);
|
|
280
|
+
}
|
|
281
|
+
await dc.initializeRequest();
|
|
282
|
+
const breakpointResponse = await dc.setBreakpointsRequest({
|
|
283
|
+
source: { path: stdSource },
|
|
284
|
+
breakpoints: [{ line: breakpointLine }],
|
|
285
|
+
});
|
|
286
|
+
assert.equal(breakpointResponse.body.breakpoints[0].verified, false);
|
|
287
|
+
const breakpointChangedPromise = dc.waitForEvent("breakpoint");
|
|
288
|
+
const stoppedPromise = waitForBreakpointStop(dc);
|
|
289
|
+
const launchArgs = {
|
|
290
|
+
program: output,
|
|
291
|
+
launchType: "wasm file",
|
|
292
|
+
runtime: "node",
|
|
293
|
+
entryFunctionName: "_start",
|
|
294
|
+
debugSessionLogFile: traceFile,
|
|
295
|
+
};
|
|
296
|
+
await launchAndConfigure(dc, launchArgs);
|
|
297
|
+
const breakpointChangedEvent = await breakpointChangedPromise;
|
|
298
|
+
const breakpointChangedBody = breakpointChangedEvent.body;
|
|
299
|
+
assert.equal(breakpointChangedBody?.reason, "changed");
|
|
300
|
+
assert.equal(breakpointChangedBody?.breakpoint?.verified, true);
|
|
301
|
+
await stoppedPromise;
|
|
302
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
303
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
304
|
+
assert.equal(frame.source?.path, normalizeDebugPath(stdSource));
|
|
305
|
+
assert.equal(frame.line, breakpointLine);
|
|
306
|
+
assert.equal(fs.existsSync(traceFile), true, "debugSessionLogFile should be created on launch");
|
|
307
|
+
if (fs.existsSync(traceFile)) {
|
|
308
|
+
fs.unlinkSync(traceFile);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
void it("should restart the debuggee and restore breakpoints", { timeout: 10000 }, async () => {
|
|
312
|
+
const source = sourcePath("debugger_basic.ts");
|
|
313
|
+
const output = await buildModule(source);
|
|
314
|
+
const breakpointLine = 13;
|
|
315
|
+
await dc.initializeRequest();
|
|
316
|
+
await dc.setBreakpointsRequest({
|
|
317
|
+
source: { path: source },
|
|
318
|
+
breakpoints: [{ line: breakpointLine }],
|
|
319
|
+
});
|
|
320
|
+
const launchArgs = {
|
|
321
|
+
program: output,
|
|
322
|
+
launchType: "wasm file",
|
|
323
|
+
runtime: "node",
|
|
324
|
+
entryFunctionName: "_start",
|
|
325
|
+
};
|
|
326
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
327
|
+
const restartedStop = waitForBreakpointStop(dc);
|
|
328
|
+
await dc.restartRequest({});
|
|
329
|
+
await restartedStop;
|
|
330
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
331
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
332
|
+
assert.equal(frame.source?.path, normalizeDebugPath(source));
|
|
333
|
+
assert.equal(frame.line, breakpointLine);
|
|
334
|
+
await dc.disconnectRequest({ terminateDebuggee: true });
|
|
203
335
|
});
|
|
204
336
|
void it("should reject a wasm launch when the file is missing", { timeout: 5000 }, async () => {
|
|
205
337
|
await dc.initializeRequest();
|
|
@@ -211,7 +343,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
211
343
|
};
|
|
212
344
|
const stderrPromise = waitForStderrOutput(dc);
|
|
213
345
|
const terminatedPromise = dc.waitForEvent("terminated");
|
|
214
|
-
await dc
|
|
346
|
+
await launchAndConfigure(dc, launchArgs);
|
|
215
347
|
const stderrEvent = await stderrPromise;
|
|
216
348
|
const stderrBody = stderrEvent.body;
|
|
217
349
|
assert.match(stderrBody?.output ?? "", /Wasm file not found/);
|
|
@@ -229,7 +361,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
229
361
|
};
|
|
230
362
|
const stderrPromise = waitForStderrOutput(dc);
|
|
231
363
|
const terminatedPromise = dc.waitForEvent("terminated");
|
|
232
|
-
await dc
|
|
364
|
+
await launchAndConfigure(dc, launchArgs);
|
|
233
365
|
const stderrEvent = await stderrPromise;
|
|
234
366
|
const stderrBody = stderrEvent.body;
|
|
235
367
|
assert.match(stderrBody?.output ?? "", /Failed to load wasm module/);
|
|
@@ -342,7 +474,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
342
474
|
await dc.continueRequest({ threadId: 1 });
|
|
343
475
|
await terminatedPromise;
|
|
344
476
|
});
|
|
345
|
-
void it("should add
|
|
477
|
+
void it("should add breakpoints after launch and while the program is executing", { timeout: 10000 }, async () => {
|
|
346
478
|
const source = sourcePath("debugger_breakpoint_update.ts");
|
|
347
479
|
const output = await buildModule(source);
|
|
348
480
|
const initialBreakpointLine = 6;
|
|
@@ -358,7 +490,15 @@ void describe("WarpoDebugSession", () => {
|
|
|
358
490
|
runtime: "node",
|
|
359
491
|
entryFunctionName: "_start",
|
|
360
492
|
};
|
|
361
|
-
|
|
493
|
+
const firstStop = waitForBreakpointStop(dc);
|
|
494
|
+
await dc.launchRequest(launchArgs);
|
|
495
|
+
const initialBreakpointResponse = await dc.setBreakpointsRequest({
|
|
496
|
+
source: { path: source },
|
|
497
|
+
breakpoints: [{ line: initialBreakpointLine }],
|
|
498
|
+
});
|
|
499
|
+
assert.equal(initialBreakpointResponse.body.breakpoints[0].line, initialBreakpointLine);
|
|
500
|
+
await dc.configurationDoneRequest({});
|
|
501
|
+
await firstStop;
|
|
362
502
|
const secondStop = waitForBreakpointStop(dc);
|
|
363
503
|
await dc.continueRequest({ threadId: 1 });
|
|
364
504
|
const breakpointResponse = await dc.setBreakpointsRequest({
|
|
@@ -402,6 +542,93 @@ void describe("WarpoDebugSession", () => {
|
|
|
402
542
|
assert.equal(delta.type, "i32");
|
|
403
543
|
assert.equal(delta.value, "2");
|
|
404
544
|
});
|
|
545
|
+
void it("should expose a function object's name without its runtime fields", { timeout: 10000 }, async () => {
|
|
546
|
+
const source = sourcePath("debugger_function_closure.ts");
|
|
547
|
+
const output = await buildModule(source);
|
|
548
|
+
await dc.initializeRequest();
|
|
549
|
+
await dc.setBreakpointsRequest({
|
|
550
|
+
source: { path: source },
|
|
551
|
+
breakpoints: [{ line: 25 }],
|
|
552
|
+
});
|
|
553
|
+
const launchArgs = {
|
|
554
|
+
program: output,
|
|
555
|
+
launchType: "wasm file",
|
|
556
|
+
runtime: "node",
|
|
557
|
+
entryFunctionName: "_start",
|
|
558
|
+
};
|
|
559
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
560
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
561
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
562
|
+
const variablesResponse = await readFrameLocals(dc, frame);
|
|
563
|
+
const f1 = assertDefined(findVariable(variablesResponse.body.variables, "f1"));
|
|
564
|
+
assert.ok(f1.variablesReference > 0);
|
|
565
|
+
const f1FieldsResponse = await dc.variablesRequest({ variablesReference: f1.variablesReference });
|
|
566
|
+
assert.deepEqual(f1FieldsResponse.body.variables.map((variable) => variable.name), ["name", "[[scopes]]"]);
|
|
567
|
+
const f1Name = assertDefined(findVariable(f1FieldsResponse.body.variables, "name"));
|
|
568
|
+
assert.match(f1Name.value, /outer/);
|
|
569
|
+
assert.equal(f1Name.type, "string");
|
|
570
|
+
assert.equal(f1Name.variablesReference, 0);
|
|
571
|
+
const f1Scopes = assertDefined(findVariable(f1FieldsResponse.body.variables, "[[scopes]]"));
|
|
572
|
+
assert.equal(f1Scopes.value, "Scopes[2]");
|
|
573
|
+
assert.equal(f1Scopes.type, "Scopes");
|
|
574
|
+
assert.ok(f1Scopes.variablesReference > 0);
|
|
575
|
+
const f1ScopeArrayResponse = await dc.variablesRequest({ variablesReference: f1Scopes.variablesReference });
|
|
576
|
+
assert.deepEqual(f1ScopeArrayResponse.body.variables.map((variable) => variable.name), ["0", "1"]);
|
|
577
|
+
const f1MiddleScope = assertDefined(findVariable(f1ScopeArrayResponse.body.variables, "0"));
|
|
578
|
+
assert.equal(f1MiddleScope.value, "Closure(middle)");
|
|
579
|
+
assert.ok(f1MiddleScope.variablesReference > 0);
|
|
580
|
+
const f1MiddleScopeResponse = await dc.variablesRequest({ variablesReference: f1MiddleScope.variablesReference });
|
|
581
|
+
const f1CapturedB = assertDefined(findVariable(f1MiddleScopeResponse.body.variables, "b"));
|
|
582
|
+
assert.equal(f1CapturedB.value, "2");
|
|
583
|
+
assert.equal(f1CapturedB.type, "i32");
|
|
584
|
+
const f1OuterScope = assertDefined(findVariable(f1ScopeArrayResponse.body.variables, "1"));
|
|
585
|
+
assert.equal(f1OuterScope.value, "Closure(outer)");
|
|
586
|
+
assert.ok(f1OuterScope.variablesReference > 0);
|
|
587
|
+
const f1OuterScopeResponse = await dc.variablesRequest({ variablesReference: f1OuterScope.variablesReference });
|
|
588
|
+
const f1CapturedA = assertDefined(findVariable(f1OuterScopeResponse.body.variables, "a"));
|
|
589
|
+
assert.equal(f1CapturedA.value, "5");
|
|
590
|
+
assert.equal(f1CapturedA.type, "i32");
|
|
591
|
+
const f1CapturedC = assertDefined(findVariable(f1OuterScopeResponse.body.variables, "c"));
|
|
592
|
+
assert.ok(f1CapturedC.variablesReference > 0);
|
|
593
|
+
const f1CapturedCResponse = await dc.variablesRequest({ variablesReference: f1CapturedC.variablesReference });
|
|
594
|
+
const f1CapturedCValue = assertDefined(findVariable(f1CapturedCResponse.body.variables, "a"));
|
|
595
|
+
assert.equal(f1CapturedCValue.value, "10");
|
|
596
|
+
assert.equal(f1CapturedCValue.type, "i32");
|
|
597
|
+
const f2 = assertDefined(findVariable(variablesResponse.body.variables, "f2"));
|
|
598
|
+
assert.ok(f2.variablesReference > 0);
|
|
599
|
+
const f2FieldsResponse = await dc.variablesRequest({ variablesReference: f2.variablesReference });
|
|
600
|
+
assert.deepEqual(f2FieldsResponse.body.variables.map((variable) => variable.name), ["name", "[[scopes]]"]);
|
|
601
|
+
const f2Name = assertDefined(findVariable(f2FieldsResponse.body.variables, "name"));
|
|
602
|
+
assert.match(f2Name.value, /outer/);
|
|
603
|
+
assert.equal(f2Name.type, "string");
|
|
604
|
+
assert.equal(f2Name.variablesReference, 0);
|
|
605
|
+
const f2Scopes = assertDefined(findVariable(f2FieldsResponse.body.variables, "[[scopes]]"));
|
|
606
|
+
assert.equal(f2Scopes.value, "Scopes[2]");
|
|
607
|
+
assert.equal(f2Scopes.type, "Scopes");
|
|
608
|
+
assert.ok(f2Scopes.variablesReference > 0);
|
|
609
|
+
const f2ScopeArrayResponse = await dc.variablesRequest({ variablesReference: f2Scopes.variablesReference });
|
|
610
|
+
assert.deepEqual(f2ScopeArrayResponse.body.variables.map((variable) => variable.name), ["0", "1"]);
|
|
611
|
+
const f2MiddleScope = assertDefined(findVariable(f2ScopeArrayResponse.body.variables, "0"));
|
|
612
|
+
assert.equal(f2MiddleScope.value, "Closure(middle)");
|
|
613
|
+
assert.ok(f2MiddleScope.variablesReference > 0);
|
|
614
|
+
const f2MiddleScopeResponse = await dc.variablesRequest({ variablesReference: f2MiddleScope.variablesReference });
|
|
615
|
+
const f2CapturedB = assertDefined(findVariable(f2MiddleScopeResponse.body.variables, "b"));
|
|
616
|
+
assert.equal(f2CapturedB.value, "2");
|
|
617
|
+
assert.equal(f2CapturedB.type, "i32");
|
|
618
|
+
const f2OuterScope = assertDefined(findVariable(f2ScopeArrayResponse.body.variables, "1"));
|
|
619
|
+
assert.equal(f2OuterScope.value, "Closure(outer)");
|
|
620
|
+
assert.ok(f2OuterScope.variablesReference > 0);
|
|
621
|
+
const f2OuterScopeResponse = await dc.variablesRequest({ variablesReference: f2OuterScope.variablesReference });
|
|
622
|
+
const f2CapturedA = assertDefined(findVariable(f2OuterScopeResponse.body.variables, "a"));
|
|
623
|
+
assert.equal(f2CapturedA.value, "10");
|
|
624
|
+
assert.equal(f2CapturedA.type, "i32");
|
|
625
|
+
const f2CapturedC = assertDefined(findVariable(f2OuterScopeResponse.body.variables, "c"));
|
|
626
|
+
assert.ok(f2CapturedC.variablesReference > 0);
|
|
627
|
+
const f2CapturedCResponse = await dc.variablesRequest({ variablesReference: f2CapturedC.variablesReference });
|
|
628
|
+
const f2CapturedCValue = assertDefined(findVariable(f2CapturedCResponse.body.variables, "a"));
|
|
629
|
+
assert.equal(f2CapturedCValue.value, "15");
|
|
630
|
+
assert.equal(f2CapturedCValue.type, "i32");
|
|
631
|
+
});
|
|
405
632
|
void it("should expose wasm call stack frames after hitting a breakpoint", { timeout: 5000 }, async () => {
|
|
406
633
|
const source = sourcePath("debugger_basic.ts");
|
|
407
634
|
const output = await buildModule(source);
|
|
@@ -467,7 +694,6 @@ void describe("WarpoDebugSession", () => {
|
|
|
467
694
|
const calleeSource = sourcePath("debugger_callee.ts");
|
|
468
695
|
const output = await buildModule(entrySource, [calleeSource]);
|
|
469
696
|
const breakpointLine = 41;
|
|
470
|
-
await dc.initializeRequest();
|
|
471
697
|
await dc.setBreakpointsRequest({
|
|
472
698
|
source: { path: calleeSource },
|
|
473
699
|
breakpoints: [{ line: breakpointLine }],
|
|
@@ -495,6 +721,241 @@ void describe("WarpoDebugSession", () => {
|
|
|
495
721
|
assert.equal(callerSeed.type, "i32");
|
|
496
722
|
assert.equal(callerSeed.value, "23");
|
|
497
723
|
});
|
|
724
|
+
void it("should step into a callee", { timeout: 10000 }, async () => {
|
|
725
|
+
const entrySource = sourcePath("debugger_stepping.ts");
|
|
726
|
+
const output = await buildModule(entrySource);
|
|
727
|
+
await dc.initializeRequest();
|
|
728
|
+
await dc.setBreakpointsRequest({
|
|
729
|
+
source: { path: entrySource },
|
|
730
|
+
breakpoints: [{ line: 5 }],
|
|
731
|
+
});
|
|
732
|
+
const launchArgs = {
|
|
733
|
+
program: output,
|
|
734
|
+
launchType: "wasm file",
|
|
735
|
+
runtime: "node",
|
|
736
|
+
entryFunctionName: "_start",
|
|
737
|
+
};
|
|
738
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
739
|
+
const stoppedPromise = dc.waitForEvent("stopped");
|
|
740
|
+
await dc.stepInRequest({ threadId: 1 });
|
|
741
|
+
await stoppedPromise;
|
|
742
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
743
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
744
|
+
assert.equal(frame.source?.path, normalizeDebugPath(entrySource));
|
|
745
|
+
assert.equal(frame.line, 11);
|
|
746
|
+
});
|
|
747
|
+
void it("should skip library frames during step into", { timeout: 10000 }, async () => {
|
|
748
|
+
const entrySource = sourcePath("debugger_closure_stepping.ts");
|
|
749
|
+
const output = await buildModule(entrySource);
|
|
750
|
+
await dc.initializeRequest();
|
|
751
|
+
await dc.setBreakpointsRequest({
|
|
752
|
+
source: { path: entrySource },
|
|
753
|
+
breakpoints: [{ line: 11 }],
|
|
754
|
+
});
|
|
755
|
+
const launchArgs = {
|
|
756
|
+
program: output,
|
|
757
|
+
launchType: "wasm file",
|
|
758
|
+
runtime: "node",
|
|
759
|
+
entryFunctionName: "main",
|
|
760
|
+
};
|
|
761
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
762
|
+
const stoppedPromise = dc.waitForEvent("stopped");
|
|
763
|
+
await dc.stepInRequest({ threadId: 1 });
|
|
764
|
+
await stoppedPromise;
|
|
765
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
766
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
767
|
+
assert.equal(frame.source?.path, normalizeDebugPath(entrySource));
|
|
768
|
+
assert.equal(frame.line, 6);
|
|
769
|
+
});
|
|
770
|
+
void it("should step within a standard library function", { timeout: 15000 }, async () => {
|
|
771
|
+
const source = sourcePath("debugger_string_stepping.ts");
|
|
772
|
+
const stdSource = path.resolve(DIRNAME, "..", "..", "..", "assemblyscript", "std", "assembly", "string.ts");
|
|
773
|
+
const output = await buildModule(source);
|
|
774
|
+
const breakpointLine = 102;
|
|
775
|
+
await dc.initializeRequest();
|
|
776
|
+
const breakpointResponse = await dc.setBreakpointsRequest({
|
|
777
|
+
source: { path: stdSource },
|
|
778
|
+
breakpoints: [{ line: breakpointLine }],
|
|
779
|
+
});
|
|
780
|
+
assert.equal(breakpointResponse.body.breakpoints[0].verified, false);
|
|
781
|
+
const breakpointChangedPromise = dc.waitForEvent("breakpoint");
|
|
782
|
+
const stoppedPromise = waitForBreakpointStop(dc);
|
|
783
|
+
const launchArgs = {
|
|
784
|
+
program: output,
|
|
785
|
+
launchType: "wasm file",
|
|
786
|
+
runtime: "node",
|
|
787
|
+
entryFunctionName: "_start",
|
|
788
|
+
};
|
|
789
|
+
await launchAndConfigure(dc, launchArgs);
|
|
790
|
+
await breakpointChangedPromise;
|
|
791
|
+
await stoppedPromise;
|
|
792
|
+
const firstStackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
793
|
+
const firstFrame = assertDefined(firstStackTraceResponse.body.stackFrames[0]);
|
|
794
|
+
assert.equal(firstFrame.source?.path, normalizeDebugPath(stdSource));
|
|
795
|
+
assert.equal(firstFrame.line, breakpointLine);
|
|
796
|
+
const nextStoppedPromise = dc.waitForEvent("stopped");
|
|
797
|
+
await dc.stepInRequest({ threadId: 1 });
|
|
798
|
+
await nextStoppedPromise;
|
|
799
|
+
const nextStackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
800
|
+
const nextFrame = assertDefined(nextStackTraceResponse.body.stackFrames[0]);
|
|
801
|
+
assert.equal(nextFrame.source?.path, normalizeDebugPath(stdSource));
|
|
802
|
+
assert.notEqual(nextFrame.line, breakpointLine);
|
|
803
|
+
});
|
|
804
|
+
void it("should pause at a valid source line", { timeout: 10000 }, async () => {
|
|
805
|
+
const entrySource = sourcePath("debugger_pause.ts");
|
|
806
|
+
const output = await buildModule(entrySource);
|
|
807
|
+
await dc.initializeRequest();
|
|
808
|
+
await dc.setBreakpointsRequest({
|
|
809
|
+
source: { path: entrySource },
|
|
810
|
+
breakpoints: [{ line: 4 }],
|
|
811
|
+
});
|
|
812
|
+
const launchArgs = {
|
|
813
|
+
program: output,
|
|
814
|
+
launchType: "wasm file",
|
|
815
|
+
runtime: "node",
|
|
816
|
+
entryFunctionName: "_start",
|
|
817
|
+
};
|
|
818
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
819
|
+
const continuedPromise = dc.waitForEvent("continued");
|
|
820
|
+
await dc.continueRequest({ threadId: 1 });
|
|
821
|
+
await continuedPromise;
|
|
822
|
+
const stoppedPromise = dc.waitForEvent("stopped");
|
|
823
|
+
await dc.pauseRequest({ threadId: 1 });
|
|
824
|
+
const stoppedEvent = await stoppedPromise;
|
|
825
|
+
const stoppedBody = stoppedEvent.body;
|
|
826
|
+
assert.equal(stoppedBody?.reason, "pause");
|
|
827
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
828
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
829
|
+
assert.equal(frame.source?.path, normalizeDebugPath(entrySource));
|
|
830
|
+
assert.ok(frame.line > 0);
|
|
831
|
+
const terminatedPromise = dc.waitForEvent("terminated");
|
|
832
|
+
await dc.terminateRequest({ restart: false });
|
|
833
|
+
await terminatedPromise;
|
|
834
|
+
});
|
|
835
|
+
void it("should step out of a callee and stop at the caller", { timeout: 10000 }, async () => {
|
|
836
|
+
const entrySource = sourcePath("debugger_stepping.ts");
|
|
837
|
+
const output = await buildModule(entrySource);
|
|
838
|
+
await dc.initializeRequest();
|
|
839
|
+
await dc.setBreakpointsRequest({
|
|
840
|
+
source: { path: entrySource },
|
|
841
|
+
breakpoints: [{ line: 5 }],
|
|
842
|
+
});
|
|
843
|
+
const launchArgs = {
|
|
844
|
+
program: output,
|
|
845
|
+
launchType: "wasm file",
|
|
846
|
+
runtime: "node",
|
|
847
|
+
entryFunctionName: "_start",
|
|
848
|
+
};
|
|
849
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
850
|
+
const enteredCallee = dc.waitForEvent("stopped");
|
|
851
|
+
await dc.stepInRequest({ threadId: 1 });
|
|
852
|
+
await enteredCallee;
|
|
853
|
+
const returnedToCaller = dc.waitForEvent("stopped");
|
|
854
|
+
await dc.stepOutRequest({ threadId: 1 });
|
|
855
|
+
await returnedToCaller;
|
|
856
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
857
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
858
|
+
assert.match(frame.name, /_start/);
|
|
859
|
+
assert.equal(frame.source?.path, normalizeDebugPath(entrySource));
|
|
860
|
+
assert.equal(frame.line, 5);
|
|
861
|
+
});
|
|
862
|
+
void it("should step over a callee and stop at the caller's next line", { timeout: 10000 }, async () => {
|
|
863
|
+
const entrySource = sourcePath("debugger_stepping.ts");
|
|
864
|
+
const output = await buildModule(entrySource);
|
|
865
|
+
await dc.initializeRequest();
|
|
866
|
+
const breakpointResponse = await dc.setBreakpointsRequest({
|
|
867
|
+
source: { path: entrySource },
|
|
868
|
+
breakpoints: [{ line: 5 }],
|
|
869
|
+
});
|
|
870
|
+
assert.equal(breakpointResponse.body.breakpoints.length, 1);
|
|
871
|
+
const launchArgs = {
|
|
872
|
+
program: output,
|
|
873
|
+
launchType: "wasm file",
|
|
874
|
+
runtime: "node",
|
|
875
|
+
entryFunctionName: "_start",
|
|
876
|
+
};
|
|
877
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
878
|
+
const stoppedPromise = dc.waitForEvent("stopped");
|
|
879
|
+
await dc.nextRequest({ threadId: 1 });
|
|
880
|
+
await stoppedPromise;
|
|
881
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
882
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
883
|
+
assert.equal(frame.source?.path, normalizeDebugPath(entrySource));
|
|
884
|
+
assert.equal(frame.line, 6);
|
|
885
|
+
});
|
|
886
|
+
void it("should step over a function-object call and stop at the caller's next line", { timeout: 10000 }, async () => {
|
|
887
|
+
const entrySource = sourcePath("debugger_stepping.ts");
|
|
888
|
+
const output = await buildModule(entrySource);
|
|
889
|
+
await dc.initializeRequest();
|
|
890
|
+
const breakpointResponse = await dc.setBreakpointsRequest({
|
|
891
|
+
source: { path: entrySource },
|
|
892
|
+
breakpoints: [{ line: 18 }],
|
|
893
|
+
});
|
|
894
|
+
assert.equal(breakpointResponse.body.breakpoints.length, 1);
|
|
895
|
+
const launchArgs = {
|
|
896
|
+
program: output,
|
|
897
|
+
launchType: "wasm file",
|
|
898
|
+
runtime: "node",
|
|
899
|
+
entryFunctionName: "indirectStart",
|
|
900
|
+
};
|
|
901
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
902
|
+
const stoppedPromise = dc.waitForEvent("stopped");
|
|
903
|
+
await dc.nextRequest({ threadId: 1 });
|
|
904
|
+
await stoppedPromise;
|
|
905
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
906
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
907
|
+
assert.equal(frame.source?.path, normalizeDebugPath(entrySource));
|
|
908
|
+
assert.equal(frame.line, 19);
|
|
909
|
+
});
|
|
910
|
+
void it("should step into a function-object call", { timeout: 10000 }, async () => {
|
|
911
|
+
const entrySource = sourcePath("debugger_stepping.ts");
|
|
912
|
+
const output = await buildModule(entrySource);
|
|
913
|
+
await dc.initializeRequest();
|
|
914
|
+
const breakpointResponse = await dc.setBreakpointsRequest({
|
|
915
|
+
source: { path: entrySource },
|
|
916
|
+
breakpoints: [{ line: 18 }],
|
|
917
|
+
});
|
|
918
|
+
assert.equal(breakpointResponse.body.breakpoints.length, 1);
|
|
919
|
+
const launchArgs = {
|
|
920
|
+
program: output,
|
|
921
|
+
launchType: "wasm file",
|
|
922
|
+
runtime: "node",
|
|
923
|
+
entryFunctionName: "indirectStart",
|
|
924
|
+
};
|
|
925
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
926
|
+
const stoppedPromise = dc.waitForEvent("stopped");
|
|
927
|
+
await dc.stepInRequest({ threadId: 1 });
|
|
928
|
+
await stoppedPromise;
|
|
929
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
930
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
931
|
+
assert.equal(frame.source?.path, normalizeDebugPath(entrySource));
|
|
932
|
+
assert.equal(frame.line, 11);
|
|
933
|
+
});
|
|
934
|
+
void it("should step over a call that is the last instruction of a function", { timeout: 10000 }, async () => {
|
|
935
|
+
const entrySource = sourcePath("debugger_stepping.ts");
|
|
936
|
+
const output = await buildModule(entrySource);
|
|
937
|
+
await dc.initializeRequest();
|
|
938
|
+
const breakpointResponse = await dc.setBreakpointsRequest({
|
|
939
|
+
source: { path: entrySource },
|
|
940
|
+
breakpoints: [{ line: 24 }],
|
|
941
|
+
});
|
|
942
|
+
assert.equal(breakpointResponse.body.breakpoints.length, 1);
|
|
943
|
+
const launchArgs = {
|
|
944
|
+
program: output,
|
|
945
|
+
launchType: "wasm file",
|
|
946
|
+
runtime: "node",
|
|
947
|
+
entryFunctionName: "tailCallStart",
|
|
948
|
+
};
|
|
949
|
+
await launchAndWaitForBreakpoint(dc, launchArgs);
|
|
950
|
+
const stoppedPromise = dc.waitForEvent("stopped");
|
|
951
|
+
await dc.nextRequest({ threadId: 1 });
|
|
952
|
+
await stoppedPromise;
|
|
953
|
+
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
954
|
+
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
955
|
+
assert.match(frame.name, /tailCallStart/);
|
|
956
|
+
assert.equal(frame.source?.path, normalizeDebugPath(entrySource));
|
|
957
|
+
assert.equal(frame.line, 29);
|
|
958
|
+
});
|
|
498
959
|
void it("should stop on a return breakpoint before evaluating its value", { timeout: 5000 }, async () => {
|
|
499
960
|
const entrySource = sourcePath("debugger_caller.ts");
|
|
500
961
|
const calleeSource = sourcePath("debugger_callee.ts");
|
|
@@ -559,7 +1020,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
559
1020
|
entryFunctionName: "_start",
|
|
560
1021
|
};
|
|
561
1022
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
562
|
-
await dc
|
|
1023
|
+
await launchAndConfigure(dc, launchArgs);
|
|
563
1024
|
await stoppedPromise;
|
|
564
1025
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
565
1026
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -612,7 +1073,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
612
1073
|
entryFunctionName: "_start",
|
|
613
1074
|
};
|
|
614
1075
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
615
|
-
await dc
|
|
1076
|
+
await launchAndConfigure(dc, launchArgs);
|
|
616
1077
|
await stoppedPromise;
|
|
617
1078
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
618
1079
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -650,7 +1111,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
650
1111
|
entryFunctionName: "_start",
|
|
651
1112
|
};
|
|
652
1113
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
653
|
-
await dc
|
|
1114
|
+
await launchAndConfigure(dc, launchArgs);
|
|
654
1115
|
await stoppedPromise;
|
|
655
1116
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
656
1117
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -706,6 +1167,79 @@ void describe("WarpoDebugSession", () => {
|
|
|
706
1167
|
{ name: "2", type: "u8", value: "34", variablesReference: 0 },
|
|
707
1168
|
]);
|
|
708
1169
|
});
|
|
1170
|
+
void it("should display utf8.ConstStr values", { timeout: 5000 }, async () => {
|
|
1171
|
+
const source = sourcePath("debugger_utf8_const_str.ts");
|
|
1172
|
+
const output = await buildModule(source);
|
|
1173
|
+
const breakpointLine = 11;
|
|
1174
|
+
await dc.initializeRequest();
|
|
1175
|
+
await dc.setBreakpointsRequest({
|
|
1176
|
+
source: { path: source },
|
|
1177
|
+
breakpoints: [{ line: breakpointLine }],
|
|
1178
|
+
});
|
|
1179
|
+
const launchArgs = {
|
|
1180
|
+
program: output,
|
|
1181
|
+
launchType: "wasm file",
|
|
1182
|
+
runtime: "node",
|
|
1183
|
+
entryFunctionName: "_start",
|
|
1184
|
+
};
|
|
1185
|
+
const { variablesResponse } = await launchAndReadTopFrameLocals(dc, launchArgs);
|
|
1186
|
+
const value = assertDefined(findVariable(variablesResponse.body.variables, "s"));
|
|
1187
|
+
assert.equal(value.type, "~lib/warpo/utf8/const_str/ConstStr");
|
|
1188
|
+
assert.equal(value.value, '"abcdef"');
|
|
1189
|
+
assert.equal(value.variablesReference, 0);
|
|
1190
|
+
});
|
|
1191
|
+
void it("should expand typed array values by index", { timeout: 5000 }, async () => {
|
|
1192
|
+
const source = sourcePath("debugger_typed_array.ts");
|
|
1193
|
+
const output = await buildModule(source);
|
|
1194
|
+
const breakpointLine = 41;
|
|
1195
|
+
await dc.initializeRequest();
|
|
1196
|
+
await dc.setBreakpointsRequest({
|
|
1197
|
+
source: { path: source },
|
|
1198
|
+
breakpoints: [{ line: breakpointLine }],
|
|
1199
|
+
});
|
|
1200
|
+
const launchArgs = {
|
|
1201
|
+
program: output,
|
|
1202
|
+
launchType: "wasm file",
|
|
1203
|
+
runtime: "node",
|
|
1204
|
+
entryFunctionName: "_start",
|
|
1205
|
+
};
|
|
1206
|
+
const { variablesResponse } = await launchAndReadTopFrameLocals(dc, launchArgs);
|
|
1207
|
+
const expected = [
|
|
1208
|
+
{ name: "int8", type: "~lib/typedarray/Int8Array", elementType: "i8", values: ["-8", "8"] },
|
|
1209
|
+
{ name: "uint8", type: "~lib/typedarray/Uint8Array", elementType: "u8", values: ["9", "19"] },
|
|
1210
|
+
{
|
|
1211
|
+
name: "uint8Clamped",
|
|
1212
|
+
type: "~lib/typedarray/Uint8ClampedArray",
|
|
1213
|
+
elementType: "u8",
|
|
1214
|
+
values: ["29", "39"],
|
|
1215
|
+
},
|
|
1216
|
+
{ name: "int16", type: "~lib/typedarray/Int16Array", elementType: "i16", values: ["-49", "49"] },
|
|
1217
|
+
{ name: "uint16", type: "~lib/typedarray/Uint16Array", elementType: "u16", values: ["59", "69"] },
|
|
1218
|
+
{ name: "int32", type: "~lib/typedarray/Int32Array", elementType: "i32", values: ["-79", "79"] },
|
|
1219
|
+
{ name: "uint32", type: "~lib/typedarray/Uint32Array", elementType: "u32", values: ["89", "99"] },
|
|
1220
|
+
{ name: "int64", type: "~lib/typedarray/Int64Array", elementType: "i64", values: ["-109", "109"] },
|
|
1221
|
+
{ name: "uint64", type: "~lib/typedarray/Uint64Array", elementType: "u64", values: ["119", "129"] },
|
|
1222
|
+
{ name: "float32", type: "~lib/typedarray/Float32Array", elementType: "f32", values: ["1.5", "2.5"] },
|
|
1223
|
+
{ name: "float64", type: "~lib/typedarray/Float64Array", elementType: "f64", values: ["3.5", "4.5"] },
|
|
1224
|
+
];
|
|
1225
|
+
for (const expectedArray of expected) {
|
|
1226
|
+
const variable = assertDefined(findVariable(variablesResponse.body.variables, expectedArray.name));
|
|
1227
|
+
assert.equal(variable.type, expectedArray.type);
|
|
1228
|
+
assert.ok(variable.variablesReference > 0);
|
|
1229
|
+
const elementsResponse = await dc.variablesRequest({ variablesReference: variable.variablesReference });
|
|
1230
|
+
assert.deepEqual(elementsResponse.body.variables.map((element) => ({
|
|
1231
|
+
name: element.name,
|
|
1232
|
+
type: element.type,
|
|
1233
|
+
value: element.value,
|
|
1234
|
+
variablesReference: element.variablesReference,
|
|
1235
|
+
})), expectedArray.values.map((value, index) => ({
|
|
1236
|
+
name: index.toString(),
|
|
1237
|
+
type: expectedArray.elementType,
|
|
1238
|
+
value,
|
|
1239
|
+
variablesReference: 0,
|
|
1240
|
+
})));
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
709
1243
|
void it("should expand class array elements as objects", { timeout: 5000 }, async () => {
|
|
710
1244
|
const source = sourcePath("debugger_class_array.ts");
|
|
711
1245
|
const output = await buildModule(source);
|
|
@@ -722,7 +1256,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
722
1256
|
entryFunctionName: "_start",
|
|
723
1257
|
};
|
|
724
1258
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
725
|
-
await dc
|
|
1259
|
+
await launchAndConfigure(dc, launchArgs);
|
|
726
1260
|
await stoppedPromise;
|
|
727
1261
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
728
1262
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -768,7 +1302,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
768
1302
|
entryFunctionName: "_start",
|
|
769
1303
|
};
|
|
770
1304
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
771
|
-
await dc
|
|
1305
|
+
await launchAndConfigure(dc, launchArgs);
|
|
772
1306
|
await stoppedPromise;
|
|
773
1307
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
774
1308
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -814,7 +1348,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
814
1348
|
entryFunctionName: "_start",
|
|
815
1349
|
};
|
|
816
1350
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
817
|
-
await dc
|
|
1351
|
+
await launchAndConfigure(dc, launchArgs);
|
|
818
1352
|
await stoppedPromise;
|
|
819
1353
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
820
1354
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -876,7 +1410,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
876
1410
|
entryFunctionName: "_start",
|
|
877
1411
|
};
|
|
878
1412
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
879
|
-
await dc
|
|
1413
|
+
await launchAndConfigure(dc, launchArgs);
|
|
880
1414
|
await stoppedPromise;
|
|
881
1415
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
882
1416
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -937,7 +1471,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
937
1471
|
entryFunctionName: "_start",
|
|
938
1472
|
};
|
|
939
1473
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
940
|
-
await dc
|
|
1474
|
+
await launchAndConfigure(dc, launchArgs);
|
|
941
1475
|
await stoppedPromise;
|
|
942
1476
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
943
1477
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -1021,7 +1555,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
1021
1555
|
entryFunctionName: "_start",
|
|
1022
1556
|
};
|
|
1023
1557
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
1024
|
-
await dc
|
|
1558
|
+
await launchAndConfigure(dc, launchArgs);
|
|
1025
1559
|
await stoppedPromise;
|
|
1026
1560
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
1027
1561
|
const frame = stackTraceResponse.body.stackFrames[0];
|
|
@@ -1097,7 +1631,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
1097
1631
|
entryFunctionName: "_start",
|
|
1098
1632
|
};
|
|
1099
1633
|
const stoppedPromise = waitForBreakpointStop(dc);
|
|
1100
|
-
await dc
|
|
1634
|
+
await launchAndConfigure(dc, launchArgs);
|
|
1101
1635
|
await stoppedPromise;
|
|
1102
1636
|
const stackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
1103
1637
|
const frame = assertDefined(stackTraceResponse.body.stackFrames[0]);
|
|
@@ -1142,7 +1676,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
1142
1676
|
entryFunctionName: "_start",
|
|
1143
1677
|
};
|
|
1144
1678
|
const firstStoppedPromise = waitForBreakpointStop(dc);
|
|
1145
|
-
await dc
|
|
1679
|
+
await launchAndConfigure(dc, launchArgs);
|
|
1146
1680
|
await firstStoppedPromise;
|
|
1147
1681
|
const firstStackTraceResponse = await dc.stackTraceRequest({ threadId: 1, startFrame: 0, levels: 1 });
|
|
1148
1682
|
const firstScopesResponse = await dc.scopesRequest({ frameId: firstStackTraceResponse.body.stackFrames[0].id });
|
|
@@ -1218,7 +1752,7 @@ void describe("WarpoDebugSession", () => {
|
|
|
1218
1752
|
};
|
|
1219
1753
|
const stoppedPromise = dc.waitForEvent("stopped");
|
|
1220
1754
|
const terminatedPromise = dc.waitForEvent("terminated");
|
|
1221
|
-
await dc
|
|
1755
|
+
await launchAndConfigure(dc, launchArgs);
|
|
1222
1756
|
const stoppedEvent = await stoppedPromise;
|
|
1223
1757
|
const stoppedBody = stoppedEvent.body;
|
|
1224
1758
|
assert.equal(stoppedBody?.reason, "exception");
|