From 2c4f271e238ceb422dbf0297d5f340d8c887087d Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sun, 17 Sep 2023 01:51:35 -0400 Subject: [PATCH] Improve die_object::has_attr implementation --- src/symbols/symbols_with_libdwarf.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/symbols/symbols_with_libdwarf.cpp b/src/symbols/symbols_with_libdwarf.cpp index c34f545..9fd1f9a 100644 --- a/src/symbols/symbols_with_libdwarf.cpp +++ b/src/symbols/symbols_with_libdwarf.cpp @@ -149,18 +149,9 @@ namespace libdwarf { } bool has_attr(Dwarf_Half dw_attrnum) const { - Dwarf_Attribute attr; - int ret = dwarf_attr(die, dw_attrnum, &attr, nullptr); - if(ret == DW_DLV_NO_ENTRY) { - return false; - } else if(ret == DW_DLV_OK) { - // TODO: Better impl that doesn't require allocation....? - dwarf_dealloc_attribute(attr); - return true; - } else { - fprintf(stderr, "Error\n"); - exit(1); - } + Dwarf_Bool present = false; + CPPTRACE_VERIFY(dwarf_hasattr(die, dw_attrnum, &present, nullptr) == DW_DLV_OK); + return present; } Dwarf_Half get_tag() const {