summary refs log tree commit diff
path: root/ripple/minitrace/src/maps_file.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ripple/minitrace/src/maps_file.rs')
-rw-r--r--ripple/minitrace/src/maps_file.rs40
1 files changed, 25 insertions, 15 deletions
diff --git a/ripple/minitrace/src/maps_file.rs b/ripple/minitrace/src/maps_file.rs
index 7a48147..86e118a 100644
--- a/ripple/minitrace/src/maps_file.rs
+++ b/ripple/minitrace/src/maps_file.rs
@@ -2,7 +2,7 @@
 // SPDX-License-Identifier: OSL-3.0
 
 use {
-	crate::syscall_abi::Device,
+	crate::syscall_abi::{Device, ProtFlags},
 	anyhow::bail,
 	nom::{
 		branch::alt,
@@ -107,14 +107,26 @@ fn mapping(input: &str) -> IResult<&str, Mapping> {
 		_ => unreachable!(),
 	};
 
+	let mut prot = ProtFlags::empty();
+
+	if perm_read {
+		prot |= ProtFlags::READ;
+	}
+
+	if perm_write {
+		prot |= ProtFlags::WRITE;
+	}
+
+	if perm_exec {
+		prot |= ProtFlags::EXEC;
+	}
+
 	Ok((
 		input,
 		Mapping {
 			start,
 			end,
-			perm_read,
-			perm_write,
-			perm_exec,
+			prot,
 			shared,
 			offset,
 			inode,
@@ -135,9 +147,7 @@ pub(crate) fn parse_mapping_line(line: &str) -> anyhow::Result<Mapping> {
 pub(crate) struct Mapping {
 	pub(crate) start: u64,
 	pub(crate) end: u64,
-	pub(crate) perm_read: bool,
-	pub(crate) perm_write: bool,
-	pub(crate) perm_exec: bool,
+	pub(crate) prot: ProtFlags,
 	pub(crate) shared: bool,
 	pub(crate) offset: u64,
 	pub(crate) inode: Option<Inode>,
@@ -157,9 +167,7 @@ impl Debug for Mapping {
 		let Mapping {
 			start,
 			end,
-			perm_read,
-			perm_write,
-			perm_exec,
+			prot,
 			shared,
 			offset,
 			inode,
@@ -172,8 +180,12 @@ impl Debug for Mapping {
 
 		write!(f, "{start:016x}-{end:016x} ")?;
 
-		for (c, p) in [('r', perm_read), ('w', perm_write), ('x', perm_exec)] {
-			f.write_char(if p { c } else { '-' })?;
+		for (c, p) in [
+			('r', ProtFlags::READ),
+			('w', ProtFlags::WRITE),
+			('x', ProtFlags::EXEC),
+		] {
+			f.write_char(if prot.contains(p) { c } else { '-' })?;
 		}
 		f.write_char(if shared { 's' } else { 'p' })?;
 		f.write_char(' ')?;
@@ -193,9 +205,7 @@ fn golden_mapping() {
 	let golden = Mapping {
 		start: 0x00400000,
 		end: 0x00407000,
-		perm_read: true,
-		perm_write: false,
-		perm_exec: false,
+		prot: ProtFlags::READ,
 		shared: false,
 		offset: 0,
 		inode: Some(Inode {