From 5929bcc83568242ff3f4a6173e4deeb500cd440f Mon Sep 17 00:00:00 2001 From: edef Date: Sat, 30 Jul 2022 15:12:11 +0000 Subject: ripple/minitrace: read /proc/$pid/map_files to disambiguate pathnames This differentiates \n in pathnames from \012 in pathnames. Change-Id: I2c86084c9e46f42b43ea7c824be147d97d26a800 --- ripple/minitrace/src/maps_file.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'ripple/minitrace/src/maps_file.rs') diff --git a/ripple/minitrace/src/maps_file.rs b/ripple/minitrace/src/maps_file.rs index 84fc0fb..af35bde 100644 --- a/ripple/minitrace/src/maps_file.rs +++ b/ripple/minitrace/src/maps_file.rs @@ -121,16 +121,16 @@ pub(crate) fn parse_mapping_line(line: &str) -> anyhow::Result { #[derive(Eq, PartialEq)] pub(crate) struct Mapping { - start: u64, - end: u64, - perm_read: bool, - perm_write: bool, - perm_exec: bool, - shared: bool, - offset: u64, - dev: (u32, u32), - inode: u64, - pathname: String, + 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) shared: bool, + pub(crate) offset: u64, + pub(crate) dev: (u32, u32), + pub(crate) inode: u64, + pub(crate) pathname: String, } impl Debug for Mapping { @@ -184,3 +184,9 @@ fn golden_mapping() { }; assert_eq!(mapping(line).unwrap().1, golden); } + +// NOTE: this is a surjective mapping, since backslashes are not escaped +// ie `escape_path("\\012") == escape_path("\n")` +pub(crate) fn escape_path(path: &str) -> String { + path.replace('\n', "\\012") +} -- cgit 1.4.1