diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-08-17 18:47:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-17 18:47:27 -0400 |
| commit | 2b05e85107dd1c637ab40f8b145b232d18e8d6c6 (patch) | |
| tree | 900da9abde9fd672a2e618e2b8f7233c71eab403 /test/src/Debugger.zig | |
| parent | cf939b096acfca67c87b698827f64d977853d722 (diff) | |
| parent | d4e3d0e676fefbe7cf3ba15576ba9574e73a6449 (diff) | |
| download | zig-2b05e85107dd1c637ab40f8b145b232d18e8d6c6.tar.gz zig-2b05e85107dd1c637ab40f8b145b232d18e8d6c6.zip | |
Merge pull request #21111 from jacobly0/self-dwarf
Dwarf: debug info progress
Diffstat (limited to 'test/src/Debugger.zig')
| -rw-r--r-- | test/src/Debugger.zig | 280 |
1 files changed, 206 insertions, 74 deletions
diff --git a/test/src/Debugger.zig b/test/src/Debugger.zig index 7360f77851..a97f723741 100644 --- a/test/src/Debugger.zig +++ b/test/src/Debugger.zig @@ -183,114 +183,171 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { }, ); db.addLldbTest( - "storage", + "pointers", target, &.{ .{ - .path = "storage.zig", + .path = "pointers.zig", .source = - \\const global_const: u64 = 0x19e50dc8d6002077; - \\var global_var: u64 = 0xcc423cec08622e32; - \\threadlocal var global_threadlocal1: u64 = 0xb4d643528c042121; - \\threadlocal var global_threadlocal2: u64 = 0x43faea1cf5ad7a22; - \\fn testStorage( - \\ param1: u64, - \\ param2: u64, - \\ param3: u64, - \\ param4: u64, - \\ param5: u64, - \\ param6: u64, - \\ param7: u64, - \\ param8: u64, - \\) callconv(.C) void { - \\ const local_comptime_val: u64 = global_const *% global_const; - \\ const local_comptime_ptr: struct { u64 } = .{ local_comptime_val *% local_comptime_val }; - \\ const local_const: u64 = global_var ^ global_threadlocal1 ^ global_threadlocal2 ^ - \\ param1 ^ param2 ^ param3 ^ param4 ^ param5 ^ param6 ^ param7 ^ param8; - \\ var local_var: u64 = local_comptime_ptr[0] ^ local_const; - \\ local_var = local_var; + \\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 { - \\ testStorage( - \\ 0x6a607e08125c7e00, - \\ 0x98944cb2a45a8b51, - \\ 0xa320cf10601ee6fb, - \\ 0x691ed3535bad3274, - \\ 0x63690e6867a5799f, - \\ 0x8e163f0ec76067f2, - \\ 0xf9a252c455fb4c06, - \\ 0xc88533722601e481, - \\ ); + \\ testPointers(.{}); \\} \\ , }, }, - \\breakpoint set --file storage.zig --source-pattern-regexp 'local_var = local_var;' + \\breakpoint set --file pointers.zig --source-pattern-regexp '_ = pointers;' \\process launch - \\target variable --show-types --format hex global_const global_var global_threadlocal1 global_threadlocal2 - \\frame variable --show-types --format hex param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val local_comptime_ptr.0 local_const local_var + \\frame variable --show-types pointers \\breakpoint delete --force 1 , &.{ - \\(lldb) target variable --show-types --format hex global_const global_var global_threadlocal1 global_threadlocal2 - \\(u64) global_const = 0x19e50dc8d6002077 - \\(u64) global_var = 0xcc423cec08622e32 - \\(u64) global_threadlocal1 = 0xb4d643528c042121 - \\(u64) global_threadlocal2 = 0x43faea1cf5ad7a22 - \\(lldb) frame variable --show-types --format hex param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val local_comptime_ptr.0 local_const local_var - \\(u64) param1 = 0x6a607e08125c7e00 - \\(u64) param2 = 0x98944cb2a45a8b51 - \\(u64) param3 = 0xa320cf10601ee6fb - \\(u64) param4 = 0x691ed3535bad3274 - \\(u64) param5 = 0x63690e6867a5799f - \\(u64) param6 = 0x8e163f0ec76067f2 - \\(u64) param7 = 0xf9a252c455fb4c06 - \\(u64) param8 = 0xc88533722601e481 - \\(u64) local_comptime_val = 0x69490636f81df751 - \\(u64) local_comptime_ptr.0 = 0x82e834dae74767a1 - \\(u64) local_const = 0xdffceb8b2f41e205 - \\(u64) local_var = 0x5d14df51c80685a4 + \\(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( - "slices", + "errors", target, &.{ .{ - .path = "slices.zig", + .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 { - \\ { - \\ var array: [4]u32 = .{ 1, 2, 4, 8 }; - \\ const slice: []u32 = &array; - \\ _ = slice; - \\ } + \\ testErrors(.{}); \\} \\ , }, }, - \\breakpoint set --file slices.zig --source-pattern-regexp '_ = slice;' + \\breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;' \\process launch - \\frame variable --show-types array slice + \\frame variable --show-types errors \\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) 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. @@ -347,6 +404,79 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { }, ); db.addLldbTest( + "storage", + target, + &.{ + .{ + .path = "storage.zig", + .source = + \\const global_const: u64 = 0x19e50dc8d6002077; + \\var global_var: u64 = 0xcc423cec08622e32; + \\threadlocal var global_threadlocal1: u64 = 0xb4d643528c042121; + \\threadlocal var global_threadlocal2: u64 = 0x43faea1cf5ad7a22; + \\fn testStorage( + \\ param1: u64, + \\ param2: u64, + \\ param3: u64, + \\ param4: u64, + \\ param5: u64, + \\ param6: u64, + \\ param7: u64, + \\ param8: u64, + \\) callconv(.C) void { + \\ const local_comptime_val: u64 = global_const *% global_const; + \\ const local_comptime_ptr: struct { u64 } = .{ local_comptime_val *% local_comptime_val }; + \\ const local_const: u64 = global_var ^ global_threadlocal1 ^ global_threadlocal2 ^ + \\ param1 ^ param2 ^ param3 ^ param4 ^ param5 ^ param6 ^ param7 ^ param8; + \\ var local_var: u64 = local_comptime_ptr[0] ^ local_const; + \\ local_var = local_var; + \\} + \\pub fn main() void { + \\ testStorage( + \\ 0x6a607e08125c7e00, + \\ 0x98944cb2a45a8b51, + \\ 0xa320cf10601ee6fb, + \\ 0x691ed3535bad3274, + \\ 0x63690e6867a5799f, + \\ 0x8e163f0ec76067f2, + \\ 0xf9a252c455fb4c06, + \\ 0xc88533722601e481, + \\ ); + \\} + \\ + , + }, + }, + \\breakpoint set --file storage.zig --source-pattern-regexp 'local_var = local_var;' + \\process launch + \\target variable --show-types --format hex global_const global_var global_threadlocal1 global_threadlocal2 + \\frame variable --show-types --format hex param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val local_comptime_ptr.0 local_const local_var + \\breakpoint delete --force 1 + , + &.{ + \\(lldb) target variable --show-types --format hex global_const global_var global_threadlocal1 global_threadlocal2 + \\(u64) global_const = 0x19e50dc8d6002077 + \\(u64) global_var = 0xcc423cec08622e32 + \\(u64) global_threadlocal1 = 0xb4d643528c042121 + \\(u64) global_threadlocal2 = 0x43faea1cf5ad7a22 + \\(lldb) frame variable --show-types --format hex param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val local_comptime_ptr.0 local_const local_var + \\(u64) param1 = 0x6a607e08125c7e00 + \\(u64) param2 = 0x98944cb2a45a8b51 + \\(u64) param3 = 0xa320cf10601ee6fb + \\(u64) param4 = 0x691ed3535bad3274 + \\(u64) param5 = 0x63690e6867a5799f + \\(u64) param6 = 0x8e163f0ec76067f2 + \\(u64) param7 = 0xf9a252c455fb4c06 + \\(u64) param8 = 0xc88533722601e481 + \\(u64) local_comptime_val = 0x69490636f81df751 + \\(u64) local_comptime_ptr.0 = 0x82e834dae74767a1 + \\(u64) local_const = 0xdffceb8b2f41e205 + \\(u64) local_var = 0x5d14df51c80685a4 + \\(lldb) breakpoint delete --force 1 + \\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; \\} + \\ , }, }, |
