|
|
4 weeks ago | |
|---|---|---|
| common | 4 weeks ago | |
| devstation | 4 weeks ago | |
| remote | 4 weeks ago | |
| README.md | 4 weeks ago | |
| docker-compose.yml | 4 weeks ago | |
README.md
DAP Remote Debugging Example
A minimal example showing how to debug a C++ program running in a remote container from any DAP-compatible client — Neovim, VSCode, Emacs, and others.
┌────────────────────────┐ ┌──────────────────────┐
│ YOUR EDITOR │ DAP over TCP │ REMOTE │
│ (Neovim, VSCode,…) │ ◀─────────────────────▶ │ (Alpine container) │
│ │ port 13000 │ │
│ • source code │ │ • codelldb DAP │
│ • breakpoints │ │ server │
│ • variable inspection │ │ • debugapp (C++17) │
│ │ │ • socat forwarder │
└────────────────────────┘ └──────────────────────┘
The remote container runs codelldb as a
DAP (Debug Adapter Protocol) server. Your editor connects to it over TCP,
sends a launch request, and codelldb starts the program on the remote.
This avoids gdbserver's entry-point assembly issue entirely and keeps source
paths clean.
Quick start (full setup)
The included docker-compose.yml spins up both the remote container and a
Neovim-based devstation:
docker compose build
docker compose up -d remote # start the codelldb DAP server
docker compose run --rm devstation # interactive Neovim session
Inside Neovim, open src/calculator.cpp, press <leader>db on a line to set
a breakpoint, then <leader>dc and select "Remote launch (codelldb remote:13000)".
See devstation/README.md for the full Neovim keybinding reference.
Using your own editor
You don't need the devstation container. Build and run the remote alone, then connect from whatever editor you prefer:
docker build -t dap-debug-remote -f remote/Dockerfile .
docker run -d --name remote \
-p 13000:13000 \
--cap-add SYS_PTRACE \
--security-opt seccomp=unconfined \
dap-debug-remote
Then follow the guide for your editor in remote/README.md — it covers VSCode, Neovim, Emacs, and generic DAP clients.
Repository layout
.
├── docker-compose.yml # Two-service compose (remote + devstation)
├── README.md # This file
│
├── common/
│ └── project/ # C++ demo project (shared by both containers)
│ ├── CMakeLists.txt
│ └── src/
│
├── remote/
│ ├── Dockerfile # Alpine + codelldb + socat + project build
│ ├── entrypoint.sh # codelldb DAP server + socat forwarder loop
│ └── README.md # Standalone usage + VSCode/other editor guides
│
└── devstation/
├── Dockerfile # Alpine + Neovim (LazyVim) + nvim-dap
├── README.md # Neovim keybindings and setup details
├── nvim-config/
│ └── lua/plugins/ # LazyVim plugin specs (theme, lsp, dap)
└── scripts/
└── precompile-treesitter.lua
How it works
- codelldb runs on the remote as a DAP server (
--port 13001 --multi-session). It binds to127.0.0.1only, so socat forwards external connections from0.0.0.0:13000to codelldb's listener. - Your editor connects to port 13000 and sends a standard DAP
launchrequest. codelldb starts the program on the remote, captures stdout/stderr, and streams output events back. - The project source lives at
/projecton the remote (and on the devstation if you use it), so debug-info paths match and editors open source files correctly when stopped at a breakpoint. - The remote entrypoint restarts codelldb after each session, so you can reconnect without restarting the container.
SYS_PTRACE+seccomp:unconfinedon the remote allow codelldb to debug the child process.
Note: codelldb is a glibc binary but runs on Alpine (musl) via
gcompatplus a tiny shim library providing the missing__res_initsymbol.