Debugging using VSCode and lldb on a remote machine or VM
- Install code-lldb vscode extension
-
Add a configuration to
.vscode/launch.json
like the following (customizing for a given system using the comment in the configuration file):{ "name": "Remote debug bpfman", "type": "lldb", "request": "launch", "program": "<ABSOLUTE_PATH>/github.com/bpfman/bpfman/target/debug/bpfman", // Local path to latest debug binary. "initCommands": [ "platform select remote-linux", // Execute `platform list` for a list of available remote platform plugins. "platform connect connect://<IP_ADDRESS_OF_VM>:8175", // replace <IP_ADDRESS_OF_VM> "settings set target.inherit-env false", ], "env": { "RUST_LOG": "debug" }, "cargo": { "args": [ "build", "--bin=bpfman", "--package=bpfman" ], "filter": { "name": "bpfman", "kind": "bin" } }, "cwd": "${workspaceFolder}", },
-
On the VM or Server install
lldb-server
:dnf
based OS:apt
based OS: -
Start
lldb-server
on the VM or Server (make sure to do this in the~/home
directory) -
Add breakpoints as needed via the vscode GUI and then hit
F5
to start debugging!