From a3ebd42802171e19c3d7cc22bf97ab83b3e93f55 Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sat, 30 Mar 2024 23:35:50 -0500 Subject: [PATCH] A couple fixes --- src/symbols/symbols_with_libdwarf.cpp | 7 ++++++- src/utils/dwarf.hpp | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/symbols/symbols_with_libdwarf.cpp b/src/symbols/symbols_with_libdwarf.cpp index 23cbcdf..ddd35a5 100644 --- a/src/symbols/symbols_with_libdwarf.cpp +++ b/src/symbols/symbols_with_libdwarf.cpp @@ -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 { diff --git a/src/utils/dwarf.hpp b/src/utils/dwarf.hpp index 492c1c4..821338b 100644 --- a/src/utils/dwarf.hpp +++ b/src/utils/dwarf.hpp @@ -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 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::max)()) { baseaddr = lowpc;