aboutsummaryrefslogtreecommitdiff
path: root/lib/std/multi_array_list.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-02-26 22:11:41 -0500
committerJacob Young <jacobly0@users.noreply.github.com>2023-02-27 05:37:03 -0500
commita3529c2dea579e0a15dcde1b8ee71d9ec9c75330 (patch)
treea06d6819520fbecc5c5c8d64de7739ac528ab280 /lib/std/multi_array_list.zig
parent9e519727014fcc484714d8230a0a8bce8744998d (diff)
downloadzig-a3529c2dea579e0a15dcde1b8ee71d9ec9c75330.tar.gz
zig-a3529c2dea579e0a15dcde1b8ee71d9ec9c75330.zip
tools: implement more lldb pretty printers
Diffstat (limited to 'lib/std/multi_array_list.zig')
-rw-r--r--lib/std/multi_array_list.zig29
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig
index 56b36aaa81..6965205b1e 100644
--- a/lib/std/multi_array_list.zig
+++ b/lib/std/multi_array_list.zig
@@ -131,8 +131,8 @@ pub fn MultiArrayList(comptime S: type) type {
.capacity = self.capacity,
};
var ptr: [*]u8 = self.bytes;
- for (sizes.bytes, 0..) |field_size, i| {
- result.ptrs[sizes.fields[i]] = ptr;
+ for (sizes.bytes, sizes.fields) |field_size, i| {
+ result.ptrs[i] = ptr;
ptr += field_size * self.capacity;
}
return result;
@@ -446,16 +446,33 @@ pub fn MultiArrayList(comptime S: type) type {
return meta.fieldInfo(S, field).type;
}
- /// This function is used in tools/zig-gdb.py to fetch the child type to facilitate
- /// fancy debug printing for this type.
- fn gdbHelper(self: *Self, child: *S) void {
+ const Entry = entry: {
+ var entry_fields: [fields.len]std.builtin.Type.StructField = undefined;
+ for (&entry_fields, sizes.fields) |*entry_field, i| entry_field.* = .{
+ .name = fields[i].name ++ "_ptr",
+ .type = *fields[i].type,
+ .default_value = null,
+ .is_comptime = fields[i].is_comptime,
+ .alignment = fields[i].alignment,
+ };
+ break :entry @Type(.{ .Struct = .{
+ .layout = .Extern,
+ .fields = &entry_fields,
+ .decls = &.{},
+ .is_tuple = false,
+ } });
+ };
+ /// This function is used in the debugger pretty formatters in tools/ to fetch the
+ /// child type to facilitate fancy debug printing for this type.
+ fn dbHelper(self: *Self, child: *S, entry: *Entry) void {
_ = self;
_ = child;
+ _ = entry;
}
comptime {
if (builtin.mode == .Debug) {
- _ = gdbHelper;
+ _ = dbHelper;
}
}
};