From 49e60413913e365eeab666424bf1046baf4844de Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Aug 2024 09:36:53 -0400 Subject: [PATCH 1/2] 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 75616627b3..04431ba960 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 fd95d8eaf5..57f17bdc76 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 a97f723741..4a89bedaf3 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, From 9a64b80377139ee0b472b6f8525181cc19f0fce7 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 18 Aug 2024 13:59:00 -0400 Subject: [PATCH 2/2] Dwarf: test enums --- test/src/Debugger.zig | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/src/Debugger.zig b/test/src/Debugger.zig index 4a89bedaf3..2ff141dd84 100644 --- a/test/src/Debugger.zig +++ b/test/src/Debugger.zig @@ -305,6 +305,51 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { \\1 breakpoints deleted; 0 breakpoint locations disabled. }, ); + db.addLldbTest( + "enums", + target, + &.{ + .{ + .path = "enums.zig", + .source = + \\const Enums = struct { + \\ const Zero = enum(u4) { _ }; + \\ const One = enum { first }; + \\ const Two = enum(i32) { first, second, _ }; + \\ const Three = enum { first, second, third }; + \\ + \\ zero: Zero = @enumFromInt(13), + \\ one: One = .first, + \\ two: Two = @enumFromInt(-1234), + \\ three: Three = .second, + \\}; + \\fn testEnums(enums: Enums) void { + \\ _ = enums; + \\} + \\pub fn main() void { + \\ testEnums(.{}); + \\} + \\ + , + }, + }, + \\breakpoint set --file enums.zig --source-pattern-regexp '_ = enums;' + \\process launch + \\frame variable --show-types enums + \\breakpoint delete --force 1 + , + &.{ + \\(lldb) frame variable --show-types enums + \\(root.enums.Enums) enums = { + \\ (root.enums.Enums.Zero) zero = @enumFromInt(13) + \\ (root.enums.Enums.One) one = .first + \\ (root.enums.Enums.Two) two = @enumFromInt(-1234) + \\ (root.enums.Enums.Three) three = .second + \\} + \\(lldb) breakpoint delete --force 1 + \\1 breakpoints deleted; 0 breakpoint locations disabled. + }, + ); db.addLldbTest( "errors", target,