update to new std.debug changes

This commit is contained in:
mlugg 2025-09-18 00:03:03 +01:00
parent 3a9c680ad7
commit 0c24b8ec66
No known key found for this signature in database
GPG Key ID: 3F5B7DCCBF4AF02E
5 changed files with 12 additions and 15 deletions

View File

@ -1566,10 +1566,7 @@ test "basics" {
// Register location description
var cpu_context: std.debug.cpu_context.Native = undefined;
std.debug.relocateContext(&cpu_context);
context = Context{
.cpu_context = &cpu_context,
};
context = .{ .cpu_context = &cpu_context };
const reg_bytes = try cpu_context.dwarfRegisterBytes(0);
mem.writeInt(usize, reg_bytes[0..@sizeOf(usize)], 0xee, native_endian);

View File

@ -17,7 +17,7 @@ pub const debug = struct {
/// crash earlier than that.
pub var zig_argv0: []const u8 = "zig";
fn handleSegfaultImpl(addr: ?usize, name: []const u8, opt_ctx: ?std.debug.ThreadContextPtr) noreturn {
fn handleSegfaultImpl(addr: ?usize, name: []const u8, opt_ctx: ?std.debug.CpuContextPtr) noreturn {
@branchHint(.cold);
dumpCrashContext() catch {};
std.debug.defaultHandleSegfault(addr, name, opt_ctx);

View File

@ -512,7 +512,7 @@ pub fn defaultUnwindTables(target: *const std.Target, libunwind: bool, libtsan:
if (target.os.tag.isDarwin()) return .async;
if (libunwind) return .async;
if (libtsan) return .async;
if (std.debug.Dwarf.abi.supportsUnwinding(target)) return .async;
if (std.debug.Dwarf.supportsUnwinding(target)) return .async;
return .none;
}

View File

@ -3,7 +3,7 @@ const builtin = @import("builtin");
const fatal = std.process.fatal;
noinline fn frame3(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTrace {
expected[0] = @returnAddress();
expected[0] = @returnAddress() - 1;
return std.debug.captureCurrentStackTrace(.{
.first_address = @returnAddress(),
.allow_unsafe_unwind = true,
@ -58,12 +58,12 @@ noinline fn frame2(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTr
}
}
expected[1] = @returnAddress();
expected[1] = @returnAddress() - 1;
return frame3(expected, addr_buf);
}
noinline fn frame1(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTrace {
expected[2] = @returnAddress();
expected[2] = @returnAddress() - 1;
// Use a stack frame that is too big to encode in __unwind_info's stack-immediate encoding
// to exercise the stack-indirect encoding path
@ -74,12 +74,12 @@ noinline fn frame1(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTr
}
noinline fn frame0(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTrace {
expected[3] = @returnAddress();
expected[3] = @returnAddress() - 1;
return frame1(expected, addr_buf);
}
pub fn main() void {
if (std.posix.ucontext_t == void and builtin.omit_frame_pointer) {
if (std.debug.cpu_context.Native == noreturn and builtin.omit_frame_pointer) {
// Stack unwinding is impossible.
return;
}

View File

@ -3,7 +3,7 @@
const std = @import("std");
noinline fn frame3(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTrace {
expected[0] = @returnAddress();
expected[0] = @returnAddress() - 1;
return std.debug.captureCurrentStackTrace(.{
.first_address = @returnAddress(),
.allow_unsafe_unwind = true,
@ -11,12 +11,12 @@ noinline fn frame3(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTr
}
noinline fn frame2(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTrace {
expected[1] = @returnAddress();
expected[1] = @returnAddress() - 1;
return frame3(expected, addr_buf);
}
noinline fn frame1(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTrace {
expected[2] = @returnAddress();
expected[2] = @returnAddress() - 1;
// Use a stack frame that is too big to encode in __unwind_info's stack-immediate encoding
// to exercise the stack-indirect encoding path
@ -27,7 +27,7 @@ noinline fn frame1(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTr
}
noinline fn frame0(expected: *[4]usize, addr_buf: *[4]usize) std.builtin.StackTrace {
expected[3] = @returnAddress();
expected[3] = @returnAddress() - 1;
return frame1(expected, addr_buf);
}