Display slices in the debugger

In zig repository there is a python pretty printer extension for lldb that can print slices, strings, optional, etc.: tools/lldb_pretty_printers.py

❯ lldb ./test
(lldb) target create "./test"
Current executable set to '/home/din/test' (x86_64).
(lldb) b main
Breakpoint 1: where = test`test.main + 8 at test.zig:4:5, address = 0x00000000010350d8
(lldb) r
Process 30732 launched: '/home/din/test' (x86_64)
Process 30732 stopped
* thread #1, name = 'test', stop reason = breakpoint 1.1
    frame #0: 0x00000000010350d8 test`test.main at test.zig:4:5
   1    const std = @import("std");
   2   
   3    pub fn main() void {
-> 4        const data: []const u8 = &[_]u8{ 'a', 'b', 'c' };
   5        std.debug.print("{s}", .{data});
   6    }
   7   
(lldb) s
Process 30732 stopped
* thread #1, name = 'test', stop reason = step in
    frame #0: 0x00000000010350e8 test`test.main at test.zig:5:20
   2   
   3    pub fn main() void {
   4        const data: []const u8 = &[_]u8{ 'a', 'b', 'c' };
-> 5        std.debug.print("{s}", .{data});
   6    }
   7   
(lldb) p data
([]u8) "abc"
(lldb) 
7 Likes