@ton/sandbox 0.21.0-debugger.1 → 0.21.0-debugger.2
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/dist/blockchain/SmartContract.js +5 -5
- package/dist/debugger/DebugInfoCache.d.ts +5 -0
- package/dist/debugger/{SourceMapCache.js → DebugInfoCache.js} +9 -5
- package/dist/debugger/Debuggee.d.ts +19 -26
- package/dist/debugger/Debuggee.js +58 -248
- package/dist/debugger/TVMDebugSession.d.ts +26 -0
- package/dist/debugger/TVMDebugSession.js +256 -0
- package/dist/debugger/debug.d.ts +3 -3
- package/dist/debugger/debug.js +7 -6
- package/dist/executor/Executor.d.ts +2 -0
- package/dist/executor/Executor.js +12 -0
- package/dist/executor/emulator-emscripten.js +1 -1
- package/dist/executor/emulator-emscripten.wasm.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/dist/debugger/SourceMapCache.d.ts +0 -5
|
@@ -16,7 +16,7 @@ exports.SmartContract = exports.EmulationError = exports.TimeError = exports.Get
|
|
|
16
16
|
const core_1 = require("@ton/core");
|
|
17
17
|
const selector_1 = require("../utils/selector");
|
|
18
18
|
const debug_1 = require("../debugger/debug");
|
|
19
|
-
const
|
|
19
|
+
const DebugInfoCache_1 = require("../debugger/DebugInfoCache");
|
|
20
20
|
function createShardAccount(args) {
|
|
21
21
|
let wc = args.workchain ?? 0;
|
|
22
22
|
let address = args.address ?? (0, core_1.contractAddress)(wc, { code: args.code, data: args.data });
|
|
@@ -232,7 +232,7 @@ class SmartContract {
|
|
|
232
232
|
console.log('Debugging uninitialized accounts is unsupported in debugger beta');
|
|
233
233
|
return await this.runCommon(() => this.blockchain.executor.runTransaction(args));
|
|
234
234
|
}
|
|
235
|
-
const sm =
|
|
235
|
+
const sm = DebugInfoCache_1.defaultDebugInfoCache.get(code.hash().toString('base64'));
|
|
236
236
|
if (sm === undefined) {
|
|
237
237
|
return await this.runCommon(() => this.blockchain.executor.runTransaction(args));
|
|
238
238
|
}
|
|
@@ -294,12 +294,12 @@ class SmartContract {
|
|
|
294
294
|
};
|
|
295
295
|
let res;
|
|
296
296
|
if (this.debug) {
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
297
|
+
const di = DebugInfoCache_1.defaultDebugInfoCache.get(args.code.hash().toString('base64'));
|
|
298
|
+
if (di === undefined) {
|
|
299
299
|
res = await this.blockchain.executor.runGetMethod(args);
|
|
300
300
|
}
|
|
301
301
|
else {
|
|
302
|
-
res = await (0, debug_1.debugGetMethod)(this.blockchain.executor, args,
|
|
302
|
+
res = await (0, debug_1.debugGetMethod)(this.blockchain.executor, args, di);
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
else {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DebugInfo } from "./Debuggee";
|
|
2
|
+
import { CompileResult } from '@ton/blueprint';
|
|
3
|
+
export type DebugInfoCache = Map<string, DebugInfo>;
|
|
4
|
+
export declare const defaultDebugInfoCache: DebugInfoCache;
|
|
5
|
+
export declare function registerCompiledContract(c: CompileResult): import("@ton/core").Cell;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerCompiledContract = exports.
|
|
3
|
+
exports.registerCompiledContract = exports.defaultDebugInfoCache = void 0;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
|
-
exports.
|
|
5
|
+
exports.defaultDebugInfoCache = new Map();
|
|
6
6
|
function registerCompiledContract(c) {
|
|
7
7
|
if (c.lang !== 'func') {
|
|
8
8
|
throw new Error('Can only register func contracts');
|
|
@@ -10,9 +10,10 @@ function registerCompiledContract(c) {
|
|
|
10
10
|
if (c.debugInfo === undefined) {
|
|
11
11
|
throw new Error('No debug info');
|
|
12
12
|
}
|
|
13
|
+
const { locations, globals } = c.debugInfo;
|
|
13
14
|
const sm = {};
|
|
14
|
-
for (let i = 0; i <
|
|
15
|
-
const di =
|
|
15
|
+
for (let i = 0; i < locations.length; i++) {
|
|
16
|
+
const di = locations[i];
|
|
16
17
|
if (di.ret || di.vars === undefined)
|
|
17
18
|
continue;
|
|
18
19
|
sm[i] = {
|
|
@@ -21,7 +22,10 @@ function registerCompiledContract(c) {
|
|
|
21
22
|
variables: di.vars ?? [],
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
|
-
exports.
|
|
25
|
+
exports.defaultDebugInfoCache.set(c.code.hash().toString('base64'), {
|
|
26
|
+
sourceMap: sm,
|
|
27
|
+
globals,
|
|
28
|
+
});
|
|
25
29
|
return c.code;
|
|
26
30
|
}
|
|
27
31
|
exports.registerCompiledContract = registerCompiledContract;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import EventEmitter from 'node:events';
|
|
3
3
|
import { Executor, GetMethodArgs, RunTransactionArgs } from '../executor/Executor';
|
|
4
4
|
import { Cell, TupleItem } from '@ton/core';
|
|
5
|
-
import { LoggingDebugSession } from '@vscode/debugadapter';
|
|
6
|
-
import { DebugProtocol } from '@vscode/debugprotocol';
|
|
7
5
|
export type SourceMapEntry = {
|
|
8
6
|
path: string;
|
|
9
7
|
line: number;
|
|
@@ -12,11 +10,22 @@ export type SourceMapEntry = {
|
|
|
12
10
|
export type SourceMap = {
|
|
13
11
|
[k: number]: SourceMapEntry;
|
|
14
12
|
};
|
|
13
|
+
export type GlobalEntry = {
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
export type DebugInfo = {
|
|
17
|
+
sourceMap: SourceMap;
|
|
18
|
+
globals: GlobalEntry[];
|
|
19
|
+
};
|
|
15
20
|
type Breakpoint = {
|
|
16
21
|
id: number;
|
|
17
22
|
line: number;
|
|
18
23
|
verified: boolean;
|
|
19
24
|
};
|
|
25
|
+
export type Variable = {
|
|
26
|
+
name: string;
|
|
27
|
+
value: TupleItem;
|
|
28
|
+
};
|
|
20
29
|
export declare class Debuggee extends EventEmitter {
|
|
21
30
|
executor: Executor;
|
|
22
31
|
ptr: number;
|
|
@@ -29,10 +38,13 @@ export declare class Debuggee extends EventEmitter {
|
|
|
29
38
|
breakpoints: Map<string, Breakpoint[]>;
|
|
30
39
|
breakpointID: number;
|
|
31
40
|
frames: string[];
|
|
41
|
+
globals: GlobalEntry[];
|
|
32
42
|
finishedCallback: (v: any) => void;
|
|
33
43
|
constructor(executor: Executor, finishedCallback: (v: any) => void);
|
|
34
44
|
setCodeCells(code: Cell): void;
|
|
45
|
+
setDebugInfo(debugInfo: DebugInfo): void;
|
|
35
46
|
setSourceMap(sourceMap: SourceMap): void;
|
|
47
|
+
setGlobals(globals: GlobalEntry[]): void;
|
|
36
48
|
getAvailableSourcePaths(): string[];
|
|
37
49
|
getAvailableLines(path: string): number[];
|
|
38
50
|
isLineAvailable(path: string, line: number): boolean;
|
|
@@ -40,12 +52,15 @@ export declare class Debuggee extends EventEmitter {
|
|
|
40
52
|
step(stopEvent?: string): void;
|
|
41
53
|
startGetMethod(args: GetMethodArgs): void;
|
|
42
54
|
startTransaction(args: RunTransactionArgs): void;
|
|
55
|
+
getC7(): TupleItem;
|
|
43
56
|
vmStep(): boolean;
|
|
44
57
|
codePos(): {
|
|
45
58
|
hash: string;
|
|
46
59
|
offset: number;
|
|
47
60
|
};
|
|
48
61
|
getStack(): TupleItem[];
|
|
62
|
+
getLocalVariables(): Variable[] | undefined;
|
|
63
|
+
getGlobalVariables(): Variable[] | undefined;
|
|
49
64
|
currentDebugInfoNumber(): number | undefined;
|
|
50
65
|
currentSourceMapEntry(): SourceMapEntry | undefined;
|
|
51
66
|
breakpointKey(path: string, line: number): string;
|
|
@@ -59,30 +74,8 @@ export declare class Debuggee extends EventEmitter {
|
|
|
59
74
|
sendEvent(event: string, ...args: any[]): void;
|
|
60
75
|
onFinished(): void;
|
|
61
76
|
stepUntilLine(breakpointsOnly: boolean, stopEvent?: string): void;
|
|
62
|
-
prepareGetMethod(args: GetMethodArgs,
|
|
63
|
-
prepareTransaction(args: RunTransactionArgs, code: Cell,
|
|
77
|
+
prepareGetMethod(args: GetMethodArgs, debugInfo: DebugInfo): void;
|
|
78
|
+
prepareTransaction(args: RunTransactionArgs, code: Cell, debugInfo: DebugInfo): void;
|
|
64
79
|
start(debug: boolean, stopOnEntry: boolean): void;
|
|
65
80
|
}
|
|
66
|
-
export declare class TVMDebugSession extends LoggingDebugSession {
|
|
67
|
-
static readonly threadID = 1;
|
|
68
|
-
static readonly stackFrameID = 1;
|
|
69
|
-
static readonly variablesReference = 1;
|
|
70
|
-
debuggee: Debuggee;
|
|
71
|
-
constructor(debuggee: Debuggee);
|
|
72
|
-
protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void;
|
|
73
|
-
protected loadedSourcesRequest(response: DebugProtocol.LoadedSourcesResponse, args: DebugProtocol.LoadedSourcesArguments, request?: DebugProtocol.Request | undefined): void;
|
|
74
|
-
protected breakpointLocationsRequest(response: DebugProtocol.BreakpointLocationsResponse, args: DebugProtocol.BreakpointLocationsArguments, request?: DebugProtocol.Request | undefined): void;
|
|
75
|
-
protected launchRequest(response: DebugProtocol.LaunchResponse, args: DebugProtocol.LaunchRequestArguments, request?: DebugProtocol.Request | undefined): void;
|
|
76
|
-
protected attachRequest(response: DebugProtocol.AttachResponse, args: DebugProtocol.AttachRequestArguments, request?: DebugProtocol.Request | undefined): void;
|
|
77
|
-
protected setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments, request?: DebugProtocol.Request | undefined): void;
|
|
78
|
-
protected threadsRequest(response: DebugProtocol.ThreadsResponse, request?: DebugProtocol.Request | undefined): void;
|
|
79
|
-
protected continueRequest(response: DebugProtocol.ContinueResponse, args: DebugProtocol.ContinueArguments, request?: DebugProtocol.Request | undefined): void;
|
|
80
|
-
protected nextRequest(response: DebugProtocol.NextResponse, args: DebugProtocol.NextArguments, request?: DebugProtocol.Request | undefined): void;
|
|
81
|
-
protected stepInRequest(response: DebugProtocol.StepInResponse, args: DebugProtocol.StepInArguments, request?: DebugProtocol.Request | undefined): void;
|
|
82
|
-
protected stepOutRequest(response: DebugProtocol.StepOutResponse, args: DebugProtocol.StepOutArguments, request?: DebugProtocol.Request | undefined): void;
|
|
83
|
-
protected stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments, request?: DebugProtocol.Request | undefined): void;
|
|
84
|
-
protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments, request?: DebugProtocol.Request | undefined): void;
|
|
85
|
-
protected variablesRequest(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments, request?: DebugProtocol.Request | undefined): void;
|
|
86
|
-
protected disconnectRequest(response: DebugProtocol.DisconnectResponse, args: DebugProtocol.DisconnectArguments, request?: DebugProtocol.Request | undefined): void;
|
|
87
|
-
}
|
|
88
81
|
export {};
|
|
@@ -3,10 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Debuggee = void 0;
|
|
7
7
|
const node_events_1 = __importDefault(require("node:events"));
|
|
8
|
-
const debugadapter_1 = require("@vscode/debugadapter");
|
|
9
|
-
const node_path_1 = require("node:path");
|
|
10
8
|
class Debuggee extends node_events_1.default {
|
|
11
9
|
constructor(executor, finishedCallback) {
|
|
12
10
|
super();
|
|
@@ -18,6 +16,7 @@ class Debuggee extends node_events_1.default {
|
|
|
18
16
|
this.breakpoints = new Map();
|
|
19
17
|
this.breakpointID = 0;
|
|
20
18
|
this.frames = [];
|
|
19
|
+
this.globals = [];
|
|
21
20
|
this.executor = executor;
|
|
22
21
|
this.executor.debugLogFunc = (s) => { this.sendEvent('output', s); };
|
|
23
22
|
this.finishedCallback = finishedCallback;
|
|
@@ -33,6 +32,10 @@ class Debuggee extends node_events_1.default {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
}
|
|
35
|
+
setDebugInfo(debugInfo) {
|
|
36
|
+
this.setSourceMap(debugInfo.sourceMap);
|
|
37
|
+
this.setGlobals(debugInfo.globals);
|
|
38
|
+
}
|
|
36
39
|
setSourceMap(sourceMap) {
|
|
37
40
|
this.sourceMap = sourceMap;
|
|
38
41
|
for (const di in sourceMap) {
|
|
@@ -43,6 +46,9 @@ class Debuggee extends node_events_1.default {
|
|
|
43
46
|
this.availableLines[sem.path].push(sem.line);
|
|
44
47
|
}
|
|
45
48
|
}
|
|
49
|
+
setGlobals(globals) {
|
|
50
|
+
this.globals = globals;
|
|
51
|
+
}
|
|
46
52
|
getAvailableSourcePaths() {
|
|
47
53
|
return Object.keys(this.availableLines);
|
|
48
54
|
}
|
|
@@ -74,6 +80,14 @@ class Debuggee extends node_events_1.default {
|
|
|
74
80
|
this.ptr = emptr;
|
|
75
81
|
this.debugType = 'tx';
|
|
76
82
|
}
|
|
83
|
+
getC7() {
|
|
84
|
+
switch (this.debugType) {
|
|
85
|
+
case 'get':
|
|
86
|
+
return this.executor.sbsGetMethodC7(this.ptr);
|
|
87
|
+
case 'tx':
|
|
88
|
+
return this.executor.sbsTransactionC7(this.ptr);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
77
91
|
vmStep() {
|
|
78
92
|
switch (this.debugType) {
|
|
79
93
|
case 'get':
|
|
@@ -98,6 +112,43 @@ class Debuggee extends node_events_1.default {
|
|
|
98
112
|
return this.executor.sbsTransactionStack(this.ptr);
|
|
99
113
|
}
|
|
100
114
|
}
|
|
115
|
+
getLocalVariables() {
|
|
116
|
+
const sme = this.currentSourceMapEntry();
|
|
117
|
+
if (sme === undefined) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
const vars = [];
|
|
121
|
+
const stack = this.getStack();
|
|
122
|
+
for (let i = 0; i < sme.variables.length; i++) {
|
|
123
|
+
vars.push({
|
|
124
|
+
name: sme.variables[i],
|
|
125
|
+
value: stack[i],
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return vars;
|
|
129
|
+
}
|
|
130
|
+
getGlobalVariables() {
|
|
131
|
+
const vars = [];
|
|
132
|
+
const c7item = this.getC7();
|
|
133
|
+
if (c7item.type !== 'tuple') {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
const c7 = c7item.items;
|
|
137
|
+
for (let i = 0; i < this.globals.length; i++) {
|
|
138
|
+
if (i + 1 < c7.length) {
|
|
139
|
+
vars.push({
|
|
140
|
+
name: this.globals[i].name,
|
|
141
|
+
value: c7[i + 1],
|
|
142
|
+
});
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
vars.push({
|
|
146
|
+
name: this.globals[i].name,
|
|
147
|
+
value: { type: 'null' },
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return vars;
|
|
151
|
+
}
|
|
101
152
|
currentDebugInfoNumber() {
|
|
102
153
|
const codepos = this.codePos();
|
|
103
154
|
const cell = this.codeCells.get(codepos.hash);
|
|
@@ -199,15 +250,15 @@ class Debuggee extends node_events_1.default {
|
|
|
199
250
|
}
|
|
200
251
|
}
|
|
201
252
|
}
|
|
202
|
-
prepareGetMethod(args,
|
|
253
|
+
prepareGetMethod(args, debugInfo) {
|
|
203
254
|
this.startGetMethod(args);
|
|
204
255
|
this.setCodeCells(args.code);
|
|
205
|
-
this.
|
|
256
|
+
this.setDebugInfo(debugInfo);
|
|
206
257
|
}
|
|
207
|
-
prepareTransaction(args, code,
|
|
258
|
+
prepareTransaction(args, code, debugInfo) {
|
|
208
259
|
this.startTransaction(args);
|
|
209
260
|
this.setCodeCells(code);
|
|
210
|
-
this.
|
|
261
|
+
this.setDebugInfo(debugInfo);
|
|
211
262
|
}
|
|
212
263
|
start(debug, stopOnEntry) {
|
|
213
264
|
if (debug) {
|
|
@@ -224,244 +275,3 @@ class Debuggee extends node_events_1.default {
|
|
|
224
275
|
}
|
|
225
276
|
}
|
|
226
277
|
exports.Debuggee = Debuggee;
|
|
227
|
-
class TVMDebugSession extends debugadapter_1.LoggingDebugSession {
|
|
228
|
-
constructor(debuggee) {
|
|
229
|
-
super();
|
|
230
|
-
this.debuggee = debuggee;
|
|
231
|
-
this.debuggee.on('stopOnEntry', () => {
|
|
232
|
-
this.sendEvent(new debugadapter_1.StoppedEvent('entry', TVMDebugSession.threadID));
|
|
233
|
-
});
|
|
234
|
-
this.debuggee.on('stopOnBreakpoint', () => {
|
|
235
|
-
this.sendEvent(new debugadapter_1.StoppedEvent('breakpoint', TVMDebugSession.threadID));
|
|
236
|
-
});
|
|
237
|
-
this.debuggee.on('stopOnStep', () => {
|
|
238
|
-
this.sendEvent(new debugadapter_1.StoppedEvent('step', TVMDebugSession.threadID));
|
|
239
|
-
});
|
|
240
|
-
this.debuggee.on('end', () => {
|
|
241
|
-
this.sendEvent(new debugadapter_1.TerminatedEvent());
|
|
242
|
-
});
|
|
243
|
-
this.debuggee.on('output', (s) => {
|
|
244
|
-
this.sendEvent(new debugadapter_1.OutputEvent(s + '\n', 'stdout'));
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
initializeRequest(response, args) {
|
|
248
|
-
response.body = response.body || {};
|
|
249
|
-
const b = response.body;
|
|
250
|
-
b.supportsConfigurationDoneRequest = false;
|
|
251
|
-
b.supportsFunctionBreakpoints = false;
|
|
252
|
-
b.supportsConditionalBreakpoints = false;
|
|
253
|
-
b.supportsHitConditionalBreakpoints = false;
|
|
254
|
-
b.supportsEvaluateForHovers = false;
|
|
255
|
-
b.supportsStepBack = false;
|
|
256
|
-
b.supportsSetVariable = false;
|
|
257
|
-
b.supportsRestartFrame = false;
|
|
258
|
-
b.supportsGotoTargetsRequest = false;
|
|
259
|
-
b.supportsStepInTargetsRequest = false;
|
|
260
|
-
b.supportsCompletionsRequest = false;
|
|
261
|
-
b.supportsModulesRequest = false;
|
|
262
|
-
b.supportsRestartRequest = false;
|
|
263
|
-
b.supportsValueFormattingOptions = false;
|
|
264
|
-
b.supportsExceptionInfoRequest = false;
|
|
265
|
-
b.supportTerminateDebuggee = false;
|
|
266
|
-
b.supportSuspendDebuggee = false;
|
|
267
|
-
b.supportsDelayedStackTraceLoading = false;
|
|
268
|
-
b.supportsLoadedSourcesRequest = true;
|
|
269
|
-
b.supportsLogPoints = false;
|
|
270
|
-
b.supportsTerminateThreadsRequest = false;
|
|
271
|
-
b.supportsSetExpression = false;
|
|
272
|
-
b.supportsTerminateRequest = false;
|
|
273
|
-
b.supportsDataBreakpoints = false;
|
|
274
|
-
b.supportsReadMemoryRequest = false;
|
|
275
|
-
b.supportsWriteMemoryRequest = false;
|
|
276
|
-
b.supportsDisassembleRequest = false;
|
|
277
|
-
b.supportsCancelRequest = false;
|
|
278
|
-
b.supportsBreakpointLocationsRequest = true;
|
|
279
|
-
b.supportsClipboardContext = false;
|
|
280
|
-
b.supportsSteppingGranularity = false;
|
|
281
|
-
b.supportsInstructionBreakpoints = false;
|
|
282
|
-
b.supportsExceptionFilterOptions = false;
|
|
283
|
-
b.supportsSingleThreadExecutionRequests = false;
|
|
284
|
-
this.sendResponse(response);
|
|
285
|
-
this.sendEvent(new debugadapter_1.InitializedEvent());
|
|
286
|
-
}
|
|
287
|
-
loadedSourcesRequest(response, args, request) {
|
|
288
|
-
response.body = response.body || {};
|
|
289
|
-
response.body.sources = this.debuggee.getAvailableSourcePaths().map(v => ({
|
|
290
|
-
path: v,
|
|
291
|
-
name: (0, node_path_1.basename)(v),
|
|
292
|
-
}));
|
|
293
|
-
this.sendResponse(response);
|
|
294
|
-
}
|
|
295
|
-
breakpointLocationsRequest(response, args, request) {
|
|
296
|
-
response.body = response.body || {};
|
|
297
|
-
const path = args.source.path;
|
|
298
|
-
if (path === undefined) {
|
|
299
|
-
this.sendErrorResponse(response, {
|
|
300
|
-
id: 1001,
|
|
301
|
-
format: 'No path',
|
|
302
|
-
});
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
response.body.breakpoints = this.debuggee.getAvailableLines(path).filter(l => l >= args.line && l <= (args.endLine ?? args.line)).map(l => ({
|
|
306
|
-
line: l,
|
|
307
|
-
}));
|
|
308
|
-
this.sendResponse(response);
|
|
309
|
-
}
|
|
310
|
-
launchRequest(response, args, request) {
|
|
311
|
-
debugadapter_1.logger.setup(debugadapter_1.Logger.LogLevel.Log);
|
|
312
|
-
this.debuggee.start(!args.noDebug, true);
|
|
313
|
-
this.sendResponse(response);
|
|
314
|
-
}
|
|
315
|
-
attachRequest(response, args, request) {
|
|
316
|
-
this.launchRequest(response, args, request);
|
|
317
|
-
}
|
|
318
|
-
setBreakPointsRequest(response, args, request) {
|
|
319
|
-
const path = args.source.path;
|
|
320
|
-
if (path === undefined) {
|
|
321
|
-
this.sendErrorResponse(response, {
|
|
322
|
-
id: 1001,
|
|
323
|
-
format: 'No path',
|
|
324
|
-
});
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
const breakpoints = args.breakpoints;
|
|
328
|
-
if (breakpoints === undefined) {
|
|
329
|
-
this.sendErrorResponse(response, {
|
|
330
|
-
id: 1002,
|
|
331
|
-
format: 'No breakpoints',
|
|
332
|
-
});
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
this.debuggee.clearBreakpoints(path);
|
|
336
|
-
const bps = [];
|
|
337
|
-
for (const bp of breakpoints) {
|
|
338
|
-
const sbp = this.debuggee.setBreakpoint(path, bp.line);
|
|
339
|
-
bps.push({
|
|
340
|
-
id: sbp.id,
|
|
341
|
-
line: sbp.line,
|
|
342
|
-
verified: sbp.verified,
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
response.body = {
|
|
346
|
-
breakpoints: bps,
|
|
347
|
-
};
|
|
348
|
-
this.sendResponse(response);
|
|
349
|
-
}
|
|
350
|
-
threadsRequest(response, request) {
|
|
351
|
-
response.body = {
|
|
352
|
-
threads: [
|
|
353
|
-
new debugadapter_1.Thread(TVMDebugSession.threadID, 'main'),
|
|
354
|
-
],
|
|
355
|
-
};
|
|
356
|
-
this.sendResponse(response);
|
|
357
|
-
}
|
|
358
|
-
continueRequest(response, args, request) {
|
|
359
|
-
this.debuggee.continue();
|
|
360
|
-
this.sendResponse(response);
|
|
361
|
-
}
|
|
362
|
-
nextRequest(response, args, request) {
|
|
363
|
-
this.debuggee.step();
|
|
364
|
-
this.sendResponse(response);
|
|
365
|
-
}
|
|
366
|
-
stepInRequest(response, args, request) {
|
|
367
|
-
this.debuggee.step();
|
|
368
|
-
this.sendResponse(response);
|
|
369
|
-
}
|
|
370
|
-
stepOutRequest(response, args, request) {
|
|
371
|
-
this.debuggee.step();
|
|
372
|
-
this.sendResponse(response);
|
|
373
|
-
}
|
|
374
|
-
stackTraceRequest(response, args, request) {
|
|
375
|
-
response.body = response.body || {};
|
|
376
|
-
const sme = this.debuggee.currentSourceMapEntry();
|
|
377
|
-
if (sme === undefined) {
|
|
378
|
-
response.body.stackFrames = [];
|
|
379
|
-
response.body.totalFrames = 0;
|
|
380
|
-
this.sendResponse(response);
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
response.body.totalFrames = 1;
|
|
384
|
-
if (args.startFrame ?? 0 > 0) {
|
|
385
|
-
response.body.stackFrames = [];
|
|
386
|
-
this.sendResponse(response);
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
response.body.stackFrames = [{
|
|
390
|
-
id: TVMDebugSession.stackFrameID,
|
|
391
|
-
name: 'func',
|
|
392
|
-
line: sme.line,
|
|
393
|
-
column: 0,
|
|
394
|
-
source: {
|
|
395
|
-
name: (0, node_path_1.basename)(sme.path),
|
|
396
|
-
path: sme.path,
|
|
397
|
-
},
|
|
398
|
-
}];
|
|
399
|
-
this.sendResponse(response);
|
|
400
|
-
}
|
|
401
|
-
scopesRequest(response, args, request) {
|
|
402
|
-
response.body = response.body || {};
|
|
403
|
-
const sme = this.debuggee.currentSourceMapEntry();
|
|
404
|
-
if (sme === undefined) {
|
|
405
|
-
response.body.scopes = [];
|
|
406
|
-
this.sendResponse(response);
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
response.body.scopes = [{
|
|
410
|
-
name: 'Locals',
|
|
411
|
-
variablesReference: TVMDebugSession.variablesReference,
|
|
412
|
-
expensive: false,
|
|
413
|
-
}];
|
|
414
|
-
this.sendResponse(response);
|
|
415
|
-
}
|
|
416
|
-
variablesRequest(response, args, request) {
|
|
417
|
-
response.body = response.body || {};
|
|
418
|
-
response.body.variables = [];
|
|
419
|
-
const sme = this.debuggee.currentSourceMapEntry();
|
|
420
|
-
if (sme === undefined) {
|
|
421
|
-
this.sendResponse(response);
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
const stack = this.debuggee.getStack();
|
|
425
|
-
for (let i = 0; i < sme.variables.length; i++) {
|
|
426
|
-
response.body.variables.push({
|
|
427
|
-
name: sme.variables[i],
|
|
428
|
-
value: tupleItemToString(stack[i]),
|
|
429
|
-
type: stack[i].type,
|
|
430
|
-
variablesReference: 0,
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
response.body.variables.sort((a, b) => (a.name < b.name) ? -1 : (a.name > b.name ? 1 : 0));
|
|
434
|
-
this.sendResponse(response);
|
|
435
|
-
}
|
|
436
|
-
disconnectRequest(response, args, request) {
|
|
437
|
-
if (args.restart) {
|
|
438
|
-
this.sendErrorResponse(response, {
|
|
439
|
-
id: 1003,
|
|
440
|
-
format: 'Cannot restart',
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
this.sendResponse(response);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
exports.TVMDebugSession = TVMDebugSession;
|
|
449
|
-
TVMDebugSession.threadID = 1;
|
|
450
|
-
TVMDebugSession.stackFrameID = 1;
|
|
451
|
-
TVMDebugSession.variablesReference = 1;
|
|
452
|
-
function tupleItemToString(ti) {
|
|
453
|
-
switch (ti.type) {
|
|
454
|
-
case 'int':
|
|
455
|
-
return ti.value.toString();
|
|
456
|
-
case 'null':
|
|
457
|
-
return 'null';
|
|
458
|
-
case 'nan':
|
|
459
|
-
return 'NaN';
|
|
460
|
-
case 'cell':
|
|
461
|
-
case 'slice':
|
|
462
|
-
case 'builder':
|
|
463
|
-
return ti.cell.toBoc().toString('base64');
|
|
464
|
-
case 'tuple':
|
|
465
|
-
return `[${ti.items.map(v => tupleItemToString(v)).join(', ')}]`;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LoggingDebugSession } from "@vscode/debugadapter";
|
|
2
|
+
import { Debuggee } from "./Debuggee";
|
|
3
|
+
import { DebugProtocol } from "@vscode/debugprotocol";
|
|
4
|
+
export declare class TVMDebugSession extends LoggingDebugSession {
|
|
5
|
+
static readonly threadID = 1;
|
|
6
|
+
static readonly stackFrameID = 1;
|
|
7
|
+
static readonly localVariablesReference = 1;
|
|
8
|
+
static readonly globalVariablesReference = 2;
|
|
9
|
+
debuggee: Debuggee;
|
|
10
|
+
constructor(debuggee: Debuggee);
|
|
11
|
+
protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void;
|
|
12
|
+
protected loadedSourcesRequest(response: DebugProtocol.LoadedSourcesResponse, args: DebugProtocol.LoadedSourcesArguments, request?: DebugProtocol.Request | undefined): void;
|
|
13
|
+
protected breakpointLocationsRequest(response: DebugProtocol.BreakpointLocationsResponse, args: DebugProtocol.BreakpointLocationsArguments, request?: DebugProtocol.Request | undefined): void;
|
|
14
|
+
protected launchRequest(response: DebugProtocol.LaunchResponse, args: DebugProtocol.LaunchRequestArguments, request?: DebugProtocol.Request | undefined): void;
|
|
15
|
+
protected attachRequest(response: DebugProtocol.AttachResponse, args: DebugProtocol.AttachRequestArguments, request?: DebugProtocol.Request | undefined): void;
|
|
16
|
+
protected setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments, request?: DebugProtocol.Request | undefined): void;
|
|
17
|
+
protected threadsRequest(response: DebugProtocol.ThreadsResponse, request?: DebugProtocol.Request | undefined): void;
|
|
18
|
+
protected continueRequest(response: DebugProtocol.ContinueResponse, args: DebugProtocol.ContinueArguments, request?: DebugProtocol.Request | undefined): void;
|
|
19
|
+
protected nextRequest(response: DebugProtocol.NextResponse, args: DebugProtocol.NextArguments, request?: DebugProtocol.Request | undefined): void;
|
|
20
|
+
protected stepInRequest(response: DebugProtocol.StepInResponse, args: DebugProtocol.StepInArguments, request?: DebugProtocol.Request | undefined): void;
|
|
21
|
+
protected stepOutRequest(response: DebugProtocol.StepOutResponse, args: DebugProtocol.StepOutArguments, request?: DebugProtocol.Request | undefined): void;
|
|
22
|
+
protected stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments, request?: DebugProtocol.Request | undefined): void;
|
|
23
|
+
protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments, request?: DebugProtocol.Request | undefined): void;
|
|
24
|
+
protected variablesRequest(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments, request?: DebugProtocol.Request | undefined): void;
|
|
25
|
+
protected disconnectRequest(response: DebugProtocol.DisconnectResponse, args: DebugProtocol.DisconnectArguments, request?: DebugProtocol.Request | undefined): void;
|
|
26
|
+
}
|