diff --git a/README.md b/README.md index 7ca17ebd..14fb74bc 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ FunC support includes: - Inlay hints for method id - On-the-fly inspections - Build and test projects based on Blueprint +- Debug Blueprint-based projects Fift assembly support includes: @@ -276,6 +277,11 @@ Setup steps: See [TROUBLESHOOTING.md](./docs/manual/troubleshooting.md). -# License +## Thanks + +- Big thanks to [TonTech](https://ton.tech) for [FunC debugger + implementation](https://github.com/krigga/tvm-debugger)! + +## License MIT diff --git a/editors/code/README.md b/editors/code/README.md index 610859af..81619146 100644 --- a/editors/code/README.md +++ b/editors/code/README.md @@ -42,6 +42,7 @@ FunC support includes: - Inlay hints for method id - On-the-fly inspections - Build and test projects based on Blueprint +- Debug Blueprint-based projects Fift assembly support includes: diff --git a/editors/code/src/debugging/index.ts b/editors/code/src/debugging/index.ts new file mode 100644 index 00000000..a7bb17d2 --- /dev/null +++ b/editors/code/src/debugging/index.ts @@ -0,0 +1,30 @@ +import * as vscode from "vscode" +import {DebugAdapterExecutable, DebugSession} from "vscode" + +export function configureDebugging(context: vscode.ExtensionContext): void { + context.subscriptions.push( + vscode.debug.registerDebugConfigurationProvider("tvm", { + provideDebugConfigurations() { + return [ + { + type: "tvm", + name: "Debug", + request: "launch", + }, + ] + }, + }), + vscode.debug.registerDebugAdapterDescriptorFactory("tvm", { + createDebugAdapterDescriptor(_s: DebugSession, _e: DebugAdapterExecutable | undefined) { + return new vscode.DebugAdapterServer(42_069) + }, + }), + vscode.commands.registerCommand("ton.debug", () => { + void vscode.debug.startDebugging(undefined, { + type: "tvm", + name: "Debug", + request: "launch", + }) + }), + ) +} diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index c67c0957..e58666a6 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -29,6 +29,7 @@ import {BocDecompilerProvider} from "./providers/BocDecompilerProvider" import {registerSaveBocDecompiledCommand} from "./commands/saveBocDecompiledCommand" import {Range, Position, FileSystemWatcher} from "vscode" import {ToolchainConfig} from "@server/settings/settings" +import {configureDebugging} from "./debugging" let client: LanguageClient | null = null let cachedToolchainInfo: SetToolchainVersionParams | null = null @@ -40,6 +41,7 @@ export async function activate(context: vscode.ExtensionContext): Promise await registerBuildTasks(context) registerOpenBocCommand(context) registerSaveBocDecompiledCommand(context) + configureDebugging(context) const config = vscode.workspace.getConfiguration("ton") const openDecompiled = config.get("boc.openDecompiledOnOpen") @@ -664,6 +666,7 @@ async function checkConflictingExtensions(): Promise { const conflictingExtensions = [ {id: "tonwhales.func-vscode", name: "FunC"}, {id: "ton-core.tolk-vscode", name: "Tolk"}, + {id: "krigga.tvm-debugger", name: "TVM Debugger"}, ] const installedConflicting = conflictingExtensions.filter(ext => { diff --git a/package.json b/package.json index e1752a02..aaa0c605 100644 --- a/package.json +++ b/package.json @@ -198,6 +198,17 @@ } ], "snippets": [], + "debuggers": [ + { + "type": "tvm", + "label": "TVM Debug" + } + ], + "breakpoints": [ + { + "language": "func" + } + ], "commands": [ { "command": "tolk.build", @@ -266,6 +277,10 @@ { "command": "tolk.getUnresolvedIdentifiers", "title": "Tolk: Get Unresolved Identifiers" + }, + { + "command": "ton.debug", + "title": "TON: Debug contract" } ], "keybindings": [