1 #ifndef liblldb_FuncUnwinders_h
2 #define liblldb_FuncUnwinders_h
6 #include "lldb/Core/AddressRange.h"
7 #include "lldb/Core/ArchSpec.h"
8 #include "lldb/Core/AddressRange.h"
9 #include "lldb/Host/Mutex.h"
11 namespace lldb_private {
18 // FuncUnwinders objects are used to track UnwindPlans for a function
19 // (named or not - really just an address range)
21 // We'll record four different UnwindPlans for each address range:
23 // 1. Unwinding from a call site (a valid exception throw location)
24 // This is often sourced from the eh_frame exception handling info
25 // 2. Unwinding from a non-call site (any location in the function)
26 // This is often done by analyzing the function prologue assembly
27 // language instructions
28 // 3. A fast unwind method for this function which only retrieves a
29 // limited set of registers necessary to walk the stack
30 // 4. An architectural default unwind plan when none of the above are
31 // available for some reason.
33 // Additionally, FuncUnwinds object can be asked where the prologue
34 // instructions are finished for migrating breakpoints past the
35 // stack frame setup instructions when we don't have line table information.
37 FuncUnwinders (lldb_private::UnwindTable& unwind_table, AddressRange range);
41 // current_offset is the byte offset into the function.
42 // 0 means no instructions have executed yet. -1 means the offset is unknown.
43 // On architectures where the pc points to the next instruction that will execute, this
44 // offset value will have already been decremented by 1 to stay within the bounds of the
45 // correct function body.
47 GetUnwindPlanAtCallSite (Target &target, int current_offset);
50 GetUnwindPlanAtNonCallSite (Target& target, lldb_private::Thread& thread, int current_offset);
53 GetUnwindPlanFastUnwind (lldb_private::Thread& Thread);
56 GetUnwindPlanArchitectureDefault (lldb_private::Thread& thread);
59 GetUnwindPlanArchitectureDefaultAtFunctionEntry (lldb_private::Thread& thread);
62 GetFirstNonPrologueInsn (Target& target);
65 GetFunctionStartAddress () const;
68 ContainsAddress (const Address& addr) const
70 return m_range.ContainsFileAddress (addr);
73 // A function may have a Language Specific Data Area specified -- a block of data in
74 // the object file which is used in the processing of an exception throw / catch.
75 // If any of the UnwindPlans have the address of the LSDA region for this function,
76 // this will return it.
78 GetLSDAAddress (Target &target);
80 // A function may have a Personality Routine associated with it -- used in the
81 // processing of throwing an exception. If any of the UnwindPlans have the
82 // address of the personality routine, this will return it. Read the target-pointer
83 // at this address to get the personality function address.
85 GetPersonalityRoutinePtrAddress (Target &target);
89 // The following methods to retrieve specific unwind plans should rarely be used.
90 // Instead, clients should ask for the *behavior* they are looking for, using one
91 // of the above UnwindPlan retrieval methods.
94 GetAssemblyUnwindPlan (Target &target, Thread &thread, int current_offset);
97 GetEHFrameUnwindPlan (Target &target, int current_offset);
100 GetEHFrameAugmentedUnwindPlan (Target &target, Thread &thread, int current_offset);
103 GetCompactUnwindUnwindPlan (Target &target, int current_offset);
106 GetArchDefaultUnwindPlan (Thread &thread);
109 GetArchDefaultAtFuncEntryUnwindPlan (Thread &thread);
113 lldb::UnwindAssemblySP
114 GetUnwindAssemblyProfiler ();
116 UnwindTable& m_unwind_table;
117 AddressRange m_range;
121 lldb::UnwindPlanSP m_unwind_plan_assembly_sp;
122 lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp;
123 lldb::UnwindPlanSP m_unwind_plan_eh_frame_augmented_sp; // augmented by assembly inspection so it's valid everywhere
124 std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind;
125 lldb::UnwindPlanSP m_unwind_plan_fast_sp;
126 lldb::UnwindPlanSP m_unwind_plan_arch_default_sp;
127 lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp;
129 // Fetching the UnwindPlans can be expensive - if we've already attempted
130 // to get one & failed, don't try again.
131 bool m_tried_unwind_plan_assembly:1,
132 m_tried_unwind_plan_eh_frame:1,
133 m_tried_unwind_plan_eh_frame_augmented:1,
134 m_tried_unwind_plan_compact_unwind:1,
135 m_tried_unwind_fast:1,
136 m_tried_unwind_arch_default:1,
137 m_tried_unwind_arch_default_at_func_entry:1;
139 Address m_first_non_prologue_insn;
141 DISALLOW_COPY_AND_ASSIGN (FuncUnwinders);
143 }; // class FuncUnwinders
145 } // namespace lldb_private
148 #endif //liblldb_FuncUnwinders_h