2023-12-16
The key is to use lldb
instead of gdb
, which comes with XCode (you might need to install xcode tools first).
Follow the CodeLLDB reference here
in a local .vscode
folder:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "zig build",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Here is an example launch.json
…
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/zig-out/bin/<yourbinaryname>",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "build"
}
]
}
And that’s it, you should be able to set up breakpoints and hit them when you launch.
I’m learning Zig, and I don’t know much about it yet, but everything appears to work. Watching locals, stack trace and view on the current variables all appear correct.
HTH.