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

Debug via containerized toolchain & DAP server #816

Open
sfavazza opened this issue Nov 28, 2024 · 1 comment
Open

Debug via containerized toolchain & DAP server #816

sfavazza opened this issue Nov 28, 2024 · 1 comment

Comments

@sfavazza
Copy link
Contributor

The setup I am working on features the entire toolchain in a container (both GDB & GDB-server).
I wonder whether it is possible to configure a debug session via launch.json file such that dap-mode execute the debugger from within the docker container.

In particular I have difficulties to understand the 2 keywords provider and template of the .lsp-docker configuration file.

Should these files be visible in the container? Do you have an example?

Assuming the .lsp-docker part is properly configured, shall I indicate docker-paths in the launch.json keywords miDebuggerPath and debugServerPath?

@sfavazza sfavazza changed the title Debug via containerized toolchain Debug via containerized toolchain & DAP server Dec 4, 2024
@sfavazza
Copy link
Contributor Author

Based on my investigation it seems that provider and (optional) template must already exist, such that the dap-docker-register will append the Dockerized word to both the newly created provider and template.

E.g. assuming I want to run a GDB session in a container I will have:

lsp:
  server:
    mappings:
    - source: .
      destination: /code
   debug:
      type: docker
      subtype: container
      name: <my-dap-container-name>
      enabled: true
      provider: "cppdbg"
      template: "cpptools::Run Configuration"
      launch_command: "/inside-docker/path/to/debugger"

This in turn creates:

  • dockerized provider named: abs-path-to-project-cppdbgDocker
  • dockerized template: cpptools::Run Configuration Dockerized

Hence to start a debugging session the launch.json file would look like this:

{
    "configurations": [
        {
            "name": "DAP C/C++ (dockerized)",
            "type": "abs-path-to-project-cppdbgDocker",
            "request": "launch",
            "MIMode": "gdb",
            "miDebuggerServerAddress": ":${env:TARGET_DBG_PORT}",
            // container local paths
            "miDebuggerPath": "/inside/docker/path/to/gdb",
            "miDebuggerArgs": "-x /code/.vscode/.gdbinit",
            "program": "<my-program-abs-path>",
            "cwd": "${workspaceFolder}",
            // launch the debug server connecting to the target
            "debugServerPath": "/inside/docker/path/gdb-server",
        },
    ]
}

Is this the intended usage? Did I miss anything?

I found a caveat with the vscode-cpptools DAP server. When starting a debug session with the newly registered provider, the GDB-DAP-server expects to find a *.ad7Engine.json file where the * is the value of the launch.json key:

  • Is this expected?
  • Does anyone bumped into the same issue with other DAP servers?

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

No branches or pull requests

1 participant