Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance debugger attachment requests #2431

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,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"
}
Comment on lines +478 to +485
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we combine these two into a single URI? I think it makes it even simpler for the user and we can easily split the host and port by using VS Code's URI API:

const uri = vscode.Uri.parse(session.configuration.debugUri)
uri.host
uri.port

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer having them separated because:

  1. When connecting with a remote console, the usage is rdbg -A host port, not rdbg -A host:port. When specifying with env, it has RUBY_DEBUG_HOST and RUBY_DEBUG_PORT but no RUBY_DEBUG_URI either. So I think having them separated is more consistent with the terminal experience.
  2. port is going to be specified a lot more often than host, which means in most cases debugUri would simply be port, like debugUri: 4000. And IMO debugPort: 4000 is a lot less confusing than it.

}
}
},
"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
Loading