Skip to content

Debugging

Wyn supports source-level debugging with DWARF debug info.

Quick Start

bash
wyn debug app.wyn

This compiles your code at -O0 with full debug info and launches lldb.

Setting Breakpoints

(lldb) breakpoint set --file app.wyn --line 5
(lldb) run

The debugger maps machine addresses back to your .wyn source lines.

Inspecting Variables

Once stopped at a breakpoint, inspect local variables:

(lldb) frame variable
(lldb) print my_var

Wyn variables map to C locals, so lldb can display their values directly. Strings show as wyn_string_t structs — use print my_var->data to see the raw content.

Stepping Through Code

(lldb) step       # Step into function calls
(lldb) next       # Step over (stay in current function)
(lldb) continue   # Run until next breakpoint
(lldb) finish     # Run until current function returns

For quick debugging without lldb, use println and Log.debug:

wyn
Log.debug("processing item: ${item}")
println("count = ${count}")

Log.debug includes timestamps and is easy to grep for. Use Log for structured logging in production.

How It Works

When you use wyn debug, the compiler emits C code with #line directives that map back to your .wyn source, then compiles at -O0 -g to produce DWARF debug information:

  • Compile unit — your .wyn filename and directory
  • Subprograms — each function with line numbers
  • Line table — maps machine addresses to source lines

This is the same debug format used by C, C++, Rust, and Swift.

VS Code Integration

The Wyn VS Code extension provides syntax highlighting and basic language support. For debugging in VS Code, configure a launch.json that runs wyn debug with the CodeLLDB extension.

See Also

See Also

MIT License — v1.11