Skip to content
Snippets Groups Projects
Commit f03e64b7 authored by Sjoerd Simons's avatar Sjoerd Simons
Browse files

Deal with various exceptions in AT_NAME


Depending on how a binary is build or post-processes the name attribute
can either be in a supplemental debug file (due to dwz) or be artificial
(due to LTO).

In this cases output warnings, but otherwise process as normal.

Signed-off-by: default avatarSjoerd Simons <sjoerd@collabora.com>
parent df42c42e
No related branches found
No related tags found
3 merge requests!7Backport deal with various exceptions in AT_NAME to v2022dev1,!4Backport deal with various exceptions in AT_NAME to v2022dev1,!2Deal with various exceptions in AT_NAME
Pipeline #238869 failed
// Based on the gimli 0.16.1 dwarfdump.rs example
use anyhow::{anyhow, Error, Result};
use fallible_iterator::{convert, FallibleIterator};
use gimli::{Endianity, Reader};
use gimli::{AttributeValue, Endianity, Reader};
use object::Object;
use serde::ser::SerializeMap;
use serde::{Serialize, Serializer};
......@@ -81,17 +81,29 @@ fn list_entries<R: Reader>(
.map::<Result<String>, _>(|s| Ok(s.to_string()?.into_owned()))
.transpose()?
.ok_or_else(|| anyhow!("Missing DW_AT_comp_dir"))?;
let comp_name = entry
let at_name = entry
.attr(gimli::DW_AT_name)?
.and_then(|attr| attr.string_value(debug_str))
.map::<Result<String>, _>(|s| Ok(s.to_string()?.into_owned()))
.transpose()?
.ok_or_else(|| anyhow!("Missing DW_AT_name"))?;
v.push(Unit {
comp_dir,
comp_name,
});
if let Some(r) = at_name.string_value(debug_str) {
let comp_name = r.to_string()?;
if comp_name == "<artificial>" {
eprintln!("Warning: Artificial name in compile unit, probably DWARF debug information has been generated with LTO")
} else {
v.push(Unit {
comp_dir,
comp_name: comp_name.into_owned(),
});
}
} else {
match at_name.raw_value() {
AttributeValue::DebugStrRefSup(_) => {
eprintln!("Warning: compilation unit name in supplemental file")
}
_ => eprintln!("Warning: compilation unit has unexpected name type"),
}
}
}
}
Ok(v)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment