Skip to content

Instantly share code, notes, and snippets.

@jdomzhang
Forked from floooh/zig_test_debugging_vscode.md
Last active August 28, 2022 08:28
Show Gist options
  • Save jdomzhang/3888ab84f4e99c8897aba3c497c8a43c to your computer and use it in GitHub Desktop.
Save jdomzhang/3888ab84f4e99c8897aba3c497c8a43c to your computer and use it in GitHub Desktop.
How to debug Zig in VSCode

Tested on macOS:

  1. Install the CodeLLDB VSCode extension. Unlike the debugger in the C/C++ extension, this allows to set breakpoints inside Zig "test" blocks (in the MS C/C++ extension debugger, breakpoints inside test blocks will be disabled once the debugger starts for unknown reasons.
  2. Set the program field with the build output, in this example it's hello. Full launch.json looks like:
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug",
            "program": "${workspaceFolder}/zig-out/bin/hello",
            "args": [],
            "cwd": "${workspaceFolder}",
            
        }
    ]
}

That should be all, now set breakpoints in you code, and start the debugger in vscode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment