summary refs log tree commit diff
path: root/ripple/minitrace/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ripple/minitrace/src/main.rs')
-rw-r--r--ripple/minitrace/src/main.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs
index cf23034..0f9cb0d 100644
--- a/ripple/minitrace/src/main.rs
+++ b/ripple/minitrace/src/main.rs
@@ -27,6 +27,8 @@ use {
 	},
 };
 
+mod maps_file;
+
 // TODO(edef): consider implementing this in terms of TID?
 // tgids are a strict subset of tids
 #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -92,6 +94,19 @@ impl Process {
 
 		Ok(CString::from_vec_with_nul(buf).expect("logic error"))
 	}
+
+	fn read_mappings(&self) -> Result<Vec<maps_file::Mapping>> {
+		let contents = std::fs::read_to_string(format!("/proc/{}/maps", self.tgid.0))?;
+
+		// TODO(edef): consult /proc/$pid/map_files/* for pathnames, since /proc/$pid/maps is unreliable with odd paths
+		// we'll want to verify the two against each other, just to be sure they're congruent
+
+		let mappings = contents
+			.lines()
+			.map(maps_file::parse_mapping_line)
+			.collect::<Result<_, _>>()?;
+		Ok(mappings)
+	}
 }
 
 macro_rules! define_syscalls {
@@ -384,6 +399,8 @@ fn main() -> Result<()> {
 		cmd
 	})?;
 
+	println!("{:#?}", process.read_mappings()?);
+
 	let options = ptrace::Options::PTRACE_O_TRACESYSGOOD
 		| ptrace::Options::PTRACE_O_TRACECLONE
 		| ptrace::Options::PTRACE_O_EXITKILL;