ruby / vscode-rdbg

VSCode Ruby rdbg Debugger
MIT License
176 stars 49 forks source link

Proposal: Support attaching multiple process #372

Open ikhsan opened 9 months ago

ikhsan commented 9 months ago

Thanks for making this awesome debugger extension! Launching tests work out of the box, which is cool, although attaching to our servers don't have a ideal developer experience.

Problem

The default behaviour of the VSCode extension is to list all process and pick only one. Our setup uses 12 puma process to ensure a good developer experience. What happens now is that to debug properly, we needed to manually click and attach them 1-by-1 🥲

Screenshot 2023-10-26 at 17 20 11

Proposal

In this fork, I send custom events attachSingleSocket and the listener will start the debug just for the socket paths https://github.com/ruby/vscode-rdbg/commit/4441cbc4b9c36f67ec23206bff3971cb178c4426

I wonder if this capability interest other folks? If yes, we can add env variable or config (eg. SUPPORT_ATTACH_MULTI_SOCKETS or supportAttachMultiSockets) where when multiple sockets are detected, we use the multi session instead

// extension.ts; attach() method

...
const list = await this.getSockList(config);
outputChannel.appendLine(JSON.stringify(list));
switch (list.length) {
    case 0:
        vscode.window.showErrorMessage("Can not find attachable Ruby process.");
    return new DebugAdapterInlineImplementation(new StopDebugAdapter);
    case 1:
    sockPath = list[0];
    break;
    default:
        // The new behaviour controller by the new config
        // --start
    if (this.supportAttachMultiSockets) {
            const adapter = new MultiSessionDebugAdapter(list);
            return new DebugAdapterInlineImplementation(adapter);
        }               
        // --end   

        const sock = await vscode.window.showQuickPick(list);
    if (sock) {
            sockPath = sock;
    }
        else {
            return new DebugAdapterInlineImplementation(new StopDebugAdapter);
        }

...

Happy to help implementing the new capabilities if this has interests 👍

ko1 commented 7 months ago

attaching to the all Ruby processes from one VSCode instance?

ikhsan commented 7 months ago

attaching to the all Ruby processes from one VSCode instance?

indeed, this way all the processes (eg we’re using 4 processes on our setup) will all be attached and will be treated as child processes

without this, then the DX isn’t ideal as we need to select manually 4 times

ikhsan commented 6 months ago

Got my first draft PR for the proposal: https://github.com/ruby/vscode-rdbg/pull/427

Let me know what you folks think 🙏

cc @ko1 @ono-max