Index: include/lldb/Symbol/FuncUnwinders.h =================================================================== --- include/lldb/Symbol/FuncUnwinders.h +++ include/lldb/Symbol/FuncUnwinders.h @@ -31,6 +31,9 @@ // instructions are finished for migrating breakpoints past the stack frame // setup instructions when we don't have line table information. + /// Create the FuncUnwinders object for the given address range. The object + /// will use the data from the given UnwindTable for UnwindPlan generation. + /// The input address range must be valid. FuncUnwinders(lldb_private::UnwindTable &unwind_table, AddressRange range); ~FuncUnwinders(); Index: source/Symbol/FuncUnwinders.cpp =================================================================== --- source/Symbol/FuncUnwinders.cpp +++ source/Symbol/FuncUnwinders.cpp @@ -45,7 +45,9 @@ m_tried_unwind_plan_arm_unwind(false), m_tried_unwind_fast(false), m_tried_unwind_arch_default(false), m_tried_unwind_arch_default_at_func_entry(false), - m_first_non_prologue_insn() {} + m_first_non_prologue_insn() { + assert(range.GetBaseAddress().IsValid()); +} /// destructor @@ -75,17 +77,15 @@ return UnwindPlanSP(); m_tried_unwind_plan_compact_unwind = true; - if (m_range.GetBaseAddress().IsValid()) { - Address current_pc(m_range.GetBaseAddress()); - CompactUnwindInfo *compact_unwind = m_unwind_table.GetCompactUnwindInfo(); - if (compact_unwind) { - UnwindPlanSP unwind_plan_sp(new UnwindPlan(lldb::eRegisterKindGeneric)); - if (compact_unwind->GetUnwindPlan(target, current_pc, *unwind_plan_sp)) { - m_unwind_plan_compact_unwind.push_back(unwind_plan_sp); - return m_unwind_plan_compact_unwind[0]; // FIXME support multiple - // compact unwind plans for one - // func - } + Address current_pc(m_range.GetBaseAddress()); + CompactUnwindInfo *compact_unwind = m_unwind_table.GetCompactUnwindInfo(); + if (compact_unwind) { + UnwindPlanSP unwind_plan_sp(new UnwindPlan(lldb::eRegisterKindGeneric)); + if (compact_unwind->GetUnwindPlan(target, current_pc, *unwind_plan_sp)) { + m_unwind_plan_compact_unwind.push_back(unwind_plan_sp); + return m_unwind_plan_compact_unwind[0]; // FIXME support multiple + // compact unwind plans for one + // func } } return UnwindPlanSP(); @@ -97,14 +97,12 @@ return m_unwind_plan_eh_frame_sp; m_tried_unwind_plan_eh_frame = true; - if (m_range.GetBaseAddress().IsValid()) { - DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo(); - if (eh_frame) { - m_unwind_plan_eh_frame_sp = - std::make_shared(lldb::eRegisterKindGeneric); - if (!eh_frame->GetUnwindPlan(m_range, *m_unwind_plan_eh_frame_sp)) - m_unwind_plan_eh_frame_sp.reset(); - } + DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo(); + if (eh_frame) { + m_unwind_plan_eh_frame_sp = + std::make_shared(lldb::eRegisterKindGeneric); + if (!eh_frame->GetUnwindPlan(m_range, *m_unwind_plan_eh_frame_sp)) + m_unwind_plan_eh_frame_sp.reset(); } return m_unwind_plan_eh_frame_sp; } @@ -115,14 +113,13 @@ return m_unwind_plan_debug_frame_sp; m_tried_unwind_plan_debug_frame = true; - if (m_range.GetBaseAddress().IsValid()) { - DWARFCallFrameInfo *debug_frame = m_unwind_table.GetDebugFrameInfo(); - if (debug_frame) { - m_unwind_plan_debug_frame_sp = - std::make_shared(lldb::eRegisterKindGeneric); - if (!debug_frame->GetUnwindPlan(m_range, *m_unwind_plan_debug_frame_sp)) - m_unwind_plan_debug_frame_sp.reset(); - } + DWARFCallFrameInfo *debug_frame = m_unwind_table.GetDebugFrameInfo(); + if (debug_frame) { + m_unwind_plan_debug_frame_sp = + std::make_shared(lldb::eRegisterKindGeneric); + if (!debug_frame->GetUnwindPlan(m_range, + *m_unwind_plan_debug_frame_sp)) + m_unwind_plan_debug_frame_sp.reset(); } return m_unwind_plan_debug_frame_sp; } @@ -133,16 +130,14 @@ return m_unwind_plan_arm_unwind_sp; m_tried_unwind_plan_arm_unwind = true; - if (m_range.GetBaseAddress().IsValid()) { - Address current_pc(m_range.GetBaseAddress()); - ArmUnwindInfo *arm_unwind_info = m_unwind_table.GetArmUnwindInfo(); - if (arm_unwind_info) { - m_unwind_plan_arm_unwind_sp = - std::make_shared(lldb::eRegisterKindGeneric); - if (!arm_unwind_info->GetUnwindPlan(target, current_pc, - *m_unwind_plan_arm_unwind_sp)) - m_unwind_plan_arm_unwind_sp.reset(); - } + Address current_pc(m_range.GetBaseAddress()); + ArmUnwindInfo *arm_unwind_info = m_unwind_table.GetArmUnwindInfo(); + if (arm_unwind_info) { + m_unwind_plan_arm_unwind_sp = + std::make_shared(lldb::eRegisterKindGeneric); + if (!arm_unwind_info->GetUnwindPlan(target, current_pc, + *m_unwind_plan_arm_unwind_sp)) + m_unwind_plan_arm_unwind_sp.reset(); } return m_unwind_plan_arm_unwind_sp; } Index: source/Symbol/UnwindTable.cpp =================================================================== --- source/Symbol/UnwindTable.cpp +++ source/Symbol/UnwindTable.cpp @@ -89,11 +89,13 @@ return range; // Does the eh_frame unwind info has a function bounds for this addr? - if (m_eh_frame_up && m_eh_frame_up->GetAddressRange(addr, range)) + if (m_eh_frame_up && m_eh_frame_up->GetAddressRange(addr, range) && + range.GetBaseAddress().IsValid()) return range; // Try debug_frame as well - if (m_debug_frame_up && m_debug_frame_up->GetAddressRange(addr, range)) + if (m_debug_frame_up && m_debug_frame_up->GetAddressRange(addr, range) && + range.GetBaseAddress().IsValid()) return range; return llvm::None;