From 9465bb5bf1d3b80aabf1b3a26f95aa0b6fcb4529 Mon Sep 17 00:00:00 2001 From: edef Date: Sat, 30 Jul 2022 16:08:43 +0000 Subject: ripple/minitrace: group contiguous mappings in debug output Specifically, contiguous linear mappings from the same backing file. Change-Id: I8adc6a3e33df6a2c27cb12218e41cb22b1b4621d --- ripple/minitrace/src/main.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'ripple/minitrace') diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 9d9a790..847fb24 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -133,6 +133,33 @@ impl Process { Ok(mappings) } + + fn dump_mappings(&self) -> Result<()> { + let mappings = self.read_mappings()?; + let mut mappings = mappings.iter().peekable(); + let mut segments = vec![]; + + while let Some(mut last) = mappings.next() { + let mut segment = vec![]; + segment.push(last); + while let Some(&next) = mappings.peek() { + if last.dev != next.dev || last.inode != next.inode { + // not the same file + break; + } + if last.end != next.start || last.offset + last.end - last.start != next.offset { + // not contiguous + break; + } + last = mappings.next().unwrap(); + segment.push(last); + } + segments.push(segment); + } + + println!("{:#?}", segments); + Ok(()) + } } macro_rules! define_syscalls { @@ -425,7 +452,7 @@ fn main() -> Result<()> { cmd })?; - println!("{:#?}", process.read_mappings()?); + process.dump_mappings()?; let options = ptrace::Options::PTRACE_O_TRACESYSGOOD | ptrace::Options::PTRACE_O_TRACECLONE -- cgit 1.4.1