Hacking LLDB for a great Zig debugging experience

Debugging Zig in LLDB is painful.

Slices show up as { ptr, len }, optionals are unreadable, and slice[0] just errors out. Python formatters help a bit but don’t fix expressions. zig-lldb fixes everything… if you’re willing to rebuild LLDB and maintain a fork.

zdb is a native LLDB plugin that sits in the middle:

  • Works with stock LLDB (Homebrew / system)
  • Native C++ type summaries (no Python)
  • Zig-style expressions work: slice[0], opt.?, err catch x
(lldb) p int_slice[0]
(int) $0 = 1

How? By calling LLDB’s internal APIs via versioned offset tables and rewriting expressions on the fly.

Limitations: no Variables View expansion (ABI issues with std::function). CLI debugging works great.

Check out the Github repo and the blog post I wrote about it.

3 Likes

nice work!

1 Like

There seems to be some duplicatied infomation of []u8 and ArrayList in the example. Are there any potential optimizations?

Surely. I have not tried optimizing things yet.

Nice! Gonna check this out soon :slight_smile: Thanks

1 Like
2 Likes

I’m in love with the small binaries that Zig produces!

I rewrote another project of mine in Zig and it was 1.2mb against Rust’s 14mb+ for the release-mode binary.

Pushed a bunch of fixes.

Sigh the AI slop blog post got jacobly’s name wrong.

I dunno man, to each their own, but pushing onto people your AI slop code with a side of AI slop blog post is in my opinion very poor manners.

7 Likes

I’m not pushing anything on anyone.

To each their own and to me — working software that solves my problems, regardless of how it was produced!

P.S Fixed Jacob’s name, it’s my oversight!

The problem is not that the code is AI generated, the problem is that it’s slop. Your blog post is slop, and the repo has a good dose of suboptimal choices and non sequiturs.

Zig communities exist so that those who take part to them can learn how to become better programmers. People reading your AI slop code will not learn good practices, and conversely mistakes in your code are not worth pointing out because your AI agent certainly won’t learn anything, and given that you can’t take a hint, chances are that you won’t learn anything either.

Edit forgot to link also this classic.

5 Likes