summary refs log tree commit diff
path: root/ripple/minitrace/src
diff options
context:
space:
mode:
Diffstat (limited to 'ripple/minitrace/src')
-rw-r--r--ripple/minitrace/src/main.rs29
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