From 3f2046af2ef71bbd8885e4610d6fceda4999bb3f Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 13 Aug 2024 18:55:56 +0100 Subject: [PATCH] Enhance debugger attachment requests (#2431) * Allow specifying debugSocketPath for attach requests * Support attaching to debugger with host and port --- vscode/package.json | 17 ++++++++++++++++- vscode/src/debugger.ts | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/vscode/package.json b/vscode/package.json index 163180600..95b10010b 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -486,7 +486,22 @@ } } }, - "attach": {} + "attach": { + "properties": { + "debugSocketPath": { + "type": "string", + "description": "The path to the debug socket. This is used to connect to the debugger" + }, + "debugPort": { + "type": "number", + "description": "The port to use to connect to the debugger" + }, + "debugHost": { + "type": "string", + "description": "The host to use to connect to the debugger" + } + } + } }, "configurationSnippets": [ { diff --git a/vscode/src/debugger.ts b/vscode/src/debugger.ts index 7d6724747..12e7547dc 100644 --- a/vscode/src/debugger.ts +++ b/vscode/src/debugger.ts @@ -161,6 +161,13 @@ export class Debugger private async getSockets(session: vscode.DebugSession) { const configuration = session.configuration; + + const debugSocketPath = session.configuration.debugSocketPath; + + if (debugSocketPath) { + return [debugSocketPath]; + } + let sockets: string[] = []; try { @@ -182,6 +189,18 @@ export class Debugger private async attachDebuggee( session: vscode.DebugSession, ): Promise { + const debugPort = session.configuration.debugPort; + + if (debugPort) { + const debugHost = session.configuration.debugHost; + + if (debugHost) { + return new vscode.DebugAdapterServer(debugPort, debugHost); + } + + return new vscode.DebugAdapterServer(debugPort); + } + // When using attach, a process will be launched using Ruby debug and it will create a socket automatically. We have // to find the available sockets and ask the user which one they want to attach to const sockets = await this.getSockets(session);