1 #ifndef liblldb_FuncUnwinders_h 2 #define liblldb_FuncUnwinders_h 3 4 #include "lldb/Core/AddressRange.h" 5 #include "lldb/Core/ArchSpec.h" 6 #include "lldb/Core/AddressRange.h" 7 #include "lldb/Host/Mutex.h" 8 9 namespace lldb_private { 10 11 class UnwindTable; 12 13 class FuncUnwinders 14 { 15 public: 16 // FuncUnwinders objects are used to track UnwindPlans for a function 17 // (named or not - really just an address range) 18 19 // We'll record three different UnwindPlans for each address range: 20 // 1. Unwinding from a call site (a valid exception throw location) 21 // This is often sourced from the eh_frame exception handling info 22 // 2. Unwinding from a non-call site (any location in the function) 23 // This is often done by analyzing the function prologue assembly 24 // langauge instructions 25 // 3. A fast unwind method for this function which only retrieves a 26 // limited set of registers necessary to walk the stack 27 // 4. An architectural default unwind plan when none of the above are 28 // available for some reason. 29 30 // Additionally, FuncUnwinds object can be asked where the prologue 31 // instructions are finished for migrating breakpoints past the 32 // stack frame setup instructions when we don't have line table information. 33 34 FuncUnwinders (lldb_private::UnwindTable& unwind_table, lldb_private::UnwindAssembly *assembly_profiler, AddressRange range); 35 36 ~FuncUnwinders (); 37 38 // current_offset is the byte offset into the function. 39 // 0 means no instructions have executed yet. -1 means the offset is unknown. 40 // On architectures where the pc points to the next instruction that will execute, this 41 // offset value will have already been decremented by 1 to stay within the bounds of the 42 // correct function body. 43 lldb::UnwindPlanSP 44 GetUnwindPlanAtCallSite (int current_offset); 45 46 lldb::UnwindPlanSP 47 GetUnwindPlanAtNonCallSite (lldb_private::Thread& thread); 48 49 lldb::UnwindPlanSP 50 GetUnwindPlanFastUnwind (lldb_private::Thread& Thread); 51 52 lldb::UnwindPlanSP 53 GetUnwindPlanArchitectureDefault (lldb_private::Thread& thread); 54 55 lldb::UnwindPlanSP 56 GetUnwindPlanArchitectureDefaultAtFunctionEntry (lldb_private::Thread& thread); 57 58 Address& 59 GetFirstNonPrologueInsn (Target& target); 60 61 const Address& 62 GetFunctionStartAddress () const; 63 64 bool ContainsAddress(const Address & addr)65 ContainsAddress (const Address& addr) const 66 { 67 return m_range.ContainsFileAddress (addr); 68 } 69 70 // When we're doing an unwind using the UnwindPlanAtNonCallSite and we find an 71 // impossible unwind condition, we know that the UnwindPlan is invalid. Calling 72 // this method on the FuncUnwinder will tell it to replace that UnwindPlan with 73 // the architectural default UnwindPlan so hopefully our stack walk will get past 74 // this frame. 75 void 76 InvalidateNonCallSiteUnwindPlan (lldb_private::Thread& Thread); 77 78 private: 79 UnwindTable& m_unwind_table; 80 UnwindAssembly *m_assembly_profiler; 81 AddressRange m_range; 82 83 Mutex m_mutex; 84 lldb::UnwindPlanSP m_unwind_plan_call_site_sp; 85 lldb::UnwindPlanSP m_unwind_plan_non_call_site_sp; 86 lldb::UnwindPlanSP m_unwind_plan_fast_sp; 87 lldb::UnwindPlanSP m_unwind_plan_arch_default_sp; 88 lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp; 89 90 bool m_tried_unwind_at_call_site:1, 91 m_tried_unwind_at_non_call_site:1, 92 m_tried_unwind_fast:1, 93 m_tried_unwind_arch_default:1, 94 m_tried_unwind_arch_default_at_func_entry:1; 95 96 97 Address m_first_non_prologue_insn; 98 99 DISALLOW_COPY_AND_ASSIGN (FuncUnwinders); 100 101 }; // class FuncUnwinders 102 103 } // namespace lldb_private 104 105 106 #endif //liblldb_FuncUnwinders_h 107