pub enum FrameAddress {
    InstructionPointer(u64),
    ReturnAddress(NonZeroU64),
}
Expand description

An absolute code address for a stack frame. Can either be taken directly from the instruction pointer (“program counter”), or from a return address.

These addresses are “AVMAs”, i.e. Actual Virtual Memory Addresses, i.e. addresses in the virtual memory of the profiled process.

Variants§

§

InstructionPointer(u64)

This address is the instruction pointer / program counter. This is what unwinding starts with.

§

ReturnAddress(NonZeroU64)

This is a return address, i.e. the address to which the CPU will jump to when returning from a function. This is the address of the instruction after the call instruction.

Unwinding produces a list of return addresses.

Implementations§

source§

impl FrameAddress

source

pub fn from_instruction_pointer(ip: u64) -> Self

source

pub fn from_return_address(return_address: u64) -> Option<Self>

Create a FrameAddress::ReturnAddress. This returns None if the given address is zero.

source

pub fn address(self) -> u64

The raw address (AVMA).

source

pub fn address_for_lookup(self) -> u64

The address (AVMA) that should be used for lookup.

If this address is taken directly from the instruction pointer, then the lookup address is just the raw address.

If this address is a return address, then the lookup address is that address minus one byte. This adjusted address will point inside the call instruction. This subtraction of one byte is needed if you want to look up unwind information or debug information, because you usually want the information for the call, not for the next instruction after the call.

Furthermore, this distinction matters if a function calls a noreturn function as the last thing it does: If the call is the final instruction of the function, then the return address will point after the function, into the next function. If, during unwinding, you look up unwind information for that next function, you’d get incorrect unwinding. This has been observed in practice with +[NSThread exit].

source

pub fn is_return_address(self) -> bool

Returns whether this address is a return address.

Trait Implementations§

source§

impl Clone for FrameAddress

source§

fn clone(&self) -> FrameAddress

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FrameAddress

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for FrameAddress

source§

fn eq(&self, other: &FrameAddress) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for FrameAddress

source§

impl Eq for FrameAddress

source§

impl StructuralEq for FrameAddress

source§

impl StructuralPartialEq for FrameAddress

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.