Debugging and Profiling
46.1 Debugging
std.debug.print, std.log, @src(), std.debug.dumpCurrentStackTrace(), @breakpoint(), @panic.
Error return traces and panic stack traces in Debug/ReleaseSafe.
Native debuggers: build Debug (the default), then gdb ./zig-out/bin/app or lldb. VS Code with CodeLLDB. Zig type pretty-printers ship in the Zig repo (tools/lldb_pretty_printers.py, gdb printers).
On Windows: Visual Studio / WinDbg with PDB files.
Memory: DebugAllocator reports (leaks with stack traces), Valgrind (std.valgrind client requests), AddressSanitizer for C parts, -fsanitize-thread.
Inspect generated code: -femit-asm, -femit-llvm-ir, Godbolt (Compiler Explorer supports Zig).
46.2 Profiling
perf (Linux) + flamegraphs, Tracy (via ztracy or tracy bindings: instrumented zones), Valgrind callgrind / KCachegrind, Instruments (macOS), VTune, samply, poop (Andrew Kelley's "performance optimizer observation platform" for comparing commands), hyperfine.
Build profiling binaries with -Doptimize=ReleaseFast (or ReleaseSafe) and debug info (-fno-strip, the default keeps symbols except in ReleaseSmall).
Micro-benchmarks with std.time.Timer and std.mem.doNotOptimizeAway(result).