warpo 3.0.0 → 3.1.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.
Files changed (86) hide show
  1. package/dist/debug_server/debugSession.d.ts +17 -1
  2. package/dist/debug_server/debugSession.js +169 -7
  3. package/dist/debug_server/debugSession.js.map +1 -1
  4. package/dist/debug_server/debugger.d.ts +25 -0
  5. package/dist/debug_server/debugger.js +4 -0
  6. package/dist/debug_server/debugger.js.map +1 -0
  7. package/dist/debug_server/debuggerWasmModule.d.ts +28 -0
  8. package/dist/debug_server/debuggerWasmModule.js +75 -0
  9. package/dist/debug_server/debuggerWasmModule.js.map +1 -0
  10. package/dist/debug_server/nodeDebugger.d.ts +27 -0
  11. package/dist/debug_server/nodeDebugger.js +240 -0
  12. package/dist/debug_server/nodeDebugger.js.map +1 -0
  13. package/dist/debug_server/tests/debugSession.test.js +45 -1
  14. package/dist/debug_server/tests/debugSession.test.js.map +1 -1
  15. package/dist/debug_server/tests/testModule/debugger_basic.d.ts +1 -0
  16. package/dist/debug_server/tests/testModule/debugger_basic.js +6 -0
  17. package/dist/debug_server/tests/testModule/debugger_basic.js.map +1 -0
  18. package/dist/debug_server/wasmEntry.js +36 -0
  19. package/dist/debug_server/wasmEntry.js.map +1 -0
  20. package/dist/heap_analyzer/cli.d.ts +1 -0
  21. package/dist/heap_analyzer/cli.js +172 -0
  22. package/dist/heap_analyzer/cli.js.map +1 -0
  23. package/dist/heap_analyzer/src/comparison.d.ts +2 -0
  24. package/dist/heap_analyzer/src/comparison.js +77 -0
  25. package/dist/heap_analyzer/src/comparison.js.map +1 -0
  26. package/dist/heap_analyzer/src/constants.d.ts +1 -1
  27. package/dist/heap_analyzer/src/constants.js +1 -1
  28. package/dist/heap_analyzer/src/debugInfoResolver.d.ts +30 -0
  29. package/dist/heap_analyzer/src/debugInfoResolver.js +334 -0
  30. package/dist/heap_analyzer/src/debugInfoResolver.js.map +1 -0
  31. package/dist/heap_analyzer/src/dumpReader.js +11 -2
  32. package/dist/heap_analyzer/src/dumpReader.js.map +1 -1
  33. package/dist/heap_analyzer/src/dwarfParser.d.ts +30 -9
  34. package/dist/heap_analyzer/src/dwarfParser.js +54 -20
  35. package/dist/heap_analyzer/src/dwarfParser.js.map +1 -1
  36. package/dist/heap_analyzer/src/index.d.ts +7 -0
  37. package/dist/heap_analyzer/src/index.js +16 -0
  38. package/dist/heap_analyzer/src/index.js.map +1 -0
  39. package/dist/heap_analyzer/src/referenceScanner.d.ts +4 -4
  40. package/dist/heap_analyzer/src/referenceScanner.js +52 -21
  41. package/dist/heap_analyzer/src/referenceScanner.js.map +1 -1
  42. package/dist/heap_analyzer/src/roots.d.ts +3 -6
  43. package/dist/heap_analyzer/src/roots.js +12 -5
  44. package/dist/heap_analyzer/src/roots.js.map +1 -1
  45. package/dist/heap_analyzer/src/snapshot.d.ts +2 -2
  46. package/dist/heap_analyzer/src/snapshot.js +36 -88
  47. package/dist/heap_analyzer/src/snapshot.js.map +1 -1
  48. package/dist/heap_analyzer/src/types.d.ts +54 -11
  49. package/dist/heap_analyzer/src/types.js +22 -1
  50. package/dist/heap_analyzer/src/types.js.map +1 -1
  51. package/dist/heap_analyzer/tests/comparison.test.d.ts +1 -0
  52. package/dist/heap_analyzer/tests/comparison.test.js +121 -0
  53. package/dist/heap_analyzer/tests/comparison.test.js.map +1 -0
  54. package/dist/heap_analyzer/tests/debugInfoResolver.test.d.ts +1 -0
  55. package/dist/heap_analyzer/tests/debugInfoResolver.test.js +205 -0
  56. package/dist/heap_analyzer/tests/debugInfoResolver.test.js.map +1 -0
  57. package/dist/heap_analyzer/tests/dumpReader.test.js +12 -2
  58. package/dist/heap_analyzer/tests/dumpReader.test.js.map +1 -1
  59. package/dist/heap_analyzer/tests/dwarfParser.test.js +40 -28
  60. package/dist/heap_analyzer/tests/dwarfParser.test.js.map +1 -1
  61. package/dist/heap_analyzer/tests/roots.test.js +21 -4
  62. package/dist/heap_analyzer/tests/roots.test.js.map +1 -1
  63. package/dist/heap_analyzer/tests/snapshot.test.js +58 -54
  64. package/dist/heap_analyzer/tests/snapshot.test.js.map +1 -1
  65. package/dist/heap_analyzer/tests/testHelper.js +1 -1
  66. package/dist/heap_analyzer/tests/testHelper.js.map +1 -1
  67. package/dist/heap_analyzer/tests/wasmExecutor.js +2 -1
  68. package/dist/heap_analyzer/tests/wasmExecutor.js.map +1 -1
  69. package/dist/scripts/lib.d.ts +5 -1
  70. package/dist/scripts/lib.js +171 -24
  71. package/dist/scripts/lib.js.map +1 -1
  72. package/dist/test_runner/core/compiler.js +0 -1
  73. package/dist/test_runner/core/compiler.js.map +1 -1
  74. package/dist/warpo.d.ts +12 -1
  75. package/dist/warpo.js +32 -7
  76. package/dist/warpo.js.map +1 -1
  77. package/dist/warpo_internal.d.ts +1 -1
  78. package/dist/warpo_internal.js +23 -14
  79. package/dist/warpo_internal.js.map +1 -1
  80. package/package.json +11 -2
  81. package/dist/heap_analyzer/src/classResolver.d.ts +0 -34
  82. package/dist/heap_analyzer/src/classResolver.js +0 -206
  83. package/dist/heap_analyzer/src/classResolver.js.map +0 -1
  84. package/dist/heap_analyzer/tests/classResolver.test.js +0 -110
  85. package/dist/heap_analyzer/tests/classResolver.test.js.map +0 -1
  86. /package/dist/{heap_analyzer/tests/classResolver.test.d.ts → debug_server/wasmEntry.d.ts} +0 -0
