A couple fixes

This commit is contained in:
Jeremy 2024-03-30 23:35:50 -05:00
parent d8b9f45a24
commit a3ebd42802
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4
2 changed files with 15 additions and 4 deletions

View File

@ -493,7 +493,12 @@ namespace libdwarf {
name.value_or(""),
true
});
current_obj_holder = die.clone();
auto d = die.clone();
if(!d) {
d.drop_error();
return false;
}
current_obj_holder = std::move(d).unwrap_value();
target_die = current_obj_holder;
return false;
} else {

View File

@ -314,7 +314,7 @@ namespace libdwarf {
if(ranges_res.is_error()) {
return ranges_res.unwrap_error();
} else if(ranges_res.unwrap_value() != DW_DLV_OK) {
return internal_error("Unexpected value from dwarf_attr: " + std::to_string(ranges_res.unwrap_value()));
return monostate{}; // normal
}
auto attrwrapper = raii_wrap(attr, [] (Dwarf_Attribute attr) { dwarf_dealloc_attribute(attr); });
PROP_ASSIGN(offset, get_ranges_offset(attr));
@ -404,10 +404,16 @@ namespace libdwarf {
NODISCARD
Result<monostate, internal_error> dwarf4_ranges(Dwarf_Addr lowpc, F callback) const {
Dwarf_Attribute attr = nullptr;
CHECK_OK(wrap(dwarf_attr, die, DW_AT_ranges, &attr));
PROP_ASSIGN(res, wrap(dwarf_attr, die, DW_AT_ranges, &attr));
if(res != DW_DLV_OK) {
return monostate{}; // normal
}
auto attrwrapper = raii_wrap(attr, [] (Dwarf_Attribute attr) { dwarf_dealloc_attribute(attr); });
Dwarf_Unsigned offset;
CHECK_OK(wrap(dwarf_global_formref, attr, &offset));
PROP_ASSIGN(res2, wrap(dwarf_global_formref, attr, &offset));
if(res2 != DW_DLV_OK) {
return monostate{}; // normal
}
Dwarf_Addr baseaddr = 0;
if(lowpc != (std::numeric_limits<Dwarf_Addr>::max)()) {
baseaddr = lowpc;