pub struct RegisterState<T: RegisterStorage> {
pub real_registers: T,
pub orig_rax: u64,
}Expand description
The state of the task’s registers when the thread of execution entered the kernel.
This is a thin wrapper around [zx::sys::zx_restricted_state_t].
Implements std::ops::Deref and std::ops::DerefMut as a way to get at the underlying
[zx::sys::zx_restricted_state_t] that this type wraps.
Fields§
§real_registers: T§orig_rax: u64A copy of the x64 rax register at the time of the syscall instruction. This is important
to store, as the return value of a syscall overwrites rax, making it impossible to recover
the original syscall number in the case of syscall restart and strace output.
Implementations§
Source§impl<T: RegisterStorage> RegisterState<T>
impl<T: RegisterStorage> RegisterState<T>
Sourcepub fn save_registers_for_restart(&mut self, syscall_number: u64)
pub fn save_registers_for_restart(&mut self, syscall_number: u64)
Saves any register state required to restart syscall_number.
Sourcepub fn prepare_for_custom_restart(&mut self)
pub fn prepare_for_custom_restart(&mut self)
Custom restart, invoke restart_syscall instead of the original syscall.
Sourcepub fn restore_original_return_register(&mut self)
pub fn restore_original_return_register(&mut self)
Restores rax to match its value before restarting.
Sourcepub fn instruction_pointer_register(&self) -> u64
pub fn instruction_pointer_register(&self) -> u64
Returns the register that indicates the single-machine-word return value from a function call.
Sourcepub fn set_instruction_pointer_register(&mut self, new_ip: u64)
pub fn set_instruction_pointer_register(&mut self, new_ip: u64)
Sets the register that indicates the single-machine-word return value from a function call.
Sourcepub fn rewind_syscall_instruction(&mut self)
pub fn rewind_syscall_instruction(&mut self)
Rewind the the register that indicates the instruction pointer by one syscall instruction.
Sourcepub fn return_register(&self) -> u64
pub fn return_register(&self) -> u64
Returns the register that indicates the single-machine-word return value from a function call.
Sourcepub fn set_return_register(&mut self, return_value: u64)
pub fn set_return_register(&mut self, return_value: u64)
Sets the register that indicates the single-machine-word return value from a function call.
Sourcepub fn stack_pointer_register(&self) -> u64
pub fn stack_pointer_register(&self) -> u64
Gets the register that indicates the current stack pointer.
Sourcepub fn set_stack_pointer_register(&mut self, sp: u64)
pub fn set_stack_pointer_register(&mut self, sp: u64)
Sets the register that indicates the current stack pointer.
Sourcepub fn set_thread_pointer_register(&mut self, tp: u64)
pub fn set_thread_pointer_register(&mut self, tp: u64)
Sets the register that indicates the TLS.
Sourcepub fn set_arg0_register(&mut self, rdi: u64)
pub fn set_arg0_register(&mut self, rdi: u64)
Sets the register that indicates the first argument to a function.
Sourcepub fn set_arg1_register(&mut self, rsi: u64)
pub fn set_arg1_register(&mut self, rsi: u64)
Sets the register that indicates the second argument to a function.
Sourcepub fn set_arg2_register(&mut self, rdx: u64)
pub fn set_arg2_register(&mut self, rdx: u64)
Sets the register that indicates the third argument to a function.
Sourcepub fn syscall_register(&self) -> u64
pub fn syscall_register(&self) -> u64
Returns the register that contains the syscall number.
Sourcepub fn reset_flags(&mut self)
pub fn reset_flags(&mut self)
Resets the register that contains the application status flags.
Sourcepub fn apply_user_register(
&mut self,
offset: usize,
f: &mut dyn FnMut(&mut u64),
) -> Result<(), Errno>
pub fn apply_user_register( &mut self, offset: usize, f: &mut dyn FnMut(&mut u64), ) -> Result<(), Errno>
Executes the given predicate on the register.
pub fn load(&mut self, regs: zx_restricted_state_t)
pub fn sync_stack_ptr(&mut self)
Trait Implementations§
Source§impl<T: Clone + RegisterStorage> Clone for RegisterState<T>
impl<T: Clone + RegisterStorage> Clone for RegisterState<T>
Source§fn clone(&self) -> RegisterState<T>
fn clone(&self) -> RegisterState<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: RegisterStorage> Debug for RegisterState<T>
impl<T: RegisterStorage> Debug for RegisterState<T>
Source§impl<T: Default + RegisterStorage> Default for RegisterState<T>
impl<T: Default + RegisterStorage> Default for RegisterState<T>
Source§fn default() -> RegisterState<T>
fn default() -> RegisterState<T>
Source§impl<T: RegisterStorage> Deref for RegisterState<T>
impl<T: RegisterStorage> Deref for RegisterState<T>
Source§impl<T: RegisterStorage> DerefMut for RegisterState<T>
impl<T: RegisterStorage> DerefMut for RegisterState<T>
Source§impl From<RegisterState<HeapRegs>> for RegisterState<RegisterStorageEnum>
impl From<RegisterState<HeapRegs>> for RegisterState<RegisterStorageEnum>
Source§fn from(regs: RegisterState<HeapRegs>) -> Self
fn from(regs: RegisterState<HeapRegs>) -> Self
Source§impl From<RegisterState<RegisterStorageEnum>> for RegisterState<HeapRegs>
impl From<RegisterState<RegisterStorageEnum>> for RegisterState<HeapRegs>
Source§fn from(regs: RegisterState<RegisterStorageEnum>) -> Self
fn from(regs: RegisterState<RegisterStorageEnum>) -> Self
Source§impl<T: PartialEq + RegisterStorage> PartialEq for RegisterState<T>
impl<T: PartialEq + RegisterStorage> PartialEq for RegisterState<T>
impl<T: Eq + RegisterStorage> Eq for RegisterState<T>
impl<T: RegisterStorage> StructuralPartialEq for RegisterState<T>
Auto Trait Implementations§
impl<T> Freeze for RegisterState<T>where
T: Freeze,
impl<T> RefUnwindSafe for RegisterState<T>where
T: RefUnwindSafe,
impl<T> Send for RegisterState<T>where
T: Send,
impl<T> Sync for RegisterState<T>where
T: Sync,
impl<T> Unpin for RegisterState<T>where
T: Unpin,
impl<T> UnsafeUnpin for RegisterState<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for RegisterState<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more