load Zig's LLDB pretty printers when debugging with CodeLLDB - #46
Open
lejmr wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: debugging Zig in Zed shows slices and std containers as raw
ptr / len / capacityfields.After:
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 viainitCommands.Two details worth a reviewer's eye:
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.# Zed zig extension additions) that puts the type into the summary (std.ArrayList(T) len=…) — Zed's Variables panel doesn't render the DAPtypefield — and registers the string summary for[]const u8(upstream only covers[]u8).Works with any scenario the locator creates (
zig testfrom the gutter,zig build run); combined with #44 it makes test debugging actually pleasant.Example:
