//! Functionality for reading a remote process's memory use super::{minidump_writer::MinidumpWriter, serializers::*, Pid}; enum Style { /// Uses [`process_vm_readv`](https://linux.die.net/man/2/process_vm_readv) /// to read the memory. /// /// This is not available on old <3.2 (really, ancient) kernels, and requires /// the same permissions as ptrace VirtualMem, /// Reads the memory from `/proc//mem` /// /// Available on basically all versions of Linux, but could fail if the process /// has insufficient privileges, ie ptrace File(std::fs::File), /// Reads the memory with [ptrace (`PTRACE_PEEKDATA`)](https://man7.org/linux/man-pages/man2/ptrace.2.html) /// /// Reads data one word at a time, so slow, but fairly reliable, as long as /// the process can be ptraced Ptrace, /// No methods succeeded, generally there isn't a case where failing a syscall /// will work if called again Unavailable { vmem: nix::Error, file: nix::Error, ptrace: nix::Error, }, } #[derive(Debug, thiserror::Error, serde::Serialize)] #[error("Copy from process {child} failed (source {src}, offset: {offset}, length: {length})")] pub struct CopyFromProcessError { pub child: Pid, pub src: usize, pub offset: usize, pub length: usize, #[serde(serialize_with = "serialize_nix_error")] pub source: nix::Error, } pub struct MemReader { /// The pid of the child to read pid: nix::unistd::Pid, style: Option