authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-18 09:36:53-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-18 16:21:10-04:00
log49e60413913e365eeab666424bf1046baf4844de
treeaeaf606fa283597d6cbf56c4d6ef61cf2529eda2
parent10455371416a37da201b6f968d47ffae597ea7ce

Dwarf: fix and test unions


3 files changed, 67 insertions(+), 2 deletions(-)

ci/x86_64-linux-debug.sh+1-1
......@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \
6464
6565stage3-debug/bin/zig build test docs \
6666 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Debug/bin/lldb \
67 -Dlldb=$HOME/deps/lldb-zig/Debug-f96d3e6fc/bin/lldb \
6868 -fqemu \
6969 -fwasmtime \
7070 -Dstatic-llvm \
ci/x86_64-linux-release.sh+1-1
......@@ -64,7 +64,7 @@ stage3-release/bin/zig build \
6464
6565stage3-release/bin/zig build test docs \
6666 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Release/bin/lldb \
67 -Dlldb=$HOME/deps/lldb-zig/Release-f96d3e6fc/bin/lldb \
6868 -fqemu \
6969 -fwasmtime \
7070 -Dstatic-llvm \
test/src/Debugger.zig+65
......@@ -403,6 +403,71 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
403403 \\1 breakpoints deleted; 0 breakpoint locations disabled.
404404 },
405405 );
406 db.addLldbTest(
407 "unions",
408 target,
409 &.{
410 .{
411 .path = "unions.zig",
412 .source =
413 \\const Unions = struct {
414 \\ const Enum = enum { first, second, third };
415 \\ const Untagged = extern union {
416 \\ u32: u32,
417 \\ i32: i32,
418 \\ f32: f32,
419 \\ };
420 \\ const SafetyTagged = union {
421 \\ void: void,
422 \\ en: Enum,
423 \\ eu: error{Error}!Enum,
424 \\ };
425 \\ const Tagged = union(enum) {
426 \\ void: void,
427 \\ en: Enum,
428 \\ eu: error{Error}!Enum,
429 \\ };
430 \\
431 \\ untagged: Untagged = .{ .f32 = -1.5 },
432 \\ safety_tagged: SafetyTagged = .{ .en = .second },
433 \\ tagged: Tagged = .{ .eu = error.Error },
434 \\};
435 \\fn testUnions(unions: Unions) void {
436 \\ _ = unions;
437 \\}
438 \\pub fn main() void {
439 \\ testUnions(.{});
440 \\}
441 \\
442 ,
443 },
444 },
445 \\breakpoint set --file unions.zig --source-pattern-regexp '_ = unions;'
446 \\process launch
447 \\frame variable --show-types unions
448 \\breakpoint delete --force 1
449 ,
450 &.{
451 \\(lldb) frame variable --show-types unions
452 \\(root.unions.Unions) unions = {
453 \\ (root.unions.Unions.Untagged) untagged = {
454 \\ (u32) u32 = 3217031168
455 \\ (i32) i32 = -1077936128
456 \\ (f32) f32 = -1.5
457 \\ }
458 \\ (root.unions.Unions.SafetyTagged) safety_tagged = {
459 \\ (root.unions.Unions.Enum) en = .second
460 \\ }
461 \\ (root.unions.Unions.Tagged) tagged = {
462 \\ (error{Error}!root.unions.Unions.Enum) eu = {
463 \\ (error{Error}) error = error.Error
464 \\ }
465 \\ }
466 \\}
467 \\(lldb) breakpoint delete --force 1
468 \\1 breakpoints deleted; 0 breakpoint locations disabled.
469 },
470 );
406471 db.addLldbTest(
407472 "storage",
408473 target,