Skip to main content

Debugging

General Tools

These tools are optional but recommended for a smooth development process.

Visual Studio Code

Setting up Debug Tasks

If you use VS Code, you should install the Zig Language extension. It can use your installed versions of Zig and ZLS, or it can download and manage its own internal versions.

You can use CodeLLDB to debug Zig code with lldb in VS Code's debugging GUI. If you'd like to automatically build the project before running the debugger, you'll need a zig build task.

{
"version": "2.0.0",
"tasks": [{
"label": "zig build",
"type": "shell",
"command": "zig",
"args": ["build", "--summary", "all"],
"options": { "cwd": "${workspaceRoot}" },
"presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": true, "clear": false },
"problemMatcher": [],
"group": { "kind": "build", "isDefault": true }
}]
}

To run the debugger, you need a run configuration. This launch.json includes an example for debugging gossip. Customize the args as desired.

{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug Gossip Mainnet",
"program": "${workspaceFolder}/zig-out/bin/sig",
"args": [
"gossip",
"--network",
"mainnet"
],
"cwd": "${workspaceFolder}",
"preLaunchTask": "zig build"
}
]
}