Function writeCurrentStackTrace [src]

Prototype

pub fn writeCurrentStackTrace( out_stream: anytype, debug_info: *SelfInfo, tty_config: io.tty.Config, start_addr: ?usize, ) !void

Parameters

debug_info: *SelfInfotty_config: io.tty.Configstart_addr: ?usize

Source

pub fn writeCurrentStackTrace( out_stream: anytype, debug_info: *SelfInfo, tty_config: io.tty.Config, start_addr: ?usize, ) !void { if (native_os == .windows) { var context: ThreadContext = undefined; assert(getContext(&context)); return writeStackTraceWindows(out_stream, debug_info, tty_config, &context, start_addr); } var context: ThreadContext = undefined; const has_context = getContext(&context); var it = (if (has_context) blk: { break :blk StackIterator.initWithContext(start_addr, debug_info, &context) catch null; } else null) orelse StackIterator.init(start_addr, null); defer it.deinit(); while (it.next()) |return_address| { printLastUnwindError(&it, debug_info, out_stream, tty_config); // On arm64 macOS, the address of the last frame is 0x0 rather than 0x1 as on x86_64 macOS, // therefore, we do a check for `return_address == 0` before subtracting 1 from it to avoid // an overflow. We do not need to signal `StackIterator` as it will correctly detect this // condition on the subsequent iteration and return `null` thus terminating the loop. // same behaviour for x86-windows-msvc const address = return_address -| 1; try printSourceAtAddress(debug_info, out_stream, address, tty_config); } else printLastUnwindError(&it, debug_info, out_stream, tty_config); }