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 
9 namespace lldb_private {
10 
11 class UnwindTable;
12 
14 public:
15  // FuncUnwinders objects are used to track UnwindPlans for a function (named
16  // or not - really just an address range)
17 
18  // We'll record four different UnwindPlans for each address range:
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 
37 
38  lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, Thread &thread);
39 
40  lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target,
41  lldb_private::Thread &thread);
42 
43  lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target,
44  lldb_private::Thread &thread);
45 
46  lldb::UnwindPlanSP
48 
49  lldb::UnwindPlanSP
51 
53 
54  const Address &GetFunctionStartAddress() const;
55 
56  bool ContainsAddress(const Address &addr) const {
57  return m_range.ContainsFileAddress(addr);
58  }
59 
60  // A function may have a Language Specific Data Area specified -- a block of
61  // data in
62  // the object file which is used in the processing of an exception throw /
63  // catch. If any of the UnwindPlans have the address of the LSDA region for
64  // this function, this will return it.
65  Address GetLSDAAddress(Target &target);
66 
67  // A function may have a Personality Routine associated with it -- used in the
68  // processing of throwing an exception. If any of the UnwindPlans have the
69  // address of the personality routine, this will return it. Read the target-
70  // pointer at this address to get the personality function address.
72 
73  // The following methods to retrieve specific unwind plans should rarely be
74  // used. Instead, clients should ask for the *behavior* they are looking for,
75  // using one of the above UnwindPlan retrieval methods.
76 
77  lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread);
78 
79  lldb::UnwindPlanSP GetObjectFileUnwindPlan(Target &target);
80 
81  lldb::UnwindPlanSP GetObjectFileAugmentedUnwindPlan(Target &target,
82  Thread &thread);
83 
84  lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target);
85 
86  lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target,
87  Thread &thread);
88 
89  lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target);
90 
91  lldb::UnwindPlanSP GetDebugFrameAugmentedUnwindPlan(Target &target,
92  Thread &thread);
93 
94  lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target);
95 
96  lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target);
97 
98  lldb::UnwindPlanSP GetSymbolFileUnwindPlan(Thread &thread);
99 
100  lldb::UnwindPlanSP GetArchDefaultUnwindPlan(Thread &thread);
101 
102  lldb::UnwindPlanSP GetArchDefaultAtFuncEntryUnwindPlan(Thread &thread);
103 
104 private:
105  lldb::UnwindAssemblySP GetUnwindAssemblyProfiler(Target &target);
106 
107  // Do a simplistic comparison for the register restore rule for getting the
108  // caller's pc value on two UnwindPlans -- returns LazyBoolYes if they have
109  // the same unwind rule for the pc, LazyBoolNo if they do not have the same
110  // unwind rule for the pc, and LazyBoolCalculate if it was unable to
111  // determine this for some reason.
113  Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP &b);
114 
117 
118  std::recursive_mutex m_mutex;
119 
120  lldb::UnwindPlanSP m_unwind_plan_assembly_sp;
121  lldb::UnwindPlanSP m_unwind_plan_object_file_sp;
122  lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp;
123  lldb::UnwindPlanSP m_unwind_plan_debug_frame_sp;
124 
125  // augmented by assembly inspection so it's valid everywhere
129 
130  std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind;
131  lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp;
132  lldb::UnwindPlanSP m_unwind_plan_symbol_file_sp;
133  lldb::UnwindPlanSP m_unwind_plan_fast_sp;
134  lldb::UnwindPlanSP m_unwind_plan_arch_default_sp;
136 
137  // Fetching the UnwindPlans can be expensive - if we've already attempted to
138  // get one & failed, don't try again.
149 
151 
152  FuncUnwinders(const FuncUnwinders &) = delete;
153  const FuncUnwinders &operator=(const FuncUnwinders &) = delete;
154 
155 }; // class FuncUnwinders
156 
157 } // namespace lldb_private
158 
159 #endif // LLDB_SYMBOL_FUNCUNWINDERS_H
lldb_private::FuncUnwinders::GetUnwindPlanFastUnwind
lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target, lldb_private::Thread &thread)
Definition: FuncUnwinders.cpp:434
lldb_private::FuncUnwinders::CompareUnwindPlansForIdenticalInitialPCLocation
lldb_private::LazyBool CompareUnwindPlansForIdenticalInitialPCLocation(Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP &b)
Definition: FuncUnwinders.cpp:352
lldb_private::FuncUnwinders::m_unwind_plan_debug_frame_augmented_sp
lldb::UnwindPlanSP m_unwind_plan_debug_frame_augmented_sp
Definition: FuncUnwinders.h:128
lldb_private::FuncUnwinders::m_unwind_plan_fast_sp
lldb::UnwindPlanSP m_unwind_plan_fast_sp
Definition: FuncUnwinders.h:133
lldb_private::FuncUnwinders::m_tried_unwind_arch_default_at_func_entry
bool m_tried_unwind_arch_default_at_func_entry
Definition: FuncUnwinders.h:148
lldb_private::FuncUnwinders::m_unwind_table
UnwindTable & m_unwind_table
Definition: FuncUnwinders.h:115
lldb_private::FuncUnwinders::m_tried_unwind_plan_object_file_augmented
bool m_tried_unwind_plan_object_file_augmented
Definition: FuncUnwinders.h:142
lldb_private::FuncUnwinders::m_tried_unwind_arch_default
bool m_tried_unwind_arch_default
Definition: FuncUnwinders.h:147
lldb_private::FuncUnwinders::ContainsAddress
bool ContainsAddress(const Address &addr) const
Definition: FuncUnwinders.h:56
lldb_private::FuncUnwinders::m_unwind_plan_symbol_file_sp
lldb::UnwindPlanSP m_unwind_plan_symbol_file_sp
Definition: FuncUnwinders.h:132
lldb_private::FuncUnwinders::GetArchDefaultAtFuncEntryUnwindPlan
lldb::UnwindPlanSP GetArchDefaultAtFuncEntryUnwindPlan(Thread &thread)
lldb_private::FuncUnwinders::m_tried_unwind_plan_debug_frame_augmented
bool m_tried_unwind_plan_debug_frame_augmented
Definition: FuncUnwinders.h:144
lldb_private::UnwindTable
Definition: UnwindTable.h:23
lldb_private::FuncUnwinders::~FuncUnwinders
~FuncUnwinders()
destructor
lldb_private::FuncUnwinders::GetUnwindAssemblyProfiler
lldb::UnwindAssemblySP GetUnwindAssemblyProfiler(Target &target)
Definition: FuncUnwinders.cpp:521
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
lldb_private::FuncUnwinders::GetFirstNonPrologueInsn
Address & GetFirstNonPrologueInsn(Target &target)
Definition: FuncUnwinders.cpp:503
lldb-private-enumerations.h
lldb_private::Target
Definition: Target.h:450
lldb_private::FuncUnwinders::m_tried_unwind_plan_debug_frame
bool m_tried_unwind_plan_debug_frame
Definition: FuncUnwinders.h:141
lldb_private::FuncUnwinders::m_tried_unwind_plan_compact_unwind
bool m_tried_unwind_plan_compact_unwind
Definition: FuncUnwinders.h:145
lldb_private::FuncUnwinders::GetEHFrameAugmentedUnwindPlan
lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target, Thread &thread)
Definition: FuncUnwinders.cpp:245
lldb_private::FuncUnwinders::m_unwind_plan_assembly_sp
lldb::UnwindPlanSP m_unwind_plan_assembly_sp
Definition: FuncUnwinders.h:120
lldb_private::FuncUnwinders::m_unwind_plan_eh_frame_augmented_sp
lldb::UnwindPlanSP m_unwind_plan_eh_frame_augmented_sp
Definition: FuncUnwinders.h:127
lldb_private::FuncUnwinders::GetAssemblyUnwindPlan
lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread)
Definition: FuncUnwinders.cpp:327
lldb_private::FuncUnwinders::GetObjectFileAugmentedUnwindPlan
lldb::UnwindPlanSP GetObjectFileAugmentedUnwindPlan(Target &target, Thread &thread)
Definition: FuncUnwinders.cpp:214
lldb_private::FuncUnwinders
Definition: FuncUnwinders.h:13
lldb_private::FuncUnwinders::m_unwind_plan_arch_default_at_func_entry_sp
lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp
Definition: FuncUnwinders.h:135
lldb_private::FuncUnwinders::FuncUnwinders
FuncUnwinders(lldb_private::UnwindTable &unwind_table, AddressRange range)
constructor
Definition: FuncUnwinders.cpp:36
lldb_private::FuncUnwinders::m_tried_unwind_plan_symbol_file
bool m_tried_unwind_plan_symbol_file
Definition: FuncUnwinders.h:146
lldb_private::FuncUnwinders::m_unwind_plan_eh_frame_sp
lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp
Definition: FuncUnwinders.h:122
lldb_private::FuncUnwinders::m_tried_unwind_plan_object_file
bool m_tried_unwind_plan_object_file
Definition: FuncUnwinders.h:140
lldb_private::Thread
Definition: Thread.h:60
lldb_private::AddressRange
Definition: AddressRange.h:25
lldb_private::FuncUnwinders::GetUnwindPlanAtNonCallSite
lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target, lldb_private::Thread &thread)
Definition: FuncUnwinders.cpp:383
lldb_private::FuncUnwinders::GetUnwindPlanArchitectureDefault
lldb::UnwindPlanSP GetUnwindPlanArchitectureDefault(lldb_private::Thread &thread)
Definition: FuncUnwinders.cpp:454
lldb_private::FuncUnwinders::GetLSDAAddress
Address GetLSDAAddress(Target &target)
Definition: FuncUnwinders.cpp:530
lldb_private::FuncUnwinders::GetDebugFrameAugmentedUnwindPlan
lldb::UnwindPlanSP GetDebugFrameAugmentedUnwindPlan(Target &target, Thread &thread)
Definition: FuncUnwinders.cpp:286
lldb_private::AddressRange::ContainsFileAddress
bool ContainsFileAddress(const Address &so_addr) const
Check if a section offset address is contained in this range.
Definition: AddressRange.cpp:71
lldb_private::FuncUnwinders::m_unwind_plan_debug_frame_sp
lldb::UnwindPlanSP m_unwind_plan_debug_frame_sp
Definition: FuncUnwinders.h:123
lldb_private::FuncUnwinders::GetEHFrameUnwindPlan
lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target)
Definition: FuncUnwinders.cpp:125
lldb_private::FuncUnwinders::m_unwind_plan_compact_unwind
std::vector< lldb::UnwindPlanSP > m_unwind_plan_compact_unwind
Definition: FuncUnwinders.h:130
lldb_private::FuncUnwinders::operator=
const FuncUnwinders & operator=(const FuncUnwinders &)=delete
lldb_private::FuncUnwinders::GetArmUnwindUnwindPlan
lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target)
Definition: FuncUnwinders.cpp:161
lldb_private::FuncUnwinders::m_tried_unwind_fast
bool m_tried_unwind_fast
Definition: FuncUnwinders.h:147
lldb_private::FuncUnwinders::m_unwind_plan_arch_default_sp
lldb::UnwindPlanSP m_unwind_plan_arch_default_sp
Definition: FuncUnwinders.h:134
lldb_private::FuncUnwinders::m_tried_unwind_plan_eh_frame_augmented
bool m_tried_unwind_plan_eh_frame_augmented
Definition: FuncUnwinders.h:143
lldb_private::FuncUnwinders::GetSymbolFileUnwindPlan
lldb::UnwindPlanSP GetSymbolFileUnwindPlan(Thread &thread)
Definition: FuncUnwinders.cpp:199
lldb_private::FuncUnwinders::GetDebugFrameUnwindPlan
lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target)
Definition: FuncUnwinders.cpp:143
lldb_private::Address
Definition: Address.h:59
lldb_private::FuncUnwinders::m_tried_unwind_plan_assembly
bool m_tried_unwind_plan_assembly
Definition: FuncUnwinders.h:139
lldb_private::FuncUnwinders::GetPersonalityRoutinePtrAddress
Address GetPersonalityRoutinePtrAddress(Target &target)
Definition: FuncUnwinders.cpp:546
lldb_private::FuncUnwinders::GetUnwindPlanAtCallSite
lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, Thread &thread)
Definition: FuncUnwinders.cpp:60
lldb_private::FuncUnwinders::m_tried_unwind_plan_arm_unwind
bool m_tried_unwind_plan_arm_unwind
Definition: FuncUnwinders.h:146
lldb_private::FuncUnwinders::GetCompactUnwindUnwindPlan
lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target)
Definition: FuncUnwinders.cpp:80
lldb_private::FuncUnwinders::m_unwind_plan_arm_unwind_sp
lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp
Definition: FuncUnwinders.h:131
lldb_private::FuncUnwinders::m_first_non_prologue_insn
Address m_first_non_prologue_insn
Definition: FuncUnwinders.h:150
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::FuncUnwinders::m_range
AddressRange m_range
Definition: FuncUnwinders.h:116
lldb_private::FuncUnwinders::m_tried_unwind_plan_eh_frame
bool m_tried_unwind_plan_eh_frame
Definition: FuncUnwinders.h:139
lldb_private::FuncUnwinders::GetObjectFileUnwindPlan
lldb::UnwindPlanSP GetObjectFileUnwindPlan(Target &target)
Definition: FuncUnwinders.cpp:105
lldb_private::FuncUnwinders::GetFunctionStartAddress
const Address & GetFunctionStartAddress() const
Definition: FuncUnwinders.cpp:516
AddressRange.h
lldb_private::FuncUnwinders::m_unwind_plan_object_file_sp
lldb::UnwindPlanSP m_unwind_plan_object_file_sp
Definition: FuncUnwinders.h:121
lldb_private::FuncUnwinders::m_mutex
std::recursive_mutex m_mutex
Definition: FuncUnwinders.h:118
lldb_private::FuncUnwinders::GetArchDefaultUnwindPlan
lldb::UnwindPlanSP GetArchDefaultUnwindPlan(Thread &thread)
lldb_private::FuncUnwinders::m_unwind_plan_object_file_augmented_sp
lldb::UnwindPlanSP m_unwind_plan_object_file_augmented_sp
Definition: FuncUnwinders.h:126
lldb_private::FuncUnwinders::GetUnwindPlanArchitectureDefaultAtFunctionEntry
lldb::UnwindPlanSP GetUnwindPlanArchitectureDefaultAtFunctionEntry(lldb_private::Thread &thread)
Definition: FuncUnwinders.cpp:478