From 49e60413913e365eeab666424bf1046baf4844de Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Aug 2024 09:36:53 -0400 Subject: [PATCH] Dwarf: fix and test unions --- ci/x86_64-linux-debug.sh | 2 +- ci/x86_64-linux-release.sh | 2 +- test/src/Debugger.zig | 65 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/ci/x86_64-linux-debug.sh b/ci/x86_64-linux-debug.sh index 75616627b3be6e460bab27516e42bb6445195bd2..04431ba9606c18649dc120f23fd3f8a4fdee8285 100755 --- a/ci/x86_64-linux-debug.sh +++ b/ci/x86_64-linux-debug.sh @@ -64,7 +64,7 @@ stage3-debug/bin/zig build \ stage3-debug/bin/zig build test docs \ --maxrss 21000000000 \ - -Dlldb=$HOME/deps/lldb-zig/Debug/bin/lldb \ + -Dlldb=$HOME/deps/lldb-zig/Debug-f96d3e6fc/bin/lldb \ -fqemu \ -fwasmtime \ -Dstatic-llvm \ diff --git a/ci/x86_64-linux-release.sh b/ci/x86_64-linux-release.sh index fd95d8eaf5736b00a18cdaac5b32a3dcf2e47b42..57f17bdc76be51e8b70da6830572c33d60e45d64 100755 --- a/ci/x86_64-linux-release.sh +++ b/ci/x86_64-linux-release.sh @@ -64,7 +64,7 @@ stage3-release/bin/zig build \ stage3-release/bin/zig build test docs \ --maxrss 21000000000 \ - -Dlldb=$HOME/deps/lldb-zig/Release/bin/lldb \ + -Dlldb=$HOME/deps/lldb-zig/Release-f96d3e6fc/bin/lldb \ -fqemu \ -fwasmtime \ -Dstatic-llvm \ diff --git a/test/src/Debugger.zig b/test/src/Debugger.zig index a97f7237418a9069e6cda4278caab8905fb6d776..4a89bedaf3c495dafafe0154414e0ec6cd41703e 100644 --- a/test/src/Debugger.zig +++ b/test/src/Debugger.zig @@ -403,6 +403,71 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { \\1 breakpoints deleted; 0 breakpoint locations disabled. }, ); + db.addLldbTest( + "unions", + target, + &.{ + .{ + .path = "unions.zig", + .source = + \\const Unions = struct { + \\ const Enum = enum { first, second, third }; + \\ const Untagged = extern union { + \\ u32: u32, + \\ i32: i32, + \\ f32: f32, + \\ }; + \\ const SafetyTagged = union { + \\ void: void, + \\ en: Enum, + \\ eu: error{Error}!Enum, + \\ }; + \\ const Tagged = union(enum) { + \\ void: void, + \\ en: Enum, + \\ eu: error{Error}!Enum, + \\ }; + \\ + \\ untagged: Untagged = .{ .f32 = -1.5 }, + \\ safety_tagged: SafetyTagged = .{ .en = .second }, + \\ tagged: Tagged = .{ .eu = error.Error }, + \\}; + \\fn testUnions(unions: Unions) void { + \\ _ = unions; + \\} + \\pub fn main() void { + \\ testUnions(.{}); + \\} + \\ + , + }, + }, + \\breakpoint set --file unions.zig --source-pattern-regexp '_ = unions;' + \\process launch + \\frame variable --show-types unions + \\breakpoint delete --force 1 + , + &.{ + \\(lldb) frame variable --show-types unions + \\(root.unions.Unions) unions = { + \\ (root.unions.Unions.Untagged) untagged = { + \\ (u32) u32 = 3217031168 + \\ (i32) i32 = -1077936128 + \\ (f32) f32 = -1.5 + \\ } + \\ (root.unions.Unions.SafetyTagged) safety_tagged = { + \\ (root.unions.Unions.Enum) en = .second + \\ } + \\ (root.unions.Unions.Tagged) tagged = { + \\ (error{Error}!root.unions.Unions.Enum) eu = { + \\ (error{Error}) error = error.Error + \\ } + \\ } + \\} + \\(lldb) breakpoint delete --force 1 + \\1 breakpoints deleted; 0 breakpoint locations disabled. + }, + ); db.addLldbTest( "storage", target, -- 2.54.0