Dwarf: fix and test unions

This commit is contained in:
Jacob Young 2024-08-18 09:36:53 -04:00
parent 1045537141
commit 49e6041391
3 changed files with 67 additions and 2 deletions

View File

@ -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 \

View File

@ -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 \

View File

@ -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,