diff --git a/src/symbols/symbols_with_libdwarf.cpp b/src/symbols/symbols_with_libdwarf.cpp index 64849fb..a8ed419 100644 --- a/src/symbols/symbols_with_libdwarf.cpp +++ b/src/symbols/symbols_with_libdwarf.cpp @@ -384,6 +384,9 @@ namespace libdwarf { ASSERT(die.get_tag() == DW_TAG_subprogram || die.get_tag() == DW_TAG_inlined_subroutine); // get_inlines_info is recursive and recurses into dies with pc ranges matching the pc we're looking for, // however, because I wouldn't want anything stack overflowing I'm breaking the recursion out into a loop + // while looping when we find the target die we need to be able to store a die somewhere that doesn't die + // at the end of the list traversal, we'll use this as a holder for it + die_object current_obj_holder(dbg, nullptr); optional> current_die = die; while(current_die.has_value()) { auto child = current_die.unwrap().get().get_child(); @@ -393,7 +396,7 @@ namespace libdwarf { optional> target_die; walk_die_list( child, - [this, &cu_die, pc, dwversion, &inlines, &target_die] (const die_object& die) { + [this, &cu_die, pc, dwversion, &inlines, &target_die, ¤t_obj_holder] (const die_object& die) { if(die.get_tag() == DW_TAG_inlined_subroutine && die.pc_in_die(dwversion, pc)) { const auto name = subprogram_symbol(die, dwversion); auto file_i = die.get_unsigned_attribute(DW_AT_call_file); @@ -427,7 +430,8 @@ namespace libdwarf { name, true }); - target_die = die; + current_obj_holder = die.clone(); + target_die = current_obj_holder; return false; } else { return true;