LLDB mainline
FuncUnwinders.h
Go to the documentation of this file.
1#ifndef LLDB_SYMBOL_FUNCUNWINDERS_H
2#define LLDB_SYMBOL_FUNCUNWINDERS_H
3
6#include <mutex>
7#include <vector>
8
9namespace lldb_private {
10
11class UnwindTable;
12
14public:
15 // FuncUnwinders objects are used to track UnwindPlans for a function (named
16 // or not - really just a set of address ranges)
17
18 // We'll record four different UnwindPlans for each function:
19 //
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 // language 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 stack frame
32 // setup instructions when we don't have line table information.
33
35 AddressRanges ranges);
36
38
39 std::shared_ptr<const UnwindPlan> GetUnwindPlanAtCallSite(Target &target,
40 Thread &thread);
41
42 std::shared_ptr<const UnwindPlan>
44
45 std::shared_ptr<const UnwindPlan>
47
48 std::shared_ptr<const UnwindPlan>
50
51 std::shared_ptr<const UnwindPlan>
53
54 const Address &GetFunctionStartAddress() const;
55
56 bool ContainsAddress(const Address &addr) const {
57 return llvm::any_of(m_ranges, [&](const AddressRange range) {
58 return range.ContainsFileAddress(addr);
59 });
60 }
61
62 // The following methods to retrieve specific unwind plans should rarely be
63 // used. Instead, clients should ask for the *behavior* they are looking for,
64 // using one of the above UnwindPlan retrieval methods.
65
66 std::shared_ptr<const UnwindPlan> GetAssemblyUnwindPlan(Target &target,
67 Thread &thread);
68
69 std::shared_ptr<const UnwindPlan> GetObjectFileUnwindPlan(Target &target);
70
71 std::shared_ptr<const UnwindPlan>
73
74 std::shared_ptr<const UnwindPlan> GetEHFrameUnwindPlan(Target &target);
75
76 std::shared_ptr<const UnwindPlan>
78
79 std::shared_ptr<const UnwindPlan> GetDebugFrameUnwindPlan(Target &target);
80
81 std::shared_ptr<const UnwindPlan>
83
84 std::shared_ptr<const UnwindPlan> GetCompactUnwindUnwindPlan(Target &target);
85
86 std::shared_ptr<const UnwindPlan> GetArmUnwindUnwindPlan(Target &target);
87
88 std::shared_ptr<const UnwindPlan> GetSymbolFileUnwindPlan(Thread &thread);
89
90 std::shared_ptr<const UnwindPlan> GetArchDefaultUnwindPlan(Thread &thread);
91
92 std::shared_ptr<const UnwindPlan>
94
95private:
97
98 // Do a simplistic comparison for the register restore rule for getting the
99 // caller's pc value on two UnwindPlans -- returns LazyBoolYes if they have
100 // the same unwind rule for the pc, LazyBoolNo if they do not have the same
101 // unwind rule for the pc, and LazyBoolCalculate if it was unable to
102 // determine this for some reason.
104 Thread &thread, const std::shared_ptr<const UnwindPlan> &a,
105 const std::shared_ptr<const UnwindPlan> &b);
106
108
109 /// Start address of the function described by this object.
111
112 /// The address ranges of the function.
114
115 std::recursive_mutex m_mutex;
116
117 std::shared_ptr<const UnwindPlan> m_unwind_plan_assembly_sp;
118 std::shared_ptr<const UnwindPlan> m_unwind_plan_object_file_sp;
119 std::shared_ptr<const UnwindPlan> m_unwind_plan_eh_frame_sp;
120 std::shared_ptr<const UnwindPlan> m_unwind_plan_debug_frame_sp;
121
122 // augmented by assembly inspection so it's valid everywhere
123 std::shared_ptr<const UnwindPlan> m_unwind_plan_object_file_augmented_sp;
124 std::shared_ptr<const UnwindPlan> m_unwind_plan_eh_frame_augmented_sp;
125 std::shared_ptr<const UnwindPlan> m_unwind_plan_debug_frame_augmented_sp;
126
127 std::vector<std::shared_ptr<const UnwindPlan>> m_unwind_plan_compact_unwind;
128 std::shared_ptr<const UnwindPlan> m_unwind_plan_arm_unwind_sp;
129 std::shared_ptr<const UnwindPlan> m_unwind_plan_symbol_file_sp;
130 std::shared_ptr<const UnwindPlan> m_unwind_plan_fast_sp;
131 std::shared_ptr<const UnwindPlan> m_unwind_plan_arch_default_sp;
132 std::shared_ptr<const UnwindPlan> m_unwind_plan_arch_default_at_func_entry_sp;
133
134 // Fetching the UnwindPlans can be expensive - if we've already attempted to
135 // get one & failed, don't try again.
146
148
149 FuncUnwinders(const FuncUnwinders &) = delete;
150 const FuncUnwinders &operator=(const FuncUnwinders &) = delete;
151
152}; // class FuncUnwinders
153
154} // namespace lldb_private
155
156#endif // LLDB_SYMBOL_FUNCUNWINDERS_H
A section + offset based address range class.
bool ContainsFileAddress(const Address &so_addr) const
Check if a section offset address is contained in this range.
A section + offset based address class.
Definition Address.h:62
std::shared_ptr< const UnwindPlan > m_unwind_plan_arch_default_sp
std::shared_ptr< const UnwindPlan > GetUnwindPlanFastUnwind(Target &target, lldb_private::Thread &thread)
std::shared_ptr< const UnwindPlan > GetEHFrameAugmentedUnwindPlan(Target &target, Thread &thread)
std::shared_ptr< const UnwindPlan > GetUnwindPlanArchitectureDefault(lldb_private::Thread &thread)
std::shared_ptr< const UnwindPlan > m_unwind_plan_eh_frame_sp
std::shared_ptr< const UnwindPlan > GetAssemblyUnwindPlan(Target &target, Thread &thread)
std::shared_ptr< const UnwindPlan > GetSymbolFileUnwindPlan(Thread &thread)
bool ContainsAddress(const Address &addr) const
std::shared_ptr< const UnwindPlan > m_unwind_plan_eh_frame_augmented_sp
std::shared_ptr< const UnwindPlan > GetObjectFileUnwindPlan(Target &target)
const Address & GetFunctionStartAddress() const
std::shared_ptr< const UnwindPlan > m_unwind_plan_object_file_sp
const FuncUnwinders & operator=(const FuncUnwinders &)=delete
std::shared_ptr< const UnwindPlan > GetObjectFileAugmentedUnwindPlan(Target &target, Thread &thread)
lldb_private::LazyBool CompareUnwindPlansForIdenticalInitialPCLocation(Thread &thread, const std::shared_ptr< const UnwindPlan > &a, const std::shared_ptr< const UnwindPlan > &b)
AddressRanges m_ranges
The address ranges of the function.
std::shared_ptr< const UnwindPlan > GetArchDefaultUnwindPlan(Thread &thread)
std::shared_ptr< const UnwindPlan > m_unwind_plan_object_file_augmented_sp
FuncUnwinders(const FuncUnwinders &)=delete
std::shared_ptr< const UnwindPlan > GetArmUnwindUnwindPlan(Target &target)
std::recursive_mutex m_mutex
std::shared_ptr< const UnwindPlan > GetCompactUnwindUnwindPlan(Target &target)
std::shared_ptr< const UnwindPlan > GetArchDefaultAtFuncEntryUnwindPlan(Thread &thread)
std::shared_ptr< const UnwindPlan > m_unwind_plan_arch_default_at_func_entry_sp
std::shared_ptr< const UnwindPlan > m_unwind_plan_assembly_sp
std::shared_ptr< const UnwindPlan > m_unwind_plan_fast_sp
std::shared_ptr< const UnwindPlan > m_unwind_plan_debug_frame_sp
std::shared_ptr< const UnwindPlan > GetUnwindPlanAtNonCallSite(Target &target, lldb_private::Thread &thread)
std::shared_ptr< const UnwindPlan > m_unwind_plan_arm_unwind_sp
std::shared_ptr< const UnwindPlan > GetUnwindPlanArchitectureDefaultAtFunctionEntry(lldb_private::Thread &thread)
std::shared_ptr< const UnwindPlan > GetDebugFrameAugmentedUnwindPlan(Target &target, Thread &thread)
std::shared_ptr< const UnwindPlan > m_unwind_plan_debug_frame_augmented_sp
std::vector< std::shared_ptr< const UnwindPlan > > m_unwind_plan_compact_unwind
FuncUnwinders(lldb_private::UnwindTable &unwind_table, Address addr, AddressRanges ranges)
std::shared_ptr< const UnwindPlan > GetEHFrameUnwindPlan(Target &target)
lldb::UnwindAssemblySP GetUnwindAssemblyProfiler(Target &target)
std::shared_ptr< const UnwindPlan > GetUnwindPlanAtCallSite(Target &target, Thread &thread)
std::shared_ptr< const UnwindPlan > GetDebugFrameUnwindPlan(Target &target)
std::shared_ptr< const UnwindPlan > m_unwind_plan_symbol_file_sp
Address m_addr
Start address of the function described by this object.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::UnwindAssembly > UnwindAssemblySP