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
impl Thread
sourcepub fn mthread(&self) -> impl Deref<Target = ManagedThread> + '_
pub fn mthread(&self) -> impl Deref<Target = ManagedThread> + '_
Minimal wrapper around the native managed thread.
sourcepub fn update_for_exec(
&mut self,
host: &Host,
mthread: ManagedThread,
new_tid: ThreadId,
)
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.
pub fn process_id(&self) -> ProcessId
pub fn host_id(&self) -> HostId
pub fn native_pid(&self) -> Pid
pub fn native_tid(&self) -> Pid
pub fn id(&self) -> ThreadId
sourcepub fn is_leader(&self) -> bool
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.
pub fn syscall_condition(&self) -> Option<SyscallConditionRef<'_>>
pub fn syscall_condition_mut(&self) -> Option<SyscallConditionRefMut<'_>>
pub fn cleanup_syscall_condition(&self)
pub fn descriptor_table(&self) -> &RootedRc<RootedRefCell<DescriptorTable>>
pub fn descriptor_table_borrow<'a>( &'a self, host: &'a Host, ) -> impl Deref<Target = DescriptorTable> + 'a
pub fn descriptor_table_borrow_mut<'a>( &'a self, host: &'a Host, ) -> impl DerefMut<Target = DescriptorTable> + 'a
sourcepub fn native_munmap(
&self,
ctx: &ProcessContext<'_>,
ptr: ForeignPtr<u8>,
size: usize,
) -> Result<(), Errno>
pub fn native_munmap( &self, ctx: &ProcessContext<'_>, ptr: ForeignPtr<u8>, size: usize, ) -> Result<(), Errno>
Natively execute munmap(2) on the given thread.
sourcepub fn native_mmap(
&self,
ctx: &ProcessContext<'_>,
addr: ForeignPtr<u8>,
len: usize,
prot: ProtFlags,
flags: MapFlags,
fd: i32,
offset: i64,
) -> Result<ForeignPtr<u8>, Errno>
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.
sourcepub 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>
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.
sourcepub fn native_mprotect(
&self,
ctx: &ProcessContext<'_>,
addr: ForeignPtr<u8>,
len: usize,
prot: ProtFlags,
) -> Result<(), Errno>
pub fn native_mprotect( &self, ctx: &ProcessContext<'_>, addr: ForeignPtr<u8>, len: usize, prot: ProtFlags, ) -> Result<(), Errno>
Natively execute mmap(2) on the given thread.
sourcepub fn native_open(
&self,
ctx: &ProcessContext<'_>,
pathname: ForeignPtr<u8>,
flags: i32,
mode: i32,
) -> Result<i32, Errno>
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.
sourcepub fn native_close(
&self,
ctx: &ProcessContext<'_>,
fd: i32,
) -> Result<(), Errno>
pub fn native_close( &self, ctx: &ProcessContext<'_>, fd: i32, ) -> Result<(), Errno>
Natively execute close(2) on the given thread.
sourcepub fn native_brk(
&self,
ctx: &ProcessContext<'_>,
addr: ForeignPtr<u8>,
) -> Result<ForeignPtr<u8>, Errno>
pub fn native_brk( &self, ctx: &ProcessContext<'_>, addr: ForeignPtr<u8>, ) -> Result<ForeignPtr<u8>, Errno>
Natively execute brk(2) on the given thread.
sourcepub fn native_chdir(
&self,
ctx: &ProcessContext<'_>,
pathname: ForeignPtr<c_char>,
) -> Result<i32, Errno>
pub fn native_chdir( &self, ctx: &ProcessContext<'_>, pathname: ForeignPtr<c_char>, ) -> Result<i32, Errno>
Natively execute a chdir(2) syscall on the given thread.
sourcepub fn malloc_foreign_ptr(
&self,
ctx: &ProcessContext<'_>,
size: usize,
) -> Result<ForeignPtr<u8>, Errno>
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.
sourcepub fn free_foreign_ptr(
&self,
ctx: &ProcessContext<'_>,
ptr: ForeignPtr<u8>,
size: usize,
) -> Result<(), Errno>
pub fn free_foreign_ptr( &self, ctx: &ProcessContext<'_>, ptr: ForeignPtr<u8>, size: usize, ) -> Result<(), Errno>
Frees a pointer previously returned by malloc_foreign_ptr
sourcepub fn wrap_mthread(
host: &Host,
mthread: ManagedThread,
desc_table: RootedRc<RootedRefCell<DescriptorTable>>,
pid: ProcessId,
tid: ThreadId,
) -> Result<Thread, Errno>
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
.
sourcepub fn shmem(&self) -> &ShMemBlock<'_, ThreadShmem>
pub fn shmem(&self) -> &ShMemBlock<'_, ThreadShmem>
Shared memory for this thread.
pub fn resume(&self, ctx: &ProcessContext<'_>) -> ResumeResult
pub fn handle_process_exit(&self)
pub fn return_code(&self) -> Option<i32>
pub fn is_running(&self) -> bool
pub fn get_tid_address(&self) -> ForeignPtr<pid_t>
sourcepub fn set_tid_address(&self, ptr: ForeignPtr<pid_t>)
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.
pub fn unblocked_signal_pending( &self, process: &Process, host_shmem: &HostShmemProtected, ) -> bool
Trait Implementations§
source§impl ExplicitDrop for Thread
impl ExplicitDrop for Thread
type ExplicitDropParam = Host
type ExplicitDropResult = ()
fn explicit_drop(self, host: &Host)
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> 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> 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