@@ -0,0 +1,240 @@
1
+ // Copyright (C) 2025 wasm-ecosystem
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { spawn } from "node:child_process";
4
+ import { appendFileSync, writeFileSync } from "node:fs";
5
+ import * as path from "node:path";
6
+ import * as net from "node:net";
7
+ import { fileURLToPath } from "node:url";
8
+ import { DebuggerWasmModule } from "./debuggerWasmModule.js";
9
+ const DIRNAME = path.dirname(fileURLToPath(import.meta.url));
10
+ const DEBUG_SERVER_TRACE_ENABLED = process.env.WARPO_DEBUG_SERVER_TRACE === "1";
11
+ const DEBUG_SERVER_TRACE_FILE = path.join(process.cwd(), ".warpo-debug-server-trace.log");
12
+ if (DEBUG_SERVER_TRACE_ENABLED) {
13
+ try {
14
+ writeFileSync(DEBUG_SERVER_TRACE_FILE, "");
15
+ }
16
+ catch {
17
+ // Tracing should never block launching the runtime.
18
+ }
19
+ }
20
+ function trace(message) {
21
+ if (DEBUG_SERVER_TRACE_ENABLED) {
22
+ try {
23
+ appendFileSync(DEBUG_SERVER_TRACE_FILE, `[node-debugger] ${message}\n`);
24
+ }
25
+ catch {
26
+ // Tracing should never block launching the runtime.
27
+ }
28
+ }
29
+ }
30
+ function findFreePort() {
31
+ return new Promise((resolve, reject) => {
32
+ const srv = net.createServer();
33
+ srv.listen(0, "127.0.0.1", () => {
34
+ const addr = srv.address();
35
+ if (addr && typeof addr === "object") {
36
+ srv.close(() => resolve(addr.port));
37
+ }
38
+ else {
39
+ srv.close(() => reject(new Error("Failed to obtain a free port")));
40
+ }
41
+ });
42
+ srv.on("error", reject);
43
+ });
44
+ }
45
+ function wait(ms) {
46
+ return new Promise((resolve) => {
47
+ setTimeout(resolve, ms);
48
+ });
49
+ }
50
+ export class NodeDebugger {
51
+ name = "node";
52
+ onModuleLoad;
53
+ onPause;
54
+ child;
55
+ ws;
56
+ cdpId = 0;
57
+ pendingCommandCallbacks = new Map();
58
+ paused = false;
59
+ wasmFilePath;
60
+ async launch(config) {
61
+ this.wasmFilePath = config.wasmFilePath;
62
+ const port = await findFreePort();
63
+ this.child = spawn(process.execPath, [
64
+ `--inspect=${port}`,
65
+ path.join(DIRNAME, "wasmEntry.js"),
66
+ config.wasmFilePath,
67
+ config.entryFunctionName,
68
+ ...config.args.map(String),
69
+ ], { stdio: ["pipe", "pipe", "pipe"] });
70
+ const wsUrl = await this.fetchWsUrl(port);
71
+ await this.connectCDP(wsUrl);
72
+ }
73
+ dispose() {
74
+ this.paused = false;
75
+ this.wasmFilePath = undefined;
76
+ this.ws?.close();
77
+ this.child?.kill();
78
+ }
79
+ isPaused() {
80
+ return this.paused;
81
+ }
82
+ pause() {
83
+ this.sendCommand("Debugger.pause");
84
+ }
85
+ async resume() {
86
+ await this.waitForCommand("Debugger.resume");
87
+ this.paused = false;
88
+ }
89
+ finishModuleLoad() {
90
+ this.sendCommand("Runtime.runIfWaitingForDebugger");
91
+ }
92
+ setWasmBreakpoint(module, bytecodeOffset, callbacks) {
93
+ this.sendCommand("Debugger.setBreakpointByUrl", {
94
+ url: module.url,
95
+ lineNumber: 0,
96
+ columnNumber: bytecodeOffset,
97
+ }, {
98
+ onSuccess: () => {
99
+ trace(`setWasmBreakpoint success offset=${bytecodeOffset}`);
100
+ callbacks?.onSuccess?.();
101
+ },
102
+ onError: (error) => {
103
+ trace(`setWasmBreakpoint error offset=${bytecodeOffset} message=${error.message}`);
104
+ callbacks?.onError?.(error);
105
+ },
106
+ });
107
+ }
108
+ async fetchWsUrl(port) {
109
+ const deadline = Date.now() + 5000;
110
+ while (Date.now() < deadline) {
111
+ try {
112
+ const resp = await fetch(`http://127.0.0.1:${port}/json`);
113
+ if (!resp.ok) {
114
+ throw new Error(`inspector endpoint returned ${resp.status}`);
115
+ }
116
+ const [info] = (await resp.json());
117
+ if (info?.webSocketDebuggerUrl) {
118
+ return info.webSocketDebuggerUrl;
119
+ }
120
+ }
121
+ catch {
122
+ // The inspector endpoint is not always ready immediately after spawn.
123
+ }
124
+ await wait(50);
125
+ }
126
+ throw new Error(`timed out waiting for inspector endpoint on port ${port}`);
127
+ }
128
+ sendCommand(method, params, callbacks) {
129
+ if (!this.ws) {
130
+ throw new Error("debugger is not connected");
131
+ }
132
+ const id = ++this.cdpId;
133
+ if (callbacks) {
134
+ this.pendingCommandCallbacks.set(id, callbacks);
135
+ }
136
+ this.ws.send(JSON.stringify({ id, method, params }));
137
+ }
138
+ waitForCommand(method, params) {
139
+ return new Promise((resolve, reject) => {
140
+ this.sendCommand(method, params, {
141
+ onSuccess: () => {
142
+ resolve();
143
+ },
144
+ onError: (error) => {
145
+ reject(error);
146
+ },
147
+ });
148
+ });
149
+ }
150
+ connectCDP(wsUrl) {
151
+ return new Promise((resolve, reject) => {
152
+ const ws = new WebSocket(wsUrl);
153
+ this.ws = ws;
154
+ ws.addEventListener("open", () => {
155
+ void (async () => {
156
+ try {
157
+ trace("ws open -> Debugger.enable");
158
+ await this.waitForCommand("Debugger.enable");
159
+ trace("Debugger.enable -> Debugger.setBreakpointsActive");
160
+ await this.waitForCommand("Debugger.setBreakpointsActive", { active: true });
161
+ trace("Debugger.setBreakpointsActive -> Runtime.runIfWaitingForDebugger");
162
+ await this.waitForCommand("Runtime.runIfWaitingForDebugger");
163
+ trace("Runtime.runIfWaitingForDebugger -> launch ready");
164
+ resolve();
165
+ }
166
+ catch (error) {
167
+ reject(error instanceof Error ? error : new Error(String(error)));
168
+ }
169
+ })();
170
+ });
171
+ ws.addEventListener("error", (e) => {
172
+ const message = e instanceof Error ? e.message : "WebSocket connection failed";
173
+ reject(new Error(message));
174
+ });
175
+ ws.addEventListener("message", (ev) => {
176
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
177
+ const msg = JSON.parse(String(ev.data));
178
+ if (typeof msg.id === "number") {
179
+ this.handleCommandResponse(msg.id, msg);
180
+ return;
181
+ }
182
+ if (msg.method === "Debugger.paused") {
183
+ const reason = this.getPauseReason(msg.params);
184
+ this.paused = true;
185
+ trace(`Debugger.paused reason=${reason}`);
186
+ void Promise.resolve(this.onPause?.({ reason })).catch((error) => {
187
+ trace(`pause handler failed: ${error instanceof Error ? error.message : "unknown error"}`);
188
+ });
189
+ return;
190
+ }
191
+ if (msg.method === "Debugger.scriptParsed") {
192
+ const params = msg.params;
193
+ const lang = typeof params?.scriptLanguage === "string" ? params.scriptLanguage : "unknown";
194
+ const url = typeof params?.url === "string" ? params.url : "";
195
+ trace(`Debugger.scriptParsed language=${lang} url=${url}`);
196
+ if (params && lang === "WebAssembly" && typeof params.scriptId === "string") {
197
+ trace(`wasm module detected scriptId=${params.scriptId}`);
198
+ void this.handleModuleLoad({
199
+ scriptId: params.scriptId,
200
+ url,
201
+ }).catch((error) => {
202
+ const message = error instanceof Error ? error.message : "unknown error";
203
+ trace(`module load handler failed: ${message}`);
204
+ process.stderr.write(`[node-debugger] module load handler failed: ${message}\n`);
205
+ });
206
+ }
207
+ }
208
+ });
209
+ });
210
+ }
211
+ handleCommandResponse(id, msg) {
212
+ const callbacks = this.pendingCommandCallbacks.get(id);
213
+ if (!callbacks) {
214
+ return;
215
+ }
216
+ this.pendingCommandCallbacks.delete(id);
217
+ if (msg.error) {
218
+ callbacks.onError?.(new Error(msg.error.message ?? "CDP command failed"));
219
+ return;
220
+ }
221
+ callbacks.onSuccess?.();
222
+ }
223
+ getPauseReason(params) {
224
+ if (Array.isArray(params?.hitBreakpoints) && params.hitBreakpoints.length > 0) {
225
+ return "breakpoint";
226
+ }
227
+ if (typeof params?.reason === "string") {
228
+ return params.reason;
229
+ }
230
+ return "unknown";
231
+ }
232
+ async handleModuleLoad(runtimeInfo) {
233
+ if (!this.wasmFilePath) {
234
+ throw new Error("wasm file path is not available");
235
+ }
236
+ const module = await DebuggerWasmModule.load(this.wasmFilePath, runtimeInfo);
237
+ void this.onModuleLoad?.(module);
238
+ }
239
+ }
240
+ //# sourceMappingURL=nodeDebugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeDebugger.js","sourceRoot":"","sources":["../../tools/debug_server/nodeDebugger.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAEtC,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa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,IAAI,oBAAoB,CAAC,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QAED,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC;IAC1B,CAAC;IAEO,cAAc,CAAC,MAAgC;QACrD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9E,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,IAAI,OAAO,MAAM,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;YACvC,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,WAA8C;QAC3E,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QAC7E,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;CACF"}
@@ -3,11 +3,15 @@
3
3
  import { DebugClient } from "@vscode/debugadapter-testsupport";
