Skip to content

Commit 344344b

Browse files
committed
Remove unused fields from /proc/maps parsing code
1 parent b65ab93 commit 344344b

File tree

1 file changed

+1
-57
lines changed

1 file changed

+1
-57
lines changed

src/symbolize/gimli/parse_running_mmaps_unix.rs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,8 @@ use core::str::FromStr;
1313
pub(super) struct MapsEntry {
1414
/// start (inclusive) and limit (exclusive) of address range.
1515
address: (usize, usize),
16-
/// The perms field are the permissions for the entry
17-
///
18-
/// r = read
19-
/// w = write
20-
/// x = execute
21-
/// s = shared
22-
/// p = private (copy on write)
23-
perms: [char; 4],
2416
/// Offset into the file (or "whatever").
2517
offset: u64,
26-
/// device (major, minor)
27-
dev: (usize, usize),
28-
/// inode on the device. 0 indicates that no inode is associated with the memory region (e.g. uninitalized data aka BSS).
29-
inode: usize,
3018
/// Usually the file backing the mapping.
3119
///
3220
/// Note: The man page for proc includes a note about "coordination" by
@@ -132,30 +120,13 @@ impl FromStr for MapsEntry {
132120
} else {
133121
return Err("Couldn't parse address range");
134122
};
135-
let perms: [char; 4] = {
136-
let mut chars = perms_str.chars();
137-
let mut c = || chars.next().ok_or("insufficient perms");
138-
let perms = [c()?, c()?, c()?, c()?];
139-
if chars.next().is_some() {
140-
return Err("too many perms");
141-
}
142-
perms
143-
};
123+
144124
let offset = hex64(offset_str)?;
145-
let dev = if let Some((major, minor)) = dev_str.split_once(':') {
146-
(hex(major)?, hex(minor)?)
147-
} else {
148-
return Err("Couldn't parse dev");
149-
};
150-
let inode = hex(inode_str)?;
151125
let pathname = pathname_str.into();
152126

153127
Ok(MapsEntry {
154128
address,
155-
perms,
156129
offset,
157-
dev,
158-
inode,
159130
pathname,
160131
})
161132
}
@@ -172,10 +143,7 @@ fn check_maps_entry_parsing_64bit() {
172143
.unwrap(),
173144
MapsEntry {
174145
address: (0xffffffffff600000, 0xffffffffff601000),
175-
perms: ['-', '-', 'x', 'p'],
176146
offset: 0x00000000,
177-
dev: (0x00, 0x00),
178-
inode: 0x0,
179147
pathname: "[vsyscall]".into(),
180148
}
181149
);
@@ -187,10 +155,7 @@ fn check_maps_entry_parsing_64bit() {
187155
.unwrap(),
188156
MapsEntry {
189157
address: (0x7f5985f46000, 0x7f5985f48000),
190-
perms: ['r', 'w', '-', 'p'],
191158
offset: 0x00039000,
192-
dev: (0x103, 0x06),
193-
inode: 0x76021795,
194159
pathname: "/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2".into(),
195160
}
196161
);
@@ -200,10 +165,7 @@ fn check_maps_entry_parsing_64bit() {
200165
.unwrap(),
201166
MapsEntry {
202167
address: (0x35b1a21000, 0x35b1a22000),
203-
perms: ['r', 'w', '-', 'p'],
204168
offset: 0x00000000,
205-
dev: (0x00, 0x00),
206-
inode: 0x0,
207169
pathname: Default::default(),
208170
}
209171
);
@@ -224,10 +186,7 @@ fn check_maps_entry_parsing_32bit() {
224186
.unwrap(),
225187
MapsEntry {
226188
address: (0x08056000, 0x08077000),
227-
perms: ['r', 'w', '-', 'p'],
228189
offset: 0x00000000,
229-
dev: (0x00, 0x00),
230-
inode: 0x0,
231190
pathname: "[heap]".into(),
232191
}
233192
);
@@ -239,10 +198,7 @@ fn check_maps_entry_parsing_32bit() {
239198
.unwrap(),
240199
MapsEntry {
241200
address: (0xb7c79000, 0xb7e02000),
242-
perms: ['r', '-', '-', 'p'],
243201
offset: 0x00000000,
244-
dev: (0x08, 0x01),
245-
inode: 0x60662705,
246202
pathname: "/usr/lib/locale/locale-archive".into(),
247203
}
248204
);
@@ -252,10 +208,7 @@ fn check_maps_entry_parsing_32bit() {
252208
.unwrap(),
253209
MapsEntry {
254210
address: (0xb7e02000, 0xb7e03000),
255-
perms: ['r', 'w', '-', 'p'],
256211
offset: 0x00000000,
257-
dev: (0x00, 0x00),
258-
inode: 0x0,
259212
pathname: Default::default(),
260213
}
261214
);
@@ -266,10 +219,7 @@ fn check_maps_entry_parsing_32bit() {
266219
.unwrap(),
267220
MapsEntry {
268221
address: (0xb7c79000, 0xb7e02000),
269-
perms: ['r', '-', '-', 'p'],
270222
offset: 0x00000000,
271-
dev: (0x08, 0x01),
272-
inode: 0x60662705,
273223
pathname: "/executable/path/with some spaces".into(),
274224
}
275225
);
@@ -280,10 +230,7 @@ fn check_maps_entry_parsing_32bit() {
280230
.unwrap(),
281231
MapsEntry {
282232
address: (0xb7c79000, 0xb7e02000),
283-
perms: ['r', '-', '-', 'p'],
284233
offset: 0x00000000,
285-
dev: (0x08, 0x01),
286-
inode: 0x60662705,
287234
pathname: "/executable/path/with multiple-continuous spaces ".into(),
288235
}
289236
);
@@ -294,10 +241,7 @@ fn check_maps_entry_parsing_32bit() {
294241
.unwrap(),
295242
MapsEntry {
296243
address: (0xb7c79000, 0xb7e02000),
297-
perms: ['r', '-', '-', 'p'],
298244
offset: 0x00000000,
299-
dev: (0x08, 0x01),
300-
inode: 0x60662705,
301245
pathname: "/executable/path/starts-with-spaces".into(),
302246
}
303247
);

0 commit comments

Comments
 (0)