]> git.proxmox.com Git - rustc.git/blobdiff - vendor/gimli/examples/simple_line.rs
New upstream version 1.65.0+dfsg1
[rustc.git] / vendor / gimli / examples / simple_line.rs
index bf1114f90406589369caf36285ea1649c8ba4fba..87b224cda3866b65bf2f92894a62c9ce1e177520 100644 (file)
@@ -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())?