Skip to content

Instantly share code, notes, and snippets.

@secondspass
Created July 7, 2023 16:28
Show Gist options
  • Save secondspass/cc3ffa376458adaf22e6951cd8af2863 to your computer and use it in GitHub Desktop.
Save secondspass/cc3ffa376458adaf22e6951cd8af2863 to your computer and use it in GitHub Desktop.
printing slice with lldb in zig
const std = @import("std");
pub fn main() !void {
const allocator = std.heap.page_allocator;
var blah: []u8 = try allocator.alloc(u8, 30);
for (blah, 0..) |_, i| {
blah[i] = @intCast(i);
}
}
(lldb)
Process 60644 stopped
* thread #1, stop reason = step over
frame #0: 0x0000000100000759 example`example.main at example.zig:6:16
3 pub fn main() !void {
4 const allocator = std.heap.page_allocator;
5 var blah: []u8 = try allocator.alloc(u8, 30);
-> 6 for (blah, 0..) |_, i| {
7 blah[i] = @intCast(i);
8 }
9 }
Target 0: (example) stopped.
(lldb) p blah
([]u8) $0 = (ptr = "", len = 30)
(lldb) p blah[0]
error: <user expression 1>:1:5: type '[]u8' does not provide a subscript operator
blah[0]
~~~~^~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment