I’m debugging some slice-heavy code using lldb from VSCode, and it’s excessively difficult to follow, because the slices aren’t null-terminated, so the debugger displays arbitrary amounts of string, and I have to figure out how much of it actually belongs to the slice.
Is there a trick to get the slice.ptr section to display just the amount covered by slice.len?
Perfect, thank you. I figured there must be something like that available, but it isn’t configured into ZLS or the Zig Extras package for VSCode (or if it is, I don’t have my settings right). That’s going to make my life a lot easier.
As a breadcrumb for others who might be searching for LLDB pretty-printing, or how to display Zig data structures in the debugger, or other such phrases, this was fairly simple to add to VSCode.
In addition to the Zig Language plugin, you’ll want Zig Language Extras. This advice may become outdated at some point, if and when the main plugin adds debug functionality. A particularly useful feature of the extras plugin is launching a debug session from a test block, as well as just running them one block at a time in the editor.
With that configured, you’ll need a local copy of the Zig repo, or at least of the file linked in the marked reply. Add the commands you need from Settings like so: search LLDB, and find this field:
Just like in the top of the pretty-print script. You need to do it this way because the plugin won’t read your .lldbinit from the home directory. There may be a way to set that up, but I found this first, and it works fine.
That’s it, now your []const u8s look like strings and so on.