Important
Set File->Preferences->Settings, set "debug.allowBreakpointsEverywhere"
This will allow you to set breakpoints graphically
Click here if you prefer to set breakpoints manually
Manually add the breakpoints at the bottom of the debug window (see bottom left of screenshot), unfortunately I have not figured out how to do so via the side of the editor window
- File and Line based breakpoints:
file_name.c3:line_numberfor example:main.c3:5 - Package and function based breakpoints:
package_name.function_namefor examplemy_library.example_fn
VSCode extension used: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
Add file: .vscode/launch.json
File content:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gdb with C++ devtools",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/your_project_exe_name",
"args": [],
"cwd": "${workspaceFolder}/build",
"environment": [],
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"text": "-enable-pretty-printing",
}
],
"preLaunchTask": "c3cbuild",
"stopAtEntry": true,
}
]
}Add file .vscode/tasks.json
File content:
{
"version": "2.0.0",
"type":"shell",
"tasks": [
{
"type": "shell",
"command": "c3c",
"args": ["build"],
"label": "c3cbuild",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "dedicated",
"showReuseMessage": false,
"clear": false,
"revealProblems": "onProblem",
"close": true
},
"problemMatcher": {
"owner": "c3c",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+)\\s+(Warning|Error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}VSCode extension used: https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap
Add file: .vscode/launch.json
File content:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// On ubuntu: sudo apt-get install llvm llvm-18 llvm-18-dev lldb lldb-18 llvm-18-tools
// add to your path /usr/lib/llvm-18/bin/lldb-dap
// I added this to my .bashrc file
// export PATH="/usr/lib/llvm-18/bin:$PATH"
//
// On Mac I believe llvm tools are already installed
{
"name": "lldb dap Debug",
"type": "lldb-dap",
"request": "launch",
"program": "${workspaceFolder}/build/your_project_exe_name",
// "args": [ "one", "two", "three" ],
// "env": {
// "FOO": "1"
// "BAR": ""
// }
"preLaunchTask": "c3cbuild",
"stopOnEntry": true
}
]
}Add file .vscode/tasks.json
File content:
{
"version": "2.0.0",
"type":"shell",
"tasks": [
{
"type": "shell",
"command": "c3c",
"args": ["build"],
"label": "c3cbuild",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "dedicated",
"showReuseMessage": false,
"clear": false,
"revealProblems": "onProblem",
"close": true
},
"problemMatcher": {
"owner": "c3c",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+)\\s+(Warning|Error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}- plugins/debuggin.lua: https://github.com/BWindey/nvim-config/blob/main/lua/plugins/debugging.lua
- plugins/adapters/lldb.lua: https://github.com/BWindey/nvim-config/blob/main/lua/plugins/adapters/lldb.lua
- VSCode extension used: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
- Follow the install instructions and run the compiler at least once following these instructions
- https://code.visualstudio.com/docs/cpp/config-msvc
Important
Set File->Preferences->Settings, set "debug.allowBreakpointsEverywhere"
This will allow you to set breakpoints graphically
Add file: .vscode/launch.json
File content:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "MSVC debugger for C3",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}\\build\\project_name_here_to_replace.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"preLaunchTask": "c3cbuild",
}
]
}Add file .vscode/tasks.json
File content:
{
"version": "2.0.0",
"type":"shell",
"tasks": [
{
"type": "shell",
"command": "c3c",
"args": ["build"],
"label": "c3cbuild",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "dedicated",
"showReuseMessage": false,
"clear": false,
"revealProblems": "onProblem",
"close": true
},
"problemMatcher": {
"owner": "c3c",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+)\\s+(Warning|Error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}- Create a new Run/Debug configuration based on Debug Adapter Protocol, make the command point to your lldb-dap exe, in my case it's just from my local mingw installation
- Under mappings specify the language and file types (you need the c3intellij plugin installed for this, I think).
- Under Configuration, specify the working dir and path to the exe, and provide the full DAP parameters to pass on in the form of JSON. You're supposed to be able to use variables here instead of hardcoding the paths, but I couldn't quite get it working so this is good enough for me right now.,
That should be it, I think. It respects my in-editor breakpoints and I can see my locals.