structstd.debug.SelfInfo.UnwindContext[src]

Fields

allocator: Allocator
cfa: ?usize
pc: usize
thread_context: *std.debug.ThreadContext
reg_context: Dwarf.abi.RegisterContext
vm: VirtualMachine
stack_machine: Dwarf.expression.StackMachine(.{ .call_frame_context = true })

Functions

Functioninit[src]

pub fn init( allocator: Allocator, thread_context: *std.debug.ThreadContext, ) !UnwindContext

Parameters

allocator: Allocator
thread_context: *std.debug.ThreadContext

Source Code

Source code
pub fn init(
    allocator: Allocator,
    thread_context: *std.debug.ThreadContext,
) !UnwindContext {
    comptime assert(supports_unwinding);

    const pc = stripInstructionPtrAuthCode(
        (try regValueNative(thread_context, ip_reg_num, null)).*,
    );

    const context_copy = try allocator.create(std.debug.ThreadContext);
    std.debug.copyContext(thread_context, context_copy);

    return .{
        .allocator = allocator,
        .cfa = null,
        .pc = pc,
        .thread_context = context_copy,
        .reg_context = undefined,
        .vm = .{},
        .stack_machine = .{},
    };
}

Functiondeinit[src]

pub fn deinit(self: *UnwindContext) void

Parameters

Source Code

Source code
pub fn deinit(self: *UnwindContext) void {
    self.vm.deinit(self.allocator);
    self.stack_machine.deinit(self.allocator);
    self.allocator.destroy(self.thread_context);
    self.* = undefined;
}

FunctiongetFp[src]

pub fn getFp(self: *const UnwindContext) !usize

Parameters

self: *const UnwindContext

Source Code

Source code
pub fn getFp(self: *const UnwindContext) !usize {
    return (try regValueNative(self.thread_context, fpRegNum(self.reg_context), self.reg_context)).*;
}

Source Code

Source code
pub const UnwindContext = struct {
    allocator: Allocator,
    cfa: ?usize,
    pc: usize,
    thread_context: *std.debug.ThreadContext,
    reg_context: Dwarf.abi.RegisterContext,
    vm: VirtualMachine,
    stack_machine: Dwarf.expression.StackMachine(.{ .call_frame_context = true }),

    pub fn init(
        allocator: Allocator,
        thread_context: *std.debug.ThreadContext,
    ) !UnwindContext {
        comptime assert(supports_unwinding);

        const pc = stripInstructionPtrAuthCode(
            (try regValueNative(thread_context, ip_reg_num, null)).*,
        );

        const context_copy = try allocator.create(std.debug.ThreadContext);
        std.debug.copyContext(thread_context, context_copy);

        return .{
            .allocator = allocator,
            .cfa = null,
            .pc = pc,
            .thread_context = context_copy,
            .reg_context = undefined,
            .vm = .{},
            .stack_machine = .{},
        };
    }

    pub fn deinit(self: *UnwindContext) void {
        self.vm.deinit(self.allocator);
        self.stack_machine.deinit(self.allocator);
        self.allocator.destroy(self.thread_context);
        self.* = undefined;
    }

    pub fn getFp(self: *const UnwindContext) !usize {
        return (try regValueNative(self.thread_context, fpRegNum(self.reg_context), self.reg_context)).*;
    }
}