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

Support command:pickRemoteProcess #771

Closed
wants to merge 1 commit into from

Conversation

zed0
Copy link

@zed0 zed0 commented Dec 5, 2022

Functionality

The little documented pickRemoteProcess command can be used with the pipeTransport option to query processes running on a potentially remote host rather than the local machine.

This effectively works by running the command to list processes in the same environment that the debugger will be run in.

See https://code.visualstudio.com/docs/cpp/pipe-transport for details.

Implementation

In order to pick a remote process it's necessary to know the rest of the pipeTransport configuration. This is currently achieved by passing the un-expanded configuration to the expand_config_variables function and each of the functions in var_placeholders_once. I'm not sure if there's a better way of doing this that would allow placeholders within the pipeTransport configuration to be used.

Reproduction

An example config might look like:

    {
      "name": "C++ Attach in hello_gdb container",
      "type": "cppdbg",
      "request": "attach",
      "program": "/hello.out",
      "processId": "${command:pickRemoteProcess}",
      "pipeTransport": {
          "pipeCwd": "${workspaceRoot}",
          "pipeProgram": "docker",
          "pipeArgs": [
              "exec", 
              "-i", 
              "hello_gdb", 
              "sh",
              "-c"
          ],
          "debuggerPath": "/usr/bin/gdb"
      },
      "sourceFileMap": {
              "/src":"${workspaceRoot}"
      },
      "linux": {
        "MIMode": "gdb"
      },
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    }

This is adapted from launch.json in https://github.com/andyneff/hello-world-gdb which also has a docker container that can be used to test the functionality.

The little documented pickRemoteProcess command can be used with the
pipeTransport option to query processes running on a potentially remote
host rather than the local machine.

This effectively works by running the command to list processes in the
same environment that the debugger will be run in.

See https://code.visualstudio.com/docs/cpp/pipe-transport for details.
Copy link
Owner

@mfussenegger mfussenegger left a comment

Choose a reason for hiding this comment

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

Thanks for the PR but I'm afraid I can't merge this. debug adapter specific functionality is out of scope for nvim-dap and the pipeTransport property is adapter specific.

You'll instead have to use a function value as property and do this in your configuration or plugin

See also:

@zed0
Copy link
Author

zed0 commented Dec 5, 2022

I had assumed that pickRemoteProcess fell into the same category as pickProcess which is already implemented.
Thanks for taking a look anyway, I'll have a look at the comments you've provided and update https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(gdb-via--vscode-cpptools) with the results.

@zed0 zed0 closed this Dec 5, 2022
@mfussenegger
Copy link
Owner

I had assumed that pickRemoteProcess fell into the same category as pickProcess which is already implemented.

It's indeed similar but for me the key difference is that pickProcess has no dependency on concrete configuration properties
In vscode it's also part of the cpptools extension: https://github.com/microsoft/vscode-cpptools/blob/20e220354d3e3a918fef25137c1b4f0e4545c45b/Extension/package.json#L3152 & https://github.com/microsoft/vscode-cpptools/blob/48653c0854c2b923da7d149505f62a0f1967c2b3/Extension/src/Debugger/extension.ts#L39

I guess nvim-dap could provide a hook to register variable handlers too.
I'll consider that for #720

@zed0
Copy link
Author

zed0 commented Dec 7, 2022

I guess nvim-dap could provide a hook to register variable handlers too.
I'll consider that for #720

That does sound pretty useful, for all sorts of adapters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants