From 655bee8c75c19b82b8f2c730feec857e85e4991b Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Fri, 2 Oct 2026 08:58:00 -0400 Subject: [PATCH] test: convert debugger tests to new runner --- build.zig | 27 +- ci/x86_64-linux-debug-llvm.sh | 2 +- ci/x86_64-linux-debug.sh | 2 +- ci/x86_64-linux-release.sh | 2 +- lib/lldb/pretty_printers.py | 10 +- test/debugger/basic/basic.zig | 71 + test/debugger/basic/lldb | 75 + test/debugger/basic/manifest | 8 + test/debugger/enums | 67 + test/debugger/errors | 75 + test/debugger/hash_map | 67 + test/debugger/identifiers | 34 + test/debugger/if_blocks | 41 + test/debugger/inline_call/lldb | 664 +++++ test/debugger/inline_call/manifest | 18 + test/debugger/inline_call/mod0.zig | 32 + test/debugger/inline_call/mod1.zig | 32 + test/debugger/inline_call/root0.zig | 42 + test/debugger/inline_call/root1.zig | 32 + test/debugger/link_object | 39 + test/debugger/multi_array_list/lldb | 209 ++ test/debugger/multi_array_list/main.zig | 30 + test/debugger/multi_array_list/manifest | 8 + test/debugger/optionals | 54 + test/debugger/pointers | 135 + test/debugger/step_single_stmt_loops/lldb | 329 +++ test/debugger/step_single_stmt_loops/manifest | 8 + .../step_single_stmt_loops.zig | 34 + test/debugger/storage | 93 + test/debugger/strings | 72 + test/debugger/switch_blocks | 44 + test/debugger/types | 67 + test/debugger/unions | 90 + test/src/Debugger.zig | 2468 ----------------- test/src/Runner.zig | 546 +++- test/tests.zig | 126 +- 36 files changed, 2992 insertions(+), 2661 deletions(-) create mode 100644 test/debugger/basic/basic.zig create mode 100644 test/debugger/basic/lldb create mode 100644 test/debugger/basic/manifest create mode 100644 test/debugger/enums create mode 100644 test/debugger/errors create mode 100644 test/debugger/hash_map create mode 100644 test/debugger/identifiers create mode 100644 test/debugger/if_blocks create mode 100644 test/debugger/inline_call/lldb create mode 100644 test/debugger/inline_call/manifest create mode 100644 test/debugger/inline_call/mod0.zig create mode 100644 test/debugger/inline_call/mod1.zig create mode 100644 test/debugger/inline_call/root0.zig create mode 100644 test/debugger/inline_call/root1.zig create mode 100644 test/debugger/link_object create mode 100644 test/debugger/multi_array_list/lldb create mode 100644 test/debugger/multi_array_list/main.zig create mode 100644 test/debugger/multi_array_list/manifest create mode 100644 test/debugger/optionals create mode 100644 test/debugger/pointers create mode 100644 test/debugger/step_single_stmt_loops/lldb create mode 100644 test/debugger/step_single_stmt_loops/manifest create mode 100644 test/debugger/step_single_stmt_loops/step_single_stmt_loops.zig create mode 100644 test/debugger/storage create mode 100644 test/debugger/strings create mode 100644 test/debugger/switch_blocks create mode 100644 test/debugger/types create mode 100644 test/debugger/unions delete mode 100644 test/src/Debugger.zig diff --git a/build.zig b/build.zig index b3b48933d6472dc9d70f1be473e12ef14e3ed212..8a216c1808022a621d44954009603ed6f3921af8 100644 --- a/build.zig +++ b/build.zig @@ -700,15 +700,6 @@ pub fn build(b: *std.Build) !void { .skip_libc = skip_libc, })); test_step.dependOn(tests.addCliTests(b)); - if (tests.addDebuggerTests(b, .{ - .test_filters = test_filters, - .test_target_filters = test_target_filters, - .gdb = b.option([]const u8, "gdb", "path to gdb binary"), - .lldb = b.option([]const u8, "lldb", "path to lldb binary"), - .optimize_modes = optimize_modes, - .skip_single_threaded = skip_single_threaded, - .skip_libc = skip_libc, - })) |test_debugger_step| test_step.dependOn(test_debugger_step); if (tests.addLlvmIrTests(b, .{ .enable_llvm = enable_llvm, .test_filters = test_filters, @@ -795,7 +786,7 @@ pub fn build(b: *std.Build) !void { .target = b.graph.host, }), }); - test_step.dependOn(try tests.addIncrementalTests(b, runner, .{ + const runner_opts: tests.RunnerOptions = .{ .test_filters = test_filters, .test_target_filters = test_target_filters, .skip_non_native = skip_non_native, @@ -807,7 +798,21 @@ pub fn build(b: *std.Build) !void { .skip_darwin = skip_darwin, .skip_linux = skip_linux, .skip_llvm = skip_llvm, - })); + .gdb = b.option([]const u8, "gdb", "path to gdb binary"), + .lldb = b.option([]const u8, "lldb", "path to lldb binary"), + }; + + const test_incremental_step = b.step("test-incremental", "Run the incremental compilation tests"); + try tests.addRunnerTests(b, runner, test_incremental_step, "test/incremental", tests.incremental_matrix, runner_opts); + test_step.dependOn(test_incremental_step); + + const test_debugger_step = b.step("test-debugger", "Run the debugger tests"); + if (runner_opts.gdb == null and runner_opts.lldb == null) { + test_debugger_step.dependOn(&b.addFail("test-debugger requires -Dgdb and/or -Dlldb").step); + } else { + try tests.addRunnerTests(b, runner, test_debugger_step, "test/debugger", tests.debugger_matrix, runner_opts); + test_step.dependOn(test_debugger_step); + } } fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { diff --git a/ci/x86_64-linux-debug-llvm.sh b/ci/x86_64-linux-debug-llvm.sh index 86fe71c1b0b9f454a310ada6136e00f9fca98fb9..e974c95af37554df459113d65dae484ba7f15a45 100755 --- a/ci/x86_64-linux-debug-llvm.sh +++ b/ci/x86_64-linux-debug-llvm.sh @@ -67,7 +67,7 @@ stage3-debug/bin/zig build install test docs \ -Dskip-windows \ -Dskip-darwin \ -Denable-superhtml \ - -Dlldb="$HOME/deps/lldb-zig/Debug-aad646607a/bin/lldb" \ + -Dlldb="$HOME/deps/lldb-zig/Debug-86a744cac9/bin/lldb" \ -Dlibc-test-path="$HOME/deps/libc-test-b95fe84" stage4-debug/bin/zig test ../test/behavior.zig diff --git a/ci/x86_64-linux-debug.sh b/ci/x86_64-linux-debug.sh index e2158607a98542f2abacafa40a5550045fd4e21e..932f153d37ff460fd1fa459b33143093645d0fbd 100755 --- a/ci/x86_64-linux-debug.sh +++ b/ci/x86_64-linux-debug.sh @@ -61,7 +61,7 @@ stage3-debug/bin/zig build install test docs \ -Denable-llvm \ -Dno-lib \ -Denable-superhtml \ - -Dlldb="$HOME/deps/lldb-zig/Debug-aad646607a/bin/lldb" \ + -Dlldb="$HOME/deps/lldb-zig/Debug-86a744cac9/bin/lldb" \ -Dskip-freebsd \ -Dskip-netbsd \ -Dskip-openbsd \ diff --git a/ci/x86_64-linux-release.sh b/ci/x86_64-linux-release.sh index e4cccef9a28180daeade9ccc832ed339145d02e3..0dbd2a8aa187bf1661e0aafb9f2bbd819b13c6f2 100755 --- a/ci/x86_64-linux-release.sh +++ b/ci/x86_64-linux-release.sh @@ -67,7 +67,7 @@ stage3-release/bin/zig build install test docs \ -Denable-llvm \ -Dno-lib \ -Denable-superhtml \ - -Dlldb="$HOME/deps/lldb-zig/Release-aad646607a/bin/lldb" \ + -Dlldb="$HOME/deps/lldb-zig/Release-86a744cac9/bin/lldb" \ -Dlibc-test-path="$HOME/deps/libc-test-b95fe84" # Ensure that the fuzzer at least compiles. diff --git a/lib/lldb/pretty_printers.py b/lib/lldb/pretty_printers.py index 222484e5b4ab55fe45e8ab03ddb85f894850bb51..8246b583607273384aec2d5779dd500acc45da65 100644 --- a/lib/lldb/pretty_printers.py +++ b/lib/lldb/pretty_printers.py @@ -899,16 +899,16 @@ def add(debugger, *, category, regex=False, type, identifier=None, synth=False, if synth: debugger.HandleCommand('type synthetic add --category %s%s --python-class %s_SynthProvider "%s"' % (category, ' --regex' if regex else '', prefix, type)) def __lldb_init_module(debugger, _=None): - # Initialize Zig Categories - debugger.HandleCommand('type category define --language c99 zig.lang zig.std') + # Initialize Zig Categories (for programs compiled with the llvm backend) + debugger.HandleCommand('type category define --language c99 zig.lang zig.std zig.compiler') - # Initialize Zig Language + # Initialize Zig Language (for programs compiled with the llvm backend) add(debugger, category='zig.lang', regex=True, type='^\\[\\]', identifier='zig_Slice', synth=True, expand=True, summary='len=${svar%#}') add(debugger, category='zig.lang', type='[]u8', identifier='zig_String', summary=True) add(debugger, category='zig.lang', regex=True, type='^\\?', identifier='zig_Optional', synth=True, summary=True) add(debugger, category='zig.lang', regex=True, type='^(error{.*}|anyerror)!', identifier='zig_ErrorUnion', synth=True, inline_children=True, summary=True) - # Initialize Zig Standard Library + # Initialize Zig Standard Library (for programs compiled with the llvm backend) add(debugger, category='zig.std', type='mem.Allocator', summary='${var.ptr}') add(debugger, category='zig.std', regex=True, type='^multi_array_list\\.MultiArrayList\\(.*\\)$', identifier='std_MultiArrayList', synth=True, expand=True, summary='len=${var.len} capacity=${var.capacity}') add(debugger, category='zig.std', regex=True, type='^multi_array_list\\.MultiArrayList\\(.*\\)\\.Slice$', identifier='std_MultiArrayList_Slice', synth=True, expand=True, summary='len=${var.len} capacity=${var.capacity}') @@ -916,7 +916,7 @@ def __lldb_init_module(debugger, _=None): add(debugger, category='zig.std', regex=True, type='^hash_map\\.HashMapUnmanaged\\(.*\\)$', identifier='std_HashMapUnmanaged', synth=True, expand=True, summary=True) add(debugger, category='zig.std', regex=True, type='^hash_map\\.HashMapUnmanaged\\(.*\\)\\.Entry$', identifier = 'std_Entry', synth=True, inline_children=True, summary=True) - # Initialize Zig Compiler + # Initialize Zig Compiler (compiled with the llvm backend) add(debugger, category='zig.compiler', type='Zir.Inst', identifier='TagAndPayload', synth=True, inline_children=True, summary=True) add(debugger, category='zig.compiler', regex=True, type=MultiArrayList_Entry('Zir\\.Inst'), identifier='TagAndPayload', synth=True, inline_children=True, summary=True) add(debugger, category='zig.compiler', regex=True, type='^Zir\\.Inst\\.Data\\.Data__struct_[1-9][0-9]*$', inline_children=True, summary=True) diff --git a/test/debugger/basic/basic.zig b/test/debugger/basic/basic.zig new file mode 100644 index 0000000000000000000000000000000000000000..c2ff5d3175a01dfae7c3b3f8e516ffc07d277264 --- /dev/null +++ b/test/debugger/basic/basic.zig @@ -0,0 +1,71 @@ +const Basic = struct { + void: void = {}, + bool_false: bool = false, + bool_true: bool = true, + u0_0: u0 = 0, + u1_0: u1 = 0, + u1_1: u1 = 1, + u2_0: u2 = 0, + u2_3: u2 = 3, + u3_0: u3 = 0, + u3_7: u3 = 7, + u4_0: u4 = 0, + u4_15: u4 = 15, + u5_0: u5 = 0, + u5_31: u5 = 31, + u6_0: u6 = 0, + u6_63: u6 = 63, + u7_0: u7 = 0, + u7_127: u7 = 127, + u8_0: u8 = 0, + u8_255: u8 = 255, + u16_0: u16 = 0, + u16_65535: u16 = 65535, + u24_0: u24 = 0, + u24_16777215: u24 = 16777215, + u32_0: u32 = 0, + u32_4294967295: u32 = 4294967295, + @"i1_-1": i1 = -1, + i1_0: i1 = 0, + @"i2_-2": i2 = -2, + i2_0: i2 = 0, + i2_1: i2 = 1, + @"i3_-4": i3 = -4, + i3_0: i3 = 0, + i3_3: i3 = 3, + @"i4_-8": i4 = -8, + i4_0: i4 = 0, + i4_7: i4 = 7, + @"i5_-16": i5 = -16, + i5_0: i5 = 0, + i5_15: i5 = 15, + @"i6_-32": i6 = -32, + i6_0: i6 = 0, + i6_31: i6 = 31, + @"i7_-64": i7 = -64, + i7_0: i7 = 0, + i7_63: i7 = 63, + @"i8_-128": i8 = -128, + i8_0: i8 = 0, + i8_127: i8 = 127, + @"i16_-32768": i16 = -32768, + i16_0: i16 = 0, + i16_32767: i16 = 32767, + @"i24_-8388608": i24 = -8388608, + i24_0: i24 = 0, + i24_8388607: i24 = 8388607, + @"i32_-2147483648": i32 = -2147483648, + i32_0: i32 = 0, + i32_2147483647: i32 = 2147483647, + @"f16_42.625": f16 = 42.625, + @"f32_-2730.65625": f32 = -2730.65625, + @"f64_357913941.33203125": f64 = 357913941.33203125, + @"f80_-91625968981.3330078125": f80 = -91625968981.3330078125, + @"f128_384307168202282325.333332061767578125": f128 = 384307168202282325.333332061767578125, +}; +fn testBasic(basic: Basic) void { + _ = basic; +} +pub fn main() void { + testBasic(.{}); +} diff --git a/test/debugger/basic/lldb b/test/debugger/basic/lldb new file mode 100644 index 0000000000000000000000000000000000000000..aa4692c45dffc3472791a39e09fed9dc2931f900 --- /dev/null +++ b/test/debugger/basic/lldb @@ -0,0 +1,75 @@ +(lldb) breakpoint set --file basic.zig --source-pattern-regexp '_ = basic;' +Breakpoint 1: where = basic`basic.testBasic + #... at basic.zig:68:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../basic' (#...) +Process #... stopped +* thread #1, name = 'basic', stop reason = breakpoint 1.1 + frame #0: basic`basic.testBasic(basic=Basic @ 0x#...) at basic.zig:68:1 +(lldb) frame variable --show-all-children --show-types -- basic +(root.basic.Basic) basic = { + (void) .void = {} + (bool) .bool_false = false + (bool) .bool_true = true + (u0) .u0_0 = 0 + (u1) .u1_0 = 0 + (u1) .u1_1 = 1 + (u2) .u2_0 = 0 + (u2) .u2_3 = 3 + (u3) .u3_0 = 0 + (u3) .u3_7 = 7 + (u4) .u4_0 = 0 + (u4) .u4_15 = 15 + (u5) .u5_0 = 0 + (u5) .u5_31 = 31 + (u6) .u6_0 = 0 + (u6) .u6_63 = 63 + (u7) .u7_0 = 0 + (u7) .u7_127 = 127 + (u8) .u8_0 = 0 + (u8) .u8_255 = 255 + (u16) .u16_0 = 0 + (u16) .u16_65535 = 65535 + (u24) .u24_0 = 0 + (u24) .u24_16777215 = 16777215 + (u32) .u32_0 = 0 + (u32) .u32_4294967295 = 4294967295 + (i1) .@"i1_-1" = -1 + (i1) .i1_0 = 0 + (i2) .@"i2_-2" = -2 + (i2) .i2_0 = 0 + (i2) .i2_1 = 1 + (i3) .@"i3_-4" = -4 + (i3) .i3_0 = 0 + (i3) .i3_3 = 3 + (i4) .@"i4_-8" = -8 + (i4) .i4_0 = 0 + (i4) .i4_7 = 7 + (i5) .@"i5_-16" = -16 + (i5) .i5_0 = 0 + (i5) .i5_15 = 15 + (i6) .@"i6_-32" = -32 + (i6) .i6_0 = 0 + (i6) .i6_31 = 31 + (i7) .@"i7_-64" = -64 + (i7) .i7_0 = 0 + (i7) .i7_63 = 63 + (i8) .@"i8_-128" = -128 + (i8) .i8_0 = 0 + (i8) .i8_127 = 127 + (i16) .@"i16_-32768" = -32768 + (i16) .i16_0 = 0 + (i16) .i16_32767 = 32767 + (i24) .@"i24_-8388608" = -8388608 + (i24) .i24_0 = 0 + (i24) .i24_8388607 = 8388607 + (i32) .@"i32_-2147483648" = -2147483648 + (i32) .i32_0 = 0 + (i32) .i32_2147483647 = 2147483647 + (f16) .@"f16_42.625" = 42.625 + (f32) .@"f32_-2730.65625" = -2730.65625 + (f64) .@"f64_357913941.33203125" = 357913941.33203125 + (f80) .@"f80_-91625968981.3330078125" = -91625968981.3330078125 + (f128) .@"f128_384307168202282325.333332061767578125" = 384307168202282325.333332061767578125 +} +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. diff --git a/test/debugger/basic/manifest b/test/debugger/basic/manifest new file mode 100644 index 0000000000000000000000000000000000000000..bddaec73e0f6d7e5ab469b041e0b5f229937fefb --- /dev/null +++ b/test/debugger/basic/manifest @@ -0,0 +1,8 @@ +#exe { +--name basic +-Mroot=basic.zig +#} + +#write basic.zig basic.zig +#update +#check lldb lldb diff --git a/test/debugger/enums b/test/debugger/enums new file mode 100644 index 0000000000000000000000000000000000000000..d6cbcf24334ee9ea2122cb88143139c22f59d701 --- /dev/null +++ b/test/debugger/enums @@ -0,0 +1,67 @@ +#todo { +passes, but prints errors +#} +#skip x86_64-linux-none-whole-selfhosted-new-nopic +#skip x86_64-linux-none-whole-selfhosted-new-pic +#skip x86_64-linux-none-incremental-selfhosted-new-nopic +#skip x86_64-linux-none-incremental-selfhosted-new-pic + +#exe { +--name enums +-Mroot=enums.zig +#} + +#write enums.zig { +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 = @fromBackingInt(13), + one: One = .first, + two: Two = @fromBackingInt(-1234), + three: Three = .second, +}; +fn testEnums(enums: Enums) void { + _ = enums; +} +pub fn main() void { + testEnums(.{}); +} +#} +#update +#check lldb { +(lldb) breakpoint set --file enums.zig --source-pattern-regexp '_ = enums;' +Breakpoint 1: where = enums`enums.testEnums + #... at enums.zig:14:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../enums' (#...) +Process #... stopped +* thread #1, name = 'enums', stop reason = breakpoint 1.1 + frame #0: enums`enums.testEnums(enums=(.zero = @fromBackingInt(13), .one = .first, .two = @fromBackingInt(-1234), .three = .second)) at enums.zig:14:1 +(lldb) expression --show-types -- Enums +(type) $0 = struct { + (type) Zero = enum {} + (type) One = enum { + (root.enums.Enums.One) first = .first + } + (type) Two = enum { + (root.enums.Enums.Two) first = .first + (root.enums.Enums.Two) second = .second + } + (type) Three = enum { + (root.enums.Enums.Three) first = .first + (root.enums.Enums.Three) second = .second + (root.enums.Enums.Three) third = .third + } +} +(lldb) frame variable --show-all-children --show-types -- enums +(root.enums.Enums) enums = { + (root.enums.Enums.Zero) .zero = @fromBackingInt(13) + (root.enums.Enums.One) .one = .first + (root.enums.Enums.Two) .two = @fromBackingInt(-1234) + (root.enums.Enums.Three) .three = .second +} +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/errors b/test/debugger/errors new file mode 100644 index 0000000000000000000000000000000000000000..156118c3addabd6b5ce13fe8bbdcb3a3dd580c92 --- /dev/null +++ b/test/debugger/errors @@ -0,0 +1,75 @@ +#todo { +passes, but prints errors +#} +#skip x86_64-linux-none-whole-selfhosted-new-nopic +#skip x86_64-linux-none-whole-selfhosted-new-pic +#skip x86_64-linux-none-incremental-selfhosted-new-nopic +#skip x86_64-linux-none-incremental-selfhosted-new-pic + +#exe { +--name errors +-Mroot=errors.zig +#} + +#write errors.zig { +const Errors = struct { + const Zero = error{}; + const One = Zero || error{One}; + const Two = One || error{Two}; + const Three = Two || error{Three}; + + one: One = error.One, + two: Two = error.Two, + three: Three = error.Three, + any: anyerror = error.Any, + any_void: anyerror!void = error.NotVoid, + any_u32: One!u32 = 42, +}; +fn testErrors(errors: Errors) void { + _ = errors; +} +pub fn main() void { + testErrors(.{}); +} +#} +#update +#check lldb { +(lldb) breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;' +Breakpoint 1: where = errors`errors.testErrors + #... at errors.zig:16:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../errors' (#...) +Process #... stopped +* thread #1, name = 'errors', stop reason = breakpoint 1.1 + frame #0: errors`errors.testErrors(errors=Errors @ 0x#...) at errors.zig:16:1 +(lldb) expression --show-types -- Errors +(type) $0 = struct { + (type) Zero = error {} + (type) One = error { + (error{One}) One = error.One + } + (type) Two = error { + (error{One,Two}) One = error.One + (error{One,Two}) Two = error.Two + } + (type) Three = error { + (error{One,Three,Two}) One = error.One + (error{One,Three,Two}) Two = error.Two + (error{One,Three,Two}) Three = error.Three + } +} +(lldb) frame variable --show-all-children --show-types -- errors +(root.errors.Errors) errors = { + (error{One}) .one = error.One + (error{One,Two}) .two = error.Two + (error{One,Three,Two}) .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. +#} diff --git a/test/debugger/hash_map b/test/debugger/hash_map new file mode 100644 index 0000000000000000000000000000000000000000..277af6873fce5cc8e10c421d62bbf9d6cd8f27b1 --- /dev/null +++ b/test/debugger/hash_map @@ -0,0 +1,67 @@ +#exe { +--name hash_map +-Mroot=main.zig +#} + +#write main.zig { +const std = @import("std"); +const Context = struct { + pub fn hash(_: Context, key: u32) Map.Hash { + return key; + } + pub fn eql(_: Context, lhs: u32, rhs: u32) bool { + return lhs == rhs; + } +}; +const Map = std.HashMapUnmanaged(u32, u32, Context, 63); +fn testHashMap(map: Map) void { + _ = map; +} +pub fn main() !void { + var map: Map = .empty; + defer map.deinit(std.heap.page_allocator); + try map.ensureTotalCapacity(std.heap.page_allocator, 10); + map.putAssumeCapacity(0, 1); + map.putAssumeCapacity(2, 3); + map.putAssumeCapacity(4, 5); + map.putAssumeCapacity(6, 7); + map.putAssumeCapacity(8, 9); + + testHashMap(map); +} +#} +#update +#check lldb { +(lldb) breakpoint set --file main.zig --source-pattern-regexp '_ = map;' +Breakpoint 1: where = hash_map`main.testHashMap + #... at main.zig:13:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../hash_map' (#...) +Process #... stopped +* thread #1, name = 'hash_map', stop reason = breakpoint 1.1 + frame #0: hash_map`main.testHashMap(map=len=5 capacity=16) at main.zig:13:1 +(lldb) frame variable --show-all-children --show-types -- map +(std.hash_map.Custom(u32,u32,main.Context,63)) map = len=5 capacity=16 { + (std.hash_map.Custom(u32,u32,main.Context,63).KV) [0] = { + (u32) .key = 0 + (u32) .value = 1 + } + (std.hash_map.Custom(u32,u32,main.Context,63).KV) [1] = { + (u32) .key = 2 + (u32) .value = 3 + } + (std.hash_map.Custom(u32,u32,main.Context,63).KV) [2] = { + (u32) .key = 4 + (u32) .value = 5 + } + (std.hash_map.Custom(u32,u32,main.Context,63).KV) [3] = { + (u32) .key = 6 + (u32) .value = 7 + } + (std.hash_map.Custom(u32,u32,main.Context,63).KV) [4] = { + (u32) .key = 8 + (u32) .value = 9 + } +} +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/identifiers b/test/debugger/identifiers new file mode 100644 index 0000000000000000000000000000000000000000..6985e9a1e94687a318472beca4ade4f64a4f887a --- /dev/null +++ b/test/debugger/identifiers @@ -0,0 +1,34 @@ +#exe { +--name identifiers +-Mroot=identifiers.zig +#} + +#write identifiers.zig { +const Struct = struct { @"zwölf": u32 }; +fn testIdentifiers(@"fünf": u32, @"struct": Struct) void { + _ = @"fünf"; + _ = @"struct"; +} +pub fn main() void { + testIdentifiers(5, .{ .@"zwölf" = 12 }); +} +#} +#update +#check lldb { +(lldb) breakpoint set --file identifiers.zig --source-pattern-regexp '_ = @"struct";' +Breakpoint 1: where = identifiers`identifiers.testIdentifiers + #... at identifiers.zig:5:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../identifiers' (#...) +Process #... stopped +* thread #1, name = 'identifiers', stop reason = breakpoint 1.1 + frame #0: identifiers`identifiers.testIdentifiers(fünf=5, struct=(.@"zw\xc3\xb6lf" = 12)) at identifiers.zig:5:1 +(lldb) frame variable --show-all-children --show-types -- @\"fünf'"' '@"f\xC3\xBCnf"' '@"f\u{FC}nf"' '@"struct".@"zwölf"' '@"struct".@"zw\xC3\xB6lf"' '@"struct".@"zw\u{F6}lf"' +(u32) @"fünf" = 5 +(u32) @"f\xC3\xBCnf" = 5 +(u32) @"f\u{FC}nf" = 5 +(u32) @"struct".@"zwölf" = 12 +(u32) @"struct".@"zw\xC3\xB6lf" = 12 +(u32) @"struct".@"zw\u{F6}lf" = 12 +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/if_blocks b/test/debugger/if_blocks new file mode 100644 index 0000000000000000000000000000000000000000..be4552a64a0c5d3a7ca27497e55f6c4d6d7170a8 --- /dev/null +++ b/test/debugger/if_blocks @@ -0,0 +1,41 @@ +#exe { +--name if_blocks +-Mroot=if_blocks.zig +#} + +#write if_blocks.zig { +pub fn main() void { + for (0..2) |i| { + if (i == 0) { + var x: u32 = 123; + _ = &x; + } else { + var x: f32 = 4.5; + _ = &x; + } + } +} +#} +#update +#check lldb { +(lldb) breakpoint set --file if_blocks.zig --source-pattern-regexp '_ = &x;' +Breakpoint 1: 2 locations. +(lldb) process launch +Process #... launched: '#.../if_blocks' (#...) +Process #... stopped +* thread #1, name = 'if_blocks', stop reason = breakpoint 1.1 + frame #0: if_blocks`if_blocks.main at if_blocks.zig:5:13 +(lldb) frame variable --show-all-children +(usize) i = 0 +(u32) x = 123 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'if_blocks', stop reason = breakpoint 1.2 + frame #0: if_blocks`if_blocks.main at if_blocks.zig:8:13 +(lldb) frame variable --show-all-children +(usize) i = 1 +(f32) x = 4.5 +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/inline_call/lldb b/test/debugger/inline_call/lldb new file mode 100644 index 0000000000000000000000000000000000000000..0ac1e75669234aad2854548ac07f98d5fbcb4fa9 --- /dev/null +++ b/test/debugger/inline_call/lldb @@ -0,0 +1,664 @@ +(lldb) breakpoint set --file root0.zig --line 26 +Breakpoint 1: where = inline_call`root0.r0cf + #... at root0.zig:26:5, address = 0x#... +(lldb) breakpoint set --file root0.zig --line 30 +Breakpoint 2: 8 locations. +(lldb) breakpoint set --file root1.zig --line 26 +Breakpoint 3: where = inline_call`root1.r1cf + #... at root1.zig:26:5, address = 0x#... +(lldb) breakpoint set --file root1.zig --line 30 +Breakpoint 4: 8 locations. +(lldb) breakpoint set --file mod0.zig --line 26 +Breakpoint 5: where = inline_call`mod0.m0cf + #... at mod0.zig:26:5, address = 0x#... +(lldb) breakpoint set --file mod0.zig --line 30 +Breakpoint 6: 8 locations. +(lldb) breakpoint set --file mod1.zig --line 26 +Breakpoint 7: where = inline_call`mod1.m1cf + #... at mod1.zig:26:5, address = 0x#... +(lldb) breakpoint set --file mod1.zig --line 30 +Breakpoint 8: 8 locations. +(lldb) #--- +(lldb) process launch +Process #... launched: '#.../inline_call' (#...) +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + frame #0: inline_call`root0.r0cf(r0ca=13) at root0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + * frame #0: inline_call`root0.r0cf(r0ca=13) at root0.zig:26:5 + frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:6:15 + frame #2: inline_call`root0.main at root0.zig:34:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 2.8 + frame #0: inline_call`r0cfi(r0cai=14) at root0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 2.8 + * frame #0: inline_call`r0cfi(r0cai=14) at root0.zig:30:5 + frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:7:16 + frame #2: inline_call`root0.main at root0.zig:34:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + frame #0: inline_call`root1.r1cf(r1ca=15) at root1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + * frame #0: inline_call`root1.r1cf(r1ca=15) at root1.zig:26:5 + frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:8:15 + frame #2: inline_call`root0.main at root0.zig:34:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 4.8 + frame #0: inline_call`r1cfi(r1cai=8) at root1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 4.8 + * frame #0: inline_call`r1cfi(r1cai=8) at root1.zig:30:5 + frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:9:16 + frame #2: inline_call`root0.main at root0.zig:34:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + frame #0: inline_call`mod0.m0cf(m0ca=9) at mod0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + * frame #0: inline_call`mod0.m0cf(m0ca=9) at mod0.zig:26:5 + frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:10:14 + frame #2: inline_call`root0.main at root0.zig:34:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 6.8 + frame #0: inline_call`m0cfi(m0cai=10) at mod0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 6.8 + * frame #0: inline_call`m0cfi(m0cai=10) at mod0.zig:30:5 + frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:11:15 + frame #2: inline_call`root0.main at root0.zig:34:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + frame #0: inline_call`mod1.m1cf(m1ca=11) at mod1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + * frame #0: inline_call`mod1.m1cf(m1ca=11) at mod1.zig:26:5 + frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:12:14 + frame #2: inline_call`root0.main at root0.zig:34:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 8.8 + frame #0: inline_call`m1cfi(m1cai=4) at mod1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 8.8 + * frame #0: inline_call`m1cfi(m1cai=4) at mod1.zig:30:5 + frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:13:15 + frame #2: inline_call`root0.main at root0.zig:34:15 +(lldb) #--- +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + frame #0: inline_call`root0.r0cf(r0ca=22) at root0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + * frame #0: inline_call`root0.r0cf(r0ca=22) at root0.zig:26:5 + frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:16:15 + frame #2: inline_call`root0.main at root0.zig:35:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 2.1 + frame #0: inline_call`r0cfi(r0cai=21) at root0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 2.1 + * frame #0: inline_call`r0cfi(r0cai=21) at root0.zig:30:5 + frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:17:16 + frame #2: inline_call`root0.main at root0.zig:35:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + frame #0: inline_call`root1.r1cf(r1ca=20) at root1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + * frame #0: inline_call`root1.r1cf(r1ca=20) at root1.zig:26:5 + frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:18:15 + frame #2: inline_call`root0.main at root0.zig:35:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 4.1 + frame #0: inline_call`r1cfi(r1cai=19) at root1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 4.1 + * frame #0: inline_call`r1cfi(r1cai=19) at root1.zig:30:5 + frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:19:16 + frame #2: inline_call`root0.main at root0.zig:35:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + frame #0: inline_call`mod0.m0cf(m0ca=18) at mod0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + * frame #0: inline_call`mod0.m0cf(m0ca=18) at mod0.zig:26:5 + frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:20:14 + frame #2: inline_call`root0.main at root0.zig:35:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 6.1 + frame #0: inline_call`m0cfi(m0cai=17) at mod0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 6.1 + * frame #0: inline_call`m0cfi(m0cai=17) at mod0.zig:30:5 + frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:21:15 + frame #2: inline_call`root0.main at root0.zig:35:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + frame #0: inline_call`mod1.m1cf(m1ca=16) at mod1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + * frame #0: inline_call`mod1.m1cf(m1ca=16) at mod1.zig:26:5 + frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:22:14 + frame #2: inline_call`root0.main at root0.zig:35:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 8.1 + frame #0: inline_call`m1cfi(m1cai=31) at mod1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 8.1 + * frame #0: inline_call`m1cfi(m1cai=31) at mod1.zig:30:5 + frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:23:15 + frame #2: inline_call`root0.main at root0.zig:35:16 +(lldb) #--- +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + frame #0: inline_call`root0.r0cf(r0ca=35) at root0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + * frame #0: inline_call`root0.r0cf(r0ca=35) at root0.zig:26:5 + frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:6:15 + frame #2: inline_call`root0.main at root0.zig:36:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 2.7 + frame #0: inline_call`r0cfi(r0cai=32) at root0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 2.7 + * frame #0: inline_call`r0cfi(r0cai=32) at root0.zig:30:5 + frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:7:16 + frame #2: inline_call`root0.main at root0.zig:36:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + frame #0: inline_call`root1.r1cf(r1ca=33) at root1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + * frame #0: inline_call`root1.r1cf(r1ca=33) at root1.zig:26:5 + frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:8:15 + frame #2: inline_call`root0.main at root0.zig:36:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 4.7 + frame #0: inline_call`r1cfi(r1cai=38) at root1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 4.7 + * frame #0: inline_call`r1cfi(r1cai=38) at root1.zig:30:5 + frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:9:16 + frame #2: inline_call`root0.main at root0.zig:36:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + frame #0: inline_call`mod0.m0cf(m0ca=39) at mod0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + * frame #0: inline_call`mod0.m0cf(m0ca=39) at mod0.zig:26:5 + frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:10:14 + frame #2: inline_call`root0.main at root0.zig:36:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 6.7 + frame #0: inline_call`m0cfi(m0cai=36) at mod0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 6.7 + * frame #0: inline_call`m0cfi(m0cai=36) at mod0.zig:30:5 + frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:11:15 + frame #2: inline_call`root0.main at root0.zig:36:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + frame #0: inline_call`mod1.m1cf(m1ca=37) at mod1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + * frame #0: inline_call`mod1.m1cf(m1ca=37) at mod1.zig:26:5 + frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:12:14 + frame #2: inline_call`root0.main at root0.zig:36:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 8.7 + frame #0: inline_call`m1cfi(m1cai=42) at mod1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 8.7 + * frame #0: inline_call`m1cfi(m1cai=42) at mod1.zig:30:5 + frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:13:15 + frame #2: inline_call`root0.main at root0.zig:36:15 +(lldb) #--- +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + frame #0: inline_call`root0.r0cf(r0ca=44) at root0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + * frame #0: inline_call`root0.r0cf(r0ca=44) at root0.zig:26:5 + frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:16:15 + frame #2: inline_call`root0.main at root0.zig:37:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 2.2 + frame #0: inline_call`r0cfi(r0cai=47) at root0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 2.2 + * frame #0: inline_call`r0cfi(r0cai=47) at root0.zig:30:5 + frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:17:16 + frame #2: inline_call`root0.main at root0.zig:37:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + frame #0: inline_call`root1.r1cf(r1ca=46) at root1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + * frame #0: inline_call`root1.r1cf(r1ca=46) at root1.zig:26:5 + frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:18:15 + frame #2: inline_call`root0.main at root0.zig:37:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 4.2 + frame #0: inline_call`r1cfi(r1cai=41) at root1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 4.2 + * frame #0: inline_call`r1cfi(r1cai=41) at root1.zig:30:5 + frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:19:16 + frame #2: inline_call`root0.main at root0.zig:37:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + frame #0: inline_call`mod0.m0cf(m0ca=40) at mod0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + * frame #0: inline_call`mod0.m0cf(m0ca=40) at mod0.zig:26:5 + frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:20:14 + frame #2: inline_call`root0.main at root0.zig:37:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 6.2 + frame #0: inline_call`m0cfi(m0cai=43) at mod0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 6.2 + * frame #0: inline_call`m0cfi(m0cai=43) at mod0.zig:30:5 + frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:21:15 + frame #2: inline_call`root0.main at root0.zig:37:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + frame #0: inline_call`mod1.m1cf(m1ca=42) at mod1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + * frame #0: inline_call`mod1.m1cf(m1ca=42) at mod1.zig:26:5 + frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:22:14 + frame #2: inline_call`root0.main at root0.zig:37:16 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 8.2 + frame #0: inline_call`m1cfi(m1cai=37) at mod1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 8.2 + * frame #0: inline_call`m1cfi(m1cai=37) at mod1.zig:30:5 + frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:23:15 + frame #2: inline_call`root0.main at root0.zig:37:16 +(lldb) #--- +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + frame #0: inline_call`root0.r0cf(r0ca=57) at root0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + * frame #0: inline_call`root0.r0cf(r0ca=57) at root0.zig:26:5 + frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:6:15 + frame #2: inline_call`root0.main at root0.zig:38:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 2.6 + frame #0: inline_call`r0cfi(r0cai=58) at root0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 2.6 + * frame #0: inline_call`r0cfi(r0cai=58) at root0.zig:30:5 + frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:7:16 + frame #2: inline_call`root0.main at root0.zig:38:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + frame #0: inline_call`root1.r1cf(r1ca=59) at root1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + * frame #0: inline_call`root1.r1cf(r1ca=59) at root1.zig:26:5 + frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:8:15 + frame #2: inline_call`root0.main at root0.zig:38:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 4.6 + frame #0: inline_call`r1cfi(r1cai=60) at root1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 4.6 + * frame #0: inline_call`r1cfi(r1cai=60) at root1.zig:30:5 + frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:9:16 + frame #2: inline_call`root0.main at root0.zig:38:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + frame #0: inline_call`mod0.m0cf(m0ca=61) at mod0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + * frame #0: inline_call`mod0.m0cf(m0ca=61) at mod0.zig:26:5 + frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:10:14 + frame #2: inline_call`root0.main at root0.zig:38:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 6.6 + frame #0: inline_call`m0cfi(m0cai=62) at mod0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 6.6 + * frame #0: inline_call`m0cfi(m0cai=62) at mod0.zig:30:5 + frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:11:15 + frame #2: inline_call`root0.main at root0.zig:38:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + frame #0: inline_call`mod1.m1cf(m1ca=63) at mod1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + * frame #0: inline_call`mod1.m1cf(m1ca=63) at mod1.zig:26:5 + frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:12:14 + frame #2: inline_call`root0.main at root0.zig:38:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 8.6 + frame #0: inline_call`m1cfi(m1cai=48) at mod1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 8.6 + * frame #0: inline_call`m1cfi(m1cai=48) at mod1.zig:30:5 + frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:13:15 + frame #2: inline_call`root0.main at root0.zig:38:14 +(lldb) #--- +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + frame #0: inline_call`root0.r0cf(r0ca=66) at root0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + * frame #0: inline_call`root0.r0cf(r0ca=66) at root0.zig:26:5 + frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:16:15 + frame #2: inline_call`root0.main at root0.zig:39:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 2.3 + frame #0: inline_call`r0cfi(r0cai=65) at root0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 2.3 + * frame #0: inline_call`r0cfi(r0cai=65) at root0.zig:30:5 + frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:17:16 + frame #2: inline_call`root0.main at root0.zig:39:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + frame #0: inline_call`root1.r1cf(r1ca=64) at root1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + * frame #0: inline_call`root1.r1cf(r1ca=64) at root1.zig:26:5 + frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:18:15 + frame #2: inline_call`root0.main at root0.zig:39:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 4.3 + frame #0: inline_call`r1cfi(r1cai=71) at root1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 4.3 + * frame #0: inline_call`r1cfi(r1cai=71) at root1.zig:30:5 + frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:19:16 + frame #2: inline_call`root0.main at root0.zig:39:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + frame #0: inline_call`mod0.m0cf(m0ca=70) at mod0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + * frame #0: inline_call`mod0.m0cf(m0ca=70) at mod0.zig:26:5 + frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:20:14 + frame #2: inline_call`root0.main at root0.zig:39:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 6.3 + frame #0: inline_call`m0cfi(m0cai=69) at mod0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 6.3 + * frame #0: inline_call`m0cfi(m0cai=69) at mod0.zig:30:5 + frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:21:15 + frame #2: inline_call`root0.main at root0.zig:39:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + frame #0: inline_call`mod1.m1cf(m1ca=68) at mod1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + * frame #0: inline_call`mod1.m1cf(m1ca=68) at mod1.zig:26:5 + frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:22:14 + frame #2: inline_call`root0.main at root0.zig:39:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 8.3 + frame #0: inline_call`m1cfi(m1cai=75) at mod1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 8.3 + * frame #0: inline_call`m1cfi(m1cai=75) at mod1.zig:30:5 + frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:23:15 + frame #2: inline_call`root0.main at root0.zig:39:15 +(lldb) #--- +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + frame #0: inline_call`root0.r0cf(r0ca=79) at root0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + * frame #0: inline_call`root0.r0cf(r0ca=79) at root0.zig:26:5 + frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:6:15 + frame #2: inline_call`root0.main at root0.zig:40:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 2.5 + frame #0: inline_call`r0cfi(r0cai=76) at root0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 2.5 + * frame #0: inline_call`r0cfi(r0cai=76) at root0.zig:30:5 + frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:7:16 + frame #2: inline_call`root0.main at root0.zig:40:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + frame #0: inline_call`root1.r1cf(r1ca=77) at root1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + * frame #0: inline_call`root1.r1cf(r1ca=77) at root1.zig:26:5 + frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:8:15 + frame #2: inline_call`root0.main at root0.zig:40:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 4.5 + frame #0: inline_call`r1cfi(r1cai=74) at root1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 4.5 + * frame #0: inline_call`r1cfi(r1cai=74) at root1.zig:30:5 + frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:9:16 + frame #2: inline_call`root0.main at root0.zig:40:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + frame #0: inline_call`mod0.m0cf(m0ca=75) at mod0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + * frame #0: inline_call`mod0.m0cf(m0ca=75) at mod0.zig:26:5 + frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:10:14 + frame #2: inline_call`root0.main at root0.zig:40:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 6.5 + frame #0: inline_call`m0cfi(m0cai=72) at mod0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 6.5 + * frame #0: inline_call`m0cfi(m0cai=72) at mod0.zig:30:5 + frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:11:15 + frame #2: inline_call`root0.main at root0.zig:40:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + frame #0: inline_call`mod1.m1cf(m1ca=73) at mod1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + * frame #0: inline_call`mod1.m1cf(m1ca=73) at mod1.zig:26:5 + frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:12:14 + frame #2: inline_call`root0.main at root0.zig:40:14 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 8.5 + frame #0: inline_call`m1cfi(m1cai=70) at mod1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 8.5 + * frame #0: inline_call`m1cfi(m1cai=70) at mod1.zig:30:5 + frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:13:15 + frame #2: inline_call`root0.main at root0.zig:40:14 +(lldb) #--- +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + frame #0: inline_call`root0.r0cf(r0ca=88) at root0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 1.1 + * frame #0: inline_call`root0.r0cf(r0ca=88) at root0.zig:26:5 + frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:16:15 + frame #2: inline_call`root0.main at root0.zig:41:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 2.4 + frame #0: inline_call`r0cfi(r0cai=91) at root0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 2.4 + * frame #0: inline_call`r0cfi(r0cai=91) at root0.zig:30:5 + frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:17:16 + frame #2: inline_call`root0.main at root0.zig:41:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + frame #0: inline_call`root1.r1cf(r1ca=90) at root1.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 3.1 + * frame #0: inline_call`root1.r1cf(r1ca=90) at root1.zig:26:5 + frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:18:15 + frame #2: inline_call`root0.main at root0.zig:41:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 4.4 + frame #0: inline_call`r1cfi(r1cai=93) at root1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 4.4 + * frame #0: inline_call`r1cfi(r1cai=93) at root1.zig:30:5 + frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:19:16 + frame #2: inline_call`root0.main at root0.zig:41:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + frame #0: inline_call`mod0.m0cf(m0ca=92) at mod0.zig:26:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 5.1 + * frame #0: inline_call`mod0.m0cf(m0ca=92) at mod0.zig:26:5 + frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:20:14 + frame #2: inline_call`root0.main at root0.zig:41:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 6.4 + frame #0: inline_call`m0cfi(m0cai=95) at mod0.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 6.4 + * frame #0: inline_call`m0cfi(m0cai=95) at mod0.zig:30:5 + frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:21:15 + frame #2: inline_call`root0.main at root0.zig:41:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + frame #0: inline_call`mod1.m1cf(m1ca=94) at mod1.zig:26:5 +(lldb) thread backtrace --count 3' +* thread #1, name = 'inline_call', stop reason = breakpoint 7.1 + * frame #0: inline_call`mod1.m1cf(m1ca=94) at mod1.zig:26:5 + frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:22:14 + frame #2: inline_call`root0.main at root0.zig:41:15 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'inline_call', stop reason = breakpoint 8.4 + frame #0: inline_call`m1cfi(m1cai=81) at mod1.zig:30:5 +(lldb) thread backtrace --count 3 +* thread #1, name = 'inline_call', stop reason = breakpoint 8.4 + * frame #0: inline_call`m1cfi(m1cai=81) at mod1.zig:30:5 + frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:23:15 + frame #2: inline_call`root0.main at root0.zig:41:15 diff --git a/test/debugger/inline_call/manifest b/test/debugger/inline_call/manifest new file mode 100644 index 0000000000000000000000000000000000000000..77b906f21de307fc4e2219ec965df5f08d3b5a19 --- /dev/null +++ b/test/debugger/inline_call/manifest @@ -0,0 +1,18 @@ +#todo { +implement inline line info in lldb +#} +#skip x86_64-linux-none-incremental-selfhosted-new-nopic +#skip x86_64-linux-none-incremental-selfhosted-new-pic + +#exe { +--name inline_call +--dep module -Mroot=root0.zig +-Mmodule=mod0.zig +#} + +#write root0.zig root0.zig +#write root1.zig root1.zig +#write mod0.zig mod0.zig +#write mod1.zig mod1.zig +#update +#check lldb lldb diff --git a/test/debugger/inline_call/mod0.zig b/test/debugger/inline_call/mod0.zig new file mode 100644 index 0000000000000000000000000000000000000000..8e64bca9e2f454994e6dac3f2aa4f3219f7c3366 --- /dev/null +++ b/test/debugger/inline_call/mod0.zig @@ -0,0 +1,32 @@ +const root0 = @import("root"); +const root1 = root0.root1; +const mod0 = @This(); +pub const mod1 = @import("mod1.zig"); +pub fn m0pf(m0pa: u32) void { + root0.r0cf(m0pa ^ 1); + root0.r0cfi(m0pa ^ 2); + root1.r1cf(m0pa ^ 3); + root1.r1cfi(m0pa ^ 4); + mod0.m0cf(m0pa ^ 5); + mod0.m0cfi(m0pa ^ 6); + mod1.m1cf(m0pa ^ 7); + mod1.m1cfi(m0pa ^ 8); +} +pub inline fn m0pfi(m0pai: u32) void { + root0.r0cf(m0pai ^ 1); + root0.r0cfi(m0pai ^ 2); + root1.r1cf(m0pai ^ 3); + root1.r1cfi(m0pai ^ 4); + mod0.m0cf(m0pai ^ 5); + mod0.m0cfi(m0pai ^ 6); + mod1.m1cf(m0pai ^ 7); + mod1.m1cfi(m0pai ^ 8); +} +pub fn m0cf(m0ca: u32) void { + var discard = m0ca; + _ = &discard; +} +pub inline fn m0cfi(m0cai: u32) void { + var discard = m0cai; + _ = &discard; +} diff --git a/test/debugger/inline_call/mod1.zig b/test/debugger/inline_call/mod1.zig new file mode 100644 index 0000000000000000000000000000000000000000..2041fa6f50b956145d62fb7b1b336e5321c09df5 --- /dev/null +++ b/test/debugger/inline_call/mod1.zig @@ -0,0 +1,32 @@ +const root0 = @import("root"); +const root1 = root0.root1; +const mod0 = @import("mod0.zig"); +const mod1 = @This(); +pub fn m1pf(m1pa: u32) void { + root0.r0cf(m1pa ^ 1); + root0.r0cfi(m1pa ^ 2); + root1.r1cf(m1pa ^ 3); + root1.r1cfi(m1pa ^ 4); + mod0.m0cf(m1pa ^ 5); + mod0.m0cfi(m1pa ^ 6); + mod1.m1cf(m1pa ^ 7); + mod1.m1cfi(m1pa ^ 8); +} +pub inline fn m1pfi(m1pai: u32) void { + root0.r0cf(m1pai ^ 1); + root0.r0cfi(m1pai ^ 2); + root1.r1cf(m1pai ^ 3); + root1.r1cfi(m1pai ^ 4); + mod0.m0cf(m1pai ^ 5); + mod0.m0cfi(m1pai ^ 6); + mod1.m1cf(m1pai ^ 7); + mod1.m1cfi(m1pai ^ 8); +} +pub fn m1cf(m1ca: u32) void { + var discard = m1ca; + _ = &discard; +} +pub inline fn m1cfi(m1cai: u32) void { + var discard = m1cai; + _ = &discard; +} diff --git a/test/debugger/inline_call/root0.zig b/test/debugger/inline_call/root0.zig new file mode 100644 index 0000000000000000000000000000000000000000..e3779f6e5b2b2ecf288e91a05c330433ea662a85 --- /dev/null +++ b/test/debugger/inline_call/root0.zig @@ -0,0 +1,42 @@ +const root0 = @This(); +pub const root1 = @import("root1.zig"); +const mod0 = @import("module"); +const mod1 = mod0.mod1; +pub fn r0pf(r0pa: u32) void { + root0.r0cf(r0pa ^ 1); + root0.r0cfi(r0pa ^ 2); + root1.r1cf(r0pa ^ 3); + root1.r1cfi(r0pa ^ 4); + mod0.m0cf(r0pa ^ 5); + mod0.m0cfi(r0pa ^ 6); + mod1.m1cf(r0pa ^ 7); + mod1.m1cfi(r0pa ^ 8); +} +pub inline fn r0pfi(r0pai: u32) void { + root0.r0cf(r0pai ^ 1); + root0.r0cfi(r0pai ^ 2); + root1.r1cf(r0pai ^ 3); + root1.r1cfi(r0pai ^ 4); + mod0.m0cf(r0pai ^ 5); + mod0.m0cfi(r0pai ^ 6); + mod1.m1cf(r0pai ^ 7); + mod1.m1cfi(r0pai ^ 8); +} +pub fn r0cf(r0ca: u32) void { + var discard = r0ca; + _ = &discard; +} +pub inline fn r0cfi(r0cai: u32) void { + var discard = r0cai; + _ = &discard; +} +pub fn main() void { + root0.r0pf(12); + root0.r0pfi(23); + root1.r1pf(34); + root1.r1pfi(45); + mod0.m0pf(56); + mod0.m0pfi(67); + mod1.m1pf(78); + mod1.m1pfi(89); +} diff --git a/test/debugger/inline_call/root1.zig b/test/debugger/inline_call/root1.zig new file mode 100644 index 0000000000000000000000000000000000000000..0da01c22ae7d4ae1a02b115736491d6f183647f2 --- /dev/null +++ b/test/debugger/inline_call/root1.zig @@ -0,0 +1,32 @@ +const root0 = @import("root0.zig"); +const root1 = @This(); +const mod0 = @import("module"); +const mod1 = mod0.mod1; +pub fn r1pf(r1pa: u32) void { + root0.r0cf(r1pa ^ 1); + root0.r0cfi(r1pa ^ 2); + root1.r1cf(r1pa ^ 3); + root1.r1cfi(r1pa ^ 4); + mod0.m0cf(r1pa ^ 5); + mod0.m0cfi(r1pa ^ 6); + mod1.m1cf(r1pa ^ 7); + mod1.m1cfi(r1pa ^ 8); +} +pub inline fn r1pfi(r1pai: u32) void { + root0.r0cf(r1pai ^ 1); + root0.r0cfi(r1pai ^ 2); + root1.r1cf(r1pai ^ 3); + root1.r1cfi(r1pai ^ 4); + mod0.m0cf(r1pai ^ 5); + mod0.m0cfi(r1pai ^ 6); + mod1.m1cf(r1pai ^ 7); + mod1.m1cfi(r1pai ^ 8); +} +pub fn r1cf(r1ca: u32) void { + var discard = r1ca; + _ = &discard; +} +pub inline fn r1cfi(r1cai: u32) void { + var discard = r1cai; + _ = &discard; +} diff --git a/test/debugger/link_object b/test/debugger/link_object new file mode 100644 index 0000000000000000000000000000000000000000..eed9e81e66336171e65667caf0795196ce1517da --- /dev/null +++ b/test/debugger/link_object @@ -0,0 +1,39 @@ +#exe { +--name link_object +-Mroot=main.zig +#} + +#write main.zig { +extern fn fabsf(f32) f32; +pub fn main() void { + var x: f32 = -1234.5; + x = fabsf(x); + _ = &x; +} +#} +#update +#check lldb { +(lldb) breakpoint set --file main.zig --source-pattern-regexp 'x = fabsf\(x\);' +Breakpoint 1: where = link_object`main.main + #... at main.zig:4:14, address = 0x#... +(lldb) process launch +Process #... launched: '#.../link_object' (#...) +Process #... stopped +* thread #1, name = 'link_object', stop reason = breakpoint 1.1 + frame #0: link_object`main.main at main.zig:4:14 +(lldb) frame variable --show-all-children -- x +(f32) x = -1234.5 +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +(lldb) #--- +(lldb) breakpoint set --file main.zig --source-pattern-regexp '_ = &x;' +Breakpoint 2: where = link_object`main.main + #... at main.zig:5:5, address = 0x#... +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'link_object', stop reason = breakpoint 2.1 + frame #0: link_object`main.main at main.zig:5:5 +(lldb) frame variable --show-all-children -- x +(f32) x = 1234.5 +(lldb) breakpoint delete --force 2 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/multi_array_list/lldb b/test/debugger/multi_array_list/lldb new file mode 100644 index 0000000000000000000000000000000000000000..6377a3e8b0477e90de08c6dbbc2937cfeba0b71c --- /dev/null +++ b/test/debugger/multi_array_list/lldb @@ -0,0 +1,209 @@ +(lldb) breakpoint set --file main.zig --source-pattern-regexp '_ = \.{ list0, slice0, list1, slice1 };' +Breakpoint 1: where = mal`main.testMultiArrayList + #... at main.zig:11:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../mal' (#...) +Process #... stopped +* thread #1, name = 'mal', stop reason = breakpoint 1.1 + frame #0: mal`main.testMultiArrayList(list0=len=3 capacity=8, slice0=len=3 capacity=8, list1=len=3 capacity=12, slice1=len=3 capacity=12) at main.zig:11:1 +(lldb) frame variable --show-all-children --show-types -- list0 list0.len list0.capacity list0[0] list0[1] list0[2] 'list0.@"0"' 'list0.@"1"' 'list0.@"2"' +(std.multi_array_list.MultiArrayList(struct { u32, u8, u16 })) list0 = len=3 capacity=8 { + (struct { u32, u8, u16 }) [0] = { + (u32) .@"0" = 1 + (u8) .@"1" = 2 + (u16) .@"2" = 3 + } + (struct { u32, u8, u16 }) [1] = { + (u32) .@"0" = 4 + (u8) .@"1" = 5 + (u16) .@"2" = 6 + } + (struct { u32, u8, u16 }) [2] = { + (u32) .@"0" = 7 + (u8) .@"1" = 8 + (u16) .@"2" = 9 + } +} +(usize) list0.len = 3 +(usize) list0.capacity = 8 +(struct { u32, u8, u16 }) list0[0] = { + (u32) .@"0" = 1 + (u8) .@"1" = 2 + (u16) .@"2" = 3 +} +(struct { u32, u8, u16 }) list0[1] = { + (u32) .@"0" = 4 + (u8) .@"1" = 5 + (u16) .@"2" = 6 +} +(struct { u32, u8, u16 }) list0[2] = { + (u32) .@"0" = 7 + (u8) .@"1" = 8 + (u16) .@"2" = 9 +} +([3]u32) list0.@"0" = { + (u32) [0] = 1 + (u32) [1] = 4 + (u32) [2] = 7 +} +([3]u8) list0.@"1" = { + (u8) [0] = 2 + (u8) [1] = 5 + (u8) [2] = 8 +} +([3]u16) list0.@"2" = { + (u16) [0] = 3 + (u16) [1] = 6 + (u16) [2] = 9 +} +(lldb) frame variable --show-all-children --show-types -- slice0 slice0.len slice0.capacity slice0[0] slice0[1] slice0[2] 'slice0.@"0"' 'slice0.@"1"' 'slice0.@"2"' +(std.multi_array_list.MultiArrayList(struct { u32, u8, u16 }).Slice) slice0 = len=3 capacity=8 { + (struct { u32, u8, u16 }) [0] = { + (u32) .@"0" = 1 + (u8) .@"1" = 2 + (u16) .@"2" = 3 + } + (struct { u32, u8, u16 }) [1] = { + (u32) .@"0" = 4 + (u8) .@"1" = 5 + (u16) .@"2" = 6 + } + (struct { u32, u8, u16 }) [2] = { + (u32) .@"0" = 7 + (u8) .@"1" = 8 + (u16) .@"2" = 9 + } +} +(usize) slice0.len = 3 +(usize) slice0.capacity = 8 +(struct { u32, u8, u16 }) slice0[0] = { + (u32) .@"0" = 1 + (u8) .@"1" = 2 + (u16) .@"2" = 3 +} +(struct { u32, u8, u16 }) slice0[1] = { + (u32) .@"0" = 4 + (u8) .@"1" = 5 + (u16) .@"2" = 6 +} +(struct { u32, u8, u16 }) slice0[2] = { + (u32) .@"0" = 7 + (u8) .@"1" = 8 + (u16) .@"2" = 9 +} +([3]u32) slice0.@"0" = { + (u32) [0] = 1 + (u32) [1] = 4 + (u32) [2] = 7 +} +([3]u8) slice0.@"1" = { + (u8) [0] = 2 + (u8) [1] = 5 + (u8) [2] = 8 +} +([3]u16) slice0.@"2" = { + (u16) [0] = 3 + (u16) [1] = 6 + (u16) [2] = 9 +} +(lldb) frame variable --show-all-children --show-types -- list1 list1.len list1.capacity list1[0] list1[1] list1[2] list1.a list1.b list1.c +(std.multi_array_list.MultiArrayList(main.Elem1)) list1 = len=3 capacity=12 { + (root.main.Elem1) [0] = { + (u32) .a = 1 + (u8) .b = 2 + (u16) .c = 3 + } + (root.main.Elem1) [1] = { + (u32) .a = 4 + (u8) .b = 5 + (u16) .c = 6 + } + (root.main.Elem1) [2] = { + (u32) .a = 7 + (u8) .b = 8 + (u16) .c = 9 + } +} +(usize) list1.len = 3 +(usize) list1.capacity = 12 +(root.main.Elem1) list1[0] = { + (u32) .a = 1 + (u8) .b = 2 + (u16) .c = 3 +} +(root.main.Elem1) list1[1] = { + (u32) .a = 4 + (u8) .b = 5 + (u16) .c = 6 +} +(root.main.Elem1) list1[2] = { + (u32) .a = 7 + (u8) .b = 8 + (u16) .c = 9 +} +([3]u32) list1.a = { + (u32) [0] = 1 + (u32) [1] = 4 + (u32) [2] = 7 +} +([3]u8) list1.b = { + (u8) [0] = 2 + (u8) [1] = 5 + (u8) [2] = 8 +} +([3]u16) list1.c = { + (u16) [0] = 3 + (u16) [1] = 6 + (u16) [2] = 9 +} +(lldb) frame variable --show-all-children --show-types -- slice1 slice1.len slice1.capacity slice1[0] slice1[1] slice1[2] slice1.a slice1.b slice1.c +(std.multi_array_list.MultiArrayList(main.Elem1).Slice) slice1 = len=3 capacity=12 { + (root.main.Elem1) [0] = { + (u32) .a = 1 + (u8) .b = 2 + (u16) .c = 3 + } + (root.main.Elem1) [1] = { + (u32) .a = 4 + (u8) .b = 5 + (u16) .c = 6 + } + (root.main.Elem1) [2] = { + (u32) .a = 7 + (u8) .b = 8 + (u16) .c = 9 + } +} +(usize) slice1.len = 3 +(usize) slice1.capacity = 12 +(root.main.Elem1) slice1[0] = { + (u32) .a = 1 + (u8) .b = 2 + (u16) .c = 3 +} +(root.main.Elem1) slice1[1] = { + (u32) .a = 4 + (u8) .b = 5 + (u16) .c = 6 +} +(root.main.Elem1) slice1[2] = { + (u32) .a = 7 + (u8) .b = 8 + (u16) .c = 9 +} +([3]u32) slice1.a = { + (u32) [0] = 1 + (u32) [1] = 4 + (u32) [2] = 7 +} +([3]u8) slice1.b = { + (u8) [0] = 2 + (u8) [1] = 5 + (u8) [2] = 8 +} +([3]u16) slice1.c = { + (u16) [0] = 3 + (u16) [1] = 6 + (u16) [2] = 9 +} +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. diff --git a/test/debugger/multi_array_list/main.zig b/test/debugger/multi_array_list/main.zig new file mode 100644 index 0000000000000000000000000000000000000000..5a23b7d089585d5c47412ceb20a78832562a4419 --- /dev/null +++ b/test/debugger/multi_array_list/main.zig @@ -0,0 +1,30 @@ +const std = @import("std"); +const Elem0 = struct { u32, u8, u16 }; +const Elem1 = struct { a: u32, b: u8, c: u16 }; +fn testMultiArrayList( + list0: std.MultiArrayList(Elem0), + slice0: std.MultiArrayList(Elem0).Slice, + list1: std.MultiArrayList(Elem1), + slice1: std.MultiArrayList(Elem1).Slice, +) void { + _ = .{ list0, slice0, list1, slice1 }; +} +pub fn main() !void { + var list0: std.MultiArrayList(Elem0) = .{}; + defer list0.deinit(std.heap.page_allocator); + try list0.setCapacity(std.heap.page_allocator, 8); + list0.appendAssumeCapacity(.{ 1, 2, 3 }); + list0.appendAssumeCapacity(.{ 4, 5, 6 }); + list0.appendAssumeCapacity(.{ 7, 8, 9 }); + const slice0 = list0.slice(); + + var list1: std.MultiArrayList(Elem1) = .{}; + defer list1.deinit(std.heap.page_allocator); + try list1.setCapacity(std.heap.page_allocator, 12); + list1.appendAssumeCapacity(.{ .a = 1, .b = 2, .c = 3 }); + list1.appendAssumeCapacity(.{ .a = 4, .b = 5, .c = 6 }); + list1.appendAssumeCapacity(.{ .a = 7, .b = 8, .c = 9 }); + const slice1 = list1.slice(); + + testMultiArrayList(list0, slice0, list1, slice1); +} diff --git a/test/debugger/multi_array_list/manifest b/test/debugger/multi_array_list/manifest new file mode 100644 index 0000000000000000000000000000000000000000..2503522bee1531df3cd11ce44cfec94b2510def5 --- /dev/null +++ b/test/debugger/multi_array_list/manifest @@ -0,0 +1,8 @@ +#exe { +--name mal +-Mroot=main.zig +#} + +#write main.zig main.zig +#update +#check lldb lldb diff --git a/test/debugger/optionals b/test/debugger/optionals new file mode 100644 index 0000000000000000000000000000000000000000..8353b3e527a180e4062486134b2fe76edd959cab --- /dev/null +++ b/test/debugger/optionals @@ -0,0 +1,54 @@ +#exe { +--name optionals +-Mroot=optionals.zig +#} + +#write optionals.zig { +pub fn main() void { + { + var null_u32: ?u32 = null; + var maybe_u32: ?u32 = null; + var nonnull_u32: ?u32 = 456; + null_u32 = null_u32; + maybe_u32 = 123; + nonnull_u32 = nonnull_u32; + } +} +#} +#update +#check lldb { +(lldb) breakpoint set --file optionals.zig --source-pattern-regexp 'maybe_u32 = 123;' +Breakpoint 1: where = optionals`optionals.main + #... at optionals.zig:7:9, address = 0x#... +(lldb) process launch +Process #... launched: '#.../optionals' (#...) +Process #... stopped +* thread #1, name = 'optionals', stop reason = breakpoint 1.1 + frame #0: optionals`optionals.main at optionals.zig:7:9 +(lldb) frame variable --show-all-children -- null_u32 maybe_u32 nonnull_u32 nonnull_u32.? +(?u32) null_u32 = null +(?u32) maybe_u32 = null +(?u32) nonnull_u32 = (nonnull_u32.? = 456) +(u32) nonnull_u32.? = 456 +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +(lldb) #--- +(lldb) breakpoint set --file optionals.zig --source-pattern-regexp 'nonnull_u32 = nonnull_u32;' +Breakpoint 2: where = optionals`optionals.main + #... at optionals.zig:8:9, address = 0x#... +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'optionals', stop reason = breakpoint 2.1 + frame #0: optionals`optionals.main at optionals.zig:8:9 +(lldb) frame variable --show-all-children --show-types -- null_u32 maybe_u32 maybe_u32.? nonnull_u32 nonnull_u32.? +(?u32) null_u32 = null +(?u32) maybe_u32 = { + (u32) maybe_u32.? = 123 +} +(u32) maybe_u32.? = 123 +(?u32) nonnull_u32 = { + (u32) nonnull_u32.? = 456 +} +(u32) nonnull_u32.? = 456 +(lldb) breakpoint delete --force 2 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/pointers b/test/debugger/pointers new file mode 100644 index 0000000000000000000000000000000000000000..f68ed7c3c7883e6a9c4af4798101ef0bcfac3537 --- /dev/null +++ b/test/debugger/pointers @@ -0,0 +1,135 @@ +#exe { +--name pointers +-Mroot=pointers.zig +#} + +#write pointers.zig { +var array: [7]u32 = .{ + 3010, + 3014, + 3018, + 3022, + 3026, + 3030, + 3034, +}; +const Pointers = struct { + 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_allowzero_const: *allowzero const u32 = @ptrFromInt(0x1024), + single_allowzero_volatile: *allowzero volatile u32 = @ptrFromInt(0x1028), + single_allowzero_const_volatile: *allowzero const volatile 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_allowzero_const: [*]allowzero const u32 = @ptrFromInt(0x2024), + many_allowzero_volatile: [*]allowzero volatile u32 = @ptrFromInt(0x2028), + many_allowzero_const_volatile: [*]allowzero const volatile 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_allowzero_const: []allowzero const u32 = array[4..5], + slice_allowzero_volatile: []allowzero volatile u32 = array[4..6], + slice_allowzero_const_volatile: []allowzero const volatile 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), +}; +const Access = struct { + single: *u32 = &array[0], + many: [*]u32 = array[1..3], + slice: []u32 = array[3..5], + c: [*c]u32 = array[5..7], +}; +fn testPointers(pointers: Pointers, access: Access) void { + _ = pointers; + _ = access; +} +pub fn main() void { + testPointers(.{}, .{}); +} +#} +#update +#check lldb { +(lldb) breakpoint set --file pointers.zig --source-pattern-regexp '_ = access;' +Breakpoint 1: where = pointers`pointers.testPointers + #... at pointers.zig:51:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../pointers' (#...) +Process #... stopped +* thread #1, name = 'pointers', stop reason = breakpoint 1.1 + frame #0: pointers`pointers.testPointers(pointers=Pointers @ 0x#..., access=Access @ 0x#...) at pointers.zig:51:1 +(lldb) frame variable --show-all-children --show-types -- pointers access.single.* access.many[0] access.many[1] access.slice[0] access.slice[1] access.c.* access.c[0] access.c[1] +(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 + (*allowzero const u32) .single_allowzero_const = 0x0000000000001024 + (*allowzero volatile u32) .single_allowzero_volatile = 0x0000000000001028 + (*allowzero const volatile u32) .single_allowzero_const_volatile = 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 + ([*]allowzero const u32) .many_allowzero_const = 0x0000000000002024 + ([*]allowzero volatile u32) .many_allowzero_volatile = 0x0000000000002028 + ([*]allowzero const volatile u32) .many_allowzero_const_volatile = 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 {} + ([]allowzero const u32) .slice_allowzero_const = len=1 { + (u32) [0] = 3026 + } + ([]allowzero volatile u32) .slice_allowzero_volatile = len=2 { + (u32) [0] = 3026 + (u32) [1] = 3030 + } + ([]allowzero const volatile u32) .slice_allowzero_const_volatile = 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 +} +(u32) access.single.* = 3010 +(u32) access.many[0] = 3014 +(u32) access.many[1] = 3018 +(u32) access.slice[0] = 3022 +(u32) access.slice[1] = 3026 +(u32) access.c.* = 3030 +(u32) access.c[0] = 3030 +(u32) access.c[1] = 3034 +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/step_single_stmt_loops/lldb b/test/debugger/step_single_stmt_loops/lldb new file mode 100644 index 0000000000000000000000000000000000000000..0b07018e0c8ed8de85ed64edf85a9b4053f7e3ea --- /dev/null +++ b/test/debugger/step_single_stmt_loops/lldb @@ -0,0 +1,329 @@ +(lldb) breakpoint set --name step_single_stmt_loops.main +Breakpoint 1: where = sssl`step_single_stmt_loops.main + #... at step_single_stmt_loops.zig:2:5, address = 0x#... +(lldb) process launch +Process #... launched: '#.../sssl' (#...) +Process #... stopped +* thread #1, name = 'sssl', stop reason = breakpoint 1.1 + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:2:5 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:3:10 +(lldb) #00 +(lldb) frame variable --show-all-children x +(u32) x = 0 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:4:9 +(lldb) #01 +(lldb) frame variable --show-all-children x +(u32) x = 0 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:5:5 +(lldb) #02 +(lldb) frame variable --show-all-children x +(u32) x = 1 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:3:10 +(lldb) #03 +(lldb) frame variable --show-all-children x +(u32) x = 1 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:4:9 +(lldb) #04 +(lldb) frame variable --show-all-children x +(u32) x = 1 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:5:5 +(lldb) #05 +(lldb) frame variable --show-all-children x +(u32) x = 2 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:3:10 +(lldb) #06 +(lldb) frame variable --show-all-children x +(u32) x = 2 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:4:9 +(lldb) #07 +(lldb) frame variable --show-all-children x +(u32) x = 2 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:5:5 +(lldb) #08 +(lldb) frame variable --show-all-children x +(u32) x = 3 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:3:10 +(lldb) #09 +(lldb) frame variable --show-all-children x +(u32) x = 3 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:7:9 +(lldb) #10 +(lldb) frame variable --show-all-children x +(u32) x = 3 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:8:16 +(lldb) #11 +(lldb) frame variable --show-all-children x +(u32) x = 3 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:9:13 +(lldb) #12 +(lldb) frame variable --show-all-children x +(u32) x = 3 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:10:9 +(lldb) #13 +(lldb) frame variable --show-all-children x +(u32) x = 4 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:8:26 +(lldb) #14 +(lldb) frame variable --show-all-children x +(u32) x = 4 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:9:13 +(lldb) #15 +(lldb) frame variable --show-all-children x +(u32) x = 4 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:10:9 +(lldb) #16 +(lldb) frame variable --show-all-children x +(u32) x = 5 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:8:26 +(lldb) #17 +(lldb) frame variable --show-all-children x +(u32) x = 5 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:9:13 +(lldb) #18 +(lldb) frame variable --show-all-children x +(u32) x = 5 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:10:9 +(lldb) #19 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:8:26 +(lldb) #20 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:13:9 +(lldb) #21 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:14:16 +(lldb) #22 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:15:13 +(lldb) #23 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:16:9 +(lldb) #24 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:14:16 +(lldb) #25 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:15:13 +(lldb) #26 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:16:9 +(lldb) #27 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:14:16 +(lldb) #28 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:15:13 +(lldb) #29 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:16:9 +(lldb) #30 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:14:16 +(lldb) #31 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:19:9 +(lldb) #32 +(lldb) frame variable --show-all-children x +(u32) x = 6 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:20:5 +(lldb) #33 +(lldb) frame variable --show-all-children x +(u32) x = 7 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:19:9 +(lldb) #34 +(lldb) frame variable --show-all-children x +(u32) x = 7 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:20:5 +(lldb) #35 +(lldb) frame variable --show-all-children x +(u32) x = 8 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:19:9 +(lldb) #36 +(lldb) frame variable --show-all-children x +(u32) x = 8 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:20:5 +(lldb) #37 +(lldb) frame variable --show-all-children x +(u32) x = 9 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:24:13 +(lldb) #38 +(lldb) frame variable --show-all-children x +(u32) x = 9 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:25:9 +(lldb) #39 +(lldb) frame variable --show-all-children x +(u32) x = 10 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:24:13 +(lldb) #40 +(lldb) frame variable --show-all-children x +(u32) x = 10 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:25:9 +(lldb) #41 +(lldb) frame variable --show-all-children x +(u32) x = 11 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:24:13 +(lldb) #42 +(lldb) frame variable --show-all-children x +(u32) x = 11 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:25:9 +(lldb) #43 +(lldb) frame variable --show-all-children x +(u32) x = 12 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:31:9 +(lldb) #44 +(lldb) frame variable --show-all-children x +(u32) x = 12 +(lldb) thread step-in +Process #... stopped +* thread #1, name = 'sssl', stop reason = step in + frame #0: sssl`step_single_stmt_loops.main at step_single_stmt_loops.zig:33:5 +(lldb) #45 +(lldb) frame variable --show-all-children x +(u32) x = 12 diff --git a/test/debugger/step_single_stmt_loops/manifest b/test/debugger/step_single_stmt_loops/manifest new file mode 100644 index 0000000000000000000000000000000000000000..d7284fe12466167a022443945763760b7655e352 --- /dev/null +++ b/test/debugger/step_single_stmt_loops/manifest @@ -0,0 +1,8 @@ +#exe { +--name sssl +-Mroot=step_single_stmt_loops.zig +#} + +#write step_single_stmt_loops.zig step_single_stmt_loops.zig +#update +#check lldb lldb diff --git a/test/debugger/step_single_stmt_loops/step_single_stmt_loops.zig b/test/debugger/step_single_stmt_loops/step_single_stmt_loops.zig new file mode 100644 index 0000000000000000000000000000000000000000..6ee488cc59b9feba8bf86b44e9407eef18f2d5ae --- /dev/null +++ b/test/debugger/step_single_stmt_loops/step_single_stmt_loops.zig @@ -0,0 +1,34 @@ +pub fn main() void { + var x: u32 = 0; + for (0..3) |_| { + x +%= 1; + } + { + var i: u32 = 0; + while (i < 3) : (i +%= 1) { + x +%= 1; + } + } + { + var i: u32 = 0; + while (i < 3) { + i +%= 1; + } + } + inline for (0..3) |_| { + x +%= 1; + } + { + comptime var i: u32 = 0; + inline while (i < 3) : (i +%= 1) { + x +%= 1; + } + } + { + comptime var i: u32 = 0; + inline while (i < 3) { + i +%= 1; + } + } + x +%= 1; +} diff --git a/test/debugger/storage b/test/debugger/storage new file mode 100644 index 0000000000000000000000000000000000000000..4cd4c55f5dece6bcb454b6db6a0101ae1c60500f --- /dev/null +++ b/test/debugger/storage @@ -0,0 +1,93 @@ +#exe { +--name storage +-Mroot=storage.zig +#} + +#write storage.zig { +comptime { + _ = @import("externs.zig"); +} +const global_const: u64 = 0x19e50dc8d6002077; +var global_var: u64 = 0xcc423cec08622e32; +threadlocal var global_threadlocal1: u64 = 0xb4d643528c042121; +threadlocal var global_threadlocal2: u64 = 0x43faea1cf5ad7a22; +extern const extern_const: u64; +extern var extern_var: u64; +extern threadlocal var extern_threadlocal1: u64; +extern threadlocal var extern_threadlocal2: u64; +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 ^ + extern_const ^ extern_var ^ extern_threadlocal1 ^ extern_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, + ); +} +#} +#write externs.zig { +export const extern_const: u64 = 0x1b0c91ea0470b0b2; +export var extern_var: u64 = 0x19bc17b3f0b61ebc; +export threadlocal var extern_threadlocal1: u64 = 0x3034c4ce967ed64d; +export threadlocal var extern_threadlocal2: u64 = 0xfd330ab00b4bc5eb; +#} +#update +#check lldb { +(lldb) breakpoint set --file storage.zig --source-pattern-regexp 'local_var = local_var;' +Breakpoint 1: where = storage`storage.testStorage + #... at storage.zig:28:5, address = 0x#... +(lldb) process launch +Process #... launched: '#.../storage' (#...) +Process #... stopped +* thread #1, name = 'storage', stop reason = breakpoint 1.1 + frame #0: storage`storage.testStorage(param1=7665265138917473792, param2=10994496920463510353, param3=11754622696676058875, param4=7574723978257576564, param5=7163272523887770015, param6=10238440135580477426, param7=17988030864880782342, param8=14449011544845051009) at storage.zig:28:5 +(lldb) target variable --show-types --format hex -- global_const global_var global_threadlocal1 global_threadlocal2 extern_const extern_var extern_threadlocal1 extern_threadlocal2 +(u64) global_const = 0x19e50dc8d6002077 +(u64) global_var = 0xcc423cec08622e32 +(u64) global_threadlocal1 = 0xb4d643528c042121 +(u64) global_threadlocal2 = 0x43faea1cf5ad7a22 +(u64) extern_const = 0x1b0c91ea0470b0b2 +(u64) extern_const = 0x1b0c91ea0470b0b2 +(u64) extern_var = 0x19bc17b3f0b61ebc +(u64) extern_var = 0x19bc17b3f0b61ebc +(u64) extern_threadlocal1 = 0x3034c4ce967ed64d +(u64) extern_threadlocal1 = 0x3034c4ce967ed64d +(u64) extern_threadlocal2 = 0xfd330ab00b4bc5eb +(u64) extern_threadlocal2 = 0xfd330ab00b4bc5eb +(lldb) frame variable --show-all-children --show-types --format hex -- param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val 'local_comptime_ptr.@"0"' 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_comptime_ptr[0] = 0x82e834dae74767a1 +(u64) local_const = 0x104ba3ac46b25fad +(u64) local_var = 0x92a39776a1f5380c +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/strings b/test/debugger/strings new file mode 100644 index 0000000000000000000000000000000000000000..dde12871b7170d2aa2edea2448497dd0c014daea --- /dev/null +++ b/test/debugger/strings @@ -0,0 +1,72 @@ +#exe { +--name strings +-Mroot=strings.zig +#} + +#write strings.zig { +const Strings = struct { + c_ptr: [*c]const u8 = "c_ptr\x07\x08\t", + many_ptr: [*:0]const u8 = "many_ptr\n\x0b\x0c", + ptr_array: *const [12:0]u8 = "ptr_array\x00\r\x1b", + slice: [:0]const u8 = "slice\"\'\\\x00", +}; +fn testStrings(strings: Strings) void { + _ = strings; +} +pub fn main() void { + testStrings(.{}); +} +#} +#update +#check lldb { +(lldb) breakpoint set --file strings.zig --source-pattern-regexp '_ = strings;' +Breakpoint 1: where = strings`strings.testStrings + #... at strings.zig:9:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../strings' (#...) +Process #... stopped +* thread #1, name = 'strings', stop reason = breakpoint 1.1 + frame #0: strings`strings.testStrings(strings=Strings @ 0x#...) at strings.zig:9:1 +(lldb) frame variable --show-all-children --show-types -- strings.slice +([:0]const u8) strings.slice = len=9 { + (u8) [0] = 115 + (u8) [1] = 108 + (u8) [2] = 105 + (u8) [3] = 99 + (u8) [4] = 101 + (u8) [5] = 34 + (u8) [6] = 39 + (u8) [7] = 92 + (u8) [8] = 0 +} +(lldb) frame variable --show-all-children --show-types --format character -- strings.slice +([:0]const u8) strings.slice = len=9 { + (u8) [0] = 's' + (u8) [1] = 'l' + (u8) [2] = 'i' + (u8) [3] = 'c' + (u8) [4] = 'e' + (u8) [5] = '\"' + (u8) [6] = '\'' + (u8) [7] = '\\' + (u8) [8] = '\x00' +} +(lldb) frame variable --show-all-children --show-types --format c-string -- strings +(root.strings.Strings) strings = { + ([*c]const u8) .c_ptr = "c_ptr\x07\x08\t" + ([*:0]const u8) .many_ptr = "many_ptr\n\x0b\x0c" + (*const [12:0]u8) .ptr_array = "ptr_array\x00\r\x1b" + ([:0]const u8) .slice = "slice\"\'\\\x00" len=9 { + (u8) [0] = "s" + (u8) [1] = "l" + (u8) [2] = "i" + (u8) [3] = "c" + (u8) [4] = "e" + (u8) [5] = "\"" + (u8) [6] = "\'" + (u8) [7] = "\\" + (u8) [8] = "\x00" + } +} +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/switch_blocks b/test/debugger/switch_blocks new file mode 100644 index 0000000000000000000000000000000000000000..1c6c66a47ae797c61ab2ab88951602cd2298653e --- /dev/null +++ b/test/debugger/switch_blocks @@ -0,0 +1,44 @@ +#exe { +--name switch_blocks +-Mroot=switch_blocks.zig +#} + +#write switch_blocks.zig { +pub fn main() void { + for (0..2) |i| { + switch (i) { + 0 => { + var x: u32 = 123; + _ = &x; + }, + else => { + var x: f32 = 4.5; + _ = &x; + }, + } + } +} +#} +#update +#check lldb { +(lldb) breakpoint set --file switch_blocks.zig --source-pattern-regexp '_ = &x;' +Breakpoint 1: 2 locations. +(lldb) process launch +Process #... launched: '#.../switch_blocks' (#...) +Process #... stopped +* thread #1, name = 'switch_blocks', stop reason = breakpoint 1.1 + frame #0: switch_blocks`switch_blocks.main at switch_blocks.zig:6:17 +(lldb) frame variable --show-all-children +(usize) i = 0 +(u32) x = 123 +(lldb) process continue +Process #... resuming +Process #... stopped +* thread #1, name = 'switch_blocks', stop reason = breakpoint 1.2 + frame #0: switch_blocks`switch_blocks.main at switch_blocks.zig:10:17 +(lldb) frame variable --show-all-children +(usize) i = 1 +(f32) x = 4.5 +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/types b/test/debugger/types new file mode 100644 index 0000000000000000000000000000000000000000..3f0a6788c57ec72c32454eef07014a76dbf61971 --- /dev/null +++ b/test/debugger/types @@ -0,0 +1,67 @@ +#exe { +--name types +-Mroot=types.zig +#} + +#write types.zig { +fn testTypes( + Anyopaque: type, + Bool: type, + Void: type, + Type: type, + ComptimeInt: type, + ComptimeFloat: type, + Noreturn: type, + Null: type, + Undefined: type, + EnumLiteral: type, +) void { + _ = Anyopaque; + _ = Bool; + _ = Void; + _ = Type; + _ = ComptimeInt; + _ = ComptimeFloat; + _ = Noreturn; + _ = Null; + _ = Undefined; + _ = EnumLiteral; +} +pub fn main() void { + testTypes( + anyopaque, + bool, + void, + type, + comptime_int, + comptime_float, + noreturn, + @TypeOf(null), + @TypeOf(undefined), + @EnumLiteral(), + ); +} +#} +#update +#check lldb { +(lldb) breakpoint set --file types.zig --source-pattern-regexp '_ = Undefined;' +Breakpoint 1: where = types`types.testTypes#... + #... at types.zig:23:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../types' (#...) +Process #... stopped +* thread #1, name = 'types', stop reason = breakpoint 1.1 + frame #0: types`types.testTypes#...(anyopaque=anyopaque, bool=bool, void=void, type=type, comptime_int=comptime_int, comptime_float=comptime_float, noreturn=noreturn, @TypeOf(null)=@TypeOf(null), @TypeOf(undefined)=@TypeOf(undefined), @EnumLiteral()=@EnumLiteral()) at types.zig:23:1 +(lldb) frame variable --show-all-children --show-types -- Anyopaque Bool Void Type ComptimeInt ComptimeFloat Noreturn Null Undefined EnumLiteral +(type) Anyopaque = anyopaque +(type) Bool = bool +(type) Void = void +(type) Type = type +(type) ComptimeInt = comptime_int +(type) ComptimeFloat = comptime_float +(type) Noreturn = noreturn +(type) Null = @TypeOf(null) +(type) Undefined = @TypeOf(undefined) +(type) EnumLiteral = @EnumLiteral() +(lldb) breakpoint delete --force 1 +1 breakpoints deleted; 0 breakpoint locations disabled. +#} diff --git a/test/debugger/unions b/test/debugger/unions new file mode 100644 index 0000000000000000000000000000000000000000..435b8ec7cf02c239392c7867d0489d8b7eb26e66 --- /dev/null +++ b/test/debugger/unions @@ -0,0 +1,90 @@ +#todo { +passes, but prints errors +#} +#skip x86_64-linux-none-whole-selfhosted-new-nopic +#skip x86_64-linux-none-whole-selfhosted-new-pic +#skip x86_64-linux-none-incremental-selfhosted-new-nopic +#skip x86_64-linux-none-incremental-selfhosted-new-pic + +#exe { +--name unions +-Mroot=unions.zig +#} + +#write unions.zig { +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(.{}); +} +#} +#update +#check lldb { +(lldb) breakpoint set --file unions.zig --source-pattern-regexp '_ = unions;' +Breakpoint 1: where = unions`unions.testUnions + #... at unions.zig:25:1, address = 0x#... +(lldb) process launch +Process #... launched: '#.../unions' (#...) +Process #... stopped +* thread #1, name = 'unions', stop reason = breakpoint 1.1 + frame #0: unions`unions.testUnions(unions=Unions @ 0x#...) at unions.zig:25:1 +(lldb) expression --show-types -- Unions +(type) $0 = struct { + (type) Untagged = union {} + (type) SafetyTagged = union(enum) { + (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) void = .void + (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) en = .en + (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) eu = .eu + } + (type) Enum = enum { + (root.unions.Unions.Enum) first = .first + (root.unions.Unions.Enum) second = .second + (root.unions.Unions.Enum) third = .third + } + (type) Tagged = union(enum) { + (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) void = .void + (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) en = .en + (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) eu = .eu + } +} +(lldb) frame variable --show-all-children --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. +#} diff --git a/test/src/Debugger.zig b/test/src/Debugger.zig deleted file mode 100644 index 6fad111e9ed5250adb3f36ee7ebbd3d073761854..0000000000000000000000000000000000000000 --- a/test/src/Debugger.zig +++ /dev/null @@ -1,2468 +0,0 @@ -b: *std.Build, -options: Options, -root_step: *std.Build.Step, -test_matrix: []const TestTarget, - -pub const Options = struct { - test_filters: []const []const u8, - test_target_filters: []const []const u8, - gdb: ?[]const u8, - lldb: ?[]const u8, - optimize_modes: []const std.builtin.Optimize, - skip_single_threaded: bool, - skip_libc: bool, -}; - -pub const TestTarget = struct { - target: std.Target.Query, - optimize_mode: std.builtin.Optimize = .debug, - link_libc: ?bool = null, - single_threaded: ?bool = null, - pic: ?bool = null, - linker: LinkerImpl, -}; - -pub const LinkerImpl = enum { default, old, new }; - -pub fn addTests(db: *Debugger) void { - db.addLldbTest( - "basic", - &.{ - .{ - .path = "basic.zig", - .source = - \\const Basic = struct { - \\ void: void = {}, - \\ bool_false: bool = false, - \\ bool_true: bool = true, - \\ u0_0: u0 = 0, - \\ u1_0: u1 = 0, - \\ u1_1: u1 = 1, - \\ u2_0: u2 = 0, - \\ u2_3: u2 = 3, - \\ u3_0: u3 = 0, - \\ u3_7: u3 = 7, - \\ u4_0: u4 = 0, - \\ u4_15: u4 = 15, - \\ u5_0: u5 = 0, - \\ u5_31: u5 = 31, - \\ u6_0: u6 = 0, - \\ u6_63: u6 = 63, - \\ u7_0: u7 = 0, - \\ u7_127: u7 = 127, - \\ u8_0: u8 = 0, - \\ u8_255: u8 = 255, - \\ u16_0: u16 = 0, - \\ u16_65535: u16 = 65535, - \\ u24_0: u24 = 0, - \\ u24_16777215: u24 = 16777215, - \\ u32_0: u32 = 0, - \\ u32_4294967295: u32 = 4294967295, - \\ @"i1_-1": i1 = -1, - \\ i1_0: i1 = 0, - \\ @"i2_-2": i2 = -2, - \\ i2_0: i2 = 0, - \\ i2_1: i2 = 1, - \\ @"i3_-4": i3 = -4, - \\ i3_0: i3 = 0, - \\ i3_3: i3 = 3, - \\ @"i4_-8": i4 = -8, - \\ i4_0: i4 = 0, - \\ i4_7: i4 = 7, - \\ @"i5_-16": i5 = -16, - \\ i5_0: i5 = 0, - \\ i5_15: i5 = 15, - \\ @"i6_-32": i6 = -32, - \\ i6_0: i6 = 0, - \\ i6_31: i6 = 31, - \\ @"i7_-64": i7 = -64, - \\ i7_0: i7 = 0, - \\ i7_63: i7 = 63, - \\ @"i8_-128": i8 = -128, - \\ i8_0: i8 = 0, - \\ i8_127: i8 = 127, - \\ @"i16_-32768": i16 = -32768, - \\ i16_0: i16 = 0, - \\ i16_32767: i16 = 32767, - \\ @"i24_-8388608": i24 = -8388608, - \\ i24_0: i24 = 0, - \\ i24_8388607: i24 = 8388607, - \\ @"i32_-2147483648": i32 = -2147483648, - \\ i32_0: i32 = 0, - \\ i32_2147483647: i32 = 2147483647, - \\ @"f16_42.625": f16 = 42.625, - \\ @"f32_-2730.65625": f32 = -2730.65625, - \\ @"f64_357913941.33203125": f64 = 357913941.33203125, - \\ @"f80_-91625968981.3330078125": f80 = -91625968981.3330078125, - \\ @"f128_384307168202282325.333332061767578125": f128 = 384307168202282325.333332061767578125, - \\}; - \\fn testBasic(basic: Basic) void { - \\ _ = basic; - \\} - \\pub fn main() void { - \\ testBasic(.{}); - \\} - \\ - , - }, - }, - \\breakpoint set --file basic.zig --source-pattern-regexp '_ = basic;' - \\process launch - \\frame variable --show-all-children --show-types -- basic - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children --show-types -- basic - \\(root.basic.Basic) basic = { - \\ (void) .void = {} - \\ (bool) .bool_false = false - \\ (bool) .bool_true = true - \\ (u0) .u0_0 = 0 - \\ (u1) .u1_0 = 0 - \\ (u1) .u1_1 = 1 - \\ (u2) .u2_0 = 0 - \\ (u2) .u2_3 = 3 - \\ (u3) .u3_0 = 0 - \\ (u3) .u3_7 = 7 - \\ (u4) .u4_0 = 0 - \\ (u4) .u4_15 = 15 - \\ (u5) .u5_0 = 0 - \\ (u5) .u5_31 = 31 - \\ (u6) .u6_0 = 0 - \\ (u6) .u6_63 = 63 - \\ (u7) .u7_0 = 0 - \\ (u7) .u7_127 = 127 - \\ (u8) .u8_0 = 0 - \\ (u8) .u8_255 = 255 - \\ (u16) .u16_0 = 0 - \\ (u16) .u16_65535 = 65535 - \\ (u24) .u24_0 = 0 - \\ (u24) .u24_16777215 = 16777215 - \\ (u32) .u32_0 = 0 - \\ (u32) .u32_4294967295 = 4294967295 - \\ (i1) .@"i1_-1" = -1 - \\ (i1) .i1_0 = 0 - \\ (i2) .@"i2_-2" = -2 - \\ (i2) .i2_0 = 0 - \\ (i2) .i2_1 = 1 - \\ (i3) .@"i3_-4" = -4 - \\ (i3) .i3_0 = 0 - \\ (i3) .i3_3 = 3 - \\ (i4) .@"i4_-8" = -8 - \\ (i4) .i4_0 = 0 - \\ (i4) .i4_7 = 7 - \\ (i5) .@"i5_-16" = -16 - \\ (i5) .i5_0 = 0 - \\ (i5) .i5_15 = 15 - \\ (i6) .@"i6_-32" = -32 - \\ (i6) .i6_0 = 0 - \\ (i6) .i6_31 = 31 - \\ (i7) .@"i7_-64" = -64 - \\ (i7) .i7_0 = 0 - \\ (i7) .i7_63 = 63 - \\ (i8) .@"i8_-128" = -128 - \\ (i8) .i8_0 = 0 - \\ (i8) .i8_127 = 127 - \\ (i16) .@"i16_-32768" = -32768 - \\ (i16) .i16_0 = 0 - \\ (i16) .i16_32767 = 32767 - \\ (i24) .@"i24_-8388608" = -8388608 - \\ (i24) .i24_0 = 0 - \\ (i24) .i24_8388607 = 8388607 - \\ (i32) .@"i32_-2147483648" = -2147483648 - \\ (i32) .i32_0 = 0 - \\ (i32) .i32_2147483647 = 2147483647 - \\ (f16) .@"f16_42.625" = 42.625 - \\ (f32) .@"f32_-2730.65625" = -2730.65625 - \\ (f64) .@"f64_357913941.33203125" = 357913941.33203125 - \\ (f80) .@"f80_-91625968981.3330078125" = -91625968981.3330078125 - \\ (f128) .@"f128_384307168202282325.333332061767578125" = 384307168202282325.333332061767578125 - \\} - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "identifiers", - &.{ - .{ - .path = "identifiers.zig", - .source = - \\const Struct = struct { @"zwölf": u32 }; - \\fn testIdentifiers(@"fünf": u32, @"struct": Struct) void { - \\ _ = @"fünf"; - \\ _ = @"struct"; - \\} - \\pub fn main() void { - \\ testIdentifiers(5, .{ .@"zwölf" = 12 }); - \\} - , - }, - }, - \\breakpoint set --file identifiers.zig --source-pattern-regexp '_ = @"struct";' - \\process launch - \\frame variable --show-all-children --show-types -- @\"fünf'"' '@"f\xC3\xBCnf"' '@"f\u{FC}nf"' '@"struct".@"zwölf"' '@"struct".@"zw\xC3\xB6lf"' '@"struct".@"zw\u{F6}lf"' - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children --show-types -- @\"fünf'"' '@"f\xC3\xBCnf"' '@"f\u{FC}nf"' '@"struct".@"zwölf"' '@"struct".@"zw\xC3\xB6lf"' '@"struct".@"zw\u{F6}lf"' - \\(u32) @"fünf" = 5 - \\(u32) @"f\xC3\xBCnf" = 5 - \\(u32) @"f\u{FC}nf" = 5 - \\(u32) @"struct".@"zwölf" = 12 - \\(u32) @"struct".@"zw\xC3\xB6lf" = 12 - \\(u32) @"struct".@"zw\u{F6}lf" = 12 - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "types", - &.{ - .{ - .path = "types.zig", - .source = - \\fn testTypes( - \\ Anyopaque: type, - \\ Bool: type, - \\ Void: type, - \\ Type: type, - \\ ComptimeInt: type, - \\ ComptimeFloat: type, - \\ Noreturn: type, - \\ Null: type, - \\ Undefined: type, - \\ EnumLiteral: type, - \\) void { - \\ _ = Anyopaque; - \\ _ = Bool; - \\ _ = Void; - \\ _ = Type; - \\ _ = ComptimeInt; - \\ _ = ComptimeFloat; - \\ _ = Noreturn; - \\ _ = Null; - \\ _ = Undefined; - \\ _ = EnumLiteral; - \\} - \\pub fn main() void { - \\ testTypes( - \\ anyopaque, - \\ bool, - \\ void, - \\ type, - \\ comptime_int, - \\ comptime_float, - \\ noreturn, - \\ @TypeOf(null), - \\ @TypeOf(undefined), - \\ @EnumLiteral(), - \\ ); - \\} - , - }, - }, - \\breakpoint set --file types.zig --source-pattern-regexp '_ = Undefined;' - \\process launch - \\frame variable --show-all-children --show-types -- Anyopaque Bool Void Type ComptimeInt ComptimeFloat Noreturn Null Undefined EnumLiteral - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children --show-types -- Anyopaque Bool Void Type ComptimeInt ComptimeFloat Noreturn Null Undefined EnumLiteral - \\(type) Anyopaque = anyopaque - \\(type) Bool = bool - \\(type) Void = void - \\(type) Type = type - \\(type) ComptimeInt = comptime_int - \\(type) ComptimeFloat = comptime_float - \\(type) Noreturn = noreturn - \\(type) Null = @TypeOf(null) - \\(type) Undefined = @TypeOf(undefined) - \\(type) EnumLiteral = @EnumLiteral() - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "pointers", - &.{ - .{ - .path = "pointers.zig", - .source = - \\var array: [7]u32 = .{ - \\ 3010, - \\ 3014, - \\ 3018, - \\ 3022, - \\ 3026, - \\ 3030, - \\ 3034, - \\}; - \\const Pointers = struct { - \\ 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_allowzero_const: *allowzero const u32 = @ptrFromInt(0x1024), - \\ single_allowzero_volatile: *allowzero volatile u32 = @ptrFromInt(0x1028), - \\ single_allowzero_const_volatile: *allowzero const volatile 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_allowzero_const: [*]allowzero const u32 = @ptrFromInt(0x2024), - \\ many_allowzero_volatile: [*]allowzero volatile u32 = @ptrFromInt(0x2028), - \\ many_allowzero_const_volatile: [*]allowzero const volatile 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_allowzero_const: []allowzero const u32 = array[4..5], - \\ slice_allowzero_volatile: []allowzero volatile u32 = array[4..6], - \\ slice_allowzero_const_volatile: []allowzero const volatile 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), - \\}; - \\const Access = struct { - \\ single: *u32 = &array[0], - \\ many: [*]u32 = array[1..3], - \\ slice: []u32 = array[3..5], - \\ c: [*c]u32 = array[5..7], - \\}; - \\fn testPointers(pointers: Pointers, access: Access) void { - \\ _ = pointers; - \\ _ = access; - \\} - \\pub fn main() void { - \\ testPointers(.{}, .{}); - \\} - \\ - , - }, - }, - \\breakpoint set --file pointers.zig --source-pattern-regexp '_ = access;' - \\process launch - \\frame variable --show-all-children --show-types -- pointers access.single.* access.many[0] access.many[1] access.slice[0] access.slice[1] access.c.* access.c[0] access.c[1] - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children --show-types -- pointers access.single.* access.many[0] access.many[1] access.slice[0] access.slice[1] access.c.* access.c[0] access.c[1] - \\(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 - \\ (*allowzero const u32) .single_allowzero_const = 0x0000000000001024 - \\ (*allowzero volatile u32) .single_allowzero_volatile = 0x0000000000001028 - \\ (*allowzero const volatile u32) .single_allowzero_const_volatile = 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 - \\ ([*]allowzero const u32) .many_allowzero_const = 0x0000000000002024 - \\ ([*]allowzero volatile u32) .many_allowzero_volatile = 0x0000000000002028 - \\ ([*]allowzero const volatile u32) .many_allowzero_const_volatile = 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 {} - \\ ([]allowzero const u32) .slice_allowzero_const = len=1 { - \\ (u32) [0] = 3026 - \\ } - \\ ([]allowzero volatile u32) .slice_allowzero_volatile = len=2 { - \\ (u32) [0] = 3026 - \\ (u32) [1] = 3030 - \\ } - \\ ([]allowzero const volatile u32) .slice_allowzero_const_volatile = 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 - \\} - \\(u32) access.single.* = 3010 - \\(u32) access.many[0] = 3014 - \\(u32) access.many[1] = 3018 - \\(u32) access.slice[0] = 3022 - \\(u32) access.slice[1] = 3026 - \\(u32) access.c.* = 3030 - \\(u32) access.c[0] = 3030 - \\(u32) access.c[1] = 3034 - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "strings", - &.{ - .{ - .path = "strings.zig", - .source = - \\const Strings = struct { - \\ c_ptr: [*c]const u8 = "c_ptr\x07\x08\t", - \\ many_ptr: [*:0]const u8 = "many_ptr\n\x0b\x0c", - \\ ptr_array: *const [12:0]u8 = "ptr_array\x00\r\x1b", - \\ slice: [:0]const u8 = "slice\"\'\\\x00", - \\}; - \\fn testStrings(strings: Strings) void { - \\ _ = strings; - \\} - \\pub fn main() void { - \\ testStrings(.{}); - \\} - \\ - , - }, - }, - \\breakpoint set --file strings.zig --source-pattern-regexp '_ = strings;' - \\process launch - \\frame variable --show-all-children --show-types -- strings.slice - \\frame variable --show-all-children --show-types --format character -- strings.slice - \\frame variable --show-all-children --show-types --format c-string -- strings - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children --show-types -- strings.slice - \\([:0]const u8) strings.slice = len=9 { - \\ (u8) [0] = 115 - \\ (u8) [1] = 108 - \\ (u8) [2] = 105 - \\ (u8) [3] = 99 - \\ (u8) [4] = 101 - \\ (u8) [5] = 34 - \\ (u8) [6] = 39 - \\ (u8) [7] = 92 - \\ (u8) [8] = 0 - \\} - \\(lldb) frame variable --show-all-children --show-types --format character -- strings.slice - \\([:0]const u8) strings.slice = len=9 { - \\ (u8) [0] = 's' - \\ (u8) [1] = 'l' - \\ (u8) [2] = 'i' - \\ (u8) [3] = 'c' - \\ (u8) [4] = 'e' - \\ (u8) [5] = '\"' - \\ (u8) [6] = '\'' - \\ (u8) [7] = '\\' - \\ (u8) [8] = '\x00' - \\} - \\(lldb) frame variable --show-all-children --show-types --format c-string -- strings - \\(root.strings.Strings) strings = { - \\ ([*c]const u8) .c_ptr = "c_ptr\x07\x08\t" - \\ ([*:0]const u8) .many_ptr = "many_ptr\n\x0b\x0c" - \\ (*const [12:0]u8) .ptr_array = "ptr_array\x00\r\x1b" - \\ ([:0]const u8) .slice = "slice\"\'\\\x00" len=9 { - \\ (u8) [0] = "s" - \\ (u8) [1] = "l" - \\ (u8) [2] = "i" - \\ (u8) [3] = "c" - \\ (u8) [4] = "e" - \\ (u8) [5] = "\"" - \\ (u8) [6] = "\'" - \\ (u8) [7] = "\\" - \\ (u8) [8] = "\x00" - \\ } - \\} - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "enums", - &.{ - .{ - .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 - \\expression --show-types -- Enums - \\frame variable --show-all-children --show-types -- enums - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) expression --show-types -- Enums - \\(type) $0 = struct { - \\ (type) Zero = enum {} - \\ (type) One = enum { - \\ (root.enums.Enums.One) first = .first - \\ } - \\ (type) Two = enum { - \\ (root.enums.Enums.Two) first = .first - \\ (root.enums.Enums.Two) second = .second - \\ } - \\ (type) Three = enum { - \\ (root.enums.Enums.Three) first = .first - \\ (root.enums.Enums.Three) second = .second - \\ (root.enums.Enums.Three) third = .third - \\ } - \\} - \\(lldb) frame variable --show-all-children --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. - }, - .{ .skip_new_linker = true }, // passes, but prints errors - ); - db.addLldbTest( - "errors", - &.{ - .{ - .path = "errors.zig", - .source = - \\const Errors = struct { - \\ const Zero = error{}; - \\ const One = Zero || error{One}; - \\ const Two = One || error{Two}; - \\ const Three = Two || error{Three}; - \\ - \\ one: One = error.One, - \\ two: Two = error.Two, - \\ three: Three = error.Three, - \\ any: anyerror = error.Any, - \\ any_void: anyerror!void = error.NotVoid, - \\ any_u32: One!u32 = 42, - \\}; - \\fn testErrors(errors: Errors) void { - \\ _ = errors; - \\} - \\pub fn main() void { - \\ testErrors(.{}); - \\} - \\ - , - }, - }, - \\breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;' - \\process launch - \\expression --show-types -- Errors - \\frame variable --show-all-children --show-types -- errors - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) expression --show-types -- Errors - \\(type) $0 = struct { - \\ (type) Zero = error {} - \\ (type) One = error { - \\ (error{One}) One = error.One - \\ } - \\ (type) Two = error { - \\ (error{One,Two}) One = error.One - \\ (error{One,Two}) Two = error.Two - \\ } - \\ (type) Three = error { - \\ (error{One,Three,Two}) One = error.One - \\ (error{One,Three,Two}) Two = error.Two - \\ (error{One,Three,Two}) Three = error.Three - \\ } - \\} - \\(lldb) frame variable --show-all-children --show-types -- errors - \\(root.errors.Errors) errors = { - \\ (error{One}) .one = error.One - \\ (error{One,Two}) .two = error.Two - \\ (error{One,Three,Two}) .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. - }, - .{ .skip_new_linker = true }, // passes, but prints errors - ); - db.addLldbTest( - "optionals", - &.{ - .{ - .path = "optionals.zig", - .source = - \\pub fn main() void { - \\ { - \\ var null_u32: ?u32 = null; - \\ var maybe_u32: ?u32 = null; - \\ var nonnull_u32: ?u32 = 456; - \\ null_u32 = null_u32; - \\ maybe_u32 = 123; - \\ nonnull_u32 = nonnull_u32; - \\ } - \\} - \\ - , - }, - }, - \\breakpoint set --file optionals.zig --source-pattern-regexp 'maybe_u32 = 123;' - \\process launch - \\frame variable --show-all-children -- null_u32 maybe_u32 nonnull_u32 nonnull_u32.? - \\breakpoint delete --force 1 - \\ - \\breakpoint set --file optionals.zig --source-pattern-regexp 'nonnull_u32 = nonnull_u32;' - \\process continue - \\frame variable --show-all-children --show-types -- null_u32 maybe_u32 maybe_u32.? nonnull_u32 nonnull_u32.? - \\breakpoint delete --force 2 - , - &.{ - \\(lldb) frame variable --show-all-children -- null_u32 maybe_u32 nonnull_u32 nonnull_u32.? - \\(?u32) null_u32 = null - \\(?u32) maybe_u32 = null - \\(?u32) nonnull_u32 = (nonnull_u32.? = 456) - \\(u32) nonnull_u32.? = 456 - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - , - \\(lldb) frame variable --show-all-children --show-types -- null_u32 maybe_u32 maybe_u32.? nonnull_u32 nonnull_u32.? - \\(?u32) null_u32 = null - \\(?u32) maybe_u32 = { - \\ (u32) maybe_u32.? = 123 - \\} - \\(u32) maybe_u32.? = 123 - \\(?u32) nonnull_u32 = { - \\ (u32) nonnull_u32.? = 456 - \\} - \\(u32) nonnull_u32.? = 456 - \\(lldb) breakpoint delete --force 2 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "unions", - &.{ - .{ - .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 - \\expression --show-types -- Unions - \\frame variable --show-all-children --show-types -- unions - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) expression --show-types -- Unions - \\(type) $0 = struct { - \\ (type) Untagged = union {} - \\ (type) SafetyTagged = union(enum) { - \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) void = .void - \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) en = .en - \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) eu = .eu - \\ } - \\ (type) Enum = enum { - \\ (root.unions.Unions.Enum) first = .first - \\ (root.unions.Unions.Enum) second = .second - \\ (root.unions.Unions.Enum) third = .third - \\ } - \\ (type) Tagged = union(enum) { - \\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) void = .void - \\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) en = .en - \\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) eu = .eu - \\ } - \\} - \\(lldb) frame variable --show-all-children --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. - }, - .{ .skip_new_linker = true }, // passes, but prints errors - ); - db.addLldbTest( - "storage", - &.{ - .{ - .path = "storage.zig", - .source = - \\comptime { - \\ _ = @import("externs.zig"); - \\} - \\const global_const: u64 = 0x19e50dc8d6002077; - \\var global_var: u64 = 0xcc423cec08622e32; - \\threadlocal var global_threadlocal1: u64 = 0xb4d643528c042121; - \\threadlocal var global_threadlocal2: u64 = 0x43faea1cf5ad7a22; - \\extern const extern_const: u64; - \\extern var extern_var: u64; - \\extern threadlocal var extern_threadlocal1: u64; - \\extern threadlocal var extern_threadlocal2: u64; - \\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 ^ - \\ extern_const ^ extern_var ^ extern_threadlocal1 ^ extern_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, - \\ ); - \\} - \\ - , - }, - .{ - .path = "externs.zig", - .source = - \\export const extern_const: u64 = 0x1b0c91ea0470b0b2; - \\export var extern_var: u64 = 0x19bc17b3f0b61ebc; - \\export threadlocal var extern_threadlocal1: u64 = 0x3034c4ce967ed64d; - \\export threadlocal var extern_threadlocal2: u64 = 0xfd330ab00b4bc5eb; - \\ - , - }, - }, - \\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 extern_const extern_var extern_threadlocal1 extern_threadlocal2 - \\frame variable --show-all-children --show-types --format hex -- param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val 'local_comptime_ptr.@"0"' 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 extern_const extern_var extern_threadlocal1 extern_threadlocal2 - \\(u64) global_const = 0x19e50dc8d6002077 - \\(u64) global_var = 0xcc423cec08622e32 - \\(u64) global_threadlocal1 = 0xb4d643528c042121 - \\(u64) global_threadlocal2 = 0x43faea1cf5ad7a22 - \\(u64) extern_const = 0x1b0c91ea0470b0b2 - \\(u64) extern_const = 0x1b0c91ea0470b0b2 - \\(u64) extern_var = 0x19bc17b3f0b61ebc - \\(u64) extern_var = 0x19bc17b3f0b61ebc - \\(u64) extern_threadlocal1 = 0x3034c4ce967ed64d - \\(u64) extern_threadlocal1 = 0x3034c4ce967ed64d - \\(u64) extern_threadlocal2 = 0xfd330ab00b4bc5eb - \\(u64) extern_threadlocal2 = 0xfd330ab00b4bc5eb - \\(lldb) frame variable --show-all-children --show-types --format hex -- param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val 'local_comptime_ptr.@"0"' 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_comptime_ptr[0] = 0x82e834dae74767a1 - \\(u64) local_const = 0x104ba3ac46b25fad - \\(u64) local_var = 0x92a39776a1f5380c - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "if_blocks", - &.{ - .{ - .path = "if_blocks.zig", - .source = - \\pub fn main() void { - \\ for (0..2) |i| { - \\ if (i == 0) { - \\ var x: u32 = 123; - \\ _ = &x; - \\ } else { - \\ var x: f32 = 4.5; - \\ _ = &x; - \\ } - \\ } - \\} - \\ - , - }, - }, - \\breakpoint set --file if_blocks.zig --source-pattern-regexp '_ = &x;' - \\process launch - \\frame variable --show-all-children - \\process continue - \\frame variable --show-all-children - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children - \\(usize) i = 0 - \\(u32) x = 123 - \\(lldb) process continue - , - \\(lldb) frame variable --show-all-children - \\(usize) i = 1 - \\(f32) x = 4.5 - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "switch_blocks", - &.{ - .{ - .path = "switch_blocks.zig", - .source = - \\pub fn main() void { - \\ for (0..2) |i| { - \\ switch (i) { - \\ 0 => { - \\ var x: u32 = 123; - \\ _ = &x; - \\ }, - \\ else => { - \\ var x: f32 = 4.5; - \\ _ = &x; - \\ }, - \\ } - \\ } - \\} - \\ - , - }, - }, - \\breakpoint set --file switch_blocks.zig --source-pattern-regexp '_ = &x;' - \\process launch - \\frame variable --show-all-children - \\process continue - \\frame variable --show-all-children - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children - \\(usize) i = 0 - \\(u32) x = 123 - \\(lldb) process continue - , - \\(lldb) frame variable --show-all-children - \\(usize) i = 1 - \\(f32) x = 4.5 - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "step_single_stmt_loops", - &.{ - .{ - .path = "step_single_stmt_loops.zig", - .source = - \\pub fn main() void { - \\ var x: u32 = 0; - \\ for (0..3) |_| { - \\ x +%= 1; - \\ } - \\ { - \\ var i: u32 = 0; - \\ while (i < 3) : (i +%= 1) { - \\ x +%= 1; - \\ } - \\ } - \\ { - \\ var i: u32 = 0; - \\ while (i < 3) { - \\ i +%= 1; - \\ } - \\ } - \\ inline for (0..3) |_| { - \\ x +%= 1; - \\ } - \\ { - \\ comptime var i: u32 = 0; - \\ inline while (i < 3) : (i +%= 1) { - \\ x +%= 1; - \\ } - \\ } - \\ { - \\ comptime var i: u32 = 0; - \\ inline while (i < 3) { - \\ i +%= 1; - \\ } - \\ } - \\ x +%= 1; - \\} - \\ - , - }, - }, - \\breakpoint set --name step_single_stmt_loops.main - \\process launch - \\thread step-in - \\#00 - \\frame variable --show-all-children x - \\thread step-in - \\#01 - \\frame variable --show-all-children x - \\thread step-in - \\#02 - \\frame variable --show-all-children x - \\thread step-in - \\#03 - \\frame variable --show-all-children x - \\thread step-in - \\#04 - \\frame variable --show-all-children x - \\thread step-in - \\#05 - \\frame variable --show-all-children x - \\thread step-in - \\#06 - \\frame variable --show-all-children x - \\thread step-in - \\#07 - \\frame variable --show-all-children x - \\thread step-in - \\#08 - \\frame variable --show-all-children x - \\thread step-in - \\#09 - \\frame variable --show-all-children x - \\thread step-in - \\#10 - \\frame variable --show-all-children x - \\thread step-in - \\#11 - \\frame variable --show-all-children x - \\thread step-in - \\#12 - \\frame variable --show-all-children x - \\thread step-in - \\#13 - \\frame variable --show-all-children x - \\thread step-in - \\#14 - \\frame variable --show-all-children x - \\thread step-in - \\#15 - \\frame variable --show-all-children x - \\thread step-in - \\#16 - \\frame variable --show-all-children x - \\thread step-in - \\#17 - \\frame variable --show-all-children x - \\thread step-in - \\#18 - \\frame variable --show-all-children x - \\thread step-in - \\#19 - \\frame variable --show-all-children x - \\thread step-in - \\#20 - \\frame variable --show-all-children x - \\thread step-in - \\#21 - \\frame variable --show-all-children x - \\thread step-in - \\#22 - \\frame variable --show-all-children x - \\thread step-in - \\#23 - \\frame variable --show-all-children x - \\thread step-in - \\#24 - \\frame variable --show-all-children x - \\thread step-in - \\#25 - \\frame variable --show-all-children x - \\thread step-in - \\#26 - \\frame variable --show-all-children x - \\thread step-in - \\#27 - \\frame variable --show-all-children x - \\thread step-in - \\#28 - \\frame variable --show-all-children x - \\thread step-in - \\#29 - \\frame variable --show-all-children x - \\thread step-in - \\#30 - \\frame variable --show-all-children x - \\thread step-in - \\#31 - \\frame variable --show-all-children x - \\thread step-in - \\#32 - \\frame variable --show-all-children x - \\thread step-in - \\#33 - \\frame variable --show-all-children x - \\thread step-in - \\#34 - \\frame variable --show-all-children x - \\thread step-in - \\#35 - \\frame variable --show-all-children x - \\thread step-in - \\#36 - \\frame variable --show-all-children x - \\thread step-in - \\#37 - \\frame variable --show-all-children x - \\thread step-in - \\#38 - \\frame variable --show-all-children x - \\thread step-in - \\#39 - \\frame variable --show-all-children x - \\thread step-in - \\#40 - \\frame variable --show-all-children x - \\thread step-in - \\#41 - \\frame variable --show-all-children x - \\thread step-in - \\#42 - \\frame variable --show-all-children x - \\thread step-in - \\#43 - \\frame variable --show-all-children x - \\thread step-in - \\#44 - \\frame variable --show-all-children x - \\thread step-in - \\#45 - \\frame variable --show-all-children x - \\ - , - &.{ - \\(lldb) #00 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 0 - \\(lldb) thread step-in - , - \\(lldb) #01 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 0 - \\(lldb) thread step-in - , - \\(lldb) #02 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 1 - \\(lldb) thread step-in - , - \\(lldb) #03 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 1 - \\(lldb) thread step-in - , - \\(lldb) #04 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 1 - \\(lldb) thread step-in - , - \\(lldb) #05 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 2 - \\(lldb) thread step-in - , - \\(lldb) #06 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 2 - \\(lldb) thread step-in - , - \\(lldb) #07 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 2 - \\(lldb) thread step-in - , - \\(lldb) #08 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 3 - \\(lldb) thread step-in - , - \\(lldb) #09 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 3 - \\(lldb) thread step-in - , - \\(lldb) #10 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 3 - \\(lldb) thread step-in - , - \\(lldb) #11 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 3 - \\(lldb) thread step-in - , - \\(lldb) #12 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 3 - \\(lldb) thread step-in - , - \\(lldb) #13 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 4 - \\(lldb) thread step-in - , - \\(lldb) #14 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 4 - \\(lldb) thread step-in - , - \\(lldb) #15 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 4 - \\(lldb) thread step-in - , - \\(lldb) #16 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 5 - \\(lldb) thread step-in - , - \\(lldb) #17 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 5 - \\(lldb) thread step-in - , - \\(lldb) #18 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 5 - \\(lldb) thread step-in - , - \\(lldb) #19 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #20 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #21 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #22 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #23 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #24 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #25 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #26 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #27 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #28 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #29 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #30 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #31 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #32 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 6 - \\(lldb) thread step-in - , - \\(lldb) #33 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 7 - \\(lldb) thread step-in - , - \\(lldb) #34 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 7 - \\(lldb) thread step-in - , - \\(lldb) #35 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 8 - \\(lldb) thread step-in - , - \\(lldb) #36 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 8 - \\(lldb) thread step-in - , - \\(lldb) #37 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 9 - \\(lldb) thread step-in - , - \\(lldb) #38 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 9 - \\(lldb) thread step-in - , - \\(lldb) #39 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 10 - \\(lldb) thread step-in - , - \\(lldb) #40 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 10 - \\(lldb) thread step-in - , - \\(lldb) #41 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 11 - \\(lldb) thread step-in - , - \\(lldb) #42 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 11 - \\(lldb) thread step-in - , - \\(lldb) #43 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 12 - \\(lldb) thread step-in - , - \\(lldb) #44 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 12 - \\(lldb) thread step-in - , - \\(lldb) #45 - \\(lldb) frame variable --show-all-children x - \\(u32) x = 12 - }, - .{}, - ); - db.addLldbTest( - "inline_call", - &.{ - .{ - .path = "root0.zig", - .source = - \\const root0 = @This(); - \\pub const root1 = @import("root1.zig"); - \\const mod0 = @import("module"); - \\const mod1 = mod0.mod1; - \\pub fn r0pf(r0pa: u32) void { - \\ root0.r0cf(r0pa ^ 1); - \\ root0.r0cfi(r0pa ^ 2); - \\ root1.r1cf(r0pa ^ 3); - \\ root1.r1cfi(r0pa ^ 4); - \\ mod0.m0cf(r0pa ^ 5); - \\ mod0.m0cfi(r0pa ^ 6); - \\ mod1.m1cf(r0pa ^ 7); - \\ mod1.m1cfi(r0pa ^ 8); - \\} - \\pub inline fn r0pfi(r0pai: u32) void { - \\ root0.r0cf(r0pai ^ 1); - \\ root0.r0cfi(r0pai ^ 2); - \\ root1.r1cf(r0pai ^ 3); - \\ root1.r1cfi(r0pai ^ 4); - \\ mod0.m0cf(r0pai ^ 5); - \\ mod0.m0cfi(r0pai ^ 6); - \\ mod1.m1cf(r0pai ^ 7); - \\ mod1.m1cfi(r0pai ^ 8); - \\} - \\pub fn r0cf(r0ca: u32) void { - \\ var discard = r0ca; - \\ _ = &discard; - \\} - \\pub inline fn r0cfi(r0cai: u32) void { - \\ var discard = r0cai; - \\ _ = &discard; - \\} - \\pub fn main() void { - \\ root0.r0pf(12); - \\ root0.r0pfi(23); - \\ root1.r1pf(34); - \\ root1.r1pfi(45); - \\ mod0.m0pf(56); - \\ mod0.m0pfi(67); - \\ mod1.m1pf(78); - \\ mod1.m1pfi(89); - \\} - \\ - , - }, - .{ - .path = "root1.zig", - .source = - \\const root0 = @import("root0.zig"); - \\const root1 = @This(); - \\const mod0 = @import("module"); - \\const mod1 = mod0.mod1; - \\pub fn r1pf(r1pa: u32) void { - \\ root0.r0cf(r1pa ^ 1); - \\ root0.r0cfi(r1pa ^ 2); - \\ root1.r1cf(r1pa ^ 3); - \\ root1.r1cfi(r1pa ^ 4); - \\ mod0.m0cf(r1pa ^ 5); - \\ mod0.m0cfi(r1pa ^ 6); - \\ mod1.m1cf(r1pa ^ 7); - \\ mod1.m1cfi(r1pa ^ 8); - \\} - \\pub inline fn r1pfi(r1pai: u32) void { - \\ root0.r0cf(r1pai ^ 1); - \\ root0.r0cfi(r1pai ^ 2); - \\ root1.r1cf(r1pai ^ 3); - \\ root1.r1cfi(r1pai ^ 4); - \\ mod0.m0cf(r1pai ^ 5); - \\ mod0.m0cfi(r1pai ^ 6); - \\ mod1.m1cf(r1pai ^ 7); - \\ mod1.m1cfi(r1pai ^ 8); - \\} - \\pub fn r1cf(r1ca: u32) void { - \\ var discard = r1ca; - \\ _ = &discard; - \\} - \\pub inline fn r1cfi(r1cai: u32) void { - \\ var discard = r1cai; - \\ _ = &discard; - \\} - \\ - , - }, - .{ - .import = "module", - .path = "mod0.zig", - .source = - \\const root0 = @import("root"); - \\const root1 = root0.root1; - \\const mod0 = @This(); - \\pub const mod1 = @import("mod1.zig"); - \\pub fn m0pf(m0pa: u32) void { - \\ root0.r0cf(m0pa ^ 1); - \\ root0.r0cfi(m0pa ^ 2); - \\ root1.r1cf(m0pa ^ 3); - \\ root1.r1cfi(m0pa ^ 4); - \\ mod0.m0cf(m0pa ^ 5); - \\ mod0.m0cfi(m0pa ^ 6); - \\ mod1.m1cf(m0pa ^ 7); - \\ mod1.m1cfi(m0pa ^ 8); - \\} - \\pub inline fn m0pfi(m0pai: u32) void { - \\ root0.r0cf(m0pai ^ 1); - \\ root0.r0cfi(m0pai ^ 2); - \\ root1.r1cf(m0pai ^ 3); - \\ root1.r1cfi(m0pai ^ 4); - \\ mod0.m0cf(m0pai ^ 5); - \\ mod0.m0cfi(m0pai ^ 6); - \\ mod1.m1cf(m0pai ^ 7); - \\ mod1.m1cfi(m0pai ^ 8); - \\} - \\pub fn m0cf(m0ca: u32) void { - \\ var discard = m0ca; - \\ _ = &discard; - \\} - \\pub inline fn m0cfi(m0cai: u32) void { - \\ var discard = m0cai; - \\ _ = &discard; - \\} - \\ - , - }, - .{ - .path = "mod1.zig", - .source = - \\const root0 = @import("root"); - \\const root1 = root0.root1; - \\const mod0 = @import("mod0.zig"); - \\const mod1 = @This(); - \\pub fn m1pf(m1pa: u32) void { - \\ root0.r0cf(m1pa ^ 1); - \\ root0.r0cfi(m1pa ^ 2); - \\ root1.r1cf(m1pa ^ 3); - \\ root1.r1cfi(m1pa ^ 4); - \\ mod0.m0cf(m1pa ^ 5); - \\ mod0.m0cfi(m1pa ^ 6); - \\ mod1.m1cf(m1pa ^ 7); - \\ mod1.m1cfi(m1pa ^ 8); - \\} - \\pub inline fn m1pfi(m1pai: u32) void { - \\ root0.r0cf(m1pai ^ 1); - \\ root0.r0cfi(m1pai ^ 2); - \\ root1.r1cf(m1pai ^ 3); - \\ root1.r1cfi(m1pai ^ 4); - \\ mod0.m0cf(m1pai ^ 5); - \\ mod0.m0cfi(m1pai ^ 6); - \\ mod1.m1cf(m1pai ^ 7); - \\ mod1.m1cfi(m1pai ^ 8); - \\} - \\pub fn m1cf(m1ca: u32) void { - \\ var discard = m1ca; - \\ _ = &discard; - \\} - \\pub inline fn m1cfi(m1cai: u32) void { - \\ var discard = m1cai; - \\ _ = &discard; - \\} - \\ - , - }, - }, - \\settings set frame-format 'frame #${frame.index}:{ ${module.file.basename}{\`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${line.file.basename}:${line.number}{:${line.column}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\n' - \\ - \\breakpoint set --file root0.zig --line 26 - \\breakpoint set --file root0.zig --line 30 - \\breakpoint set --file root1.zig --line 26 - \\breakpoint set --file root1.zig --line 30 - \\breakpoint set --file mod0.zig --line 26 - \\breakpoint set --file mod0.zig --line 30 - \\breakpoint set --file mod1.zig --line 26 - \\breakpoint set --file mod1.zig --line 30 - \\ - \\process launch - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\ - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\ - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\ - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\ - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\ - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\ - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\ - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - \\process continue - \\thread backtrace --count 3 - , - &.{ - \\ * frame #0: inline_call`root0.r0cf(r0ca=13) at root0.zig:26:5 - \\ frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:6:15 - \\ frame #2: inline_call`root0.main at root0.zig:34:15 - , - \\ * frame #0: inline_call`r0cfi(r0cai=14) at root0.zig:30:5 - \\ frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:7:16 - \\ frame #2: inline_call`root0.main at root0.zig:34:15 - , - \\ * frame #0: inline_call`root1.r1cf(r1ca=15) at root1.zig:26:5 - \\ frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:8:15 - \\ frame #2: inline_call`root0.main at root0.zig:34:15 - , - \\ * frame #0: inline_call`r1cfi(r1cai=8) at root1.zig:30:5 - \\ frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:9:16 - \\ frame #2: inline_call`root0.main at root0.zig:34:15 - , - \\ * frame #0: inline_call`mod0.m0cf(m0ca=9) at mod0.zig:26:5 - \\ frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:10:14 - \\ frame #2: inline_call`root0.main at root0.zig:34:15 - , - \\ * frame #0: inline_call`m0cfi(m0cai=10) at mod0.zig:30:5 - \\ frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:11:15 - \\ frame #2: inline_call`root0.main at root0.zig:34:15 - , - \\ * frame #0: inline_call`mod1.m1cf(m1ca=11) at mod1.zig:26:5 - \\ frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:12:14 - \\ frame #2: inline_call`root0.main at root0.zig:34:15 - , - \\ * frame #0: inline_call`m1cfi(m1cai=4) at mod1.zig:30:5 - \\ frame #1: inline_call`root0.r0pf(r0pa=12) at root0.zig:13:15 - \\ frame #2: inline_call`root0.main at root0.zig:34:15 - , - \\ * frame #0: inline_call`root0.r0cf(r0ca=22) at root0.zig:26:5 - \\ frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:16:15 - \\ frame #2: inline_call`root0.main at root0.zig:35:16 - , - \\ * frame #0: inline_call`r0cfi(r0cai=21) at root0.zig:30:5 - \\ frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:17:16 - \\ frame #2: inline_call`root0.main at root0.zig:35:16 - , - \\ * frame #0: inline_call`root1.r1cf(r1ca=20) at root1.zig:26:5 - \\ frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:18:15 - \\ frame #2: inline_call`root0.main at root0.zig:35:16 - , - \\ * frame #0: inline_call`r1cfi(r1cai=19) at root1.zig:30:5 - \\ frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:19:16 - \\ frame #2: inline_call`root0.main at root0.zig:35:16 - , - \\ * frame #0: inline_call`mod0.m0cf(m0ca=18) at mod0.zig:26:5 - \\ frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:20:14 - \\ frame #2: inline_call`root0.main at root0.zig:35:16 - , - \\ * frame #0: inline_call`m0cfi(m0cai=17) at mod0.zig:30:5 - \\ frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:21:15 - \\ frame #2: inline_call`root0.main at root0.zig:35:16 - , - \\ * frame #0: inline_call`mod1.m1cf(m1ca=16) at mod1.zig:26:5 - \\ frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:22:14 - \\ frame #2: inline_call`root0.main at root0.zig:35:16 - , - \\ * frame #0: inline_call`m1cfi(m1cai=31) at mod1.zig:30:5 - \\ frame #1: inline_call`r0pfi(r0pai=23) at root0.zig:23:15 - \\ frame #2: inline_call`root0.main at root0.zig:35:16 - , - \\ * frame #0: inline_call`root0.r0cf(r0ca=35) at root0.zig:26:5 - \\ frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:6:15 - \\ frame #2: inline_call`root0.main at root0.zig:36:15 - , - \\ * frame #0: inline_call`r0cfi(r0cai=32) at root0.zig:30:5 - \\ frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:7:16 - \\ frame #2: inline_call`root0.main at root0.zig:36:15 - , - \\ * frame #0: inline_call`root1.r1cf(r1ca=33) at root1.zig:26:5 - \\ frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:8:15 - \\ frame #2: inline_call`root0.main at root0.zig:36:15 - , - \\ * frame #0: inline_call`r1cfi(r1cai=38) at root1.zig:30:5 - \\ frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:9:16 - \\ frame #2: inline_call`root0.main at root0.zig:36:15 - , - \\ * frame #0: inline_call`mod0.m0cf(m0ca=39) at mod0.zig:26:5 - \\ frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:10:14 - \\ frame #2: inline_call`root0.main at root0.zig:36:15 - , - \\ * frame #0: inline_call`m0cfi(m0cai=36) at mod0.zig:30:5 - \\ frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:11:15 - \\ frame #2: inline_call`root0.main at root0.zig:36:15 - , - \\ * frame #0: inline_call`mod1.m1cf(m1ca=37) at mod1.zig:26:5 - \\ frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:12:14 - \\ frame #2: inline_call`root0.main at root0.zig:36:15 - , - \\ * frame #0: inline_call`m1cfi(m1cai=42) at mod1.zig:30:5 - \\ frame #1: inline_call`root1.r1pf(r1pa=34) at root1.zig:13:15 - \\ frame #2: inline_call`root0.main at root0.zig:36:15 - , - \\ * frame #0: inline_call`root0.r0cf(r0ca=44) at root0.zig:26:5 - \\ frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:16:15 - \\ frame #2: inline_call`root0.main at root0.zig:37:16 - , - \\ * frame #0: inline_call`r0cfi(r0cai=47) at root0.zig:30:5 - \\ frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:17:16 - \\ frame #2: inline_call`root0.main at root0.zig:37:16 - , - \\ * frame #0: inline_call`root1.r1cf(r1ca=46) at root1.zig:26:5 - \\ frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:18:15 - \\ frame #2: inline_call`root0.main at root0.zig:37:16 - , - \\ * frame #0: inline_call`r1cfi(r1cai=41) at root1.zig:30:5 - \\ frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:19:16 - \\ frame #2: inline_call`root0.main at root0.zig:37:16 - , - \\ * frame #0: inline_call`mod0.m0cf(m0ca=40) at mod0.zig:26:5 - \\ frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:20:14 - \\ frame #2: inline_call`root0.main at root0.zig:37:16 - , - \\ * frame #0: inline_call`m0cfi(m0cai=43) at mod0.zig:30:5 - \\ frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:21:15 - \\ frame #2: inline_call`root0.main at root0.zig:37:16 - , - \\ * frame #0: inline_call`mod1.m1cf(m1ca=42) at mod1.zig:26:5 - \\ frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:22:14 - \\ frame #2: inline_call`root0.main at root0.zig:37:16 - , - \\ * frame #0: inline_call`m1cfi(m1cai=37) at mod1.zig:30:5 - \\ frame #1: inline_call`r1pfi(r1pai=45) at root1.zig:23:15 - \\ frame #2: inline_call`root0.main at root0.zig:37:16 - , - \\ * frame #0: inline_call`root0.r0cf(r0ca=57) at root0.zig:26:5 - \\ frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:6:15 - \\ frame #2: inline_call`root0.main at root0.zig:38:14 - , - \\ * frame #0: inline_call`r0cfi(r0cai=58) at root0.zig:30:5 - \\ frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:7:16 - \\ frame #2: inline_call`root0.main at root0.zig:38:14 - , - \\ * frame #0: inline_call`root1.r1cf(r1ca=59) at root1.zig:26:5 - \\ frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:8:15 - \\ frame #2: inline_call`root0.main at root0.zig:38:14 - , - \\ * frame #0: inline_call`r1cfi(r1cai=60) at root1.zig:30:5 - \\ frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:9:16 - \\ frame #2: inline_call`root0.main at root0.zig:38:14 - , - \\ * frame #0: inline_call`mod0.m0cf(m0ca=61) at mod0.zig:26:5 - \\ frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:10:14 - \\ frame #2: inline_call`root0.main at root0.zig:38:14 - , - \\ * frame #0: inline_call`m0cfi(m0cai=62) at mod0.zig:30:5 - \\ frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:11:15 - \\ frame #2: inline_call`root0.main at root0.zig:38:14 - , - \\ * frame #0: inline_call`mod1.m1cf(m1ca=63) at mod1.zig:26:5 - \\ frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:12:14 - \\ frame #2: inline_call`root0.main at root0.zig:38:14 - , - \\ * frame #0: inline_call`m1cfi(m1cai=48) at mod1.zig:30:5 - \\ frame #1: inline_call`mod0.m0pf(m0pa=56) at mod0.zig:13:15 - \\ frame #2: inline_call`root0.main at root0.zig:38:14 - , - \\ * frame #0: inline_call`root0.r0cf(r0ca=66) at root0.zig:26:5 - \\ frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:16:15 - \\ frame #2: inline_call`root0.main at root0.zig:39:15 - , - \\ * frame #0: inline_call`r0cfi(r0cai=65) at root0.zig:30:5 - \\ frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:17:16 - \\ frame #2: inline_call`root0.main at root0.zig:39:15 - , - \\ * frame #0: inline_call`root1.r1cf(r1ca=64) at root1.zig:26:5 - \\ frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:18:15 - \\ frame #2: inline_call`root0.main at root0.zig:39:15 - , - \\ * frame #0: inline_call`r1cfi(r1cai=71) at root1.zig:30:5 - \\ frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:19:16 - \\ frame #2: inline_call`root0.main at root0.zig:39:15 - , - \\ * frame #0: inline_call`mod0.m0cf(m0ca=70) at mod0.zig:26:5 - \\ frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:20:14 - \\ frame #2: inline_call`root0.main at root0.zig:39:15 - , - \\ * frame #0: inline_call`m0cfi(m0cai=69) at mod0.zig:30:5 - \\ frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:21:15 - \\ frame #2: inline_call`root0.main at root0.zig:39:15 - , - \\ * frame #0: inline_call`mod1.m1cf(m1ca=68) at mod1.zig:26:5 - \\ frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:22:14 - \\ frame #2: inline_call`root0.main at root0.zig:39:15 - , - \\ * frame #0: inline_call`m1cfi(m1cai=75) at mod1.zig:30:5 - \\ frame #1: inline_call`m0pfi(m0pai=67) at mod0.zig:23:15 - \\ frame #2: inline_call`root0.main at root0.zig:39:15 - , - \\ * frame #0: inline_call`root0.r0cf(r0ca=79) at root0.zig:26:5 - \\ frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:6:15 - \\ frame #2: inline_call`root0.main at root0.zig:40:14 - , - \\ * frame #0: inline_call`r0cfi(r0cai=76) at root0.zig:30:5 - \\ frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:7:16 - \\ frame #2: inline_call`root0.main at root0.zig:40:14 - , - \\ * frame #0: inline_call`root1.r1cf(r1ca=77) at root1.zig:26:5 - \\ frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:8:15 - \\ frame #2: inline_call`root0.main at root0.zig:40:14 - , - \\ * frame #0: inline_call`r1cfi(r1cai=74) at root1.zig:30:5 - \\ frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:9:16 - \\ frame #2: inline_call`root0.main at root0.zig:40:14 - , - \\ * frame #0: inline_call`mod0.m0cf(m0ca=75) at mod0.zig:26:5 - \\ frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:10:14 - \\ frame #2: inline_call`root0.main at root0.zig:40:14 - , - \\ * frame #0: inline_call`m0cfi(m0cai=72) at mod0.zig:30:5 - \\ frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:11:15 - \\ frame #2: inline_call`root0.main at root0.zig:40:14 - , - \\ * frame #0: inline_call`mod1.m1cf(m1ca=73) at mod1.zig:26:5 - \\ frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:12:14 - \\ frame #2: inline_call`root0.main at root0.zig:40:14 - , - \\ * frame #0: inline_call`m1cfi(m1cai=70) at mod1.zig:30:5 - \\ frame #1: inline_call`mod1.m1pf(m1pa=78) at mod1.zig:13:15 - \\ frame #2: inline_call`root0.main at root0.zig:40:14 - , - \\ * frame #0: inline_call`root0.r0cf(r0ca=88) at root0.zig:26:5 - \\ frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:16:15 - \\ frame #2: inline_call`root0.main at root0.zig:41:15 - , - \\ * frame #0: inline_call`r0cfi(r0cai=91) at root0.zig:30:5 - \\ frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:17:16 - \\ frame #2: inline_call`root0.main at root0.zig:41:15 - , - \\ * frame #0: inline_call`root1.r1cf(r1ca=90) at root1.zig:26:5 - \\ frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:18:15 - \\ frame #2: inline_call`root0.main at root0.zig:41:15 - , - \\ * frame #0: inline_call`r1cfi(r1cai=93) at root1.zig:30:5 - \\ frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:19:16 - \\ frame #2: inline_call`root0.main at root0.zig:41:15 - , - \\ * frame #0: inline_call`mod0.m0cf(m0ca=92) at mod0.zig:26:5 - \\ frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:20:14 - \\ frame #2: inline_call`root0.main at root0.zig:41:15 - , - \\ * frame #0: inline_call`m0cfi(m0cai=95) at mod0.zig:30:5 - \\ frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:21:15 - \\ frame #2: inline_call`root0.main at root0.zig:41:15 - , - \\ * frame #0: inline_call`mod1.m1cf(m1ca=94) at mod1.zig:26:5 - \\ frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:22:14 - \\ frame #2: inline_call`root0.main at root0.zig:41:15 - , - \\ * frame #0: inline_call`m1cfi(m1cai=81) at mod1.zig:30:5 - \\ frame #1: inline_call`m1pfi(m1pai=89) at mod1.zig:23:15 - \\ frame #2: inline_call`root0.main at root0.zig:41:15 - }, - .{}, - ); - db.addLldbTest( - "link_object", - &.{ - .{ - .path = "main.zig", - .source = - \\extern fn fabsf(f32) f32; - \\pub fn main() void { - \\ var x: f32 = -1234.5; - \\ x = fabsf(x); - \\ _ = &x; - \\} - \\ - , - }, - }, - \\breakpoint set --file main.zig --source-pattern-regexp 'x = fabsf\(x\);' - \\process launch - \\frame variable --show-all-children -- x - \\breakpoint delete --force 1 - \\ - \\breakpoint set --file main.zig --source-pattern-regexp '_ = &x;' - \\process continue - \\frame variable --show-all-children -- x - \\breakpoint delete --force 2 - , - &.{ - \\(lldb) frame variable --show-all-children -- x - \\(f32) x = -1234.5 - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - , - \\(lldb) frame variable --show-all-children -- x - \\(f32) x = 1234.5 - \\(lldb) breakpoint delete --force 2 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "hash_map", - &.{ - .{ - .path = "main.zig", - .source = - \\const std = @import("std"); - \\const Context = struct { - \\ pub fn hash(_: Context, key: u32) Map.Hash { - \\ return key; - \\ } - \\ pub fn eql(_: Context, lhs: u32, rhs: u32) bool { - \\ return lhs == rhs; - \\ } - \\}; - \\const Map = std.HashMapUnmanaged(u32, u32, Context, 63); - \\fn testHashMap(map: Map) void { - \\ _ = map; - \\} - \\pub fn main() !void { - \\ var map: Map = .empty; - \\ defer map.deinit(std.heap.page_allocator); - \\ try map.ensureTotalCapacity(std.heap.page_allocator, 10); - \\ map.putAssumeCapacity(0, 1); - \\ map.putAssumeCapacity(2, 3); - \\ map.putAssumeCapacity(4, 5); - \\ map.putAssumeCapacity(6, 7); - \\ map.putAssumeCapacity(8, 9); - \\ - \\ testHashMap(map); - \\} - \\ - , - }, - }, - \\breakpoint set --file main.zig --source-pattern-regexp '_ = map;' - \\process launch - \\frame variable --show-all-children --show-types -- map - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children --show-types -- map - \\(std.hash_map.Custom(u32,u32,main.Context,63)) map = len=5 capacity=16 { - \\ (std.hash_map.Custom(u32,u32,main.Context,63).KV) [0] = { - \\ (u32) .key = 0 - \\ (u32) .value = 1 - \\ } - \\ (std.hash_map.Custom(u32,u32,main.Context,63).KV) [1] = { - \\ (u32) .key = 2 - \\ (u32) .value = 3 - \\ } - \\ (std.hash_map.Custom(u32,u32,main.Context,63).KV) [2] = { - \\ (u32) .key = 4 - \\ (u32) .value = 5 - \\ } - \\ (std.hash_map.Custom(u32,u32,main.Context,63).KV) [3] = { - \\ (u32) .key = 6 - \\ (u32) .value = 7 - \\ } - \\ (std.hash_map.Custom(u32,u32,main.Context,63).KV) [4] = { - \\ (u32) .key = 8 - \\ (u32) .value = 9 - \\ } - \\} - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); - db.addLldbTest( - "multi_array_list", - &.{ - .{ - .path = "main.zig", - .source = - \\const std = @import("std"); - \\const Elem0 = struct { u32, u8, u16 }; - \\const Elem1 = struct { a: u32, b: u8, c: u16 }; - \\fn testMultiArrayList( - \\ list0: std.MultiArrayList(Elem0), - \\ slice0: std.MultiArrayList(Elem0).Slice, - \\ list1: std.MultiArrayList(Elem1), - \\ slice1: std.MultiArrayList(Elem1).Slice, - \\) void { - \\ _ = .{ list0, slice0, list1, slice1 }; - \\} - \\pub fn main() !void { - \\ var list0: std.MultiArrayList(Elem0) = .{}; - \\ defer list0.deinit(std.heap.page_allocator); - \\ try list0.setCapacity(std.heap.page_allocator, 8); - \\ list0.appendAssumeCapacity(.{ 1, 2, 3 }); - \\ list0.appendAssumeCapacity(.{ 4, 5, 6 }); - \\ list0.appendAssumeCapacity(.{ 7, 8, 9 }); - \\ const slice0 = list0.slice(); - \\ - \\ var list1: std.MultiArrayList(Elem1) = .{}; - \\ defer list1.deinit(std.heap.page_allocator); - \\ try list1.setCapacity(std.heap.page_allocator, 12); - \\ list1.appendAssumeCapacity(.{ .a = 1, .b = 2, .c = 3 }); - \\ list1.appendAssumeCapacity(.{ .a = 4, .b = 5, .c = 6 }); - \\ list1.appendAssumeCapacity(.{ .a = 7, .b = 8, .c = 9 }); - \\ const slice1 = list1.slice(); - \\ - \\ testMultiArrayList(list0, slice0, list1, slice1); - \\} - \\ - , - }, - }, - \\breakpoint set --file main.zig --source-pattern-regexp '_ = \.{ list0, slice0, list1, slice1 };' - \\process launch - \\frame variable --show-all-children --show-types -- list0 list0.len list0.capacity list0[0] list0[1] list0[2] 'list0.@"0"' 'list0.@"1"' 'list0.@"2"' - \\frame variable --show-all-children --show-types -- slice0 slice0.len slice0.capacity slice0[0] slice0[1] slice0[2] 'slice0.@"0"' 'slice0.@"1"' 'slice0.@"2"' - \\frame variable --show-all-children --show-types -- list1 list1.len list1.capacity list1[0] list1[1] list1[2] list1.a list1.b list1.c - \\frame variable --show-all-children --show-types -- slice1 slice1.len slice1.capacity slice1[0] slice1[1] slice1[2] slice1.a slice1.b slice1.c - \\breakpoint delete --force 1 - , - &.{ - \\(lldb) frame variable --show-all-children --show-types -- list0 list0.len list0.capacity list0[0] list0[1] list0[2] 'list0.@"0"' 'list0.@"1"' 'list0.@"2"' - \\(std.multi_array_list.MultiArrayList(struct { u32, u8, u16 })) list0 = len=3 capacity=8 { - \\ (struct { u32, u8, u16 }) [0] = { - \\ (u32) .@"0" = 1 - \\ (u8) .@"1" = 2 - \\ (u16) .@"2" = 3 - \\ } - \\ (struct { u32, u8, u16 }) [1] = { - \\ (u32) .@"0" = 4 - \\ (u8) .@"1" = 5 - \\ (u16) .@"2" = 6 - \\ } - \\ (struct { u32, u8, u16 }) [2] = { - \\ (u32) .@"0" = 7 - \\ (u8) .@"1" = 8 - \\ (u16) .@"2" = 9 - \\ } - \\} - \\(usize) list0.len = 3 - \\(usize) list0.capacity = 8 - \\(struct { u32, u8, u16 }) list0[0] = { - \\ (u32) .@"0" = 1 - \\ (u8) .@"1" = 2 - \\ (u16) .@"2" = 3 - \\} - \\(struct { u32, u8, u16 }) list0[1] = { - \\ (u32) .@"0" = 4 - \\ (u8) .@"1" = 5 - \\ (u16) .@"2" = 6 - \\} - \\(struct { u32, u8, u16 }) list0[2] = { - \\ (u32) .@"0" = 7 - \\ (u8) .@"1" = 8 - \\ (u16) .@"2" = 9 - \\} - \\([3]u32) list0.@"0" = { - \\ (u32) [0] = 1 - \\ (u32) [1] = 4 - \\ (u32) [2] = 7 - \\} - \\([3]u8) list0.@"1" = { - \\ (u8) [0] = 2 - \\ (u8) [1] = 5 - \\ (u8) [2] = 8 - \\} - \\([3]u16) list0.@"2" = { - \\ (u16) [0] = 3 - \\ (u16) [1] = 6 - \\ (u16) [2] = 9 - \\} - \\(lldb) frame variable --show-all-children --show-types -- slice0 slice0.len slice0.capacity slice0[0] slice0[1] slice0[2] 'slice0.@"0"' 'slice0.@"1"' 'slice0.@"2"' - \\(std.multi_array_list.MultiArrayList(struct { u32, u8, u16 }).Slice) slice0 = len=3 capacity=8 { - \\ (struct { u32, u8, u16 }) [0] = { - \\ (u32) .@"0" = 1 - \\ (u8) .@"1" = 2 - \\ (u16) .@"2" = 3 - \\ } - \\ (struct { u32, u8, u16 }) [1] = { - \\ (u32) .@"0" = 4 - \\ (u8) .@"1" = 5 - \\ (u16) .@"2" = 6 - \\ } - \\ (struct { u32, u8, u16 }) [2] = { - \\ (u32) .@"0" = 7 - \\ (u8) .@"1" = 8 - \\ (u16) .@"2" = 9 - \\ } - \\} - \\(usize) slice0.len = 3 - \\(usize) slice0.capacity = 8 - \\(struct { u32, u8, u16 }) slice0[0] = { - \\ (u32) .@"0" = 1 - \\ (u8) .@"1" = 2 - \\ (u16) .@"2" = 3 - \\} - \\(struct { u32, u8, u16 }) slice0[1] = { - \\ (u32) .@"0" = 4 - \\ (u8) .@"1" = 5 - \\ (u16) .@"2" = 6 - \\} - \\(struct { u32, u8, u16 }) slice0[2] = { - \\ (u32) .@"0" = 7 - \\ (u8) .@"1" = 8 - \\ (u16) .@"2" = 9 - \\} - \\([3]u32) slice0.@"0" = { - \\ (u32) [0] = 1 - \\ (u32) [1] = 4 - \\ (u32) [2] = 7 - \\} - \\([3]u8) slice0.@"1" = { - \\ (u8) [0] = 2 - \\ (u8) [1] = 5 - \\ (u8) [2] = 8 - \\} - \\([3]u16) slice0.@"2" = { - \\ (u16) [0] = 3 - \\ (u16) [1] = 6 - \\ (u16) [2] = 9 - \\} - \\(lldb) frame variable --show-all-children --show-types -- list1 list1.len list1.capacity list1[0] list1[1] list1[2] list1.a list1.b list1.c - \\(std.multi_array_list.MultiArrayList(main.Elem1)) list1 = len=3 capacity=12 { - \\ (root.main.Elem1) [0] = { - \\ (u32) .a = 1 - \\ (u8) .b = 2 - \\ (u16) .c = 3 - \\ } - \\ (root.main.Elem1) [1] = { - \\ (u32) .a = 4 - \\ (u8) .b = 5 - \\ (u16) .c = 6 - \\ } - \\ (root.main.Elem1) [2] = { - \\ (u32) .a = 7 - \\ (u8) .b = 8 - \\ (u16) .c = 9 - \\ } - \\} - \\(usize) list1.len = 3 - \\(usize) list1.capacity = 12 - \\(root.main.Elem1) list1[0] = { - \\ (u32) .a = 1 - \\ (u8) .b = 2 - \\ (u16) .c = 3 - \\} - \\(root.main.Elem1) list1[1] = { - \\ (u32) .a = 4 - \\ (u8) .b = 5 - \\ (u16) .c = 6 - \\} - \\(root.main.Elem1) list1[2] = { - \\ (u32) .a = 7 - \\ (u8) .b = 8 - \\ (u16) .c = 9 - \\} - \\([3]u32) list1.a = { - \\ (u32) [0] = 1 - \\ (u32) [1] = 4 - \\ (u32) [2] = 7 - \\} - \\([3]u8) list1.b = { - \\ (u8) [0] = 2 - \\ (u8) [1] = 5 - \\ (u8) [2] = 8 - \\} - \\([3]u16) list1.c = { - \\ (u16) [0] = 3 - \\ (u16) [1] = 6 - \\ (u16) [2] = 9 - \\} - \\(lldb) frame variable --show-all-children --show-types -- slice1 slice1.len slice1.capacity slice1[0] slice1[1] slice1[2] slice1.a slice1.b slice1.c - \\(std.multi_array_list.MultiArrayList(main.Elem1).Slice) slice1 = len=3 capacity=12 { - \\ (root.main.Elem1) [0] = { - \\ (u32) .a = 1 - \\ (u8) .b = 2 - \\ (u16) .c = 3 - \\ } - \\ (root.main.Elem1) [1] = { - \\ (u32) .a = 4 - \\ (u8) .b = 5 - \\ (u16) .c = 6 - \\ } - \\ (root.main.Elem1) [2] = { - \\ (u32) .a = 7 - \\ (u8) .b = 8 - \\ (u16) .c = 9 - \\ } - \\} - \\(usize) slice1.len = 3 - \\(usize) slice1.capacity = 12 - \\(root.main.Elem1) slice1[0] = { - \\ (u32) .a = 1 - \\ (u8) .b = 2 - \\ (u16) .c = 3 - \\} - \\(root.main.Elem1) slice1[1] = { - \\ (u32) .a = 4 - \\ (u8) .b = 5 - \\ (u16) .c = 6 - \\} - \\(root.main.Elem1) slice1[2] = { - \\ (u32) .a = 7 - \\ (u8) .b = 8 - \\ (u16) .c = 9 - \\} - \\([3]u32) slice1.a = { - \\ (u32) [0] = 1 - \\ (u32) [1] = 4 - \\ (u32) [2] = 7 - \\} - \\([3]u8) slice1.b = { - \\ (u8) [0] = 2 - \\ (u8) [1] = 5 - \\ (u8) [2] = 8 - \\} - \\([3]u16) slice1.c = { - \\ (u16) [0] = 3 - \\ (u16) [1] = 6 - \\ (u16) [2] = 9 - \\} - \\(lldb) breakpoint delete --force 1 - \\1 breakpoints deleted; 0 breakpoint locations disabled. - }, - .{}, - ); -} - -const File = struct { import: ?[]const u8 = null, path: []const u8, source: []const u8 }; - -const TestOptions = struct { - skip_new_linker: bool = false, -}; - -fn addGdbTest( - db: *Debugger, - name: []const u8, - files: []const File, - commands: []const u8, - expected_output: []const []const u8, - options: TestOptions, -) void { - db.addTest( - name, - files, - &.{}, - &.{ - db.options.gdb orelse return, - "--batch", - "--command", - }, - "set remotetimeout 0", - commands, - &.{"--args"}, - expected_output, - options, - ); -} - -fn addLldbTest( - db: *Debugger, - name: []const u8, - files: []const File, - commands: []const u8, - expected_output: []const []const u8, - options: TestOptions, -) void { - db.addTest( - name, - files, - &.{.{ "LANG", "C.UTF-8" }}, // affects output formatting - &.{ - db.options.lldb orelse return, - "--batch", - "--source", - }, - "settings set plugin.process.gdb-remote.packet-timeout 0", - commands, - &.{"--"}, - expected_output, - options, - ); -} - -/// After a failure while running a script, the debugger starts accepting commands from stdin, and -/// because it is empty, the debugger exits normally with status 0. Choose a non-zero status to -/// return from the debugger script instead to detect it running to completion and indicate success. -const success = 99; - -fn addTest( - db: *Debugger, - name: []const u8, - files: []const File, - env: []const struct { []const u8, []const u8 }, - db_argv1: []const []const u8, - db_commands: []const u8, - commands: []const u8, - db_argv2: []const []const u8, - expected_output: []const []const u8, - options: TestOptions, -) void { - if (db.options.test_filters.len > 0) { - for (db.options.test_filters) |test_filter| { - if (std.mem.find(u8, name, test_filter) != null) break; - } else return; - } - - const wf = db.b.addWriteFiles(); - const root_source_file = wf.add(files[0].path, files[0].source); - var imports: std.array_hash_map.String(*std.Build.Module) = .empty; - for (files[1..]) |file| { - const path = wf.add(file.path, file.source); - if (file.import) |import| imports.putNoClobber(db.b.allocator, import, db.b.createModule(.{ - .root_source_file = path, - })) catch @panic("OOM"); - } - const commands_file = wf.add( - db.b.fmt("{s}.cmd", .{name}), - db.b.fmt("{s}\n\n{s}\n\nquit {d}\n", .{ db_commands, commands, success }), - ); - - for (db.test_matrix) |test_target| { - if (options.skip_new_linker and test_target.linker == .new) continue; - - const resolved_target = db.b.resolveTargetQuery(test_target.target); - - const target_str = db.b.fmt("{s}{s}{s}", .{ - resolved_target.query.zigTriple(db.b.allocator) catch @panic("OOM"), - switch (test_target.linker) { - .default, .old => "", - .new => "-new-linker", - }, - if (test_target.pic == true) "-pic" else "", - }); - - if (db.options.test_target_filters.len > 0) { - for (db.options.test_target_filters) |filter| { - if (std.mem.find(u8, target_str, filter) != null) break; - } else continue; - } - - const mod = db.b.createModule(.{ - .target = resolved_target, - .root_source_file = root_source_file, - .optimize = test_target.optimize_mode, - .link_libc = test_target.link_libc, - .single_threaded = test_target.single_threaded, - .pic = test_target.pic, - .strip = false, - }); - for (imports.keys(), imports.values()) |import_name, import_mod| - mod.addImport(import_name, import_mod); - - const exe = db.b.addExecutable(.{ - .name = name, - .root_module = mod, - .use_llvm = false, - .use_lld = false, - }); - exe.use_new_linker = switch (test_target.linker) { - .default => null, - .old => false, - .new => true, - }; - - const run = std.Build.Step.Run.create(db.b, db.b.fmt("run {s} {s}", .{ name, target_str })); - for (env) |env_var| run.setEnvironmentVariable(env_var[0], env_var[1]); - run.addArgs(db_argv1); - run.addFileArg(commands_file); - run.addArgs(db_argv2); - run.addArtifactArg(exe); - for (expected_output) |expected| run.addCheck(.{ - .expect_stdout_match = db.b.fmt("{s}\n", .{expected}), - }); - run.addCheck(.{ .expect_term = .{ .exited = success } }); - run.setStdIn(.{ .bytes = "" }); - db.root_step.dependOn(&run.step); - } -} - -const Debugger = @This(); -const std = @import("std"); diff --git a/test/src/Runner.zig b/test/src/Runner.zig index f917fccc32541d0395512e332d9d5317536921c1..0598fbaecd48053c1f8a166bc0eaefb516d4a435 100644 --- a/test/src/Runner.zig +++ b/test/src/Runner.zig @@ -1,10 +1,11 @@ const assert = std.debug.assert; +const builtin = @import("builtin"); const std = @import("std"); const Runner = @This(); -const zig_version_string = @import("builtin").zig_version_string; gpa: std.mem.Allocator, arena: *std.heap.ArenaAllocator, +environ_map: std.process.Environ.Map, io: std.Io, prog_node: std.Progress.Node, args: Args, @@ -23,12 +24,17 @@ const Args = struct { src_dir: ?std.Io.Dir, targets: std.ArrayList(u32), target_bytes: std.ArrayList(u8), + libc_runtimes_dir: ?std.Io.Dir, enable_darling: bool, enable_qemu: bool, enable_rosetta: bool, enable_wasmtime: bool, enable_wine: bool, + + gdb_exe: ?std.Io.File, + lldb_exe: ?std.Io.File, + quiet: bool, fn deinit(args: *Args, gpa: std.mem.Allocator) void { @@ -46,6 +52,7 @@ const Args = struct { }; fn deinit(runner: *Runner) void { + runner.environ_map.deinit(); runner.prog_node.end(); runner.args.deinit(runner.gpa); runner.eb_wip.deinit(); @@ -69,7 +76,7 @@ pub const ProtocolError = error{ ServerEndOfStream, } || FailError; pub fn runServer(runner: *Runner) ProtocolError { - runner.server.serveStringMessage(.zig_version, zig_version_string) catch |err| switch (err) { + runner.server.serveStringMessage(.zig_version, builtin.zig_version_string) catch |err| switch (err) { error.WriteFailed => return error.ServerWriteFailed, }; while (true) { @@ -92,20 +99,22 @@ pub fn runServer(runner: *Runner) ProtocolError { @"--src", @"--target", @"--libc-runtimes", + @"--gdb", + @"--lldb", }; var state: State = .positional; - const state_expected: std.enums.EnumArray(State, enum { - path, - dir, - file, - string, - }) = .init(.{ + const state_expected: std.enums.EnumArray( + State, + enum { path, dir, file, string }, + ) = .init(.{ .positional = .path, .@"--zig" = .file, .@"--lib" = .dir, .@"--src" = .dir, .@"--target" = .string, .@"--libc-runtimes" = .dir, + .@"--gdb" = .file, + .@"--lldb" = .file, }); var input_dir: std.zig.Server.Message.InputDir = .cwd; var args_body_offset: usize = 0; @@ -137,6 +146,12 @@ pub fn runServer(runner: *Runner) ProtocolError { runner.args.enable_wasmtime = true; } else if (std.mem.eql(u8, string, "-fwine")) { runner.args.enable_wine = true; + } else if (std.mem.eql(u8, string, "--gdb")) { + state = .@"--gdb"; + continue; + } else if (std.mem.eql(u8, string, "--lldb")) { + state = .@"--lldb"; + continue; } else if (std.mem.eql(u8, string, "--quiet")) { runner.args.quiet = true; }, @@ -160,6 +175,10 @@ pub fn runServer(runner: *Runner) ProtocolError { .@"--src" else if (std.mem.eql(u8, string, "--libc-runtimes=")) .@"--libc-runtimes" + else if (std.mem.eql(u8, string, "--gdb=")) + .@"--gdb" + else if (std.mem.eql(u8, string, "--lldb=")) + .@"--lldb" else return runner.fail("unsupported arg prefix: {q}", .{string}); continue; @@ -270,6 +289,20 @@ pub fn runServer(runner: *Runner) ProtocolError { ); runner.args.zig_exe = file; }, + .@"--gdb" => { + if (runner.args.gdb_exe != null) return runner.fail( + "\"{t}\" specified multiple times", + .{state}, + ); + runner.args.gdb_exe = file; + }, + .@"--lldb" => { + if (runner.args.lldb_exe != null) return runner.fail( + "\"{t}\" specified multiple times", + .{state}, + ); + runner.args.lldb_exe = file; + }, else => return runner.fail( "\"{t}\" expected {t}, got {t}", .{ state, state_expected.get(state), arg }, @@ -746,20 +779,24 @@ fn handleCommand( .lib => .Lib, .obj => .Obj, }, contents_r, target: { - const backend_split = std.mem.findScalarLast(u8, update.target_query, '-') orelse - return runner.fail("target {q} missing query", .{update.target_query}); - const mode_split = - std.mem.findScalarLast(u8, update.target_query[0..backend_split], '-') orelse - return runner.fail("target {q} missing mode", .{update.target_query}); - const triple = update.target_query[0..mode_split]; - const backend_str = update.target_query[backend_split + 1 ..]; + var component_it = std.mem.splitBackwardsScalar(u8, update.target_query, '-'); + const pic_str = component_it.next() orelse + return runner.fail("target {q} missing pic", .{update.target_query}); + const pic = std.meta.stringToEnum(Compiler.Target.Pic, pic_str) orelse + return runner.fail("target {q} unknown pic {q}", .{ update.target_query, pic_str }); + const linker_str = component_it.next() orelse + return runner.fail("target {q} missing linker", .{update.target_query}); + const linker = std.meta.stringToEnum(Compiler.Target.Linker, linker_str) orelse + return runner.fail("target {q} unknown linker {q}", .{ update.target_query, linker_str }); + const backend_str = component_it.next() orelse + return runner.fail("target {q} missing backend", .{update.target_query}); const backend = std.meta.stringToEnum(Compiler.Target.Backend, backend_str) orelse - return runner.fail("target {q} unknown backend {q}", .{ - update.target_query, backend_str, - }); - const mode_str = update.target_query[mode_split + 1 .. backend_split]; - const mode = std.meta.stringToEnum(Compiler.Target.Mode, mode_str) orelse - return runner.fail("target {q} unknown mode {q}", .{ update.target_query, mode_str }); + return runner.fail("target {q} unknown backend {q}", .{ update.target_query, backend_str }); + const cache_mode_str = component_it.next() orelse + return runner.fail("target {q} missing cache mode", .{update.target_query}); + const cache_mode = std.meta.stringToEnum(Compiler.Target.CacheMode, cache_mode_str) orelse + return runner.fail("target {q} unknown cache mode {q}", .{ update.target_query, cache_mode_str }); + const triple = component_it.rest(); break :target .{ .triple = triple, .resolved = std.zig.system.resolveTargetQuery( @@ -779,8 +816,10 @@ fn handleCommand( error.Canceled => |e| return e, else => |e| return runner.fail("unable to resolve target {q}: {t}", .{ triple, e }), }, - .mode = mode, + .cache_mode = cache_mode, .backend = backend, + .linker = linker, + .pic = pic, }; }) catch |err| switch (err) { error.Canceled, error.OutOfMemory, error.AlreadyReported => |e| return e, @@ -925,7 +964,7 @@ fn handleCommand( ), }; }, - .stdout, .exit, .lldb => if (eb.errorMessageCount() > 0) { + .stdout, .exit, .gdb, .lldb => if (eb.errorMessageCount() > 0) { eb.renderToStderr(runner.io, .{}, .auto) catch |err| switch (err) { error.Canceled => {}, else => {}, @@ -989,7 +1028,7 @@ fn spawnCompiler( "--cache-dir", ".zig-cache", }); - switch (target.mode) { + switch (target.cache_mode) { .whole => {}, .incremental => try argv.append(gpa, "-fincremental"), } @@ -1005,7 +1044,19 @@ fn spawnCompiler( error.Canceled => |e| return e, else => |e| return runner.fail("unable to get lib path: {t}", .{e}), }] }); + switch (target.linker) { + .lld => try argv.appendSlice(gpa, &.{ "-flld", "-fno-new-linker" }), + .old => try argv.appendSlice(gpa, &.{ "-fno-lld", "-fno-new-linker" }), + .new => try argv.appendSlice(gpa, &.{ "-fno-lld", "-fnew-linker" }), + } + switch (target.pic) { + .nopic => try argv.appendSlice(gpa, &.{ "-fno-PIC", "-fno-PIE" }), + .pic => try argv.appendSlice(gpa, &.{ "-fPIC", "-fno-PIE" }), + .pie => try argv.appendSlice(gpa, &.{ "-fPIC", "-fPIE" }), + } + var need: usize = 1; + var state: enum { positional, @"--name" } = .positional; var root_name: ?[]const u8 = null; while (true) { const done = if (args_r.fill(need)) false else |err| switch (err) { @@ -1017,10 +1068,18 @@ fn spawnCompiler( const end = std.mem.findAnyPos(u8, buffered, start, "\n ") orelse buffered.len; if (end - start > 0) { const arg = try arena.dupe(u8, buffered[start..end]); - if (std.mem.cutPrefix(u8, arg, "-M")) |module| { - var module_name_it = std.mem.splitScalar(u8, module, '='); - const module_name = module_name_it.next().?; - root_name = root_name orelse module_name; + switch (state) { + .positional => if (std.mem.eql(u8, arg, "--name")) { + state = .@"--name"; + } else if (std.mem.cutPrefix(u8, arg, "-M")) |module| { + var module_name_it = std.mem.splitScalar(u8, module, '='); + const module_name = module_name_it.next().?; + root_name = root_name orelse module_name; + }, + .@"--name" => { + root_name = arg; + state = .positional; + }, } try argv.append(gpa, arg); args_r.toss(end); @@ -1101,13 +1160,12 @@ const Compiler = struct { const Target = struct { triple: []const u8, resolved: std.Target, - mode: Mode, + cache_mode: CacheMode, backend: ?Backend, + linker: Linker, + pic: Pic, - const Mode = enum { - whole, - incremental, - }; + const CacheMode = enum { whole, incremental }; const Backend = enum { /// Run semantic analysis only. Runtime output will not be tested, but we still verify @@ -1123,6 +1181,10 @@ const Compiler = struct { /// Corresponds to `-ofmt=c`. cbe, }; + + const Linker = enum { old, new, lld }; + + const Pic = enum { nopic, pic, pie }; }; fn receiveMessage(comp: *Compiler) FailError!?struct { @@ -1153,7 +1215,7 @@ const Compiler = struct { return .{ .tag = header.tag, .body = body }; } - const Check = enum { errors, stdout, exit, lldb }; + const Check = enum { errors, stdout, exit, gdb, lldb }; fn checkSuccess( comp: *Compiler, check: Check, @@ -1167,22 +1229,91 @@ const Compiler = struct { const io = runner.io; const target = &comp.target.resolved; const config = &comp.config.?; - const out_dir = ".zig-cache" ++ std.Io.Dir.path.sep_str ++ + var path_buffer: [std.Io.Dir.max_path_bytes]u8 = undefined; + + // After a failure while running a script, the debugger starts accepting commands from stdin, and + // because it is empty, the debugger exits normally with status 0. Choose a non-zero status to + // return from the debugger script instead to detect it running to completion and indicate success. + const debug_success = 99; + + const tmp_dir_path = ".zig-cache" ++ std.Io.Dir.path.sep_str ++ "tmp"; + src_dir.createDirPath(io, tmp_dir_path) catch |err| switch (err) { + error.Canceled => |e| return e, + else => |e| return runner.fail("unable to create dir path {q}: {t}", .{ + tmp_dir_path, e, + }), + }; + + var argv: std.ArrayList([]const u8) = .initBuffer(try arena.alloc([]const u8, 5 + 4)); + var environ_map: std.process.Environ.Map = .init(gpa); + defer environ_map.deinit(); + try environ_map.putAll(&runner.environ_map); + var script_buffer: [512]u8 = undefined; + const script_path, const script_file, var script_fw = script: switch (check) { + .errors => return, + .stdout, .exit => .{ undefined, null, undefined }, + .gdb => { + const script_path = tmp_dir_path ++ std.Io.Dir.path.sep_str ++ "gdb"; + argv.appendSliceAssumeCapacity(&.{ "gdb", "--batch", "--command", script_path, "--args" }); + const script_file = src_dir.createFile(io, script_path, .{}) catch |err| switch (err) { + error.Canceled => |e| return e, + else => |e| return runner.fail("unable to create debugger script {q}: {t}", .{ + script_path, e, + }), + }; + errdefer script_file.close(io); + var script_fw = script_file.writer(io, &script_buffer); + script_fw.interface.writeAll( + \\set remotetimeout 0 + \\ + \\ + ) catch |err| switch (err) { + error.WriteFailed => switch (script_fw.err.?) { + error.Canceled => |e| return e, + else => |e| return runner.fail("unable to write debugger script {q}: {t}", .{ script_path, e }), + }, + }; + break :script .{ script_path, script_file, script_fw }; + }, + .lldb => { + const script_path = tmp_dir_path ++ std.Io.Dir.path.sep_str ++ "lldb"; + argv.appendSliceAssumeCapacity(&.{ "lldb", "--batch", "--source", script_path, "--" }); + try environ_map.put("LANG", "C.UTF-8"); // affects output formatting + const script_file = src_dir.createFile(io, script_path, .{}) catch |err| switch (err) { + error.Canceled => |e| return e, + else => |e| return runner.fail("unable to create debugger script {q}: {t}", .{ + script_path, + e, + }), + }; + errdefer script_file.close(io); + var script_fw = script_file.writer(io, &script_buffer); + script_fw.interface.writeAll( + \\settings set frame-format 'frame #${frame.index}:{ ${module.file.basename}{\`${function.name-with-args}{${frame.no-debug}${function.pc-offset}}}}{ at ${line.file.basename}:${line.number}{:${line.column}}}{${function.is-optimized} [opt]}{${frame.is-artificial} [artificial]}\n' + \\settings set plugin.process.gdb-remote.packet-timeout 0 + \\settings set stop-line-count-after 0 + \\settings set stop-line-count-before 0 + \\ + ) catch |err| switch (err) { + error.WriteFailed => switch (script_fw.err.?) { + error.Canceled => |e| return e, + else => |e| return runner.fail("unable to write debugger script {q}: {t}", .{ script_path, e }), + }, + }; + break :script .{ script_path, script_file, script_fw }; + }, + }; + defer if (script_file) |file| file.close(io); + + const out_dir_path = ".zig-cache" ++ std.Io.Dir.path.sep_str ++ "o" ++ std.Io.Dir.path.sep_str ++ std.Build.Cache.binToHex(digest.*); - const out_path = try std.Io.Dir.path.join(arena, &.{ out_dir, comp.out_name }); + const out_path = try std.Io.Dir.path.join(arena, &.{ out_dir_path, comp.out_name }); const bin_path = switch (comp.target.backend.?) { .sema => return, .selfhosted, .llvm => out_path, .cbe => try comp.compileC(src_dir, out_path), }; - switch (check) { - .errors => return, - .stdout, .exit, .lldb => {}, - } - var argv: std.ArrayList([]const u8) = .initBuffer(try arena.alloc([]const u8, 4)); - var environ_map: std.process.Environ.Map = .init(gpa); - defer environ_map.deinit(); const need_cross_libc = target.os.tag == .linux and config.flags.link_libc and config.flags.link_mode == .dynamic; const use_executor = use_executor: switch (std.zig.system.getExternalExecutor(io, target, .{ @@ -1210,9 +1341,8 @@ const Compiler = struct { if (need_cross_libc) { const libc_runtimes_dir = runner.args.libc_runtimes_dir orelse continue :use_executor .bad_os_or_cpu; - var path_buffer: [std.Io.Dir.max_path_bytes]u8 = undefined; const libc_runtimes_path = path_buffer[0 .. libc_runtimes_dir.realPath( - runner.io, + io, &path_buffer, ) catch |err| switch (err) { error.Canceled => |e| return e, @@ -1252,6 +1382,18 @@ const Compiler = struct { }; argv.appendAssumeCapacity(bin_path); + if (!runner.args.quiet) std.log.info("{f}", .{std.zig.SubprocessCommand{ + .argv = argv.items, + .cwd = cwd_path: { + break :cwd_path path_buffer[0 .. src_dir.realPath(io, &path_buffer) catch |err| switch (err) { + error.Canceled => |e| return e, + else => break :cwd_path null, + }]; + }, + .parent_env = &runner.environ_map, + .child_env = &environ_map, + }}); + var name_buffer: [std.Progress.Node.max_name_len]u8 = undefined; const run_prog_node = runner.prog_node.start(std.mem.print(&name_buffer, "run {s}", .{ comp.out_name, @@ -1263,81 +1405,158 @@ const Compiler = struct { else => |e| return runner.fail("unable to open {q}: {t}", .{ bin_path, e }), }; defer bin_file.close(io); - switch (check) { - .errors => unreachable, - .stdout, .exit => { - const result = std.process.run(gpa, io, .{ - .exe = if (use_executor) .search else .{ .file = bin_file }, - .argv = argv.items, - .cwd = .{ .dir = src_dir }, - .environ_map = &environ_map, - .progress_node = run_prog_node, - }) catch |err| if (use_executor) { - // Chances are the foreign executor isn't available. Skip this evaluation. - if (!runner.args.quiet) std.log.warn( - "skipping execution of {q} via executor for foreign target {q}: {t}", - .{ bin_path, comp.target.triple, err }, - ); - return; - } else return runner.fail("unable to run the generated executable {q}: {t}", .{ - bin_path, err, - }); - defer { - gpa.free(result.stdout); - gpa.free(result.stderr); - } - switch (result.term) { - .exited => |code| switch (check) { - .errors, .lldb => unreachable, - .stdout => { - if (code != 0) return runner.fail( - "generated executable {q} failed with code {d}", - .{ bin_path, code }, - ); - std.testing.expectEqualStrings( - expected, - result.stdout, - ) catch |err| switch (err) { - error.TestExpectedEqual => return runner.fail( - "stdout did not match expected", - .{}, - ), - }; + const result = std.process.run(gpa, io, .{ + .exe = exe: switch (check) { + .errors => unreachable, + .stdout, .exit => if (use_executor) .search else .{ .file = bin_file }, + .gdb, .lldb => { + if (use_executor) { + if (!runner.args.quiet) std.log.warn( + "skipping debugging of {q} via executor for foreign target {q}", + .{ bin_path, comp.target.triple }, + ); + return; + } + + var line_it = std.mem.splitScalar(u8, expected, '\n'); + while (line_it.next()) |line| if (std.mem.cutPrefix(u8, line, switch (check) { + else => unreachable, + .gdb => "(gdb) ", + .lldb => "(lldb) ", + })) |cmd| script_fw.interface.print( + \\{s} + \\ + , .{cmd}) catch |err| switch (err) { + error.WriteFailed => switch (script_fw.err.?) { + error.Canceled => |e| return e, + else => |e| return runner.fail("unable to write debugger script {q}: {t}", .{ + script_path, e, + }), }, - .exit => { - var actual_code_buffer: [std.fmt.count("{d}", .{std.math.maxInt(u8)})]u8 = - undefined; - std.testing.expectEqualStrings( - expected, - std.mem.print(&actual_code_buffer, "{d}", .{code}) catch unreachable, - ) catch |err| switch (err) { - error.TestExpectedEqual => return runner.fail( - "exit code did not match expected", - .{}, - ), - }; + }; + script_fw.interface.print( + \\ + \\quit {d} + \\ + , .{debug_success}) catch |err| switch (err) { + error.WriteFailed => switch (script_fw.err.?) { + error.Canceled => |e| return e, + else => |e| return runner.fail("unable to write debugger script {q}: {t}", .{ + script_path, e, + }), }, - }, - .signal => |sig| return runner.fail( - "generated executable {q} terminated with signal {t}", - .{ bin_path, sig }, - ), - .stopped => |sig| return runner.fail( - "generated executable {q} stopped with signal {t}", - .{ bin_path, sig }, - ), - .unknown => return runner.fail( - "generated executable {q} terminated unexpectedly", - .{bin_path}, - ), - } - if (!use_executor and result.stderr.len > 0) { - std.log.err("generated executable {q} had unexpected stderr:\n{s}", .{ - bin_path, result.stderr, - }); - } + }; + script_fw.flush() catch |err| switch (err) { + error.Canceled => |e| return e, + else => |e| return runner.fail("unable to write debugger script {q}: {t}", .{ + script_path, e, + }), + }; + break :exe .{ .file = switch (check) { + else => unreachable, + .gdb => runner.args.gdb_exe, + .lldb => runner.args.lldb_exe, + } orelse { + if (!runner.args.quiet) std.log.warn( + "skipping debugging of {q} because of missing \"--{t}=path/to/{[1]t}\" arg", + .{ bin_path, check }, + ); + return; + } }; + }, + }, + .argv = argv.items, + .cwd = .{ .dir = src_dir }, + .environ_map = &environ_map, + .progress_node = run_prog_node, + }) catch |err| if (use_executor) { + // Chances are the foreign executor isn't available. Skip this evaluation. + if (!runner.args.quiet) std.log.warn( + "skipping execution of {q} via executor for foreign target {q}: {t}", + .{ bin_path, comp.target.triple, err }, + ); + return; + } else return runner.fail("unable to run the generated executable {q}: {t}", .{ + bin_path, err, + }); + defer { + gpa.free(result.stdout); + gpa.free(result.stderr); + } + switch (result.term) { + .exited => |code| switch (check) { + .errors => unreachable, + .stdout => { + if (code != 0) return runner.fail( + "generated executable {q} failed with code {d}", + .{ bin_path, code }, + ); + std.testing.expectEqualStrings( + expected, + result.stdout, + ) catch |err| switch (err) { + error.TestExpectedEqual => return runner.fail("stdout did not match expected", .{}), + }; + }, + .exit => { + var actual_code_buffer: [std.fmt.count("{d}", .{std.math.maxInt(u8)})]u8 = undefined; + std.testing.expectEqualStrings( + expected, + std.mem.print(&actual_code_buffer, "{d}", .{code}) catch unreachable, + ) catch |err| switch (err) { + error.TestExpectedEqual => return runner.fail( + "exit code did not match expected", + .{}, + ), + }; + }, + .gdb, .lldb => { + if (code != debug_success) return runner.fail( + "debugging {q} failed with code {d}", + .{ bin_path, code }, + ); + var expected_match_it = std.mem.splitSequence(u8, expected, "#..."); + var pos: usize = 0; + while (expected_match_it.next()) |expected_match| : (pos += expected_match.len) { + var context_len: usize = expected_match.len; + pos = while (true) : (context_len -= 1) break std.mem.findPos( + u8, + result.stdout, + pos, + expected_match[0..context_len], + ) orelse continue; + const actual_match = result.stdout[pos..]; + std.testing.expectEqualStrings( + expected_match, + actual_match[0..@min(actual_match.len, expected_match.len)], + ) catch |err| switch (err) { + error.TestExpectedEqual => { + std.testing.failPrint("\n=============== full output: =========\n", .{}); + std.testing.failPrintWithVisibleNewlines(actual_match); + std.testing.failPrint("\n======================================\n", .{}); + return runner.fail("stdout did not match expected", .{}); + }, + }; + } + }, }, - .lldb => {}, + .signal => |sig| return runner.fail( + "generated executable {q} terminated with signal {t}", + .{ bin_path, sig }, + ), + .stopped => |sig| return runner.fail( + "generated executable {q} stopped with signal {t}", + .{ bin_path, sig }, + ), + .unknown => return runner.fail( + "generated executable {q} terminated unexpectedly", + .{bin_path}, + ), + } + if (!use_executor and result.stderr.len > 0) { + std.log.err("generated executable {q} had unexpected stderr:\n{s}", .{ + bin_path, result.stderr, + }); } } @@ -1353,8 +1572,10 @@ const Compiler = struct { resolved.ofmt = .default(resolved.os.tag, resolved.cpu.arch); break :resolved resolved; }, - .mode = .whole, + .cache_mode = .whole, .backend = null, + .linker = .lld, + .pic = parent_comp.target.pic, }) catch |err| switch (err) { error.Canceled, error.OutOfMemory, error.AlreadyReported => |e| return e, error.ReadFailed => unreachable, // .fixed @@ -1439,14 +1660,19 @@ const ClientArgs = struct { lib_dir: std.Io.Dir, src_dir: std.Io.Dir, targets: std.ArrayList([]const u8), + + libc_runtimes_dir: ?std.Io.Dir, + enable_darling: bool, + enable_qemu: bool, + enable_rosetta: bool, + enable_wine: bool, + enable_wasmtime: bool, + + gdb_exe: ?std.Io.File, + lldb_exe: ?std.Io.File, + + quiet: bool, keep_src: bool, - libc_runtimes_dir: ?std.Io.Dir, - enable_darling: bool, - enable_qemu: bool, - enable_rosetta: bool, - enable_wine: bool, - enable_wasmtime: bool, - quiet: bool, }; pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelable)!u8 { const fatal = struct { @@ -1461,6 +1687,8 @@ pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelabl var zig_path_arg: ?[]const u8 = null; var lib_path_arg: ?[]const u8 = null; var libc_runtimes_path_arg: ?[]const u8 = null; + var gdb_path_arg: ?[]const u8 = null; + var lldb_path_arg: ?[]const u8 = null; var args: ClientArgs = .{ .test_file = undefined, .test_kind = undefined, @@ -1468,14 +1696,19 @@ pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelabl .lib_dir = undefined, .src_dir = undefined, .targets = .empty, - .keep_src = false, + .libc_runtimes_dir = null, .enable_darling = false, .enable_qemu = false, .enable_rosetta = false, .enable_wine = false, .enable_wasmtime = false, + + .gdb_exe = null, + .lldb_exe = null, + .quiet = false, + .keep_src = false, }; defer args.targets.deinit(init.gpa); @@ -1490,6 +1723,10 @@ pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelabl var runner: Runner = .{ .gpa = init.gpa, .arena = init.arena, + .environ_map = init.minimal.environ.createMap(init.gpa) catch |err| switch (err) { + error.OutOfMemory => |e| return e, + else => |e| fatal("unable to get environment: {t}", .{e}), + }, .io = init.io, .prog_node = std.Progress.start(init.io, .{}), .args = .{ @@ -1500,12 +1737,17 @@ pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelabl .src_dir = null, .targets = .empty, .target_bytes = .empty, + .libc_runtimes_dir = null, .enable_darling = false, .enable_qemu = false, .enable_rosetta = false, .enable_wasmtime = false, .enable_wine = false, + + .gdb_exe = null, + .lldb_exe = null, + .quiet = false, }, .host = std.zig.system.resolveTargetQuery(init.io, .{}) catch |err| switch (err) { @@ -1555,8 +1797,6 @@ pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelabl ); } else if (std.mem.cutPrefix(u8, arg, "--target=")) |target| { try args.targets.append(init.gpa, try arena.dupe(u8, target)); - } else if (std.mem.eql(u8, arg, "--keep-src")) { - args.keep_src = true; } else if (std.mem.eql(u8, arg, "--libc-runtimes")) { libc_runtimes_path_arg = arg_it.next() orelse fatal("missing arg after {q}", .{arg}); } else if (std.mem.cutPrefix(u8, arg, "--libc-runtimes=")) |libc_runtimes_path| { @@ -1571,8 +1811,18 @@ pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelabl args.enable_wine = true; } else if (std.mem.eql(u8, arg, "-fwasmtime")) { args.enable_wasmtime = true; + } else if (std.mem.eql(u8, arg, "--gdb")) { + gdb_path_arg = arg_it.next() orelse fatal("missing arg after {q}", .{arg}); + } else if (std.mem.cutPrefix(u8, arg, "--gdb=")) |gdb_path| { + gdb_path_arg = gdb_path; + } else if (std.mem.eql(u8, arg, "--lldb")) { + lldb_path_arg = arg_it.next() orelse fatal("missing arg after {q}", .{arg}); + } else if (std.mem.cutPrefix(u8, arg, "--lldb=")) |lldb_path| { + lldb_path_arg = lldb_path; } else if (std.mem.eql(u8, arg, "--quiet")) { args.quiet = true; + } else if (std.mem.eql(u8, arg, "--keep-src")) { + args.keep_src = true; } else { if (test_path_arg) |_| fatal("unexpected arg {q}", .{arg}); test_path_arg = arg; @@ -1614,6 +1864,16 @@ pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelabl else => |e| fatal("unable to open {q}: {t}", .{ lib_path, e }), }; defer if (args.libc_runtimes_dir) |libc_runtimes_dir| libc_runtimes_dir.close(init.io); + if (gdb_path_arg) |gdb_path| args.gdb_exe = cwd.openFile(init.io, gdb_path, .{}) catch |err| switch (err) { + error.Canceled => |e| return e, + else => |e| fatal("unable to open {q}: {t}", .{ gdb_path, e }), + }; + defer if (args.gdb_exe) |gdb_exe| gdb_exe.close(init.io); + if (lldb_path_arg) |lldb_path| args.lldb_exe = cwd.openFile(init.io, lldb_path, .{}) catch |err| switch (err) { + error.Canceled => |e| return e, + else => |e| fatal("unable to open {q}: {t}", .{ lldb_path, e }), + }; + defer if (args.lldb_exe) |lldb_exe| lldb_exe.close(init.io); const src_dir_path = "src_" ++ std.fmt.hex(rand_int: { var rand_int: u64 = undefined; @@ -1631,12 +1891,19 @@ pub fn main(init: std.process.Init) (std.mem.Allocator.Error || std.Io.Cancelabl }; } + var inherit_dirs: std.ArrayList(std.Io.Dir) = .initBuffer(try arena.alloc(std.Io.Dir, 3)); + var inherit_files: std.ArrayList(std.Io.File) = .initBuffer(try arena.alloc(std.Io.File, 4)); + inherit_files.appendSliceAssumeCapacity(&.{ args.test_file, args.zig_exe }); + inherit_dirs.appendSliceAssumeCapacity(&.{ args.lib_dir, args.src_dir }); + if (args.libc_runtimes_dir) |libc_runtimes_dir| inherit_dirs.appendAssumeCapacity(libc_runtimes_dir); + if (args.gdb_exe) |gdb_exe| inherit_files.appendAssumeCapacity(gdb_exe); + if (args.lldb_exe) |lldb_exe| inherit_files.appendAssumeCapacity(lldb_exe); var child = std.process.spawn(init.io, .{ .argv = &.{ self, "--listen=-" }, .stdin = .pipe, .stdout = .pipe, - .inherit_dirs = &.{ args.lib_dir, args.src_dir }, - .inherit_files = &.{ args.zig_exe, args.test_file }, + .inherit_dirs = inherit_dirs.items, + .inherit_files = inherit_files.items, }) catch |err| switch (err) { error.Canceled, error.OutOfMemory => |e| return e, else => |e| fatal("unable to spawn runner: {t}", .{e}), @@ -1754,6 +2021,21 @@ fn runClient( try argv.append(gpa, 0); } + if (args.gdb_exe) |gdb_exe| { + try argv.append(gpa, @backingInt(Arg.prefix)); + try argv.appendSlice(gpa, "--gdb="); + try argv.append(gpa, 0); + try argv.append(gpa, @backingInt(Arg.input_file)); + try argv.appendSlice(gpa, @ptrCast(&gdb_exe.handle)); + } + if (args.lldb_exe) |lldb_exe| { + try argv.append(gpa, @backingInt(Arg.prefix)); + try argv.appendSlice(gpa, "--lldb="); + try argv.append(gpa, 0); + try argv.append(gpa, @backingInt(Arg.input_file)); + try argv.appendSlice(gpa, @ptrCast(&lldb_exe.handle)); + } + if (args.quiet) { try argv.append(gpa, @backingInt(Arg.string)); try argv.appendSlice(gpa, "--quiet"); @@ -1803,10 +2085,10 @@ fn runClient( else => try client.in.discardAll(hdr.bytes_len), .zig_version => { const actual_version = try client.in.take(hdr.bytes_len); - if (!std.mem.eql(u8, zig_version_string, actual_version)) { + if (!std.mem.eql(u8, builtin.zig_version_string, actual_version)) { try stderr.print( "error: zig version mismatch compiler test runner vs compiler: {q} vs {q}\n", - .{ zig_version_string, actual_version }, + .{ builtin.zig_version_string, actual_version }, ); try stderr.flush(); std.process.exit(1); diff --git a/test/tests.zig b/test/tests.zig index 307a061ac885678ee2868821135896409e01e817..89a95c9f32aa2b15bdc11f0f581d3395daebc8e6 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -13,7 +13,6 @@ const link = @import("link.zig"); // Implementations pub const ErrorTracesContext = @import("src/ErrorTrace.zig"); pub const StackTracesContext = @import("src/StackTrace.zig"); -pub const DebuggerContext = @import("src/Debugger.zig"); pub const LlvmIrContext = @import("src/LlvmIr.zig"); pub const LibcContext = @import("src/Libc.zig"); pub const LinkContext = @import("src/Link.zig"); @@ -2207,17 +2206,20 @@ const link_targets = blk: { }; }; -const IncrementalTarget = struct { - target: std.Target.Query, - backend: enum { selfhosted, llvm, cbe }, -}; - -/// These are passed to `incr-check` as `-` strings. +/// These are passed to `src/Runner.zig` as `----` strings. /// /// If only one specific test is failing on a target, instead of entirely disabling the target here, you /// can skip the target for that specific test only by adding a line like this to top of the manifest: /// #skip x86_64-linux-selfhosted -const incremental_targets = &[_]IncrementalTarget{ +const RunnerTarget = struct { + target: std.Target.Query, + cache_mode: enum { whole, incremental }, + backend: enum { selfhosted, llvm, cbe }, + linker: enum { lld, old, new }, + pic: enum { nopic, pic, pie }, +}; + +pub const incremental_matrix: []const RunnerTarget = &.{ // Avoid adding more CBE or LLVM targets without good reason: they're a lot slower than others // to run due to the output (C source code or LLVM IR) being built non-incrementally (by Clang // or LLVM). We just have a couple here to make sure that it works. @@ -2225,49 +2227,71 @@ const incremental_targets = &[_]IncrementalTarget{ .target = .{ .cpu_arch = .x86_64, .os_tag = .linux, + .abi = .musl, }, + .cache_mode = .incremental, .backend = .cbe, + .linker = .old, + .pic = .nopic, }, .{ .target = .{ .cpu_arch = .x86_64, .os_tag = .linux, + .abi = .none, }, + .cache_mode = .incremental, .backend = .llvm, + .linker = .lld, + .pic = .nopic, }, .{ .target = .{ .cpu_arch = .x86_64, .os_tag = .linux, + .abi = .none, }, + .cache_mode = .incremental, .backend = .selfhosted, + .linker = .new, + .pic = .nopic, }, .{ .target = .{ .cpu_arch = .x86_64, .os_tag = .windows, + .abi = .none, }, + .cache_mode = .incremental, .backend = .selfhosted, + .linker = .old, + .pic = .pic, }, .{ .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi, + .abi = .none, }, + .cache_mode = .incremental, .backend = .selfhosted, + .linker = .old, + .pic = .nopic, }, }; -const debugger_matrix: []const DebuggerContext.TestTarget = &.{ +pub const debugger_matrix: []const RunnerTarget = &.{ .{ .target = .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .none, }, - .pic = false, + .cache_mode = .whole, + .backend = .selfhosted, .linker = .old, + .pic = .nopic, }, .{ .target = .{ @@ -2275,8 +2299,10 @@ const debugger_matrix: []const DebuggerContext.TestTarget = &.{ .os_tag = .linux, .abi = .none, }, - .pic = true, + .cache_mode = .whole, + .backend = .selfhosted, .linker = .old, + .pic = .pic, }, .{ .target = .{ @@ -2284,8 +2310,10 @@ const debugger_matrix: []const DebuggerContext.TestTarget = &.{ .os_tag = .linux, .abi = .none, }, - .pic = false, + .cache_mode = .whole, + .backend = .selfhosted, .linker = .new, + .pic = .nopic, }, .{ .target = .{ @@ -2293,8 +2321,32 @@ const debugger_matrix: []const DebuggerContext.TestTarget = &.{ .os_tag = .linux, .abi = .none, }, - .pic = true, + .cache_mode = .whole, + .backend = .selfhosted, .linker = .new, + .pic = .pic, + }, + .{ + .target = .{ + .cpu_arch = .x86_64, + .os_tag = .linux, + .abi = .none, + }, + .cache_mode = .incremental, + .backend = .selfhosted, + .linker = .new, + .pic = .nopic, + }, + .{ + .target = .{ + .cpu_arch = .x86_64, + .os_tag = .linux, + .abi = .none, + }, + .cache_mode = .incremental, + .backend = .selfhosted, + .linker = .new, + .pic = .pic, }, }; @@ -3311,24 +3363,7 @@ pub fn addCases( ); } -pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step { - const step = b.step("test-debugger", "Run the debugger tests"); - if (options.gdb == null and options.lldb == null) { - step.dependOn(&b.addFail("test-debugger requires -Dgdb and/or -Dlldb").step); - return null; - } - - var context: DebuggerContext = .{ - .b = b, - .options = options, - .root_step = step, - .test_matrix = debugger_matrix, - }; - context.addTests(); - return step; -} - -const IncrementalTestOptions = struct { +pub const RunnerOptions = struct { test_filters: []const []const u8, test_target_filters: []const []const u8, skip_non_native: bool, @@ -3340,19 +3375,22 @@ const IncrementalTestOptions = struct { skip_darwin: bool, skip_linux: bool, skip_llvm: bool, + gdb: ?[]const u8, + lldb: ?[]const u8, }; -pub fn addIncrementalTests( +pub fn addRunnerTests( b: *std.Build, runner: *std.Build.Step.Compile, - options: IncrementalTestOptions, -) !*Step { - const tests_step = b.step("test-incremental", "Run the new incremental compilation test cases"); - - const tests_path = b.path("test/incremental"); + tests_step: *Step, + tests: []const u8, + matrix: []const RunnerTarget, + options: RunnerOptions, +) !void { + const tests_path = b.path(tests); b.dependOnDirectoryContents(tests_path); - var tests_dir = try b.root.openDir(b.graph.io, "test/incremental", .{ .iterate = true }); + var tests_dir = try b.root.openDir(b.graph.io, tests, .{ .iterate = true }); defer tests_dir.close(b.graph.io); var test_it = tests_dir.iterate(); while (try test_it.next(b.graph.io)) |@"test"| { @@ -3380,7 +3418,7 @@ pub fn addIncrementalTests( run.addPrefixedDirectoryArg("--lib=", .zig_lib); _ = run.addPrefixedOutputDirectoryArg("--src=", "src"); - for (incremental_targets) |test_target| { + for (matrix) |test_target| { const resolved_target = b.resolveTargetQuery(test_target.target); if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) @@ -3399,9 +3437,12 @@ pub fn addIncrementalTests( if (options.skip_llvm and test_target.backend == .llvm) continue; - const target_str = b.fmt("{s}-incremental-{t}", .{ + const target_str = b.fmt("{s}-{t}-{t}-{t}-{t}", .{ resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"), + test_target.cache_mode, test_target.backend, + test_target.linker, + test_target.pic, }); for (options.test_target_filters) |filter| { @@ -3418,12 +3459,13 @@ pub fn addIncrementalTests( run.addThirdPartyEnabledArgWasmtime(.{ .enabled = "-fwasmtime" }); run.addThirdPartyEnabledArgWine(.{ .enabled = "-fwine" }); + if (options.gdb) |gdb| run.addPrefixedFileArg("--gdb=", b.graph.cwdRelativePath(gdb)); + if (options.lldb) |lldb| run.addPrefixedFileArg("--lldb=", b.graph.cwdRelativePath(lldb)); + run.addArg("--quiet"); // don't fill stderr telling us about skipped tests etc tests_step.dependOn(&run.step); } - - return tests_step; } fn isEditorFileName(name: []const u8) bool { -- 2.54.0