Skip to content

Commit

Permalink
Enhance debugger attachment requests (#2431)
Browse files Browse the repository at this point in the history
* Allow specifying debugSocketPath for attach requests

* Support attaching to debugger with host and port
  • Loading branch information
st0012 authored Aug 13, 2024
1 parent a356ce3 commit 3f2046a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
17 changes: 16 additions & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
19 changes: 19 additions & 0 deletions vscode/src/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -182,6 +189,18 @@ export class Debugger
private async attachDebuggee(
session: vscode.DebugSession,
): Promise<vscode.DebugAdapterDescriptor> {
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);
Expand Down

0 comments on commit 3f2046a

Please sign in to comment.