diff options
author | edef <edef@unfathomable.blue> | 2022-07-30 15:12:11 +0000 |
---|---|---|
committer | edef <edef@unfathomable.blue> | 2022-07-30 15:12:11 +0000 |
commit | 5929bcc83568242ff3f4a6173e4deeb500cd440f (patch) | |
tree | cf1158534c7767dfad1b063f9a953254577f9d01 /ripple/minitrace/src/maps_file.rs | |
parent | 264db440596908879070b146837b516722826bf5 (diff) | |
download | unf-legacy-5929bcc83568242ff3f4a6173e4deeb500cd440f.tar.zst |
ripple/minitrace: read /proc/$pid/map_files to disambiguate pathnames
This differentiates \n in pathnames from \012 in pathnames. Change-Id: I2c86084c9e46f42b43ea7c824be147d97d26a800
Diffstat (limited to 'ripple/minitrace/src/maps_file.rs')
-rw-r--r-- | ripple/minitrace/src/maps_file.rs | 26 |
1 files changed, 16 insertions, 10 deletions
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<Mapping> { #[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") +} |