Temporary chapter name for all chapters
the-debugger

If you already know how to debug code in your editor of choice, skip this.

We're not doing printf debugging in 2026. We hover the mouse over a variable and see its current value. We press F10 repeatedly and walk through the code as it runs. The debugger is the single best tool for understanding what your program is actually doing.

Install VS Code with three extensions: Zig Language, ZLS (Zig Language Server -- autocomplete and error highlighting), and CodeLLDB (breakpoints).

Create a .vscode folder in your project with this launch.json:

{
    "version": "0.2.0",
    "configurations": [{
        "type": "lldb",
        "request": "launch",
        "name": "Debug minizig",
        "program": "${workspaceFolder}/minizig.exe",
        "preLaunchTask": "build"
    }]
}

And this tasks.json:

{
    "version": "2.0.0",
    "tasks": [{
        "label": "build",
        "type": "shell",
        "command": "zig build-exe minizig.zig -lc"
    }]
}

(The -lc we'll explain in the next problem.)

Set a breakpoint, press F5, watch the program freeze. Hover over a variable to see its value.