shadow_rs::host::thread

Struct Thread

source
pub struct Thread { /* private fields */ }
Expand description

A virtual Thread in Shadow. Currently a thin wrapper around the C Thread, which this object owns, and frees on Drop.

Implementations§

source§

impl Thread

source

pub fn mthread(&self) -> impl Deref<Target = ManagedThread> + '_

Minimal wrapper around the native managed thread.

source

pub fn update_for_exec( &mut self, host: &Host, mthread: ManagedThread, new_tid: ThreadId, )

Update this thread to be the new thread group leader as part of an execve or execveat syscall. Replaces the managed thread with mthread and updates the thread ID.

source

pub fn process_id(&self) -> ProcessId

source

pub fn host_id(&self) -> HostId

source

pub fn native_pid(&self) -> Pid

source

pub fn native_tid(&self) -> Pid

source

pub fn id(&self) -> ThreadId

source

pub fn is_leader(&self) -> bool

Returns whether the given thread is its thread group (aka process) leader. Typically this is true for the first thread created in a process.

source

pub fn syscall_condition(&self) -> Option<SyscallConditionRef<'_>>

source

pub fn syscall_condition_mut(&self) -> Option<SyscallConditionRefMut<'_>>

source

pub fn cleanup_syscall_condition(&self)

source

pub fn descriptor_table(&self) -> &RootedRc<RootedRefCell<DescriptorTable>>

source

pub fn descriptor_table_borrow<'a>( &'a self, host: &'a Host, ) -> impl Deref<Target = DescriptorTable> + 'a

source

pub fn descriptor_table_borrow_mut<'a>( &'a self, host: &'a Host, ) -> impl DerefMut<Target = DescriptorTable> + 'a

source

pub fn native_munmap( &self, ctx: &ProcessContext<'_>, ptr: ForeignPtr<u8>, size: usize, ) -> Result<(), Errno>

Natively execute munmap(2) on the given thread.

source

pub fn native_mmap( &self, ctx: &ProcessContext<'_>, addr: ForeignPtr<u8>, len: usize, prot: ProtFlags, flags: MapFlags, fd: i32, offset: i64, ) -> Result<ForeignPtr<u8>, Errno>

Natively execute mmap(2) on the given thread.

source

pub fn native_mremap( &self, ctx: &ProcessContext<'_>, old_addr: ForeignPtr<u8>, old_len: usize, new_len: usize, flags: i32, new_addr: ForeignPtr<u8>, ) -> Result<ForeignPtr<u8>, Errno>

Natively execute mremap(2) on the given thread.

source

pub fn native_mprotect( &self, ctx: &ProcessContext<'_>, addr: ForeignPtr<u8>, len: usize, prot: ProtFlags, ) -> Result<(), Errno>

Natively execute mmap(2) on the given thread.

source

pub fn native_open( &self, ctx: &ProcessContext<'_>, pathname: ForeignPtr<u8>, flags: i32, mode: i32, ) -> Result<i32, Errno>

Natively execute open(2) on the given thread.

source

pub fn native_close( &self, ctx: &ProcessContext<'_>, fd: i32, ) -> Result<(), Errno>

Natively execute close(2) on the given thread.

source

pub fn native_brk( &self, ctx: &ProcessContext<'_>, addr: ForeignPtr<u8>, ) -> Result<ForeignPtr<u8>, Errno>

Natively execute brk(2) on the given thread.

source

pub fn native_chdir( &self, ctx: &ProcessContext<'_>, pathname: ForeignPtr<c_char>, ) -> Result<i32, Errno>

Natively execute a chdir(2) syscall on the given thread.

source

pub fn malloc_foreign_ptr( &self, ctx: &ProcessContext<'_>, size: usize, ) -> Result<ForeignPtr<u8>, Errno>

Allocates some space in the plugin’s memory. Use get_writeable_ptr to write to it, and flush to ensure that the write is flushed to the plugin’s memory.

source

pub fn free_foreign_ptr( &self, ctx: &ProcessContext<'_>, ptr: ForeignPtr<u8>, size: usize, ) -> Result<(), Errno>

Frees a pointer previously returned by malloc_foreign_ptr

source

pub fn wrap_mthread( host: &Host, mthread: ManagedThread, desc_table: RootedRc<RootedRefCell<DescriptorTable>>, pid: ProcessId, tid: ThreadId, ) -> Result<Thread, Errno>

Create a new Thread, wrapping mthread. Intended for use by syscall handlers such as clone.

source

pub fn shmem(&self) -> &ShMemBlock<'_, ThreadShmem>

Shared memory for this thread.

source

pub fn resume(&self, ctx: &ProcessContext<'_>) -> ResumeResult

source

pub fn handle_process_exit(&self)

source

pub fn return_code(&self) -> Option<i32>

source

pub fn is_running(&self) -> bool

source

pub fn get_tid_address(&self) -> ForeignPtr<pid_t>

source

pub fn set_tid_address(&self, ptr: ForeignPtr<pid_t>)

Sets the clear_child_tid attribute as for set_tid_address(2). The thread will perform a futex-wake operation on the given address on termination.

source

pub fn unblocked_signal_pending( &self, process: &Process, host_shmem: &HostShmemProtected, ) -> bool

Trait Implementations§

source§

impl Drop for Thread

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl ExplicitDrop for Thread

source§

impl IsSend for Thread

Auto Trait Implementations§

§

impl !Freeze for Thread

§

impl !RefUnwindSafe for Thread

§

impl Send for Thread

§

impl !Sync for Thread

§

impl Unpin for Thread

§

impl !UnwindSafe for Thread

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> NoTypeInference for T

source§

type This = T

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

source§

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>,

source§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V