Skip to content

Commit 3f2046a

Browse files
authored
Enhance debugger attachment requests (#2431)
* Allow specifying debugSocketPath for attach requests * Support attaching to debugger with host and port
1 parent a356ce3 commit 3f2046a

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

vscode/package.json

+16-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,22 @@
486486
}
487487
}
488488
},
489-
"attach": {}
489+
"attach": {
490+
"properties": {
491+
"debugSocketPath": {
492+
"type": "string",
493+
"description": "The path to the debug socket. This is used to connect to the debugger"
494+
},
495+
"debugPort": {
496+
"type": "number",
497+
"description": "The port to use to connect to the debugger"
498+
},
499+
"debugHost": {
500+
"type": "string",
501+
"description": "The host to use to connect to the debugger"
502+
}
503+
}
504+
}
490505
},
491506
"configurationSnippets": [
492507
{

vscode/src/debugger.ts

+19
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ export class Debugger
161161

162162
private async getSockets(session: vscode.DebugSession) {
163163
const configuration = session.configuration;
164+
165+
const debugSocketPath = session.configuration.debugSocketPath;
166+
167+
if (debugSocketPath) {
168+
return [debugSocketPath];
169+
}
170+
164171
let sockets: string[] = [];
165172

166173
try {
@@ -182,6 +189,18 @@ export class Debugger
182189
private async attachDebuggee(
183190
session: vscode.DebugSession,
184191
): Promise<vscode.DebugAdapterDescriptor> {
192+
const debugPort = session.configuration.debugPort;
193+
194+
if (debugPort) {
195+
const debugHost = session.configuration.debugHost;
196+
197+
if (debugHost) {
198+
return new vscode.DebugAdapterServer(debugPort, debugHost);
199+
}
200+
201+
return new vscode.DebugAdapterServer(debugPort);
202+
}
203+
185204
// When using attach, a process will be launched using Ruby debug and it will create a socket automatically. We have
186205
// to find the available sockets and ask the user which one they want to attach to
187206
const sockets = await this.getSockets(session);

0 commit comments

Comments
 (0)