diff options
author | edef <edef@unfathomable.blue> | 2022-07-30 16:08:43 +0000 |
---|---|---|
committer | edef <edef@unfathomable.blue> | 2022-07-30 16:08:43 +0000 |
commit | 9465bb5bf1d3b80aabf1b3a26f95aa0b6fcb4529 (patch) | |
tree | c0d933f46fc3ad7f011a6370294c18d4da633924 /ripple | |
parent | 5929bcc83568242ff3f4a6173e4deeb500cd440f (diff) | |
download | unf-legacy-9465bb5bf1d3b80aabf1b3a26f95aa0b6fcb4529.tar.zst |
ripple/minitrace: group contiguous mappings in debug output
Specifically, contiguous linear mappings from the same backing file. Change-Id: I8adc6a3e33df6a2c27cb12218e41cb22b1b4621d
Diffstat (limited to 'ripple')
-rw-r--r-- | ripple/minitrace/src/main.rs | 29 |
1 files changed, 28 insertions, 1 deletions
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 |