summaryrefslogtreecommitdiffstats
path: root/vendor/gimli/examples/simple_line.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:28 +0000
commit94a0819fe3a0d679c3042a77bfe6a2afc505daea (patch)
tree2b827afe6a05f3538db3f7803a88c4587fe85648 /vendor/gimli/examples/simple_line.rs
parentAdding upstream version 1.64.0+dfsg1. (diff)
downloadrustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.tar.xz
rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.zip
Adding upstream version 1.66.0+dfsg1.upstream/1.66.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vendor/gimli/examples/simple_line.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/vendor/gimli/examples/simple_line.rs b/vendor/gimli/examples/simple_line.rs
index bf1114f90..87b224cda 100644
--- a/vendor/gimli/examples/simple_line.rs
+++ b/vendor/gimli/examples/simple_line.rs
@@ -6,7 +6,7 @@ use std::{borrow, env, fs, path};
fn main() {
for path in env::args().skip(1) {
let file = fs::File::open(&path).unwrap();
- let mmap = unsafe { memmap::Mmap::map(&file).unwrap() };
+ let mmap = unsafe { memmap2::Mmap::map(&file).unwrap() };
let object = object::File::parse(&*mmap).unwrap();
let endian = if object.is_little_endian() {
gimli::RunTimeEndian::Little
@@ -68,9 +68,16 @@ fn dump_file(object: &object::File, endian: gimli::RunTimeEndian) -> Result<(),
let mut path = path::PathBuf::new();
if let Some(file) = row.file(header) {
path = comp_dir.clone();
- if let Some(dir) = file.directory(header) {
- path.push(dwarf.attr_string(&unit, dir)?.to_string_lossy().as_ref());
+
+ // The directory index 0 is defined to correspond to the compilation unit directory.
+ if file.directory_index() != 0 {
+ if let Some(dir) = file.directory(header) {
+ path.push(
+ dwarf.attr_string(&unit, dir)?.to_string_lossy().as_ref(),
+ );
+ }
}
+
path.push(
dwarf
.attr_string(&unit, file.path_name())?