Skip to content

Commit 278ba22

Browse files
authored
feat(vscode): add action to attach to FunC debugger (#36)
Big thanks to TonTech for implementation in https://github.com/krigga/tvm-debugger Fixes #35
1 parent d589db5 commit 278ba22

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ FunC support includes:
4242
- Inlay hints for method id
4343
- On-the-fly inspections
4444
- Build and test projects based on Blueprint
45+
- Debug Blueprint-based projects
4546

4647
Fift assembly support includes:
4748

@@ -276,6 +277,11 @@ Setup steps:
276277
277278
See [TROUBLESHOOTING.md](./docs/manual/troubleshooting.md).
278279
279-
# License
280+
## Thanks
281+
282+
- Big thanks to [TonTech](https://ton.tech) for [FunC debugger
283+
implementation](https://github.com/krigga/tvm-debugger)!
284+
285+
## License
280286
281287
MIT

editors/code/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ FunC support includes:
4242
- Inlay hints for method id
4343
- On-the-fly inspections
4444
- Build and test projects based on Blueprint
45+
- Debug Blueprint-based projects
4546

4647
Fift assembly support includes:
4748

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as vscode from "vscode"
2+
import {DebugAdapterExecutable, DebugSession} from "vscode"
3+
4+
export function configureDebugging(context: vscode.ExtensionContext): void {
5+
context.subscriptions.push(
6+
vscode.debug.registerDebugConfigurationProvider("tvm", {
7+
provideDebugConfigurations() {
8+
return [
9+
{
10+
type: "tvm",
11+
name: "Debug",
12+
request: "launch",
13+
},
14+
]
15+
},
16+
}),
17+
vscode.debug.registerDebugAdapterDescriptorFactory("tvm", {
18+
createDebugAdapterDescriptor(_s: DebugSession, _e: DebugAdapterExecutable | undefined) {
19+
return new vscode.DebugAdapterServer(42_069)
20+
},
21+
}),
22+
vscode.commands.registerCommand("ton.debug", () => {
23+
void vscode.debug.startDebugging(undefined, {
24+
type: "tvm",
25+
name: "Debug",
26+
request: "launch",
27+
})
28+
}),
29+
)
30+
}

editors/code/src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {BocDecompilerProvider} from "./providers/BocDecompilerProvider"
2929
import {registerSaveBocDecompiledCommand} from "./commands/saveBocDecompiledCommand"
3030
import {Range, Position, FileSystemWatcher} from "vscode"
3131
import {ToolchainConfig} from "@server/settings/settings"
32+
import {configureDebugging} from "./debugging"
3233

3334
let client: LanguageClient | null = null
3435
let cachedToolchainInfo: SetToolchainVersionParams | null = null
@@ -40,6 +41,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
4041
await registerBuildTasks(context)
4142
registerOpenBocCommand(context)
4243
registerSaveBocDecompiledCommand(context)
44+
configureDebugging(context)
4345

4446
const config = vscode.workspace.getConfiguration("ton")
4547
const openDecompiled = config.get<boolean>("boc.openDecompiledOnOpen")
@@ -664,6 +666,7 @@ async function checkConflictingExtensions(): Promise<void> {
664666
const conflictingExtensions = [
665667
{id: "tonwhales.func-vscode", name: "FunC"},
666668
{id: "ton-core.tolk-vscode", name: "Tolk"},
669+
{id: "krigga.tvm-debugger", name: "TVM Debugger"},
667670
]
668671

669672
const installedConflicting = conflictingExtensions.filter(ext => {

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@
198198
}
199199
],
200200
"snippets": [],
201+
"debuggers": [
202+
{
203+
"type": "tvm",
204+
"label": "TVM Debug"
205+
}
206+
],
207+
"breakpoints": [
208+
{
209+
"language": "func"
210+
}
211+
],
201212
"commands": [
202213
{
203214
"command": "tolk.build",
@@ -266,6 +277,10 @@
266277
{
267278
"command": "tolk.getUnresolvedIdentifiers",
268279
"title": "Tolk: Get Unresolved Identifiers"
280+
},
281+
{
282+
"command": "ton.debug",
283+
"title": "TON: Debug contract"
269284
}
270285
],
271286
"keybindings": [

0 commit comments

Comments
 (0)