Enum framehop::FrameAddress
source · 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
impl FrameAddress
sourcepub fn from_instruction_pointer(ip: u64) -> Self
pub fn from_instruction_pointer(ip: u64) -> Self
Create a FrameAddress::InstructionPointer
.
sourcepub fn from_return_address(return_address: u64) -> Option<Self>
pub fn from_return_address(return_address: u64) -> Option<Self>
Create a FrameAddress::ReturnAddress
. This returns None
if the given
address is zero.
sourcepub fn address_for_lookup(self) -> u64
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]
.
sourcepub fn is_return_address(self) -> bool
pub fn is_return_address(self) -> bool
Returns whether this address is a return address.
Trait Implementations§
source§impl Clone for FrameAddress
impl Clone for FrameAddress
source§fn clone(&self) -> FrameAddress
fn clone(&self) -> FrameAddress
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FrameAddress
impl Debug for FrameAddress
source§impl PartialEq for FrameAddress
impl PartialEq for FrameAddress
source§fn eq(&self, other: &FrameAddress) -> bool
fn eq(&self, other: &FrameAddress) -> bool
self
and other
values to be equal, and is used
by ==
.