diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig index bf63acdead65..267ef390fcaf 100644 --- a/lib/std/Build/Cache.zig +++ b/lib/std/Build/Cache.zig @@ -962,6 +962,7 @@ pub const Manifest = struct { gop.key_ptr.* = .{ .prefixed_path = prefixed_path, .max_file_size = max_file_size, + .handle = null, .stat = undefined, .bin_digest = undefined, .contents = null, diff --git a/lib/std/debug.zig b/lib/std/debug.zig index dbf8e110a28d..dfd213c45d61 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -763,12 +763,14 @@ pub const StackIterator = struct { // When SelfInfo and a register context is available, this iterator can unwind // stacks with frames that don't use a frame pointer (ie. -fomit-frame-pointer), // using DWARF and MachO unwind info. - unwind_state: if (have_ucontext) ?struct { + unwind_state: if (have_ucontext) ?UnwindState else void = if (have_ucontext) null else {}, + + const UnwindState = struct { debug_info: *SelfInfo, dwarf_context: SelfInfo.UnwindContext, last_error: ?UnwindError = null, failed: bool = false, - } else void = if (have_ucontext) null else {}, + }; pub fn init(first_address: ?usize, fp: ?usize) StackIterator { if (native_arch.isSPARC()) { @@ -869,19 +871,24 @@ pub const StackIterator = struct { return address; } - fn next_unwind(it: *StackIterator) !usize { - const unwind_state = &it.unwind_state.?; - const module = try unwind_state.debug_info.getModuleForAddress(unwind_state.dwarf_context.pc); + // must not be a member function of StackIterator as it + // creates a dependency loop due to UnwindError + fn next_unwind( + ma: *MemoryAccessor, + debug_info: *SelfInfo, + dwarf_context: *SelfInfo.UnwindContext, + ) !usize { + const module = try debug_info.getModuleForAddress(dwarf_context.pc); switch (native_os) { .macos, .ios, .watchos, .tvos, .visionos => { // __unwind_info is a requirement for unwinding on Darwin. It may fall back to DWARF, but unwinding // via DWARF before attempting to use the compact unwind info will produce incorrect results. if (module.unwind_info) |unwind_info| { if (SelfInfo.unwindFrameMachO( - unwind_state.debug_info.allocator, + debug_info.allocator, module.base_address, - &unwind_state.dwarf_context, - &it.ma, + dwarf_context, + ma, unwind_info, module.eh_frame, )) |return_address| { @@ -894,13 +901,13 @@ pub const StackIterator = struct { else => {}, } - if (try module.getDwarfInfoForAddress(unwind_state.debug_info.allocator, unwind_state.dwarf_context.pc)) |di| { + if (try module.getDwarfInfoForAddress(debug_info.allocator, dwarf_context.pc)) |di| { return SelfInfo.unwindFrameDwarf( - unwind_state.debug_info.allocator, + debug_info.allocator, di, module.base_address, - &unwind_state.dwarf_context, - &it.ma, + dwarf_context, + ma, null, ); } else return error.MissingDebugInfo; @@ -912,7 +919,11 @@ pub const StackIterator = struct { if (!unwind_state.failed) { if (unwind_state.dwarf_context.pc == 0) return null; defer it.fp = unwind_state.dwarf_context.getFp() catch 0; - if (it.next_unwind()) |return_address| { + if (next_unwind( + &it.ma, + it.unwind_state.?.debug_info, + &it.unwind_state.?.dwarf_context, + )) |return_address| { return return_address; } else |err| { unwind_state.last_error = err; diff --git a/lib/std/debug/SelfInfo.zig b/lib/std/debug/SelfInfo.zig index 70f3075de7ab..365233d05341 100644 --- a/lib/std/debug/SelfInfo.zig +++ b/lib/std/debug/SelfInfo.zig @@ -787,11 +787,7 @@ pub const Module = switch (native_os) { pub fn getDwarfInfoForAddress(self: *@This(), allocator: Allocator, address: usize) !?*Dwarf { _ = allocator; _ = address; - - return switch (self.debug_data) { - .dwarf => |*dwarf| dwarf, - else => null, - }; + return &(self.dwarf orelse return null); } }, .linux, .netbsd, .freebsd, .dragonfly, .openbsd, .haiku, .solaris, .illumos => Dwarf.ElfModule, diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index 552ded4d51d3..ee379164cbae 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -2070,7 +2070,7 @@ pub const Const = struct { for (self.limbs[0..self.limbs.len]) |limb| { std.debug.print("{x} ", .{limb}); } - std.debug.print("len={} positive={}\n", .{ self.len, self.positive }); + std.debug.print("len={} positive={}\n", .{ self.limbs.len, self.positive }); } pub fn abs(self: Const) Const { diff --git a/lib/std/os/uefi/protocol/service_binding.zig b/lib/std/os/uefi/protocol/service_binding.zig index 06cc64001e2a..ddbda29ee638 100644 --- a/lib/std/os/uefi/protocol/service_binding.zig +++ b/lib/std/os/uefi/protocol/service_binding.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const uefi = std.uefi; +const uefi = std.os.uefi; const Guid = uefi.Guid; const Handle = uefi.Handle; const Status = uefi.Status; diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 936c19591a88..999b990616ba 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -5739,7 +5739,7 @@ pub fn clock_gettime(clock_id: clockid_t) ClockGetTimeError!timespec { if (native_os == .windows) { @compileError("Windows does not support POSIX; use Windows-specific API or cross-platform std.time API"); } else if (native_os == .wasi and !builtin.link_libc) { - var ts: timestamp_t = undefined; + var ts: wasi.timestamp_t = undefined; switch (system.clock_time_get(clock_id, 1, &ts)) { .SUCCESS => { tp = .{ @@ -5763,7 +5763,7 @@ pub fn clock_gettime(clock_id: clockid_t) ClockGetTimeError!timespec { pub fn clock_getres(clock_id: clockid_t, res: *timespec) ClockGetTimeError!void { if (native_os == .wasi and !builtin.link_libc) { - var ts: timestamp_t = undefined; + var ts: wasi.timestamp_t = undefined; switch (system.clock_res_get(@bitCast(clock_id), &ts)) { .SUCCESS => res.* = .{ .sec = @intCast(ts / std.time.ns_per_s),