From 79f054f77f2edf84ff9b46b1e0ad57a423e6727b Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Tue, 7 Jul 2020 18:20:32 +0200 Subject: [PATCH] Correct the files' directory index when downgrading DWARF5 -> 4 (#1989) * correct the files' directory index when downgrading DWARF5 -> 4 --- crates/debug/src/transform/line_program.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/debug/src/transform/line_program.rs b/crates/debug/src/transform/line_program.rs index b34df1d4b9..0de0a39d83 100644 --- a/crates/debug/src/transform/line_program.rs +++ b/crates/debug/src/transform/line_program.rs @@ -121,8 +121,11 @@ where dirs.push(dir_id); } let mut files = Vec::new(); + // Since we are outputting DWARF-4, perform base change. + let directory_index_correction = if header.version() >= 5 { 1 } else { 0 }; for file_entry in header.file_names() { - let dir_id = dirs[file_entry.directory_index() as usize]; + let dir_index = file_entry.directory_index() + directory_index_correction; + let dir_id = dirs[dir_index as usize]; let file_id = out_program.add_file( clone_attr_string( &file_entry.path_name(),