Zig Debugging
Purpose
Guide agents through debugging Zig programs: GDB/LLDB sessions, interpreting Zig panics and error return traces, std.debug.print logging, debug build configuration, and IDE integration.
Triggers
- "How do I debug a Zig program with GDB?"
- "How do I interpret a Zig panic message?"
- "How do I use std.debug.print for debugging?"
- "Zig is showing an error return trace — what does it mean?"
- "How do I set up Zig debugging in VS Code?"
- "How do I get a stack trace from a Zig crash?"
Workflow
1. Build for debugging
2. GDB with Zig
Zig emits standard DWARF debug information compatible with GDB:
Break on Zig panics:
3. LLDB with Zig
4. Interpreting Zig panics
Zig panics include the source location and reason:
Common panic messages:
5. Error return traces
Zig tracks where errors propagate with error return traces:
The trace shows the exact try chain where the error propagated. Read bottom-up: main → run → openConfig.
Enable in release builds:
6. std.debug.print for tracing
7. std.log configuration
8. VS Code / IDE integration
Install the zig.vscode-zig extension and CodeLLDB.
.vscode/launch.json:
.vscode/tasks.json:
Related skills
- Use
skills/zig/zig-compilerfor build modes and debug info flags - Use
skills/debuggers/gdbfor GDB fundamentals - Use
skills/debuggers/lldbfor LLDB fundamentals - Use
skills/zig/zig-cinteropwhen debugging mixed Zig/C code


