Merge pull request #21111 from jacobly0/self-dwarf

Dwarf: debug info progress
This commit is contained in:
Jacob Young 2024-08-17 18:47:27 -04:00 committed by GitHub
commit 2b05e85107
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 227 additions and 98 deletions

View File

@ -224,7 +224,6 @@ pub const ZIG_parent = 0x2ccd;
pub const ZIG_padding = 0x2cce;
pub const ZIG_relative_decl = 0x2cd0;
pub const ZIG_decl_line_relative = 0x2cd1;
pub const ZIG_is_allowzero = 0x2ce1;
pub const ZIG_sentinel = 0x2ce2;
// UPC extension.

View File

@ -2338,7 +2338,6 @@ fn updateType(
const ptr_child_type = Type.fromInterned(ptr_type.child);
try uleb128(diw, @intFromEnum(AbbrevCode.ptr_type));
try wip_nav.strp(name);
try diw.writeByte(@intFromBool(ptr_type.flags.is_allowzero));
try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse
ptr_child_type.abiAlignment(pt).toByteUnits().?);
try diw.writeByte(@intFromEnum(ptr_type.flags.address_space));
@ -2486,10 +2485,10 @@ fn updateType(
{
try uleb128(diw, @intFromEnum(AbbrevCode.generated_field));
try wip_nav.strp("is_error");
const is_error_field_type = Type.fromInterned(try pt.intern(.{
.opt_type = error_union_type.error_set_type,
}));
try wip_nav.refType(is_error_field_type);
try wip_nav.refType(Type.fromInterned(try pt.intern(.{ .int_type = .{
.signedness = .unsigned,
.bits = pt.zcu.errorSetBits(),
} })));
try uleb128(diw, error_union_error_set_offset);
try uleb128(diw, @intFromEnum(AbbrevCode.unsigned_tagged_union_field));
@ -3612,7 +3611,6 @@ const AbbrevCode = enum(u8) {
.tag = .pointer_type,
.attrs = &.{
.{ .name, .strp },
.{ .ZIG_is_allowzero, .flag },
.{ .alignment, .udata },
.{ .address_class, .data1 },
.{ .type, .ref_addr },

View File

@ -182,6 +182,227 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\1 breakpoints deleted; 0 breakpoint locations disabled.
},
);
db.addLldbTest(
"pointers",
target,
&.{
.{
.path = "pointers.zig",
.source =
\\const Pointers = struct {
\\ var array: [7]u32 = .{
\\ 3010,
\\ 3014,
\\ 3018,
\\ 3022,
\\ 3026,
\\ 3030,
\\ 3034,
\\ };
\\
\\ single: *u32 = @ptrFromInt(0x1010),
\\ single_const: *const u32 = @ptrFromInt(0x1014),
\\ single_volatile: *volatile u32 = @ptrFromInt(0x1018),
\\ single_const_volatile: *const volatile u32 = @ptrFromInt(0x101c),
\\ single_allowzero: *allowzero u32 = @ptrFromInt(0x1020),
\\ single_const_allowzero: *const allowzero u32 = @ptrFromInt(0x1024),
\\ single_volatile_allowzero: *volatile allowzero u32 = @ptrFromInt(0x1028),
\\ single_const_volatile_allowzero: *const volatile allowzero u32 = @ptrFromInt(0x102c),
\\
\\ many: [*]u32 = @ptrFromInt(0x2010),
\\ many_const: [*]const u32 = @ptrFromInt(0x2014),
\\ many_volatile: [*]volatile u32 = @ptrFromInt(0x2018),
\\ many_const_volatile: [*]const volatile u32 = @ptrFromInt(0x201c),
\\ many_allowzero: [*]allowzero u32 = @ptrFromInt(0x2020),
\\ many_const_allowzero: [*]const allowzero u32 = @ptrFromInt(0x2024),
\\ many_volatile_allowzero: [*]volatile allowzero u32 = @ptrFromInt(0x2028),
\\ many_const_volatile_allowzero: [*]const volatile allowzero u32 = @ptrFromInt(0x202c),
\\ slice: []u32 = array[0..1],
\\ slice_const: []const u32 = array[0..2],
\\ slice_volatile: []volatile u32 = array[0..3],
\\ slice_const_volatile: []const volatile u32 = array[0..4],
\\ slice_allowzero: []allowzero u32 = array[4..4],
\\ slice_const_allowzero: []const allowzero u32 = array[4..5],
\\ slice_volatile_allowzero: []volatile allowzero u32 = array[4..6],
\\ slice_const_volatile_allowzero: []const volatile allowzero u32 = array[4..7],
\\
\\ c: [*c]u32 = @ptrFromInt(0x4010),
\\ c_const: [*c]const u32 = @ptrFromInt(0x4014),
\\ c_volatile: [*c]volatile u32 = @ptrFromInt(0x4018),
\\ c_const_volatile: [*c]const volatile u32 = @ptrFromInt(0x401c),
\\};
\\fn testPointers(pointers: Pointers) void {
\\ _ = pointers;
\\}
\\pub fn main() void {
\\ testPointers(.{});
\\}
\\
,
},
},
\\breakpoint set --file pointers.zig --source-pattern-regexp '_ = pointers;'
\\process launch
\\frame variable --show-types pointers
\\breakpoint delete --force 1
,
&.{
\\(lldb) frame variable --show-types pointers
\\(root.pointers.Pointers) pointers = {
\\ (*u32) single = 0x0000000000001010
\\ (*const u32) single_const = 0x0000000000001014
\\ (*volatile u32) single_volatile = 0x0000000000001018
\\ (*const volatile u32) single_const_volatile = 0x000000000000101c
\\ (*allowzero u32) single_allowzero = 0x0000000000001020
\\ (*const allowzero u32) single_const_allowzero = 0x0000000000001024
\\ (*volatile allowzero u32) single_volatile_allowzero = 0x0000000000001028
\\ (*const volatile allowzero u32) single_const_volatile_allowzero = 0x000000000000102c
\\ ([*]u32) many = 0x0000000000002010
\\ ([*]const u32) many_const = 0x0000000000002014
\\ ([*]volatile u32) many_volatile = 0x0000000000002018
\\ ([*]const volatile u32) many_const_volatile = 0x000000000000201c
\\ ([*]allowzero u32) many_allowzero = 0x0000000000002020
\\ ([*]const allowzero u32) many_const_allowzero = 0x0000000000002024
\\ ([*]volatile allowzero u32) many_volatile_allowzero = 0x0000000000002028
\\ ([*]const volatile allowzero u32) many_const_volatile_allowzero = 0x000000000000202c
\\ ([]u32) slice = len=1 {
\\ (u32) [0] = 3010
\\ }
\\ ([]const u32) slice_const = len=2 {
\\ (u32) [0] = 3010
\\ (u32) [1] = 3014
\\ }
\\ ([]volatile u32) slice_volatile = len=3 {
\\ (u32) [0] = 3010
\\ (u32) [1] = 3014
\\ (u32) [2] = 3018
\\ }
\\ ([]const volatile u32) slice_const_volatile = len=4 {
\\ (u32) [0] = 3010
\\ (u32) [1] = 3014
\\ (u32) [2] = 3018
\\ (u32) [3] = 3022
\\ }
\\ ([]allowzero u32) slice_allowzero = len=0 {}
\\ ([]const allowzero u32) slice_const_allowzero = len=1 {
\\ (u32) [0] = 3026
\\ }
\\ ([]volatile allowzero u32) slice_volatile_allowzero = len=2 {
\\ (u32) [0] = 3026
\\ (u32) [1] = 3030
\\ }
\\ ([]const volatile allowzero u32) slice_const_volatile_allowzero = len=3 {
\\ (u32) [0] = 3026
\\ (u32) [1] = 3030
\\ (u32) [2] = 3034
\\ }
\\ ([*c]u32) c = 0x0000000000004010
\\ ([*c]const u32) c_const = 0x0000000000004014
\\ ([*c]volatile u32) c_volatile = 0x0000000000004018
\\ ([*c]const volatile u32) c_const_volatile = 0x000000000000401c
\\}
\\(lldb) breakpoint delete --force 1
\\1 breakpoints deleted; 0 breakpoint locations disabled.
},
);
db.addLldbTest(
"errors",
target,
&.{
.{
.path = "errors.zig",
.source =
\\const Errors = struct {
\\ one: error{One} = error.One,
\\ two: error{One,Two} = error.Two,
\\ three: error{One,Two,Three} = error.Three,
\\ any: anyerror = error.Any,
\\ any_void: anyerror!void = error.NotVoid,
\\ any_u32: error{One}!u32 = 42,
\\};
\\fn testErrors(errors: Errors) void {
\\ _ = errors;
\\}
\\pub fn main() void {
\\ testErrors(.{});
\\}
\\
,
},
},
\\breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;'
\\process launch
\\frame variable --show-types errors
\\breakpoint delete --force 1
,
&.{
\\(lldb) frame variable --show-types errors
\\(root.errors.Errors) errors = {
\\ (error{One}) one = error.One
\\ (error{One,Two}) two = error.Two
\\ (error{One,Two,Three}) three = error.Three
\\ (anyerror) any = error.Any
\\ (anyerror!void) any_void = {
\\ (anyerror) error = error.NotVoid
\\ }
\\ (error{One}!u32) any_u32 = {
\\ (u32) value = 42
\\ }
\\}
\\(lldb) breakpoint delete --force 1
\\1 breakpoints deleted; 0 breakpoint locations disabled.
},
);
db.addLldbTest(
"optionals",
target,
&.{
.{
.path = "optionals.zig",
.source =
\\pub fn main() void {
\\ {
\\ var null_u32: ?u32 = null;
\\ var maybe_u32: ?u32 = null;
\\ var nonnull_u32: ?u32 = 456;
\\ maybe_u32 = 123;
\\ _ = .{ &null_u32, &nonnull_u32 };
\\ }
\\}
\\
,
},
},
\\breakpoint set --file optionals.zig --source-pattern-regexp 'maybe_u32 = 123;'
\\process launch
\\frame variable null_u32 maybe_u32 nonnull_u32
\\breakpoint delete --force 1
\\
\\breakpoint set --file optionals.zig --source-pattern-regexp '_ = .{ &null_u32, &nonnull_u32 };'
\\process continue
\\frame variable --show-types null_u32 maybe_u32 nonnull_u32
\\breakpoint delete --force 2
,
&.{
\\(lldb) frame variable null_u32 maybe_u32 nonnull_u32
\\(?u32) null_u32 = null
\\(?u32) maybe_u32 = null
\\(?u32) nonnull_u32 = (nonnull_u32.? = 456)
\\(lldb) breakpoint delete --force 1
\\1 breakpoints deleted; 0 breakpoint locations disabled.
,
\\(lldb) frame variable --show-types null_u32 maybe_u32 nonnull_u32
\\(?u32) null_u32 = null
\\(?u32) maybe_u32 = {
\\ (u32) maybe_u32.? = 123
\\}
\\(?u32) nonnull_u32 = {
\\ (u32) nonnull_u32.? = 456
\\}
\\(lldb) breakpoint delete --force 2
\\1 breakpoints deleted; 0 breakpoint locations disabled.
},
);
db.addLldbTest(
"storage",
target,
@ -255,97 +476,6 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\1 breakpoints deleted; 0 breakpoint locations disabled.
},
);
db.addLldbTest(
"slices",
target,
&.{
.{
.path = "slices.zig",
.source =
\\pub fn main() void {
\\ {
\\ var array: [4]u32 = .{ 1, 2, 4, 8 };
\\ const slice: []u32 = &array;
\\ _ = slice;
\\ }
\\}
\\
,
},
},
\\breakpoint set --file slices.zig --source-pattern-regexp '_ = slice;'
\\process launch
\\frame variable --show-types array slice
\\breakpoint delete --force 1
,
&.{
\\(lldb) frame variable --show-types array slice
\\([4]u32) array = {
\\ (u32) [0] = 1
\\ (u32) [1] = 2
\\ (u32) [2] = 4
\\ (u32) [3] = 8
\\}
\\([]u32) slice = {
\\ (u32) [0] = 1
\\ (u32) [1] = 2
\\ (u32) [2] = 4
\\ (u32) [3] = 8
\\}
\\(lldb) breakpoint delete --force 1
\\1 breakpoints deleted; 0 breakpoint locations disabled.
},
);
db.addLldbTest(
"optionals",
target,
&.{
.{
.path = "optionals.zig",
.source =
\\pub fn main() void {
\\ {
\\ var null_u32: ?u32 = null;
\\ var maybe_u32: ?u32 = null;
\\ var nonnull_u32: ?u32 = 456;
\\ maybe_u32 = 123;
\\ _ = .{ &null_u32, &nonnull_u32 };
\\ }
\\}
\\
,
},
},
\\breakpoint set --file optionals.zig --source-pattern-regexp 'maybe_u32 = 123;'
\\process launch
\\frame variable null_u32 maybe_u32 nonnull_u32
\\breakpoint delete --force 1
\\
\\breakpoint set --file optionals.zig --source-pattern-regexp '_ = .{ &null_u32, &nonnull_u32 };'
\\process continue
\\frame variable --show-types null_u32 maybe_u32 nonnull_u32
\\breakpoint delete --force 2
,
&.{
\\(lldb) frame variable null_u32 maybe_u32 nonnull_u32
\\(?u32) null_u32 = null
\\(?u32) maybe_u32 = null
\\(?u32) nonnull_u32 = (nonnull_u32.? = 456)
\\(lldb) breakpoint delete --force 1
\\1 breakpoints deleted; 0 breakpoint locations disabled.
,
\\(lldb) frame variable --show-types null_u32 maybe_u32 nonnull_u32
\\(?u32) null_u32 = null
\\(?u32) maybe_u32 = {
\\ (u32) maybe_u32.? = 123
\\}
\\(?u32) nonnull_u32 = {
\\ (u32) nonnull_u32.? = 456
\\}
\\(lldb) breakpoint delete --force 2
\\1 breakpoints deleted; 0 breakpoint locations disabled.
},
);
db.addLldbTest(
"cross_module_call",
target,
@ -358,6 +488,7 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\ module.foo(123);
\\ module.bar(456);
\\}
\\
,
},
.{
@ -370,6 +501,7 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\pub inline fn bar(y: u32) void {
\\ _ = y;
\\}
\\
,
},
},