Skip to content

load Zig's LLDB pretty printers when debugging with CodeLLDB - #46

Open
lejmr wants to merge 1 commit into
zed-extensions:mainfrom
lejmr:lldb-pretty-printers
Open

load Zig's LLDB pretty printers when debugging with CodeLLDB#46
lejmr wants to merge 1 commit into
zed-extensions:mainfrom
lejmr:lldb-pretty-printers

Conversation

@lejmr

@lejmr lejmr commented Aug 9, 2026

Copy link
Copy Markdown

Before: debugging Zig in Zed shows slices and std containers as raw ptr / len / capacity fields.

After:

parts = std.ArrayList(Ast.Node) len=3 capacity=4
  items = []Ast.Node len=3
    [0] = {children:len=0, value:"b", kind:value}

Zig already ships LLDB formatters for this (tools/lldb_pretty_printers.py, MIT). This PR bundles the script, materializes it into the extension's work directory when a CodeLLDB scenario is created, and loads it via initCommands.

Two details worth a reviewer's eye:

  • The commands are routed through script + HandleCommand, because a directly failing initCommand aborts the whole CodeLLDB launch — this way a missing/broken script only logs to the debug console and the session runs as before.
  • On top of the upstream script there is a small marked section (# Zed zig extension additions) that puts the type into the summary (std.ArrayList(T) len=…) — Zed's Variables panel doesn't render the DAP type field — and registers the string summary for []const u8 (upstream only covers []u8).

Works with any scenario the locator creates (zig test from the gutter, zig build run); combined with #44 it makes test debugging actually pleasant.

Example:
image

Without type formatters, slices and std containers show up in the debugger's
variable list as raw ptr/len/capacity fields. Zig ships LLDB formatters
(tools/lldb_pretty_printers.py) that render slices, ArrayList, optionals,
error unions and more as structured values.

Bundle the script with the extension, materialize it into the extension's
work directory when a CodeLLDB debug scenario is created, and load it via
initCommands. The commands are routed through `script` + HandleCommand
because a directly failing initCommand aborts the whole launch in CodeLLDB;
this way a missing or broken script only prints an error to the debug
console and the session runs as before.
@cla-bot cla-bot Bot added the cla-signed label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant