Don't require DW_AT_comp_dir for debuginfo

I'm not too well-versed in this area of debuginfo, but I think this
should address #3184 where it appears not all compilers emit
`DW_AT_comp_dir`. This seems to match the default behavior of `gimli`
when it maps an existing line program to a new line program as well
(choosing an empty name for the compilation directory).

Closes #3184
This commit is contained in:
Alex Crichton
2021-08-16 10:48:10 -07:00
parent 0313e30d76
commit 1bdafbf226

View File

@@ -63,17 +63,20 @@ where
};
let comp_dir = root.attr_value(gimli::DW_AT_comp_dir)?;
let comp_name = root.attr_value(gimli::DW_AT_name)?;
let out_comp_dir = clone_attr_string(
comp_dir.as_ref().context("comp_dir")?,
gimli::DW_FORM_strp,
unit,
debug_str,
debug_str_offsets,
debug_line_str,
out_strings,
)?;
let out_comp_dir = match &comp_dir {
Some(comp_dir) => Some(clone_attr_string(
comp_dir,
gimli::DW_FORM_strp,
unit,
debug_str,
debug_str_offsets,
debug_line_str,
out_strings,
)?),
None => None,
};
let out_comp_name = clone_attr_string(
comp_name.as_ref().context("comp_name")?,
comp_name.as_ref().context("missing DW_AT_name attribute")?,
gimli::DW_FORM_strp,
unit,
debug_str,
@@ -102,7 +105,7 @@ where
let mut out_program = write::LineProgram::new(
out_encoding,
line_encoding,
out_comp_dir,
out_comp_dir.unwrap_or_else(|| write::LineString::String(Vec::new())),
out_comp_name,
None,
);