Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ nix = { version = "0.26", default-features = false, features = [
"user",
] }
# Used for parsing procfs info.
procfs = "0.15.1"
procfs-core = { git = "https://github.com/eminence/procfs", rev = "591016286d195f523628eccf5cac9c923ae6ea45" }

[target.'cfg(target_os = "windows")'.dependencies]
bitflags = "2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/linux/auxv_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct AuxvPair {
pub value: AuxvType,
}

/// An iterator across auxv pairs froom procfs.
/// An iterator across auxv pairs from procfs.
pub struct ProcfsAuxvIter {
pair_size: usize,
buf: Vec<u8>,
Expand Down
2 changes: 1 addition & 1 deletion src/linux/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub enum SectionMemInfoListError {
#[error("Failed to write to memory")]
MemoryWriterError(#[from] MemoryWriterError),
#[error("Failed to read from procfs")]
ProcfsError(#[from] procfs::ProcError),
ProcfsError(#[from] procfs_core::ProcError),
}

#[derive(Debug, Error)]
Expand Down
7 changes: 4 additions & 3 deletions src/linux/maps_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::thread_info::Pid;
use byteorder::{NativeEndian, ReadBytesExt};
use goblin::elf;
use memmap2::{Mmap, MmapOptions};
use procfs::process::{MMPermissions, MMapPath, MemoryMaps};
use procfs_core::process::{MMPermissions, MMapPath, MemoryMaps};
use std::ffi::{OsStr, OsString};
use std::os::unix::ffi::OsStrExt;
use std::{fs::File, mem::size_of, path::PathBuf};
Expand Down Expand Up @@ -73,7 +73,7 @@ impl MappingInfo {
pub fn aggregate(memory_maps: MemoryMaps, linux_gate_loc: AuxvType) -> Result<Vec<Self>> {
let mut infos = Vec::<Self>::new();

for mm in memory_maps.memory_maps {
for mm in memory_maps {
let start_address: usize = mm.address.0.try_into()?;
let end_address: usize = mm.address.1.try_into()?;
let mut offset: usize = mm.offset.try_into()?;
Expand Down Expand Up @@ -345,10 +345,11 @@ impl MappingInfo {
#[cfg(target_pointer_width = "64")] // All addresses are 64 bit and I'm currently too lazy to adjust it to work for both
mod tests {
use super::*;
use procfs_core::prelude::*;

fn get_mappings_for(map: &str, linux_gate_loc: u64) -> Vec<MappingInfo> {
MappingInfo::aggregate(
MemoryMaps::from_reader(map.as_bytes()).expect("failed to read mapping info"),
MemoryMaps::from_read(map.as_bytes()).expect("failed to read mapping info"),
linux_gate_loc,
)
.unwrap_or_default()
Expand Down
3 changes: 2 additions & 1 deletion src/linux/ptrace_dumper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ impl PtraceDumper {
let maps_path = path::PathBuf::from(&filename);
let maps_file = std::fs::File::open(maps_path).map_err(errmap)?;

self.mappings = procfs::process::MemoryMaps::from_reader(maps_file)
use procfs_core::prelude::*;
self.mappings = procfs_core::process::MemoryMaps::from_read(maps_file)
.ok()
.and_then(|maps| MappingInfo::aggregate(maps, linux_gate_loc).ok())
.unwrap_or_default();
Expand Down
15 changes: 10 additions & 5 deletions src/linux/sections/memory_info_list_stream.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
use super::*;
use minidump_common::format::{MemoryProtection, MemoryState, MemoryType};
use procfs::process::MMPermissions;
use procfs_core::{
prelude::*,
process::{MMPermissions, MemoryMaps},
};

/// Write a MemoryInfoListStream using information from procfs.
pub fn write(
config: &mut MinidumpWriter,
buffer: &mut DumpBuf,
) -> Result<MDRawDirectory, errors::SectionMemInfoListError> {
let process = procfs::process::Process::new(config.blamed_thread)?;
let maps = process.maps()?;
let maps = MemoryMaps::from_file(std::path::PathBuf::from(format!(
"/proc/{}/maps",
config.blamed_thread
)))?;

let list_header = MemoryWriter::alloc_with_val(
buffer,
MDMemoryInfoList {
size_of_header: std::mem::size_of::<MDMemoryInfoList>() as u32,
size_of_entry: std::mem::size_of::<MDMemoryInfo>() as u32,
number_of_entries: maps.memory_maps.len() as u64,
number_of_entries: maps.len() as u64,
},
)?;

Expand All @@ -26,7 +31,7 @@ pub fn write(

let block_list = MemoryArrayWriter::<MDMemoryInfo>::alloc_from_iter(
buffer,
maps.memory_maps.iter().map(|mm| MDMemoryInfo {
maps.iter().map(|mm| MDMemoryInfo {
base_address: mm.address.0,
allocation_base: mm.address.0,
allocation_protection: get_memory_protection(mm.perms).bits(),
Expand Down