This crate provides a cross platform way of querying information about other processes running
on the system. This let's you build profiling and debugging tools.
Features:
- Getting the process executable name and current working directory
- Listing all the threads in the process
- Suspending the execution of a process or thread
- Returning if a thread is running or not
- Getting a stack trace for a thread in the target process
- Resolve symbols for an address in the other process
- Copy memory from the other process (using the read_process_memory crate)
This crate provides implementations for Linux, OSX and Windows. However this crate is still
very much in alpha stage, and the following caveats apply:
- Stack unwinding only works on x86_64 processors right now, and is disabled for arm/x86
- the OSX stack unwinding code is very unstable and shouldn't be relied on
- Getting the cwd on windows returns incorrect results
#[cfg(feature="unwind")]
fn get_backtrace(pid: remoteprocess::Pid) -> Result<(), remoteprocess::Error> {
let process = remoteprocess::Process::new(pid)?;
let unwinder = process.unwinder()?;
let symbolicator = process.symbolicator()?;
for thread in process.threads()?.iter() {
println!("Thread {} - {}", thread.id()?, if thread.active()? { "running" } else { "idle" });
let _lock = thread.lock()?;
for ip in unwinder.cursor(&thread)? {
let ip = ip?;
symbolicator.symbolicate(ip, true, &mut |sf| {
println!("\t{}", sf);
})?;
}
}
Ok(())
}