Skip to content

Commit

Permalink
Dedupe comp-dir/directory in line-table paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Nov 9, 2021
1 parent fdd7ee4 commit ff6e2a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 9 additions & 2 deletions examples/simple_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?
Expand Down
2 changes: 0 additions & 2 deletions src/read/value.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Definitions for values used in DWARF expressions.

use core::mem;

use crate::constants;
#[cfg(feature = "read")]
use crate::read::{AttributeValue, DebuggingInformationEntry};
Expand Down

0 comments on commit ff6e2a8

Please sign in to comment.