Debug with LLDB
integrated in VSCode - CodeLLDB
Debug Action
F5 - Continue / Pause
F10 - Step Over
F11 - Step Into
see also
- GDB Vs LLDB debuggers
- Scripting Bridge API - The SB APIs constitute the stable C++ API that lldb presents to external clients, and which get processed by SWIG to produce the Python bindings to lldb.
VSCode
- CodeLLDB User’s Manual - how to use this extension.
- Debugging in VS Code - if you are new to VSCode debugging.
Troubleshooting
Extension can conflict with other, and make debugging unavailable: disabling all extension & reloading selectively can solve the issue.
So far compatible extension are
- Code Runner - runs selected code snippets per click or keyboard shortcut.
- CodeLLDB
Issue remains
LLDB launch config
- Debug a C++ project in VS Code - launch syntax is different for each plugin.
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "build/cg",
"preLaunchTask": "cg-build", // build task to invoke before launching debugger, see below for definition
//"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stdio": ["test_21.txt"],
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"initCommands": [ // in debug script fonctionnality
"command script import ${workspaceRoot}/debug/debugvis.py" // <<<<< This is the important bit
]
}
]
}
Example of lldb plugin, invoking python script on conditional break, to have a custom visualisation of program state.
How run build task automatically before debugging in Visual Studio Code?
{
"version": "2.0.0",
"tasks": [
{
"label": "cg-build",
"command": "ninja",
"args": [],
"options": {
"cwd": "${workspaceFolder}/"
}
}
]
}
Written on September 26, 2022, Last update on June 27, 2024
debug-c++
vscode
gdb