@ton/sandbox 0.41.0 → 0.43.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/dist/blockchain/Blockchain.d.ts +1 -6
- package/dist/blockchain/Blockchain.js +0 -15
- package/dist/blockchain/SmartContract.d.ts +0 -3
- package/dist/blockchain/SmartContract.js +1 -39
- package/dist/config/config.tlb-gen.d.ts +69 -18
- package/dist/config/config.tlb-gen.js +273 -53
- package/dist/config/defaultConfig.d.ts +2 -2
- package/dist/config/defaultConfig.js +2 -2
- package/dist/config/slimConfig.d.ts +2 -2
- package/dist/config/slimConfig.js +2 -2
- package/dist/executor/Executor.d.ts +1 -37
- package/dist/executor/Executor.js +3 -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 +4 -6
- package/CHANGELOG.md +0 -531
- package/dist/debugger/DebugContext.d.ts +0 -14
- package/dist/debugger/DebugContext.js +0 -29
- package/dist/debugger/DebugInfoCache.d.ts +0 -9
- package/dist/debugger/DebugInfoCache.js +0 -87
- package/dist/debugger/Debuggee.d.ts +0 -147
- package/dist/debugger/Debuggee.js +0 -451
- package/dist/debugger/TVMDebugSession.d.ts +0 -26
- package/dist/debugger/TVMDebugSession.js +0 -272
- package/dist/debugger/debug.d.ts +0 -4
- package/dist/debugger/debug.js +0 -76
- package/dist/debugger/index.d.ts +0 -1
- package/dist/debugger/index.js +0 -5
- package/dist/debugger/marks.d.ts +0 -2
- package/dist/debugger/marks.js +0 -127
- package/dist/executor/emulator-emscripten.debugger.bpatch.gzip.js +0 -1
- package/dist/executor/emulator-emscripten.debugger.js +0 -20
- package/dist/utils/bpatch.d.ts +0 -9
- package/dist/utils/bpatch.js +0 -52
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDebugInfo = getDebugInfo;
|
|
4
|
-
exports.registerCompiledContract = registerCompiledContract;
|
|
5
|
-
const marks_1 = require("./marks");
|
|
6
|
-
const environment_1 = require("../utils/environment");
|
|
7
|
-
const defaultDebugInfoCache = new Map();
|
|
8
|
-
function getDebugInfo(acc) {
|
|
9
|
-
if (acc.account === undefined || acc.account === null) {
|
|
10
|
-
return { uninitialized: true, debugInfo: undefined };
|
|
11
|
-
}
|
|
12
|
-
if (acc.account.storage.state.type !== 'active') {
|
|
13
|
-
return { uninitialized: true, debugInfo: undefined };
|
|
14
|
-
}
|
|
15
|
-
const code = acc.account.storage.state.state.code;
|
|
16
|
-
if (code === undefined || code === null) {
|
|
17
|
-
return { uninitialized: true, debugInfo: undefined };
|
|
18
|
-
}
|
|
19
|
-
const debugInfo = defaultDebugInfoCache.get(code.hash().toString('base64'));
|
|
20
|
-
return { uninitialized: false, debugInfo };
|
|
21
|
-
}
|
|
22
|
-
function registerCompiledContract(code, debugInfo, marks) {
|
|
23
|
-
if ((0, environment_1.isBrowser)()) {
|
|
24
|
-
throw new Error('Debug feature is not supported in browser environment');
|
|
25
|
-
}
|
|
26
|
-
const parsedMarks = (0, marks_1.parseMarks)(marks, code);
|
|
27
|
-
const { locations, globals } = debugInfo;
|
|
28
|
-
const sm = {};
|
|
29
|
-
for (let i = 0; i < locations.length; i++) {
|
|
30
|
-
const di = locations[i];
|
|
31
|
-
const common = {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
33
|
-
path: require('node:path').resolve(di.file),
|
|
34
|
-
line: di.line,
|
|
35
|
-
function: di.func,
|
|
36
|
-
contextId: di.ctx_id,
|
|
37
|
-
requireContextId: di.req_ctx_id,
|
|
38
|
-
};
|
|
39
|
-
if (di.ret) {
|
|
40
|
-
sm[i] = {
|
|
41
|
-
...common,
|
|
42
|
-
type: 'return',
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
else if (di.try_catch_ctx_id !== undefined) {
|
|
46
|
-
sm[i] = {
|
|
47
|
-
...common,
|
|
48
|
-
type: 'try_begin',
|
|
49
|
-
catchContextId: di.try_catch_ctx_id,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
else if (di.is_try_end) {
|
|
53
|
-
sm[i] = {
|
|
54
|
-
...common,
|
|
55
|
-
type: 'try_end',
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
else if (di.vars !== undefined) {
|
|
59
|
-
sm[i] = {
|
|
60
|
-
...common,
|
|
61
|
-
type: 'statement',
|
|
62
|
-
variables: di.vars ?? [],
|
|
63
|
-
firstStatement: di.first_stmt,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
else if (di.branch_true_ctx_id !== undefined) {
|
|
67
|
-
sm[i] = {
|
|
68
|
-
...common,
|
|
69
|
-
type: 'branch',
|
|
70
|
-
trueContextId: di.branch_true_ctx_id,
|
|
71
|
-
falseContextId: di.branch_false_ctx_id,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
sm[i] = {
|
|
76
|
-
...common,
|
|
77
|
-
type: 'context',
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
defaultDebugInfoCache.set(code.hash().toString('base64'), {
|
|
82
|
-
sourceMap: sm,
|
|
83
|
-
globals,
|
|
84
|
-
marks: parsedMarks,
|
|
85
|
-
});
|
|
86
|
-
return code;
|
|
87
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import EventEmitter from 'node:events';
|
|
2
|
-
import { TupleItem } from '@ton/core';
|
|
3
|
-
import { Executor, GetMethodArgs, RunTransactionArgs } from '../executor/Executor';
|
|
4
|
-
export type SourceMapEntry = {
|
|
5
|
-
path: string;
|
|
6
|
-
line: number;
|
|
7
|
-
function: string;
|
|
8
|
-
contextId: number;
|
|
9
|
-
requireContextId?: number;
|
|
10
|
-
} & ({
|
|
11
|
-
type: 'statement';
|
|
12
|
-
variables: string[];
|
|
13
|
-
firstStatement?: true;
|
|
14
|
-
} | {
|
|
15
|
-
type: 'return';
|
|
16
|
-
} | {
|
|
17
|
-
type: 'try_begin';
|
|
18
|
-
catchContextId: number;
|
|
19
|
-
} | {
|
|
20
|
-
type: 'try_end';
|
|
21
|
-
} | {
|
|
22
|
-
type: 'context';
|
|
23
|
-
} | {
|
|
24
|
-
type: 'branch';
|
|
25
|
-
trueContextId: number;
|
|
26
|
-
falseContextId?: number;
|
|
27
|
-
});
|
|
28
|
-
export type DebugMarks = Map<string, Map<number, number[]>>;
|
|
29
|
-
export type SourceMap = {
|
|
30
|
-
[k: number]: SourceMapEntry;
|
|
31
|
-
};
|
|
32
|
-
export type GlobalEntry = {
|
|
33
|
-
name: string;
|
|
34
|
-
};
|
|
35
|
-
export type DebugInfo = {
|
|
36
|
-
sourceMap: SourceMap;
|
|
37
|
-
globals: GlobalEntry[];
|
|
38
|
-
marks: DebugMarks;
|
|
39
|
-
};
|
|
40
|
-
type Breakpoint = {
|
|
41
|
-
id: number;
|
|
42
|
-
line: number;
|
|
43
|
-
verified: boolean;
|
|
44
|
-
};
|
|
45
|
-
export type Variable = {
|
|
46
|
-
name: string;
|
|
47
|
-
value: TupleItem;
|
|
48
|
-
};
|
|
49
|
-
type StackFrame = {
|
|
50
|
-
function: string;
|
|
51
|
-
path: string;
|
|
52
|
-
line: number;
|
|
53
|
-
nextContextId: number;
|
|
54
|
-
contextId: number;
|
|
55
|
-
shouldTryNoStep: boolean;
|
|
56
|
-
stepped: boolean;
|
|
57
|
-
};
|
|
58
|
-
type StepUntil = {
|
|
59
|
-
type: 'breakpoint';
|
|
60
|
-
} | {
|
|
61
|
-
type: 'any-line';
|
|
62
|
-
stopEvent: 'stopOnBreakpoint' | 'stopOnStep';
|
|
63
|
-
} | {
|
|
64
|
-
type: 'next-line';
|
|
65
|
-
depth: number;
|
|
66
|
-
} | {
|
|
67
|
-
type: 'out';
|
|
68
|
-
depth: number;
|
|
69
|
-
};
|
|
70
|
-
type TryContext = {
|
|
71
|
-
contextId: number;
|
|
72
|
-
frameDepth: number;
|
|
73
|
-
};
|
|
74
|
-
export declare class Debuggee extends EventEmitter {
|
|
75
|
-
executor: Executor;
|
|
76
|
-
ptr: number;
|
|
77
|
-
debugType: 'get' | 'tx';
|
|
78
|
-
sourceMap: SourceMap;
|
|
79
|
-
availableLines: {
|
|
80
|
-
[k: string]: number[];
|
|
81
|
-
};
|
|
82
|
-
breakpoints: Map<string, Breakpoint[]>;
|
|
83
|
-
breakpointID: number;
|
|
84
|
-
frames: StackFrame[];
|
|
85
|
-
globals: GlobalEntry[];
|
|
86
|
-
debugMarks: DebugMarks;
|
|
87
|
-
tryContexts: TryContext[];
|
|
88
|
-
finishedCallback: (v: unknown) => void;
|
|
89
|
-
constructor(executor: Executor, finishedCallback: (v: unknown) => void);
|
|
90
|
-
setDebugInfo(debugInfo: DebugInfo): void;
|
|
91
|
-
setDebugMarks(marks: DebugMarks): void;
|
|
92
|
-
setSourceMap(sourceMap: SourceMap): void;
|
|
93
|
-
setGlobals(globals: GlobalEntry[]): void;
|
|
94
|
-
getAvailableSourcePaths(): string[];
|
|
95
|
-
getAvailableLines(path: string): number[];
|
|
96
|
-
isLineAvailable(path: string, line: number): boolean;
|
|
97
|
-
continue(): void;
|
|
98
|
-
stepIn(): void;
|
|
99
|
-
stepOver(): void;
|
|
100
|
-
stepOut(): void;
|
|
101
|
-
startGetMethod(args: GetMethodArgs): void;
|
|
102
|
-
startTransaction(args: RunTransactionArgs): void;
|
|
103
|
-
getC7(): TupleItem;
|
|
104
|
-
vmStep(): boolean;
|
|
105
|
-
codePos(): {
|
|
106
|
-
hash: string;
|
|
107
|
-
offset: number;
|
|
108
|
-
};
|
|
109
|
-
getStack(): TupleItem[];
|
|
110
|
-
getContDistinguisher(): number;
|
|
111
|
-
setContDistinguishers(distinguisher: number, trueDistinguisher: number, falseDistinguisher: number): void;
|
|
112
|
-
getContDistinguisherTriggered(): boolean;
|
|
113
|
-
setTryParams(primed: number, triggered: number): void;
|
|
114
|
-
getTriggeredTryParam(): number;
|
|
115
|
-
getLocalVariables(): Variable[] | undefined;
|
|
116
|
-
getGlobalVariables(): Variable[] | undefined;
|
|
117
|
-
currentDebugMarks(): number[] | undefined;
|
|
118
|
-
currentSourceMapEntry(honorStepped: boolean): SourceMapEntry | undefined;
|
|
119
|
-
breakpointKey(path: string, line: number): string;
|
|
120
|
-
splitBreakpointKey(k: string): {
|
|
121
|
-
path: string;
|
|
122
|
-
line: number;
|
|
123
|
-
};
|
|
124
|
-
clearBreakpoints(path: string): void;
|
|
125
|
-
hasBreakpoint(path: string, line: number): boolean;
|
|
126
|
-
setBreakpoint(path: string, line: number): Breakpoint;
|
|
127
|
-
sendEvent(event: string, ...args: unknown[]): void;
|
|
128
|
-
onFinished(): void;
|
|
129
|
-
stackFrames(): StackFrame[];
|
|
130
|
-
applySourceMapEntry(sme: SourceMapEntry, until: StepUntil): {
|
|
131
|
-
stopStepping: boolean;
|
|
132
|
-
};
|
|
133
|
-
stepUntil(what: {
|
|
134
|
-
type: 'breakpoint';
|
|
135
|
-
} | {
|
|
136
|
-
type: 'any-line';
|
|
137
|
-
stopEvent: 'stopOnBreakpoint' | 'stopOnStep';
|
|
138
|
-
} | {
|
|
139
|
-
type: 'next-line';
|
|
140
|
-
} | {
|
|
141
|
-
type: 'out';
|
|
142
|
-
}): void;
|
|
143
|
-
prepareGetMethod(args: GetMethodArgs, debugInfo: DebugInfo): void;
|
|
144
|
-
prepareTransaction(args: RunTransactionArgs, debugInfo: DebugInfo): void;
|
|
145
|
-
start(debug: boolean, stopOnEntry: boolean): void;
|
|
146
|
-
}
|
|
147
|
-
export {};
|
|
@@ -1,451 +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
|
-
executor;
|
|
10
|
-
ptr = 0;
|
|
11
|
-
debugType = 'get';
|
|
12
|
-
sourceMap = {};
|
|
13
|
-
availableLines = {};
|
|
14
|
-
breakpoints = new Map();
|
|
15
|
-
breakpointID = 0;
|
|
16
|
-
frames = [];
|
|
17
|
-
globals = [];
|
|
18
|
-
debugMarks = new Map();
|
|
19
|
-
tryContexts = [];
|
|
20
|
-
finishedCallback;
|
|
21
|
-
constructor(executor, finishedCallback) {
|
|
22
|
-
super();
|
|
23
|
-
this.executor = executor;
|
|
24
|
-
this.executor.debugLogFunc = (s) => {
|
|
25
|
-
this.sendEvent('output', s);
|
|
26
|
-
};
|
|
27
|
-
this.finishedCallback = finishedCallback;
|
|
28
|
-
}
|
|
29
|
-
setDebugInfo(debugInfo) {
|
|
30
|
-
this.setSourceMap(debugInfo.sourceMap);
|
|
31
|
-
this.setGlobals(debugInfo.globals);
|
|
32
|
-
this.setDebugMarks(debugInfo.marks);
|
|
33
|
-
}
|
|
34
|
-
setDebugMarks(marks) {
|
|
35
|
-
this.debugMarks = marks;
|
|
36
|
-
}
|
|
37
|
-
setSourceMap(sourceMap) {
|
|
38
|
-
this.sourceMap = sourceMap;
|
|
39
|
-
for (const di in sourceMap) {
|
|
40
|
-
const sem = sourceMap[di];
|
|
41
|
-
if (!(sem.path in this.availableLines)) {
|
|
42
|
-
this.availableLines[sem.path] = [];
|
|
43
|
-
}
|
|
44
|
-
this.availableLines[sem.path].push(sem.line);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
setGlobals(globals) {
|
|
48
|
-
this.globals = globals;
|
|
49
|
-
}
|
|
50
|
-
getAvailableSourcePaths() {
|
|
51
|
-
return Object.keys(this.availableLines);
|
|
52
|
-
}
|
|
53
|
-
getAvailableLines(path) {
|
|
54
|
-
return this.availableLines[path] ?? [];
|
|
55
|
-
}
|
|
56
|
-
isLineAvailable(path, line) {
|
|
57
|
-
if (!(path in this.availableLines)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const lines = this.availableLines[path];
|
|
61
|
-
return lines.indexOf(line) >= 0;
|
|
62
|
-
}
|
|
63
|
-
continue() {
|
|
64
|
-
this.stepUntil({ type: 'breakpoint' });
|
|
65
|
-
}
|
|
66
|
-
stepIn() {
|
|
67
|
-
this.stepUntil({ type: 'any-line', stopEvent: 'stopOnStep' });
|
|
68
|
-
}
|
|
69
|
-
stepOver() {
|
|
70
|
-
this.stepUntil({ type: 'next-line' });
|
|
71
|
-
}
|
|
72
|
-
stepOut() {
|
|
73
|
-
this.stepUntil({ type: 'out' });
|
|
74
|
-
}
|
|
75
|
-
startGetMethod(args) {
|
|
76
|
-
this.ptr = this.executor.sbsGetMethodSetup(args);
|
|
77
|
-
this.debugType = 'get';
|
|
78
|
-
}
|
|
79
|
-
startTransaction(args) {
|
|
80
|
-
const { emptr, res } = this.executor.sbsTransactionSetup(args);
|
|
81
|
-
if (res !== 1) {
|
|
82
|
-
throw new Error('Could not setup SBS transaction, result: ' + res);
|
|
83
|
-
}
|
|
84
|
-
this.ptr = emptr;
|
|
85
|
-
this.debugType = 'tx';
|
|
86
|
-
}
|
|
87
|
-
getC7() {
|
|
88
|
-
switch (this.debugType) {
|
|
89
|
-
case 'get':
|
|
90
|
-
return this.executor.sbsGetMethodC7(this.ptr);
|
|
91
|
-
case 'tx':
|
|
92
|
-
return this.executor.sbsTransactionC7(this.ptr);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
vmStep() {
|
|
96
|
-
switch (this.debugType) {
|
|
97
|
-
case 'get':
|
|
98
|
-
return this.executor.sbsGetMethodStep(this.ptr);
|
|
99
|
-
case 'tx':
|
|
100
|
-
return this.executor.sbsTransactionStep(this.ptr);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
codePos() {
|
|
104
|
-
switch (this.debugType) {
|
|
105
|
-
case 'get':
|
|
106
|
-
return this.executor.sbsGetMethodCodePos(this.ptr);
|
|
107
|
-
case 'tx':
|
|
108
|
-
return this.executor.sbsTransactionCodePos(this.ptr);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
getStack() {
|
|
112
|
-
switch (this.debugType) {
|
|
113
|
-
case 'get':
|
|
114
|
-
return this.executor.sbsGetMethodStack(this.ptr);
|
|
115
|
-
case 'tx':
|
|
116
|
-
return this.executor.sbsTransactionStack(this.ptr);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
getContDistinguisher() {
|
|
120
|
-
switch (this.debugType) {
|
|
121
|
-
case 'get':
|
|
122
|
-
return this.executor.sbsGetMethodGetContDistinguisher(this.ptr);
|
|
123
|
-
case 'tx':
|
|
124
|
-
return this.executor.sbsTransactionGetContDistinguisher(this.ptr);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
setContDistinguishers(distinguisher, trueDistinguisher, falseDistinguisher) {
|
|
128
|
-
switch (this.debugType) {
|
|
129
|
-
case 'get':
|
|
130
|
-
this.executor.sbsGetMethodSetContDistinguishers(this.ptr, distinguisher, trueDistinguisher, falseDistinguisher);
|
|
131
|
-
break;
|
|
132
|
-
case 'tx':
|
|
133
|
-
this.executor.sbsTransactionSetContDistinguishers(this.ptr, distinguisher, trueDistinguisher, falseDistinguisher);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
getContDistinguisherTriggered() {
|
|
138
|
-
switch (this.debugType) {
|
|
139
|
-
case 'get':
|
|
140
|
-
return this.executor.sbsGetMethodGetContDistinguisherTriggered(this.ptr);
|
|
141
|
-
case 'tx':
|
|
142
|
-
return this.executor.sbsTransactionGetContDistinguisherTriggered(this.ptr);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
setTryParams(primed, triggered) {
|
|
146
|
-
switch (this.debugType) {
|
|
147
|
-
case 'get':
|
|
148
|
-
this.executor.sbsGetMethodSetTryParams(this.ptr, primed, triggered);
|
|
149
|
-
break;
|
|
150
|
-
case 'tx':
|
|
151
|
-
this.executor.sbsTransactionSetTryParams(this.ptr, primed, triggered);
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
getTriggeredTryParam() {
|
|
156
|
-
switch (this.debugType) {
|
|
157
|
-
case 'get':
|
|
158
|
-
return this.executor.sbsGetMethodGetTriggeredTryParam(this.ptr);
|
|
159
|
-
case 'tx':
|
|
160
|
-
return this.executor.sbsTransactionGetTriggeredTryParam(this.ptr);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
getLocalVariables() {
|
|
164
|
-
const sme = this.currentSourceMapEntry(false);
|
|
165
|
-
if (sme === undefined || sme.type !== 'statement') {
|
|
166
|
-
return undefined;
|
|
167
|
-
}
|
|
168
|
-
const vars = [];
|
|
169
|
-
const stack = this.getStack();
|
|
170
|
-
for (let i = 0; i < sme.variables.length; i++) {
|
|
171
|
-
vars.push({
|
|
172
|
-
name: sme.variables[i],
|
|
173
|
-
value: stack[i],
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
return vars;
|
|
177
|
-
}
|
|
178
|
-
getGlobalVariables() {
|
|
179
|
-
const vars = [];
|
|
180
|
-
const c7item = this.getC7();
|
|
181
|
-
if (c7item.type !== 'tuple') {
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
const c7 = c7item.items;
|
|
185
|
-
for (let i = 0; i < this.globals.length; i++) {
|
|
186
|
-
if (i + 1 < c7.length) {
|
|
187
|
-
vars.push({
|
|
188
|
-
name: this.globals[i].name,
|
|
189
|
-
value: c7[i + 1],
|
|
190
|
-
});
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
vars.push({
|
|
194
|
-
name: this.globals[i].name,
|
|
195
|
-
value: { type: 'null' },
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
return vars;
|
|
199
|
-
}
|
|
200
|
-
currentDebugMarks() {
|
|
201
|
-
const codepos = this.codePos();
|
|
202
|
-
return this.debugMarks.get(codepos.hash)?.get(codepos.offset);
|
|
203
|
-
}
|
|
204
|
-
currentSourceMapEntry(honorStepped) {
|
|
205
|
-
const dms = this.currentDebugMarks();
|
|
206
|
-
if (dms === undefined) {
|
|
207
|
-
return undefined;
|
|
208
|
-
}
|
|
209
|
-
let currentContextId;
|
|
210
|
-
let stepped;
|
|
211
|
-
if (this.frames.length > 0) {
|
|
212
|
-
const topFrame = this.frames[this.frames.length - 1];
|
|
213
|
-
currentContextId = topFrame.contextId;
|
|
214
|
-
stepped = topFrame.stepped;
|
|
215
|
-
}
|
|
216
|
-
for (const dm of dms) {
|
|
217
|
-
const entry = this.sourceMap[dm];
|
|
218
|
-
if ((entry.type === 'statement' &&
|
|
219
|
-
entry.firstStatement &&
|
|
220
|
-
entry.requireContextId === undefined &&
|
|
221
|
-
(stepped || !honorStepped)) ||
|
|
222
|
-
entry.requireContextId === currentContextId) {
|
|
223
|
-
return entry;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return undefined;
|
|
227
|
-
}
|
|
228
|
-
breakpointKey(path, line) {
|
|
229
|
-
return path + ':' + line;
|
|
230
|
-
}
|
|
231
|
-
splitBreakpointKey(k) {
|
|
232
|
-
const i = k.lastIndexOf(':');
|
|
233
|
-
return {
|
|
234
|
-
path: k.slice(0, i),
|
|
235
|
-
line: parseInt(k.slice(i + 1)),
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
clearBreakpoints(path) {
|
|
239
|
-
this.breakpoints.set(path, []);
|
|
240
|
-
}
|
|
241
|
-
hasBreakpoint(path, line) {
|
|
242
|
-
return (this.breakpoints.get(path) ?? []).findIndex((v) => v.line === line) >= 0;
|
|
243
|
-
}
|
|
244
|
-
setBreakpoint(path, line) {
|
|
245
|
-
let arr = this.breakpoints.get(path);
|
|
246
|
-
if (arr === undefined) {
|
|
247
|
-
arr = [];
|
|
248
|
-
this.breakpoints.set(path, arr);
|
|
249
|
-
}
|
|
250
|
-
const bp = {
|
|
251
|
-
id: this.breakpointID++,
|
|
252
|
-
line,
|
|
253
|
-
verified: this.isLineAvailable(path, line),
|
|
254
|
-
};
|
|
255
|
-
arr.push(bp);
|
|
256
|
-
return bp;
|
|
257
|
-
}
|
|
258
|
-
sendEvent(event, ...args) {
|
|
259
|
-
setTimeout(() => {
|
|
260
|
-
this.emit(event, ...args);
|
|
261
|
-
}, 0);
|
|
262
|
-
}
|
|
263
|
-
onFinished() {
|
|
264
|
-
this.sendEvent('end');
|
|
265
|
-
let r;
|
|
266
|
-
switch (this.debugType) {
|
|
267
|
-
case 'get': {
|
|
268
|
-
r = this.executor.sbsGetMethodResult(this.ptr);
|
|
269
|
-
this.executor.destroyTvmEmulator(this.ptr);
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
case 'tx': {
|
|
273
|
-
r = this.executor.sbsTransactionResult(this.ptr);
|
|
274
|
-
this.executor.destroyEmulator(this.ptr);
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
this.finishedCallback(r);
|
|
279
|
-
}
|
|
280
|
-
stackFrames() {
|
|
281
|
-
return this.frames;
|
|
282
|
-
}
|
|
283
|
-
applySourceMapEntry(sme, until) {
|
|
284
|
-
let stopStepping = false;
|
|
285
|
-
switch (sme.type) {
|
|
286
|
-
case 'statement': {
|
|
287
|
-
if (sme.firstStatement) {
|
|
288
|
-
this.frames.push({
|
|
289
|
-
function: sme.function,
|
|
290
|
-
path: sme.path,
|
|
291
|
-
line: sme.line,
|
|
292
|
-
contextId: sme.contextId,
|
|
293
|
-
shouldTryNoStep: true,
|
|
294
|
-
nextContextId: sme.contextId,
|
|
295
|
-
stepped: false,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
if (this.frames.length > 0) {
|
|
299
|
-
const topFrame = this.frames[this.frames.length - 1];
|
|
300
|
-
topFrame.line = sme.line;
|
|
301
|
-
}
|
|
302
|
-
switch (until.type) {
|
|
303
|
-
case 'breakpoint': {
|
|
304
|
-
if (this.hasBreakpoint(sme.path, sme.line)) {
|
|
305
|
-
this.sendEvent('stopOnBreakpoint');
|
|
306
|
-
stopStepping = true;
|
|
307
|
-
}
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
case 'any-line': {
|
|
311
|
-
this.sendEvent(until.stopEvent);
|
|
312
|
-
stopStepping = true;
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
case 'next-line': {
|
|
316
|
-
if (this.frames.length <= until.depth) {
|
|
317
|
-
this.sendEvent('stopOnStep');
|
|
318
|
-
stopStepping = true;
|
|
319
|
-
}
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
case 'out': {
|
|
323
|
-
if (this.frames.length < until.depth) {
|
|
324
|
-
this.sendEvent('stopOnStep');
|
|
325
|
-
stopStepping = true;
|
|
326
|
-
}
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
case 'return': {
|
|
333
|
-
this.frames.pop();
|
|
334
|
-
return { stopStepping };
|
|
335
|
-
}
|
|
336
|
-
case 'try_begin': {
|
|
337
|
-
this.tryContexts.push({
|
|
338
|
-
contextId: sme.catchContextId,
|
|
339
|
-
frameDepth: this.frames.length,
|
|
340
|
-
});
|
|
341
|
-
this.setTryParams(this.tryContexts.length - 1, -1);
|
|
342
|
-
break;
|
|
343
|
-
}
|
|
344
|
-
case 'try_end': {
|
|
345
|
-
this.tryContexts.pop();
|
|
346
|
-
this.setTryParams(-1, -1);
|
|
347
|
-
break;
|
|
348
|
-
}
|
|
349
|
-
case 'branch': {
|
|
350
|
-
let falseId = -1;
|
|
351
|
-
if (sme.falseContextId !== undefined) {
|
|
352
|
-
falseId = sme.falseContextId;
|
|
353
|
-
}
|
|
354
|
-
this.setContDistinguishers(-1, sme.trueContextId, falseId);
|
|
355
|
-
break;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
if (this.frames.length > 0) {
|
|
359
|
-
const topFrame = this.frames[this.frames.length - 1];
|
|
360
|
-
topFrame.shouldTryNoStep = true;
|
|
361
|
-
topFrame.nextContextId = sme.contextId;
|
|
362
|
-
}
|
|
363
|
-
return { stopStepping };
|
|
364
|
-
}
|
|
365
|
-
stepUntil(what) {
|
|
366
|
-
let until;
|
|
367
|
-
switch (what.type) {
|
|
368
|
-
case 'next-line':
|
|
369
|
-
case 'out': {
|
|
370
|
-
until = { type: what.type, depth: this.frames.length };
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
default:
|
|
374
|
-
until = what;
|
|
375
|
-
}
|
|
376
|
-
while (true) {
|
|
377
|
-
if (this.frames.length > 0) {
|
|
378
|
-
const topFrame = this.frames[this.frames.length - 1];
|
|
379
|
-
while (topFrame.shouldTryNoStep) {
|
|
380
|
-
topFrame.contextId = topFrame.nextContextId;
|
|
381
|
-
const sme = this.currentSourceMapEntry(true);
|
|
382
|
-
if (sme === undefined) {
|
|
383
|
-
topFrame.shouldTryNoStep = false;
|
|
384
|
-
break;
|
|
385
|
-
}
|
|
386
|
-
const { stopStepping } = this.applySourceMapEntry(sme, until);
|
|
387
|
-
if (stopStepping) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
if (this.frames.length > 0) {
|
|
393
|
-
const topFrame = this.frames[this.frames.length - 1];
|
|
394
|
-
topFrame.stepped = true;
|
|
395
|
-
}
|
|
396
|
-
const finished = this.vmStep();
|
|
397
|
-
if (finished) {
|
|
398
|
-
this.onFinished();
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
const triggeredTryParam = this.getTriggeredTryParam();
|
|
402
|
-
if (triggeredTryParam >= 0) {
|
|
403
|
-
if (triggeredTryParam !== this.tryContexts.length - 1) {
|
|
404
|
-
throw new Error(`Got triggered try param ${triggeredTryParam} but expected ${this.tryContexts.length - 1}`);
|
|
405
|
-
}
|
|
406
|
-
const tryContext = this.tryContexts[triggeredTryParam];
|
|
407
|
-
this.tryContexts.pop();
|
|
408
|
-
this.setTryParams(-1, -1);
|
|
409
|
-
this.frames = this.frames.slice(0, tryContext.frameDepth);
|
|
410
|
-
this.frames[this.frames.length - 1].contextId = tryContext.contextId;
|
|
411
|
-
}
|
|
412
|
-
if (this.getContDistinguisherTriggered()) {
|
|
413
|
-
const distinguisher = this.getContDistinguisher();
|
|
414
|
-
this.setContDistinguishers(-1, -1, -1);
|
|
415
|
-
if (distinguisher >= 0 && this.frames.length > 0) {
|
|
416
|
-
const topFrame = this.frames[this.frames.length - 1];
|
|
417
|
-
topFrame.contextId = distinguisher;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
const sme = this.currentSourceMapEntry(true);
|
|
421
|
-
if (sme !== undefined) {
|
|
422
|
-
const { stopStepping } = this.applySourceMapEntry(sme, until);
|
|
423
|
-
if (stopStepping) {
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
prepareGetMethod(args, debugInfo) {
|
|
430
|
-
this.startGetMethod(args);
|
|
431
|
-
this.setDebugInfo(debugInfo);
|
|
432
|
-
}
|
|
433
|
-
prepareTransaction(args, debugInfo) {
|
|
434
|
-
this.startTransaction(args);
|
|
435
|
-
this.setDebugInfo(debugInfo);
|
|
436
|
-
}
|
|
437
|
-
start(debug, stopOnEntry) {
|
|
438
|
-
if (debug) {
|
|
439
|
-
if (stopOnEntry) {
|
|
440
|
-
this.stepUntil({ type: 'any-line', stopEvent: 'stopOnBreakpoint' });
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
this.continue();
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
this.continue();
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
exports.Debuggee = Debuggee;
|