| author | |
| committer | |
| log | c9f7b32fbd4ea99da7fdf435b83ce0e582f33c08 |
| tree | 0d777b728b0ae376990048059f99a42fa535a7fe |
| parent | 7f604b6f48905faf0bbe1ad795b53aeb11332063 |
- test `lib/std/std.zig` passes
- stack traces work3 files changed, 33 insertions(+), 9 deletions(-)
lib/std/c/netbsd.zig+29-9| ... | ... | @@ -1061,17 +1061,37 @@ pub const sigset_t = extern struct { |
| 1061 | 1061 | |
| 1062 | 1062 | pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS }; |
| 1063 | 1063 | |
| 1064 | // XXX x86_64 specific | |
| 1065 | pub const mcontext_t = extern struct { | |
| 1066 | gregs: [26]u64, | |
| 1067 | mc_tlsbase: u64, | |
| 1068 | fpregs: [512]u8 align(8), | |
| 1064 | pub const mcontext_t = switch (builtin.cpu.arch) { | |
| 1065 | .aarch64 => extern struct { | |
| 1066 | gregs: [35]u64, | |
| 1067 | fregs: [528]u8 align(16), | |
| 1068 | spare: [8]u64, | |
| 1069 | }, | |
| 1070 | .x86_64 => extern struct { | |
| 1071 | gregs: [26]u64, | |
| 1072 | mc_tlsbase: u64, | |
| 1073 | fpregs: [512]u8 align(8), | |
| 1074 | }, | |
| 1075 | else => struct {}, | |
| 1069 | 1076 | }; |
| 1070 | 1077 | |
| 1071 | pub const REG = struct { | |
| 1072 | pub const RBP = 12; | |
| 1073 | pub const RIP = 21; | |
| 1074 | pub const RSP = 24; | |
| 1078 | pub const REG = switch (builtin.cpu.arch) { | |
| 1079 | .aarch64 => struct { | |
| 1080 | pub const FP = 29; | |
| 1081 | pub const SP = 31; | |
| 1082 | pub const PC = 32; | |
| 1083 | }, | |
| 1084 | .arm => struct { | |
| 1085 | pub const FP = 11; | |
| 1086 | pub const SP = 13; | |
| 1087 | pub const PC = 15; | |
| 1088 | }, | |
| 1089 | .x86_64 => struct { | |
| 1090 | pub const RBP = 12; | |
| 1091 | pub const RIP = 21; | |
| 1092 | pub const RSP = 24; | |
| 1093 | }, | |
| 1094 | else => struct {}, | |
| 1075 | 1095 | }; |
| 1076 | 1096 | |
| 1077 | 1097 | pub const ucontext_t = extern struct { |
lib/std/debug.zig+2| ... | ... | @@ -1985,11 +1985,13 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any |
| 1985 | 1985 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); |
| 1986 | 1986 | const ip = switch (native_os) { |
| 1987 | 1987 | .macos => @intCast(usize, ctx.mcontext.ss.pc), |
| 1988 | .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.PC]), | |
| 1988 | 1989 | else => @intCast(usize, ctx.mcontext.pc), |
| 1989 | 1990 | }; |
| 1990 | 1991 | // x29 is the ABI-designated frame pointer |
| 1991 | 1992 | const bp = switch (native_os) { |
| 1992 | 1993 | .macos => @intCast(usize, ctx.mcontext.ss.fp), |
| 1994 | .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.FP]), | |
| 1993 | 1995 | else => @intCast(usize, ctx.mcontext.regs[29]), |
| 1994 | 1996 | }; |
| 1995 | 1997 | dumpStackTraceFromBase(bp, ip); |
src/crash_report.zig+2| ... | ... | @@ -237,11 +237,13 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any |
| 237 | 237 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); |
| 238 | 238 | const ip = switch (native_os) { |
| 239 | 239 | .macos => @intCast(usize, ctx.mcontext.ss.pc), |
| 240 | .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.PC]), | |
| 240 | 241 | else => @intCast(usize, ctx.mcontext.pc), |
| 241 | 242 | }; |
| 242 | 243 | // x29 is the ABI-designated frame pointer |
| 243 | 244 | const bp = switch (native_os) { |
| 244 | 245 | .macos => @intCast(usize, ctx.mcontext.ss.fp), |
| 246 | .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.FP]), | |
| 245 | 247 | else => @intCast(usize, ctx.mcontext.regs[29]), |
| 246 | 248 | }; |
| 247 | 249 | break :ctx StackContext{ .exception = .{ .bp = bp, .ip = ip } }; |