summaryrefslogtreecommitdiffstats
path: root/vendor/backtrace/src/symbolize/gimli
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/backtrace/src/symbolize/gimli
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/backtrace/src/symbolize/gimli')
-rw-r--r--vendor/backtrace/src/symbolize/gimli/parse_running_mmaps_unix.rs81
1 files changed, 72 insertions, 9 deletions
diff --git a/vendor/backtrace/src/symbolize/gimli/parse_running_mmaps_unix.rs b/vendor/backtrace/src/symbolize/gimli/parse_running_mmaps_unix.rs
index deeeb2971..5d4b34675 100644
--- a/vendor/backtrace/src/symbolize/gimli/parse_running_mmaps_unix.rs
+++ b/vendor/backtrace/src/symbolize/gimli/parse_running_mmaps_unix.rs
@@ -85,16 +85,37 @@ impl FromStr for MapsEntry {
// e.g.: "ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 [vsyscall]"
// e.g.: "7f5985f46000-7f5985f48000 rw-p 00039000 103:06 76021795 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2"
// e.g.: "35b1a21000-35b1a22000 rw-p 00000000 00:00 0"
+ //
+ // Note that paths may contain spaces, so we can't use `str::split` for parsing (until
+ // Split::remainder is stabilized #77998).
fn from_str(s: &str) -> Result<Self, Self::Err> {
- let mut parts = s
- .split(' ') // space-separated fields
- .filter(|s| s.len() > 0); // multiple spaces implies empty strings that need to be skipped.
- let range_str = parts.next().ok_or("Couldn't find address")?;
- let perms_str = parts.next().ok_or("Couldn't find permissions")?;
- let offset_str = parts.next().ok_or("Couldn't find offset")?;
- let dev_str = parts.next().ok_or("Couldn't find dev")?;
- let inode_str = parts.next().ok_or("Couldn't find inode")?;
- let pathname_str = parts.next().unwrap_or(""); // pathname may be omitted.
+ let (range_str, s) = s.trim_start().split_once(' ').unwrap_or((s, ""));
+ if range_str.is_empty() {
+ return Err("Couldn't find address");
+ }
+
+ let (perms_str, s) = s.trim_start().split_once(' ').unwrap_or((s, ""));
+ if perms_str.is_empty() {
+ return Err("Couldn't find permissions");
+ }
+
+ let (offset_str, s) = s.trim_start().split_once(' ').unwrap_or((s, ""));
+ if offset_str.is_empty() {
+ return Err("Couldn't find offset");
+ }
+
+ let (dev_str, s) = s.trim_start().split_once(' ').unwrap_or((s, ""));
+ if dev_str.is_empty() {
+ return Err("Couldn't find dev");
+ }
+
+ let (inode_str, s) = s.trim_start().split_once(' ').unwrap_or((s, ""));
+ if inode_str.is_empty() {
+ return Err("Couldn't find inode");
+ }
+
+ // Pathname may be omitted in which case it will be empty
+ let pathname_str = s.trim_start();
let hex = |s| usize::from_str_radix(s, 16).map_err(|_| "Couldn't parse hex number");
let address = if let Some((start, limit)) = range_str.split_once('-') {
@@ -229,4 +250,46 @@ fn check_maps_entry_parsing_32bit() {
pathname: Default::default(),
}
);
+ assert_eq!(
+ "b7c79000-b7e02000 r--p 00000000 08:01 60662705 \
+ /executable/path/with some spaces"
+ .parse::<MapsEntry>()
+ .unwrap(),
+ MapsEntry {
+ address: (0xb7c79000, 0xb7e02000),
+ perms: ['r', '-', '-', 'p'],
+ offset: 0x00000000,
+ dev: (0x08, 0x01),
+ inode: 0x60662705,
+ pathname: "/executable/path/with some spaces".into(),
+ }
+ );
+ assert_eq!(
+ "b7c79000-b7e02000 r--p 00000000 08:01 60662705 \
+ /executable/path/with multiple-continuous spaces "
+ .parse::<MapsEntry>()
+ .unwrap(),
+ MapsEntry {
+ address: (0xb7c79000, 0xb7e02000),
+ perms: ['r', '-', '-', 'p'],
+ offset: 0x00000000,
+ dev: (0x08, 0x01),
+ inode: 0x60662705,
+ pathname: "/executable/path/with multiple-continuous spaces ".into(),
+ }
+ );
+ assert_eq!(
+ " b7c79000-b7e02000 r--p 00000000 08:01 60662705 \
+ /executable/path/starts-with-spaces"
+ .parse::<MapsEntry>()
+ .unwrap(),
+ MapsEntry {
+ address: (0xb7c79000, 0xb7e02000),
+ perms: ['r', '-', '-', 'p'],
+ offset: 0x00000000,
+ dev: (0x08, 0x01),
+ inode: 0x60662705,
+ pathname: "/executable/path/starts-with-spaces".into(),
+ }
+ );
}