Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions humility-core/src/hubris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,12 @@ impl HubrisArchive {
while let Some(attr) = attrs.next()? {
match attr.name() {
gimli::constants::DW_AT_name => {
name = dwarf_name(dwarf, attr.value());
let value = attr.value();
if let gimli::AttributeValue::String(s) = value {
name = s.to_string().ok();
} else {
name = dwarf_name(dwarf, value);
}
}

gimli::constants::DW_AT_type => {
Expand All @@ -1469,6 +1474,8 @@ impl HubrisArchive {
}
}

let name = name.or(Some("<anonymous>"));

if let (Some(name), Some(dgoff), Some(size)) = (name, dgoff, size) {
self.enums.insert(
goff,
Expand Down Expand Up @@ -1682,7 +1689,12 @@ impl HubrisArchive {
while let Some(attr) = attrs.next()? {
match attr.name() {
gimli::constants::DW_AT_name => {
name = dwarf_name(dwarf, attr.value());
let value = attr.value();
if let gimli::AttributeValue::String(s) = value {
name = s.to_string().ok();
} else {
name = dwarf_name(dwarf, value);
}
}

gimli::constants::DW_AT_data_member_location => {
Expand All @@ -1699,6 +1711,8 @@ impl HubrisArchive {
}
}

name = name.or(Some("<anonymous>"));

if let Some(pstruct) = self.structs.get_mut(&parent) {
if let (Some(n), Some(offs), Some(g)) = (name, offset, goff) {
pstruct.members.push(HubrisStructMember {
Expand Down Expand Up @@ -5664,6 +5678,11 @@ fn dwarf_name<'a>(
let ddstring = str::from_utf8(dstring.slice()).ok()?;
Some(ddstring)
}
gimli::AttributeValue::DebugStrRefSup(strref) => {
let dstring = dwarf.debug_str.get_str(strref).ok()?;
let ddstring = str::from_utf8(dstring.slice()).ok()?;
Some(ddstring)
}
_ => None,
}
}
Expand Down