1 #ifndef liblldb_FuncUnwinders_h
2 #define liblldb_FuncUnwinders_h
4 #include "lldb/Core/AddressRange.h"
5 #include "lldb/Core/ArchSpec.h"
6 #include "lldb/Core/AddressRange.h"
7 #include "lldb/Host/Mutex.h"
9 namespace lldb_private {
16 // FuncUnwinders objects are used to track UnwindPlans for a function
17 // (named or not - really just an address range)
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.
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.
34 FuncUnwinders (lldb_private::UnwindTable& unwind_table, const lldb::UnwindAssemblySP& assembly_profiler, AddressRange range);
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.
44 GetUnwindPlanAtCallSite (int current_offset);
47 GetUnwindPlanAtNonCallSite (lldb_private::Thread& thread);
50 GetUnwindPlanFastUnwind (lldb_private::Thread& Thread);
53 GetUnwindPlanArchitectureDefault (lldb_private::Thread& thread);
56 GetUnwindPlanArchitectureDefaultAtFunctionEntry (lldb_private::Thread& thread);
59 GetFirstNonPrologueInsn (Target& target);
62 GetFunctionStartAddress () const;
65 ContainsAddress (const Address& addr) const
67 return m_range.ContainsFileAddress (addr);
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
76 InvalidateNonCallSiteUnwindPlan (lldb_private::Thread& Thread);
79 UnwindTable& m_unwind_table;
80 lldb::UnwindAssemblySP m_assembly_profiler;
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;
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;
97 Address m_first_non_prologue_insn;
99 DISALLOW_COPY_AND_ASSIGN (FuncUnwinders);
101 }; // class FuncUnwinders
103 } // namespace lldb_private
106 #endif //liblldb_FuncUnwinders_h