From f13d7a25762b4cc0c61fbfed7b2f24f156a158f9 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 21 Mar 2024 16:19:04 +0100 Subject: [PATCH] Send `SIGCONT` unconditionally (#110) * Send SIGCONT unconditionally * Fix clippy 1.77 lints * Add Gabriel to CODEOWNERS * Oops --- .github/CODEOWNERS | 2 +- src/linux/maps_reader.rs | 14 +++----------- src/linux/ptrace_dumper.rs | 8 +------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0baeae36..f4fd57b2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @Jake-Shadle +* @Jake-Shadle @gabrielesvelto diff --git a/src/linux/maps_reader.rs b/src/linux/maps_reader.rs index bfc32123..b5b7fb23 100644 --- a/src/linux/maps_reader.rs +++ b/src/linux/maps_reader.rs @@ -304,11 +304,7 @@ impl MappingInfo { #[inline] fn so_version(&self) -> Option { - let Some(name) = self.name.as_deref() else { - return None; - }; - - SoVersion::parse(name) + SoVersion::parse(self.name.as_deref()?) } pub fn get_mapping_effective_path_name_and_version( @@ -422,16 +418,12 @@ pub struct SoVersion { impl SoVersion { /// Attempts to retrieve the .so version of the elf path via its filename fn parse(so_path: &OsStr) -> Option { - let Some(filename) = std::path::Path::new(so_path).file_name() else { - return None; - }; + let filename = std::path::Path::new(so_path).file_name()?; // Avoid an allocation unless the string contains non-utf8 let filename = filename.to_string_lossy(); - let Some((_, version)) = filename.split_once(".so.") else { - return None; - }; + let (_, version) = filename.split_once(".so.")?; let mut sov = Self { major: 0, diff --git a/src/linux/ptrace_dumper.rs b/src/linux/ptrace_dumper.rs index 9de95a65..0dd0fa27 100644 --- a/src/linux/ptrace_dumper.rs +++ b/src/linux/ptrace_dumper.rs @@ -39,7 +39,6 @@ pub struct Thread { #[derive(Debug)] pub struct PtraceDumper { pub pid: Pid, - process_stopped: bool, threads_suspended: bool, pub threads: Vec, pub auxv: HashMap, @@ -99,7 +98,6 @@ impl PtraceDumper { pub fn new(pid: Pid, stop_timeout: Duration) -> Result { let mut dumper = PtraceDumper { pid, - process_stopped: false, threads_suspended: false, threads: Vec::new(), auxv: HashMap::new(), @@ -255,7 +253,6 @@ impl PtraceDumper { loop { if let Ok(ProcState::Stopped) = Stat::from_file(&proc_file)?.state() { - self.process_stopped = true; return Ok(()); } @@ -270,10 +267,7 @@ impl PtraceDumper { /// /// Unlike `stop_process`, this function does not wait for the process to continue. fn continue_process(&mut self) -> Result<(), ContinueProcessError> { - if self.process_stopped { - signal::kill(nix::unistd::Pid::from_raw(self.pid), Some(signal::SIGCONT))?; - } - self.process_stopped = false; + signal::kill(nix::unistd::Pid::from_raw(self.pid), Some(signal::SIGCONT))?; Ok(()) }