4
4
  import * as assert from "node:assert/strict";
5
5
  import * as path from "node:path";
6
- import { describe, it, beforeEach, afterEach } from "node:test";
6
+ import { describe, it, before, beforeEach, afterEach } from "node:test";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { launchDapServer } from "./launcher.js";
9
+ import { build } from "../../scripts/lib.js";
9
10
  const DIRNAME = path.dirname(fileURLToPath(import.meta.url));
10
11
  const DAP_SERVER = path.resolve(DIRNAME, "..", "..", "..", "dist", "debug_server", "dapServer.js");
12
+ const TEST_MODULE_DIR = path.resolve(DIRNAME, "testModule");
13
+ const TEST_MODULE_SOURCE = path.join(TEST_MODULE_DIR, "debugger_basic.ts");
14
+ const TEST_MODULE_OUTPUT = path.join(TEST_MODULE_DIR, "build/debugger_basic.wasm");
11
15
  const waitForExit = (child, timeoutMs) => new Promise((resolve) => {
12
16
  if (child.exitCode !== null) {
13
17
  resolve(true);
@@ -23,6 +27,19 @@ const waitForExit = (child, timeoutMs) => new Promise((resolve) => {
23
27
  };
24
28
  child.once("exit", onExit);
25
29
  });
30
+ before(async () => {
31
+ let buildOutput = "";
32
+ const exitCode = await build({
33
+ argv: [TEST_MODULE_SOURCE, "-o", TEST_MODULE_OUTPUT, "--debug"],
34
+ cwd: TEST_MODULE_DIR,
35
+ onStdout: (chunk) => {
36
+ buildOutput += chunk;
37
+ },
38
+ });
39
+ if (exitCode !== 0) {
40
+ throw new Error(`failed to build debugger test module: ${buildOutput}`);
41
+ }
42
+ });
26
43
  void describe("WarpoDebugSession", () => {
27
44
  let dc;
28
45
  let serverChild;
@@ -57,5 +74,32 @@ void describe("WarpoDebugSession", () => {
57
74
  assert.equal(response.body.breakpoints[1].verified, true);
58
75
  assert.equal(response.body.breakpoints[1].line, 10);
59
76
  });
77
+ void it("should report the built wasm as a loaded source on launch", { timeout: 5000 }, async () => {
78
+ await dc.initializeRequest();
79
+ const breakpointResponse = await dc.setBreakpointsRequest({
80
+ source: { path: TEST_MODULE_SOURCE },
81
+ breakpoints: [{ line: 3 }],
82
+ });
83
+ assert.equal(breakpointResponse.body.breakpoints.length, 1);
84
+ assert.equal(breakpointResponse.body.breakpoints[0].verified, true);
85
+ assert.equal(breakpointResponse.body.breakpoints[0].line, 3);
86
+ const launchArgs = {
87
+ program: TEST_MODULE_OUTPUT,
88
+ launchType: "wasm file",
89
+ runtime: "node",
90
+ entryFunctionName: "_start",
91
+ };
92
+ const loadedSourcePromise = dc.waitForEvent("loadedSource");
93
+ const stoppedPromise = dc.waitForEvent("stopped");
94
+ await dc.launchRequest(launchArgs);
95
+ const loadedSourceEvent = await loadedSourcePromise;
96
+ const loadedSourceBody = loadedSourceEvent.body;
97
+ const stoppedEvent = await stoppedPromise;
98
+ const stoppedBody = stoppedEvent.body;
99
+ assert.equal(loadedSourceBody?.reason, "new");
100
+ assert.equal(loadedSourceBody?.source?.path, path.resolve(TEST_MODULE_OUTPUT));
101
+ assert.equal(loadedSourceBody?.source?.name, path.basename(TEST_MODULE_OUTPUT));
102
+ assert.equal(stoppedBody?.reason, "breakpoint");
103
+ });
60
104
  });
61
105
  //# sourceMappingURL=debugSession.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debugSession.test.js","sourceRoot":"","sources":["../../../tools/debug_server/tests/debugSession.test.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAwB,MAAM,eAAe,CAAC;AAEtE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;AAEnG,MAAM,WAAW,GAAG,CAAC,KAA+B,EAAE,SAAiB,EAAoB,EAAE,CAC3F,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACtB,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,UA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QAChF,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function _start(): i32;
@@ -0,0 +1,6 @@
1
+ // @ts-nocheck
2
+ export function _start() {
3
+ let a = 1;
4
+ return a;
5
+ }
6
+ //# sourceMappingURL=debugger_basic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debugger_basic.js","sourceRoot":"","sources":["../../../../tools/debug_server/tests/testModule/debugger_basic.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,UAAU,MAAM;IACpB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,36 @@
1
+ // Copyright (C) 2025 wasm-ecosystem
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ /* eslint-disable n/no-process-exit, unicorn/no-process-exit */
4
+ import * as fs from "node:fs";
5
+ import * as inspector from "node:inspector";
6
+ import * as path from "node:path";
7
+ const [wasmFilePath, entryFunctionName, ...rawArgs] = process.argv.slice(2);
8
+ if (!wasmFilePath || !entryFunctionName) {
9
+ console.error("Usage: wasmEntry.js <wasmFilePath> <entryFunctionName> [args...]");
10
+ process.exit(1);
11
+ }
12
+ const resolvedPath = path.resolve(wasmFilePath);
13
+ if (!fs.existsSync(resolvedPath)) {
14
+ console.error(`Wasm file not found: ${resolvedPath}`);
15
+ process.exit(1);
16
+ }
17
+ const args = rawArgs.map(Number);
18
+ async function main() {
19
+ inspector.waitForDebugger();
20
+ const buffer = fs.readFileSync(resolvedPath);
21
+ const module = await WebAssembly.compile(buffer);
22
+ const instance = await WebAssembly.instantiate(module, {});
23
+ inspector.waitForDebugger();
24
+ const fn = instance.exports[entryFunctionName];
25
+ if (typeof fn !== "function") {
26
+ const keys = Object.keys(instance.exports).join(", ");
27
+ console.error(`Export "${entryFunctionName}" is not a function. Available exports: ${keys}`);
28
+ process.exit(1);
29
+ }
30
+ console.log(`Calling ${entryFunctionName}(${args.join(", ")})...`);
31
+ const result = fn(...args);
32
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions
33
+ console.log(`Result: ${result}`);
34
+ }
35
+ await main();
36
+ //# sourceMappingURL=wasmEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasmEntry.js","sourceRoot":"","sources":["../../tools/debug_server/wasmEntry.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AACtC,+DAA+D;AAE/D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE5E,IAAI,CAAC,YAAY,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACxC,OAAO,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;IAClF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAChD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;IACjC,OAAO,CAAC,KAAK,CAAC,wBAAwB,YAAY,EAAE,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAEjC,KAAK,UAAU,IAAI;IACjB,SAAS,CAAC,eAAe,EAAE,CAAC;IAE5B,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAE3D,SAAS,CAAC,eAAe,EAAE,CAAC;IAE5B,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC/C,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,CAAC,KAAK,CAAC,WAAW,iBAAiB,2CAA2C,IAAI,EAAE,CAAC,CAAC;QAC7F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,WAAW,iBAAiB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,MAAM,GAAI,EAAkC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5D,kHAAkH;IAClH,OAAO,CAAC,GAAG,CAAC,WAAW,MAAM,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function main(args?: string[]): Promise<void>;
@@ -0,0 +1,172 @@
1
+ // Copyright (C) 2026 wasm-ecosystem
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { readFileSync } from "node:fs";
4
+ import { argv as processArgv, exit as processExit } from "node:process";
5
+ import { fileURLToPath } from "node:url";
6
+ import { Command } from "commander";
7
+ import { analyzeDump, compareDumps } from "./src/index.js";
8
+ const CONSTRUCTOR_SORTS = new Set(["retained", "shallow", "count"]);
9
+ const COMPARISON_SORTS = new Set(["delta", "alloc", "freed", "count"]);
10
+ function readVersion() {
11
+ const packageJson = readFileSync(new URL("../../package.json", import.meta.url), "utf8");
12
+ const parsed = JSON.parse(packageJson);
13
+ const version = parsed.version;
14
+ if (typeof version !== "string") {
15
+ throw new TypeError("Invalid package.json: missing string version");
16
+ }
17
+ return version;
18
+ }
19
+ function parsePositiveInteger(value, optionName) {
20
+ const parsed = Number.parseInt(value, 10);
21
+ if (!Number.isInteger(parsed) || parsed < 1) {
22
+ throw new Error(`${optionName} must be a positive integer`);
23
+ }
24
+ return parsed;
25
+ }
26
+ function parseSortField(value) {
27
+ return value;
28
+ }
29
+ function formatErrorMessage(error) {
30
+ if (error instanceof Error) {
31
+ return error.message;
32
+ }
33
+ if (typeof error === "string") {
34
+ return error;
35
+ }
36
+ return JSON.stringify(error);
37
+ }
38
+ function readArrayBuffer(filePath, label) {
39
+ try {
40
+ const buffer = readFileSync(filePath);
41
+ return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
42
+ }
43
+ catch (error) {
44
+ const message = error instanceof Error ? error.message : String(error);
45
+ throw new Error(`Error reading ${label}: ${message}`);
46
+ }
47
+ }
48
+ function readUint8Array(filePath, label) {
49
+ try {
50
+ return new Uint8Array(readFileSync(filePath));
51
+ }
52
+ catch (error) {
53
+ const message = error instanceof Error ? error.message : String(error);
54
+ throw new Error(`Error reading ${label}: ${message}`);
55
+ }
56
+ }
57
+ function sortConstructors(constructors, sortField) {
58
+ if (!CONSTRUCTOR_SORTS.has(sortField)) {
59
+ throw new Error(`Invalid constructor sort field: ${sortField}. Must be retained, shallow, or count.`);
60
+ }
61
+ switch (sortField) {
62
+ case "retained": {
63
+ return constructors;
64
+ }
65
+ case "shallow": {
66
+ return constructors.toSorted((lhs, rhs) => rhs.totalShallowSize - lhs.totalShallowSize);
67
+ }
68
+ case "count": {
69
+ return constructors.toSorted((lhs, rhs) => rhs.count - lhs.count);
70
+ }
71
+ default: {
72
+ throw new Error(`Invalid constructor sort field: ${sortField}. Must be retained, shallow, or count.`);
73
+ }
74
+ }
75
+ }
76
+ function sortConstructorComparisons(constructors, sortField) {
77
+ if (!COMPARISON_SORTS.has(sortField)) {
78
+ throw new Error(`Invalid comparison sort field: ${sortField}. Must be delta, alloc, freed, or count.`);
79
+ }
80
+ switch (sortField) {
81
+ case "delta": {
82
+ return constructors;
83
+ }
84
+ case "alloc": {
85
+ return constructors.toSorted((lhs, rhs) => rhs.allocatedSize - lhs.allocatedSize ||
86
+ rhs.sizeDelta - lhs.sizeDelta ||
87
+ rhs.countDelta - lhs.countDelta ||
88
+ lhs.className.localeCompare(rhs.className));
89
+ }
90
+ case "freed": {
91
+ return constructors.toSorted((lhs, rhs) => rhs.freedSize - lhs.freedSize || lhs.sizeDelta - rhs.sizeDelta || lhs.className.localeCompare(rhs.className));
92
+ }
93
+ case "count": {
94
+ return constructors.toSorted((lhs, rhs) => rhs.countDelta - lhs.countDelta || rhs.sizeDelta - lhs.sizeDelta || lhs.className.localeCompare(rhs.className));
95
+ }
96
+ default: {
97
+ throw new Error(`Invalid comparison sort field: ${sortField}. Must be delta, alloc, freed, or count.`);
98
+ }
99
+ }
100
+ }
101
+ function analyzeDumpWithCli(dumpFile, options) {
102
+ const dumpBuffer = readArrayBuffer(dumpFile, "dump file");
103
+ const wasmBytes = readUint8Array(options.wasm, "wasm file");
104
+ const snapshot = analyzeDump(dumpBuffer, wasmBytes);
105
+ const sortField = options.sort ?? "retained";
106
+ let constructors = sortConstructors(snapshot.constructors, sortField);
107
+ if (options.top !== undefined) {
108
+ constructors = constructors.slice(0, options.top);
109
+ }
110
+ console.log(JSON.stringify({
111
+ totalHeapSize: snapshot.totalHeapSize,
112
+ totalLiveSize: snapshot.totalLiveSize,
113
+ constructors,
114
+ }, null, 2));
115
+ }
116
+ function diffDumpsWithCli(beforeDumpFile, afterDumpFile, options) {
117
+ const beforeDumpBuffer = readArrayBuffer(beforeDumpFile, "baseline dump file");
118
+ const afterDumpBuffer = readArrayBuffer(afterDumpFile, "current dump file");
119
+ const wasmBytes = readUint8Array(options.wasm, "wasm file");
120
+ const comparison = compareDumps(beforeDumpBuffer, afterDumpBuffer, wasmBytes);
121
+ const sortField = options.sort ?? "delta";
122
+ let constructors = sortConstructorComparisons(comparison.constructors, sortField);
123
+ if (options.top !== undefined) {
124
+ constructors = constructors.slice(0, options.top);
125
+ }
126
+ console.log(JSON.stringify({
127
+ beforeTotalHeapSize: comparison.beforeTotalHeapSize,
128
+ afterTotalHeapSize: comparison.afterTotalHeapSize,
129
+ totalHeapSizeDelta: comparison.totalHeapSizeDelta,
130
+ beforeTotalLiveSize: comparison.beforeTotalLiveSize,
131
+ afterTotalLiveSize: comparison.afterTotalLiveSize,
132
+ totalLiveSizeDelta: comparison.totalLiveSizeDelta,
133
+ constructors,
134
+ }, null, 2));
135
+ }
136
+ export async function main(args = processArgv.slice(2)) {
137
+ const program = new Command();
138
+ program
139
+ .name("as-heap-analyzer")
140
+ .description("Analyze or diff AssemblyScript heap dumps and output heap analysis as JSON.")
141
+ .version(readVersion(), "-v, --version")
142
+ .showHelpAfterError();
143
+ program
144
+ .command("analyze <dump-file>")
145
+ .description("Show the constructor view for a single heap dump")
146
+ .requiredOption("--wasm <file>", "Path to the wasm binary with DWARF custom sections")
147
+ .option("--sort <field>", "Sort constructors by retained|shallow|count", parseSortField)
148
+ .option("--top <n>", "Show top N classes in constructor view", (value) => parsePositiveInteger(value, "--top"))
149
+ .action((dumpFile, options) => {
150
+ analyzeDumpWithCli(dumpFile, options);
151
+ });
152
+ program
153
+ .command("diff <before-dump-file> <after-dump-file>")
154
+ .description("Show the comparison view between two heap dumps")
155
+ .requiredOption("--wasm <file>", "Path to the wasm binary with DWARF custom sections")
156
+ .option("--sort <field>", "Sort comparison rows by delta|alloc|freed|count", parseSortField)
157
+ .option("--top <n>", "Show top N classes in comparison view", (value) => parsePositiveInteger(value, "--top"))
158
+ .action((beforeDumpFile, afterDumpFile, options) => {
159
+ diffDumpsWithCli(beforeDumpFile, afterDumpFile, options);
160
+ });
161
+ await program.parseAsync(args, { from: "user" });
162
+ }
163
+ if (processArgv[1] !== undefined && fileURLToPath(import.meta.url) === processArgv[1]) {
164
+ try {
165
+ await main();
166
+ }
167
+ catch (error) {
168
+ console.error(formatErrorMessage(error));
169
+ processExit(1);
170
+ }
171
+ }
172
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../tools/heap_analyzer/cli.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAGvE,SAAS,WAAW;IAClB,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IACzF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAA0B,CAAC;IAChE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,oBA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C,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,2CAA2C,CAAC;SACpD,WAAW,CAAC,iDAAiD,CAAC;SAC9D,cAAc,CAAC,eAAe,EAAE,oDAAoD,CAAC;SACrF,MAAM,CAAC,gBAAgB,EAAE,iDAAiD,EAAE,cAAc,CAAC;SAC3F,MAAM,CAAC,WAAW,EAAE,uCAAuC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SAC7G,MAAM,CAAC,CAAC,cAAsB,EAAE,aAAqB,EAAE,OAAmC,EAAE,EAAE;QAC7F,gBAAgB,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEL,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,IAAI,CAAC;QACH,MAAM,IAAI,EAAE,CAAC;IACf,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;QACzC,WAAW,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { HeapComparison, HeapSnapshot } from "./types.js";
2
+ export declare function compareSnapshots(before: HeapSnapshot, after: HeapSnapshot): HeapComparison;