This type abstracts the target-specific implementation of accessing this process' own debug information behind a generic interface which supports looking up source locations associated with addresses, as well as unwinding the stack where a safe mechanism to do so exists.
The Zig Standard Library provides default implementations of SelfInfo for common targets, but
the implementation can be overriden by exposing root.debug.SelfInfo. Setting SelfInfo to
void indicates that the SelfInfo API is not supported.
This type must expose the following declarations:
pub const init: SelfInfo;
pub fn deinit(si: *SelfInfo, io: Io) void;
/// Appends the symbols for the instruction at `address` to `symbols`.
pub fn getSymbols(si: *SelfInfo, io: Io, symbol_allocator: Allocator, text_arena: Allocator, address: usize, include_inline_callers: bool, symbols: *std.ArrayList(Symbol)) SelfInfoError!void;
/// Returns a name for the "module" (e.g. shared library or executable image) containing `address`.
pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) SelfInfoError![]const u8;
pub fn getModuleSlide(si: *SelfInfo, io: Io, address: usize) SelfInfoError!usize;
/// Whether a reliable stack unwinding strategy, such as DWARF unwinding, is available.
pub const can_unwind: bool;
/// Only required if `can_unwind == true`.
pub const UnwindContext = struct {
/// An address representing the instruction pointer in the last frame.
pc: usize,
pub fn init(ctx: *cpu_context.Native) Allocator.Error!UnwindContext;
pub fn deinit(ctx: *UnwindContext) void;
/// Returns the frame pointer associated with the last unwound stack frame.
/// If the frame pointer is unknown, 0 may be returned instead.
pub fn getFp(uc: *UnwindContext) usize;
};
/// Only required if `can_unwind == true`. Unwinds a single stack frame, returning the frame's
/// return address, or 0 if the end of the stack has been reached.
pub fn unwindFrame(si: *SelfInfo, io: Io, context: *UnwindContext) SelfInfoError!usize;
pub const SelfInfo = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "SelfInfo"))
root.debug.SelfInfo
else
TargetInfo(native_os, native_arch)
pub const SelfInfo = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "SelfInfo"))
root.debug.SelfInfo
else
TargetInfo(native_os, native_arch)