@ton/sandbox 0.21.0-debugger.3 → 0.22.0
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/CHANGELOG.md +16 -0
- package/dist/blockchain/Blockchain.d.ts +6 -4
- package/dist/blockchain/Blockchain.js +5 -5
- package/dist/blockchain/SmartContract.d.ts +2 -2
- package/dist/blockchain/SmartContract.js +16 -52
- package/dist/executor/Executor.d.ts +0 -29
- package/dist/executor/Executor.js +1 -160
- package/dist/executor/emulator-emscripten.js +1 -1
- package/dist/executor/emulator-emscripten.wasm.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -3
- package/package.json +7 -13
- package/dist/debugger/DebugInfoCache.d.ts +0 -5
- package/dist/debugger/DebugInfoCache.js +0 -49
- package/dist/debugger/Debuggee.d.ts +0 -108
- package/dist/debugger/Debuggee.js +0 -354
- package/dist/debugger/TVMDebugSession.d.ts +0 -26
- package/dist/debugger/TVMDebugSession.js +0 -267
- package/dist/debugger/debug.d.ts +0 -5
- package/dist/debugger/debug.js +0 -64
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,3 @@ export { Treasury, TreasuryContract, } from './treasury/Treasury';
|
|
|
10
10
|
export { prettyLogTransaction, prettyLogTransactions, } from './utils/prettyLogTransaction';
|
|
11
11
|
export { printTransactionFees, } from './utils/printTransactionFees';
|
|
12
12
|
export { internal, } from './utils/message';
|
|
13
|
-
export { registerCompiledContract, } from './debugger/DebugInfoCache';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.internal = exports.printTransactionFees = exports.prettyLogTransactions = exports.prettyLogTransaction = exports.TreasuryContract = exports.Executor = exports.EmulationError = exports.TimeError = exports.GetMethodError = exports.createShardAccount = exports.createEmptyShardAccount = exports.SmartContract = exports.wrapTonClient4ForRemote = exports.RemoteBlockchainStorage = exports.LocalBlockchainStorage = exports.BlockchainSender = exports.BlockchainContractProvider = exports.toSandboxContract = exports.Blockchain = exports.defaultConfigSeqno = exports.defaultConfig = void 0;
|
|
4
4
|
var defaultConfig_1 = require("./config/defaultConfig");
|
|
5
5
|
Object.defineProperty(exports, "defaultConfig", { enumerable: true, get: function () { return defaultConfig_1.defaultConfig; } });
|
|
6
6
|
Object.defineProperty(exports, "defaultConfigSeqno", { enumerable: true, get: function () { return defaultConfig_1.defaultConfigSeqno; } });
|
|
@@ -33,5 +33,3 @@ var printTransactionFees_1 = require("./utils/printTransactionFees");
|
|
|
33
33
|
Object.defineProperty(exports, "printTransactionFees", { enumerable: true, get: function () { return printTransactionFees_1.printTransactionFees; } });
|
|
34
34
|
var message_1 = require("./utils/message");
|
|
35
35
|
Object.defineProperty(exports, "internal", { enumerable: true, get: function () { return message_1.internal; } });
|
|
36
|
-
var DebugInfoCache_1 = require("./debugger/DebugInfoCache");
|
|
37
|
-
Object.defineProperty(exports, "registerCompiledContract", { enumerable: true, get: function () { return DebugInfoCache_1.registerCompiledContract; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ton/sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "TON transaction emulator",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,33 +13,27 @@
|
|
|
13
13
|
"url": "git+https://github.com/ton-org/sandbox"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@ton/
|
|
17
|
-
"@ton/
|
|
18
|
-
"@ton/crypto": "3.2.0",
|
|
16
|
+
"@ton/core": "^0.58.1",
|
|
17
|
+
"@ton/crypto": "3.3.0",
|
|
19
18
|
"@ton/test-utils": "^0.3.1",
|
|
20
|
-
"@ton/ton": "^
|
|
19
|
+
"@ton/ton": "^15.0.0",
|
|
21
20
|
"@types/jest": "^29.5.0",
|
|
22
21
|
"@types/node": "^18.15.11",
|
|
23
|
-
"@vscode/debugprotocol": "^1.66.0",
|
|
24
22
|
"jest": "^29.5.0",
|
|
25
23
|
"ts-jest": "^29.0.5",
|
|
26
24
|
"ts-node": "^10.9.1",
|
|
27
25
|
"typescript": "^4.9.5"
|
|
28
26
|
},
|
|
29
27
|
"peerDependencies": {
|
|
30
|
-
"@ton/core": ">=0.
|
|
31
|
-
"@ton/crypto": ">=3.
|
|
28
|
+
"@ton/core": ">=0.58.1",
|
|
29
|
+
"@ton/crypto": ">=3.3.0"
|
|
32
30
|
},
|
|
33
31
|
"scripts": {
|
|
34
32
|
"wasm:pack": "ts-node ./scripts/pack-wasm.ts",
|
|
35
33
|
"wasm:copy": "cp src/executor/emulator-emscripten.js src/executor/emulator-emscripten.wasm.js ./dist/executor",
|
|
36
34
|
"test": "yarn wasm:pack && yarn jest src",
|
|
37
35
|
"build": "rm -rf dist && yarn wasm:pack && yarn test && tsc && yarn wasm:copy",
|
|
38
|
-
"build:notest": "rm -rf dist && yarn wasm:pack && tsc && yarn wasm:copy",
|
|
39
36
|
"config:pack": "ts-node ./scripts/pack-config.ts"
|
|
40
37
|
},
|
|
41
|
-
"packageManager": "yarn@3.6.1"
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"@vscode/debugadapter": "^1.66.0"
|
|
44
|
-
}
|
|
38
|
+
"packageManager": "yarn@3.6.1"
|
|
45
39
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
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,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerCompiledContract = exports.defaultDebugInfoCache = void 0;
|
|
4
|
-
const node_path_1 = require("node:path");
|
|
5
|
-
exports.defaultDebugInfoCache = new Map();
|
|
6
|
-
function registerCompiledContract(c) {
|
|
7
|
-
if (c.lang !== 'func') {
|
|
8
|
-
throw new Error('Can only register func contracts');
|
|
9
|
-
}
|
|
10
|
-
if (c.debugInfo === undefined) {
|
|
11
|
-
throw new Error('No debug info');
|
|
12
|
-
}
|
|
13
|
-
const { locations, globals } = c.debugInfo;
|
|
14
|
-
const sm = {};
|
|
15
|
-
for (let i = 0; i < locations.length; i++) {
|
|
16
|
-
const di = locations[i];
|
|
17
|
-
const common = {
|
|
18
|
-
path: (0, node_path_1.resolve)(di.file),
|
|
19
|
-
line: di.line,
|
|
20
|
-
function: di.func,
|
|
21
|
-
};
|
|
22
|
-
if (di.ret) {
|
|
23
|
-
sm[i] = {
|
|
24
|
-
...common,
|
|
25
|
-
type: 'return',
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
else if (di.is_catch) {
|
|
29
|
-
sm[i] = {
|
|
30
|
-
...common,
|
|
31
|
-
type: 'catch',
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
sm[i] = {
|
|
36
|
-
...common,
|
|
37
|
-
type: 'statement',
|
|
38
|
-
variables: di.vars ?? [],
|
|
39
|
-
firstStatement: di.first_stmt,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.defaultDebugInfoCache.set(c.code.hash().toString('base64'), {
|
|
44
|
-
sourceMap: sm,
|
|
45
|
-
globals,
|
|
46
|
-
});
|
|
47
|
-
return c.code;
|
|
48
|
-
}
|
|
49
|
-
exports.registerCompiledContract = registerCompiledContract;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from 'node:events';
|
|
3
|
-
import { Executor, GetMethodArgs, RunTransactionArgs } from '../executor/Executor';
|
|
4
|
-
import { Cell, TupleItem } from '@ton/core';
|
|
5
|
-
export type SourceMapEntry = ({
|
|
6
|
-
path: string;
|
|
7
|
-
line: number;
|
|
8
|
-
function: string;
|
|
9
|
-
}) & ({
|
|
10
|
-
type: 'statement';
|
|
11
|
-
variables: string[];
|
|
12
|
-
firstStatement?: true;
|
|
13
|
-
} | {
|
|
14
|
-
type: 'return';
|
|
15
|
-
} | {
|
|
16
|
-
type: 'catch';
|
|
17
|
-
});
|
|
18
|
-
export type SourceMap = {
|
|
19
|
-
[k: number]: SourceMapEntry;
|
|
20
|
-
};
|
|
21
|
-
export type GlobalEntry = {
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
export type DebugInfo = {
|
|
25
|
-
sourceMap: SourceMap;
|
|
26
|
-
globals: GlobalEntry[];
|
|
27
|
-
};
|
|
28
|
-
type Breakpoint = {
|
|
29
|
-
id: number;
|
|
30
|
-
line: number;
|
|
31
|
-
verified: boolean;
|
|
32
|
-
};
|
|
33
|
-
export type Variable = {
|
|
34
|
-
name: string;
|
|
35
|
-
value: TupleItem;
|
|
36
|
-
};
|
|
37
|
-
type StackFrame = {
|
|
38
|
-
function: string;
|
|
39
|
-
path: string;
|
|
40
|
-
line: number;
|
|
41
|
-
};
|
|
42
|
-
export declare class Debuggee extends EventEmitter {
|
|
43
|
-
executor: Executor;
|
|
44
|
-
ptr: number;
|
|
45
|
-
debugType: 'get' | 'tx';
|
|
46
|
-
sourceMap: SourceMap;
|
|
47
|
-
availableLines: {
|
|
48
|
-
[k: string]: number[];
|
|
49
|
-
};
|
|
50
|
-
codeCells: Map<string, Cell>;
|
|
51
|
-
breakpoints: Map<string, Breakpoint[]>;
|
|
52
|
-
breakpointID: number;
|
|
53
|
-
frames: StackFrame[];
|
|
54
|
-
globals: GlobalEntry[];
|
|
55
|
-
finishedCallback: (v: any) => void;
|
|
56
|
-
constructor(executor: Executor, finishedCallback: (v: any) => void);
|
|
57
|
-
setCodeCells(code: Cell): void;
|
|
58
|
-
setDebugInfo(debugInfo: DebugInfo): void;
|
|
59
|
-
setSourceMap(sourceMap: SourceMap): void;
|
|
60
|
-
setGlobals(globals: GlobalEntry[]): void;
|
|
61
|
-
getAvailableSourcePaths(): string[];
|
|
62
|
-
getAvailableLines(path: string): number[];
|
|
63
|
-
isLineAvailable(path: string, line: number): boolean;
|
|
64
|
-
continue(): void;
|
|
65
|
-
stepIn(): void;
|
|
66
|
-
stepOver(): void;
|
|
67
|
-
stepOut(): void;
|
|
68
|
-
startGetMethod(args: GetMethodArgs): void;
|
|
69
|
-
startTransaction(args: RunTransactionArgs): void;
|
|
70
|
-
getC7(): TupleItem;
|
|
71
|
-
vmStep(): boolean;
|
|
72
|
-
codePos(): {
|
|
73
|
-
hash: string;
|
|
74
|
-
offset: number;
|
|
75
|
-
};
|
|
76
|
-
getStack(): TupleItem[];
|
|
77
|
-
getContParam(): number;
|
|
78
|
-
setContParam(param: number): number;
|
|
79
|
-
getLocalVariables(): Variable[] | undefined;
|
|
80
|
-
getGlobalVariables(): Variable[] | undefined;
|
|
81
|
-
currentDebugInfoNumber(): number | undefined;
|
|
82
|
-
currentSourceMapEntry(): SourceMapEntry | undefined;
|
|
83
|
-
breakpointKey(path: string, line: number): string;
|
|
84
|
-
splitBreakpointKey(k: string): {
|
|
85
|
-
path: string;
|
|
86
|
-
line: number;
|
|
87
|
-
};
|
|
88
|
-
clearBreakpoints(path: string): void;
|
|
89
|
-
hasBreakpoint(path: string, line: number): boolean;
|
|
90
|
-
setBreakpoint(path: string, line: number): Breakpoint;
|
|
91
|
-
sendEvent(event: string, ...args: any[]): void;
|
|
92
|
-
onFinished(): void;
|
|
93
|
-
stackFrames(): StackFrame[];
|
|
94
|
-
stepUntil(what: {
|
|
95
|
-
type: 'breakpoint';
|
|
96
|
-
} | {
|
|
97
|
-
type: 'any-line';
|
|
98
|
-
stopEvent: 'stopOnBreakpoint' | 'stopOnStep';
|
|
99
|
-
} | {
|
|
100
|
-
type: 'next-line';
|
|
101
|
-
} | {
|
|
102
|
-
type: 'out';
|
|
103
|
-
}): void;
|
|
104
|
-
prepareGetMethod(args: GetMethodArgs, debugInfo: DebugInfo): void;
|
|
105
|
-
prepareTransaction(args: RunTransactionArgs, code: Cell, debugInfo: DebugInfo): void;
|
|
106
|
-
start(debug: boolean, stopOnEntry: boolean): void;
|
|
107
|
-
}
|
|
108
|
-
export {};
|
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Debuggee = void 0;
|
|
7
|
-
const node_events_1 = __importDefault(require("node:events"));
|
|
8
|
-
class Debuggee extends node_events_1.default {
|
|
9
|
-
constructor(executor, finishedCallback) {
|
|
10
|
-
super();
|
|
11
|
-
this.ptr = 0;
|
|
12
|
-
this.debugType = 'get';
|
|
13
|
-
this.sourceMap = {};
|
|
14
|
-
this.availableLines = {};
|
|
15
|
-
this.codeCells = new Map();
|
|
16
|
-
this.breakpoints = new Map();
|
|
17
|
-
this.breakpointID = 0;
|
|
18
|
-
this.frames = [];
|
|
19
|
-
this.globals = [];
|
|
20
|
-
this.executor = executor;
|
|
21
|
-
this.executor.debugLogFunc = (s) => { this.sendEvent('output', s); };
|
|
22
|
-
this.finishedCallback = finishedCallback;
|
|
23
|
-
}
|
|
24
|
-
setCodeCells(code) {
|
|
25
|
-
const q = [code];
|
|
26
|
-
while (q.length > 0) {
|
|
27
|
-
const c = q.pop();
|
|
28
|
-
const h = c.hash().toString('hex').toUpperCase();
|
|
29
|
-
this.codeCells.set(h, c);
|
|
30
|
-
for (const r of c.refs) {
|
|
31
|
-
q.push(r);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
setDebugInfo(debugInfo) {
|
|
36
|
-
this.setSourceMap(debugInfo.sourceMap);
|
|
37
|
-
this.setGlobals(debugInfo.globals);
|
|
38
|
-
}
|
|
39
|
-
setSourceMap(sourceMap) {
|
|
40
|
-
this.sourceMap = sourceMap;
|
|
41
|
-
for (const di in sourceMap) {
|
|
42
|
-
const sem = sourceMap[di];
|
|
43
|
-
if (!(sem.path in this.availableLines)) {
|
|
44
|
-
this.availableLines[sem.path] = [];
|
|
45
|
-
}
|
|
46
|
-
this.availableLines[sem.path].push(sem.line);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
setGlobals(globals) {
|
|
50
|
-
this.globals = globals;
|
|
51
|
-
}
|
|
52
|
-
getAvailableSourcePaths() {
|
|
53
|
-
return Object.keys(this.availableLines);
|
|
54
|
-
}
|
|
55
|
-
getAvailableLines(path) {
|
|
56
|
-
return this.availableLines[path] ?? [];
|
|
57
|
-
}
|
|
58
|
-
isLineAvailable(path, line) {
|
|
59
|
-
if (!(path in this.availableLines)) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
const lines = this.availableLines[path];
|
|
63
|
-
return lines.indexOf(line) >= 0;
|
|
64
|
-
}
|
|
65
|
-
continue() {
|
|
66
|
-
this.stepUntil({ type: 'breakpoint' });
|
|
67
|
-
}
|
|
68
|
-
stepIn() {
|
|
69
|
-
this.stepUntil({ type: 'any-line', stopEvent: 'stopOnStep' });
|
|
70
|
-
}
|
|
71
|
-
stepOver() {
|
|
72
|
-
this.stepUntil({ type: 'next-line' });
|
|
73
|
-
}
|
|
74
|
-
stepOut() {
|
|
75
|
-
this.stepUntil({ type: 'out' });
|
|
76
|
-
}
|
|
77
|
-
startGetMethod(args) {
|
|
78
|
-
this.ptr = this.executor.sbsGetMethodSetup(args);
|
|
79
|
-
this.debugType = 'get';
|
|
80
|
-
}
|
|
81
|
-
startTransaction(args) {
|
|
82
|
-
const { emptr, res } = this.executor.sbsTransactionSetup(args);
|
|
83
|
-
if (res !== 1) {
|
|
84
|
-
throw new Error('Could not setup SBS transaction, result: ' + res);
|
|
85
|
-
}
|
|
86
|
-
this.ptr = emptr;
|
|
87
|
-
this.debugType = 'tx';
|
|
88
|
-
}
|
|
89
|
-
getC7() {
|
|
90
|
-
switch (this.debugType) {
|
|
91
|
-
case 'get':
|
|
92
|
-
return this.executor.sbsGetMethodC7(this.ptr);
|
|
93
|
-
case 'tx':
|
|
94
|
-
return this.executor.sbsTransactionC7(this.ptr);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
vmStep() {
|
|
98
|
-
switch (this.debugType) {
|
|
99
|
-
case 'get':
|
|
100
|
-
return this.executor.sbsGetMethodStep(this.ptr);
|
|
101
|
-
case 'tx':
|
|
102
|
-
return this.executor.sbsTransactionStep(this.ptr);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
codePos() {
|
|
106
|
-
switch (this.debugType) {
|
|
107
|
-
case 'get':
|
|
108
|
-
return this.executor.sbsGetMethodCodePos(this.ptr);
|
|
109
|
-
case 'tx':
|
|
110
|
-
return this.executor.sbsTransactionCodePos(this.ptr);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
getStack() {
|
|
114
|
-
switch (this.debugType) {
|
|
115
|
-
case 'get':
|
|
116
|
-
return this.executor.sbsGetMethodStack(this.ptr);
|
|
117
|
-
case 'tx':
|
|
118
|
-
return this.executor.sbsTransactionStack(this.ptr);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
getContParam() {
|
|
122
|
-
switch (this.debugType) {
|
|
123
|
-
case 'get':
|
|
124
|
-
return this.executor.sbsGetMethodGetContParam(this.ptr);
|
|
125
|
-
case 'tx':
|
|
126
|
-
return this.executor.sbsTransactionGetContParam(this.ptr);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
setContParam(param) {
|
|
130
|
-
switch (this.debugType) {
|
|
131
|
-
case 'get':
|
|
132
|
-
return this.executor.sbsGetMethodSetContParam(this.ptr, param);
|
|
133
|
-
case 'tx':
|
|
134
|
-
return this.executor.sbsTransactionSetContParam(this.ptr, param);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
getLocalVariables() {
|
|
138
|
-
const sme = this.currentSourceMapEntry();
|
|
139
|
-
if (sme === undefined || sme.type !== 'statement') {
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
const vars = [];
|
|
143
|
-
const stack = this.getStack();
|
|
144
|
-
for (let i = 0; i < sme.variables.length; i++) {
|
|
145
|
-
vars.push({
|
|
146
|
-
name: sme.variables[i],
|
|
147
|
-
value: stack[i],
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return vars;
|
|
151
|
-
}
|
|
152
|
-
getGlobalVariables() {
|
|
153
|
-
const vars = [];
|
|
154
|
-
const c7item = this.getC7();
|
|
155
|
-
if (c7item.type !== 'tuple') {
|
|
156
|
-
return undefined;
|
|
157
|
-
}
|
|
158
|
-
const c7 = c7item.items;
|
|
159
|
-
for (let i = 0; i < this.globals.length; i++) {
|
|
160
|
-
if (i + 1 < c7.length) {
|
|
161
|
-
vars.push({
|
|
162
|
-
name: this.globals[i].name,
|
|
163
|
-
value: c7[i + 1],
|
|
164
|
-
});
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
vars.push({
|
|
168
|
-
name: this.globals[i].name,
|
|
169
|
-
value: { type: 'null' },
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
return vars;
|
|
173
|
-
}
|
|
174
|
-
currentDebugInfoNumber() {
|
|
175
|
-
const codepos = this.codePos();
|
|
176
|
-
const cell = this.codeCells.get(codepos.hash);
|
|
177
|
-
if (cell !== undefined) {
|
|
178
|
-
try {
|
|
179
|
-
const s = cell.beginParse();
|
|
180
|
-
s.skip(codepos.offset);
|
|
181
|
-
const opp = s.loadUint(12);
|
|
182
|
-
if (opp !== 0xfef) {
|
|
183
|
-
return undefined;
|
|
184
|
-
}
|
|
185
|
-
const n = s.loadUint(4);
|
|
186
|
-
const b = s.loadBuffer(n + 1);
|
|
187
|
-
const bstr = b.toString('utf-8');
|
|
188
|
-
if (!bstr.startsWith('DI')) {
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
return parseInt(bstr.slice(2));
|
|
192
|
-
}
|
|
193
|
-
catch (e) { }
|
|
194
|
-
}
|
|
195
|
-
return undefined;
|
|
196
|
-
}
|
|
197
|
-
currentSourceMapEntry() {
|
|
198
|
-
const di = this.currentDebugInfoNumber();
|
|
199
|
-
if (di === undefined) {
|
|
200
|
-
return undefined;
|
|
201
|
-
}
|
|
202
|
-
return this.sourceMap[di];
|
|
203
|
-
}
|
|
204
|
-
breakpointKey(path, line) {
|
|
205
|
-
return path + ':' + line;
|
|
206
|
-
}
|
|
207
|
-
splitBreakpointKey(k) {
|
|
208
|
-
const i = k.lastIndexOf(':');
|
|
209
|
-
return {
|
|
210
|
-
path: k.slice(0, i),
|
|
211
|
-
line: parseInt(k.slice(i + 1)),
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
clearBreakpoints(path) {
|
|
215
|
-
this.breakpoints.set(path, []);
|
|
216
|
-
}
|
|
217
|
-
hasBreakpoint(path, line) {
|
|
218
|
-
return (this.breakpoints.get(path) ?? []).findIndex(v => v.line === line) >= 0;
|
|
219
|
-
}
|
|
220
|
-
setBreakpoint(path, line) {
|
|
221
|
-
let arr = this.breakpoints.get(path);
|
|
222
|
-
if (arr === undefined) {
|
|
223
|
-
arr = [];
|
|
224
|
-
this.breakpoints.set(path, arr);
|
|
225
|
-
}
|
|
226
|
-
const bp = {
|
|
227
|
-
id: this.breakpointID++,
|
|
228
|
-
line,
|
|
229
|
-
verified: this.isLineAvailable(path, line),
|
|
230
|
-
};
|
|
231
|
-
arr.push(bp);
|
|
232
|
-
return bp;
|
|
233
|
-
}
|
|
234
|
-
sendEvent(event, ...args) {
|
|
235
|
-
setTimeout(() => {
|
|
236
|
-
this.emit(event, ...args);
|
|
237
|
-
}, 0);
|
|
238
|
-
}
|
|
239
|
-
onFinished() {
|
|
240
|
-
this.sendEvent('end');
|
|
241
|
-
let r;
|
|
242
|
-
switch (this.debugType) {
|
|
243
|
-
case 'get': {
|
|
244
|
-
r = this.executor.sbsGetMethodResult(this.ptr);
|
|
245
|
-
this.executor.destroyTvmEmulator(this.ptr);
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
case 'tx': {
|
|
249
|
-
r = this.executor.sbsTransactionResult(this.ptr);
|
|
250
|
-
this.executor.destroyEmulator(this.ptr);
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
this.finishedCallback(r);
|
|
255
|
-
}
|
|
256
|
-
stackFrames() {
|
|
257
|
-
return this.frames;
|
|
258
|
-
}
|
|
259
|
-
stepUntil(what) {
|
|
260
|
-
let until;
|
|
261
|
-
switch (what.type) {
|
|
262
|
-
case 'next-line':
|
|
263
|
-
case 'out': {
|
|
264
|
-
until = { type: what.type, depth: this.frames.length };
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
default:
|
|
268
|
-
until = what;
|
|
269
|
-
}
|
|
270
|
-
while (true) {
|
|
271
|
-
const finished = this.vmStep();
|
|
272
|
-
if (finished) {
|
|
273
|
-
this.onFinished();
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
const sme = this.currentSourceMapEntry();
|
|
277
|
-
if (sme !== undefined) {
|
|
278
|
-
switch (sme.type) {
|
|
279
|
-
case 'statement': {
|
|
280
|
-
if (sme.firstStatement) {
|
|
281
|
-
this.frames.push({
|
|
282
|
-
function: sme.function,
|
|
283
|
-
path: sme.path,
|
|
284
|
-
line: sme.line,
|
|
285
|
-
});
|
|
286
|
-
this.setContParam(this.frames.length);
|
|
287
|
-
}
|
|
288
|
-
this.frames[this.frames.length - 1].line = sme.line;
|
|
289
|
-
switch (until.type) {
|
|
290
|
-
case 'breakpoint': {
|
|
291
|
-
if (this.hasBreakpoint(sme.path, sme.line)) {
|
|
292
|
-
this.sendEvent('stopOnBreakpoint');
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
case 'any-line': {
|
|
298
|
-
this.sendEvent(until.stopEvent);
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
case 'next-line': {
|
|
302
|
-
if (this.frames.length <= until.depth) {
|
|
303
|
-
this.sendEvent('stopOnStep');
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
case 'out': {
|
|
309
|
-
if (this.frames.length < until.depth) {
|
|
310
|
-
this.sendEvent('stopOnStep');
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
break;
|
|
317
|
-
}
|
|
318
|
-
case 'return': {
|
|
319
|
-
this.frames.pop();
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
case 'catch': {
|
|
323
|
-
this.frames = this.frames.slice(0, this.getContParam());
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
prepareGetMethod(args, debugInfo) {
|
|
331
|
-
this.startGetMethod(args);
|
|
332
|
-
this.setCodeCells(args.code);
|
|
333
|
-
this.setDebugInfo(debugInfo);
|
|
334
|
-
}
|
|
335
|
-
prepareTransaction(args, code, debugInfo) {
|
|
336
|
-
this.startTransaction(args);
|
|
337
|
-
this.setCodeCells(code);
|
|
338
|
-
this.setDebugInfo(debugInfo);
|
|
339
|
-
}
|
|
340
|
-
start(debug, stopOnEntry) {
|
|
341
|
-
if (debug) {
|
|
342
|
-
if (stopOnEntry) {
|
|
343
|
-
this.stepUntil({ type: 'any-line', stopEvent: 'stopOnBreakpoint' });
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
this.continue();
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
this.continue();
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
exports.Debuggee = Debuggee;
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|