Struct minidump_writer::task_dumper::TaskDumper
source · pub struct TaskDumper { /* private fields */ }
Expand description
Similarly to PtraceDumper for Linux, this provides access to information for a task (MacOS process)
Implementations§
source§impl TaskDumper
impl TaskDumper
sourcepub fn new(task: task_t) -> Self
pub fn new(task: task_t) -> Self
Constructs a TaskDumper
for the specified task
sourcepub fn read_task_memory<T>(
&self,
address: u64,
count: usize
) -> Result<Vec<T>, TaskDumpError>
pub fn read_task_memory<T>( &self, address: u64, count: usize ) -> Result<Vec<T>, TaskDumpError>
Reads a block of memory from the task
§Errors
The syscall to read the task’s memory fails for some reason, eg bad address.
sourcepub fn read_string(
&self,
addr: u64,
expected_size: Option<usize>
) -> Result<Option<String>, TaskDumpError>
pub fn read_string( &self, addr: u64, expected_size: Option<usize> ) -> Result<Option<String>, TaskDumpError>
Reads a null terminated string starting at the specified address. This
is a specialization of [read_task_memory
] since strings can span VM
regions.
If not specified, the string is capped at 8k which should never be close to being hit in normal scenarios, at least for “system” strings, which is all this interface is used to retrieve
§Errors
Fails if the address cannot be read for some reason, or the string is not utf-8.
sourcepub fn get_vm_region(&self, addr: u64) -> Result<VMRegionInfo, TaskDumpError>
pub fn get_vm_region(&self, addr: u64) -> Result<VMRegionInfo, TaskDumpError>
Retrives information on the virtual memory region the specified address is located within.
§Errors
The syscall to retrieve the VM region information fails for some reason, eg. a bad address.
sourcepub fn read_thread_state(&self, tid: u32) -> Result<ThreadState, TaskDumpError>
pub fn read_thread_state(&self, tid: u32) -> Result<ThreadState, TaskDumpError>
Retrieves the state of the specified thread. The state is an architecture specific block of CPU context ie register state.
§Errors
The specified thread id is invalid, or the thread is in a task that is compiled for a different architecture than this local task.
sourcepub fn task_info<T: TaskInfo>(&self) -> Result<T, TaskDumpError>
pub fn task_info<T: TaskInfo>(&self) -> Result<T, TaskDumpError>
Reads the specified task information.
§Errors
The syscall to receive the task information failed for some reason, eg. the specified type and the flavor are mismatched and considered invalid.
sourcepub fn thread_info<T: ThreadInfo>(&self, tid: u32) -> Result<T, TaskDumpError>
pub fn thread_info<T: ThreadInfo>(&self, tid: u32) -> Result<T, TaskDumpError>
Reads the specified task information.
§Errors
The syscall to receive the task information failed for some reason, eg. the specified type and the flavor are mismatched and considered invalid, or the thread no longer exists
sourcepub fn read_images(
&self
) -> Result<(AllImagesInfo, Vec<ImageInfo>), TaskDumpError>
pub fn read_images( &self ) -> Result<(AllImagesInfo, Vec<ImageInfo>), TaskDumpError>
Retrieves all of the images loaded in the task.
Note that there may be multiple images with the same load address.
§Errors
The syscall to retrieve the location of the loaded images fails, or the syscall to read the loaded images from the process memory fails
sourcepub fn read_executable_image(&self) -> Result<ImageInfo, TaskDumpError>
pub fn read_executable_image(&self) -> Result<ImageInfo, TaskDumpError>
Retrieves the main executable image for the task.
Note that this method is currently only used for tests due to deficiencies
in otool
§Errors
Any of the errors that apply to Self::read_images
apply here, in
addition to not being able to find the main executable image
sourcepub fn read_load_commands(
&self,
img: &ImageInfo
) -> Result<LoadCommands, TaskDumpError>
pub fn read_load_commands( &self, img: &ImageInfo ) -> Result<LoadCommands, TaskDumpError>
Retrieves the load commands for the specified image
§Errors
We fail to read the image header for the specified image, the header we read is determined to be invalid, or we fail to read the block of memory containing the load commands themselves.
sourcepub fn read_threads(&self) -> Result<&'static [u32], TaskDumpError>
pub fn read_threads(&self) -> Result<&'static [u32], TaskDumpError>
Gets a list of all of the thread ids in the task
§Errors
The syscall to retrieve the list of threads fails
sourcepub fn pid_for_task(&self) -> Result<i32, TaskDumpError>
pub fn pid_for_task(&self) -> Result<i32, TaskDumpError>
Retrieves the PID for the task
§Errors
Presumably the only way this would fail would be if the task we are dumping disappears.