diff options
| author | kcbanner <kcbanner@gmail.com> | 2023-05-25 13:11:21 -0400 |
|---|---|---|
| committer | kcbanner <kcbanner@gmail.com> | 2023-07-20 22:58:13 -0400 |
| commit | 2f75d20d87fe68eb2695acd37fc2364c06c4c582 (patch) | |
| tree | e002f84e8e47bdc303baab0316cbecef366a614f /lib/std/debug.zig | |
| parent | d74c8acdfbf297587db2c85a85808bcedbb9e219 (diff) | |
| download | zig-2f75d20d87fe68eb2695acd37fc2364c06c4c582.tar.gz zig-2f75d20d87fe68eb2695acd37fc2364c06c4c582.zip | |
debug: use an explicit context type instead of anytype for dumpStackTraceFromBase, update crash_report to use this for exceptions
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 2652ad57a8..a8e8b7bce8 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -133,11 +133,20 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { } } +pub const StackTraceContext = blk: { + if (native_os == .windows) { + break :blk @typeInfo(@TypeOf(os.windows.CONTEXT.getRegs)).Fn.return_type.?; + } else if (@hasDecl(os.system, "ucontext_t")) { + break :blk *const os.ucontext_t; + } else { + break :blk void; + } +}; + /// Tries to print the stack trace starting from the supplied base pointer to stderr, /// unbuffered, and ignores any error returned. -/// `context` is either *const os.ucontext_t on posix, or the result of CONTEXT.getRegs() on Windows. /// TODO multithreaded awareness -pub fn dumpStackTraceFromBase(context: anytype) void { +pub fn dumpStackTraceFromBase(context: StackTraceContext) void { nosuspend { if (comptime builtin.target.isWasm()) { if (native_os == .wasi) { |
