C / C++
Debugger: GDB 14+ (--interpreter=dap) or lldb-dap Status: Stable Transport: stdin/stdout (not TCP)
Prerequisites
# Ubuntu/Debian
sudo apt install gdb
gdb --version # must be 14+
# Fedora/RHEL
sudo dnf install gdb# Via Xcode Command Line Tools
xcode-select --install
# Or via Homebrew
brew install llvm
lldb-dap --versionGDB 14 added native DAP support via --interpreter=dap. Earlier versions are not supported.
Quick Start
The adapter compiles source files automatically with debug symbols if you provide a .c or .cpp file:
# Compile and debug a C program
krometrail launch "gcc -g -o app app.c && ./app" --break app.c:42
# Or let the adapter compile:
krometrail launch "app.c" --break app.c:42
# C++ with g++
krometrail launch "g++ -g -o app app.cpp && ./app" --break app.cpp:42
# Debug an existing binary
krometrail launch "./app" --break app.c:42 --language cppConditional Breakpoints
C/C++ expressions:
krometrail break "order.c:147 when discount < 0"
krometrail break "loop.c:25 when i == 99"
krometrail break "api.c:30 when strcmp(method, \"POST\") == 0"Inspecting C/C++ Values
Structs and unions are shown with their fields:
Locals:
order = {id=482, total=149.97, tier=2}
discount = -149.97
items = 0x... -> [{price=49.99, qty=3}, ...]Pointers show the address and the dereferenced value. Use debug_evaluate with GDB expressions for deeper inspection:
krometrail eval "order->tier"
krometrail eval "*(double*)(&raw_value)"
krometrail eval "((Order*)ptr)->id"stdin/stdout Transport
Unlike other adapters, C/C++ uses stdin/stdout transport (GDB's DAP mode communicates via pipes, not TCP). This is handled transparently — no configuration needed.
Tips
- Always compile with
-g(debug info) and without-O2/-O3(optimization breaks debug info) - For CMake projects:
cmake -DCMAKE_BUILD_TYPE=Debug ..then debug the built binary - Thread debugging works —
debug_threadslists pthreads created bypthread_create - Valgrind and AddressSanitizer can be combined:
krometrail launch "valgrind --vgdb=yes ./app"for memory debugging
GDB vs lldb-dap
krometrail doctor checks for both. GDB is the default on Linux; lldb-dap is preferred on macOS. Override with --language if needed:
krometrail launch "./app" --language cpp