File indexing completed on 2026-05-10 08:42:56
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_TARGET_UNWINDLLDB_H
0010 #define LLDB_TARGET_UNWINDLLDB_H
0011
0012 #include <vector>
0013
0014 #include "lldb/Symbol/FuncUnwinders.h"
0015 #include "lldb/Symbol/SymbolContext.h"
0016 #include "lldb/Symbol/UnwindPlan.h"
0017 #include "lldb/Target/RegisterContext.h"
0018 #include "lldb/Target/Unwind.h"
0019 #include "lldb/Utility/ConstString.h"
0020 #include "lldb/lldb-public.h"
0021
0022 namespace lldb_private {
0023
0024 class RegisterContextUnwind;
0025
0026 class UnwindLLDB : public lldb_private::Unwind {
0027 public:
0028 UnwindLLDB(lldb_private::Thread &thread);
0029
0030 ~UnwindLLDB() override = default;
0031
0032 enum RegisterSearchResult {
0033 eRegisterFound = 0,
0034 eRegisterNotFound,
0035 eRegisterIsVolatile
0036 };
0037
0038 protected:
0039 friend class lldb_private::RegisterContextUnwind;
0040
0041
0042
0043
0044 struct ConcreteRegisterLocation {
0045 enum RegisterLocationTypes {
0046 eRegisterNotSaved = 0,
0047
0048 eRegisterSavedAtMemoryLocation,
0049
0050 eRegisterInRegister,
0051
0052 eRegisterSavedAtHostMemoryLocation,
0053
0054 eRegisterValueInferred,
0055
0056 eRegisterInLiveRegisterContext
0057
0058 };
0059 int type;
0060 union {
0061 lldb::addr_t target_memory_location;
0062 uint32_t
0063 register_number;
0064 void *host_memory_location;
0065 uint64_t inferred_value;
0066
0067 } location;
0068 };
0069
0070 void DoClear() override {
0071 m_frames.clear();
0072 m_candidate_frame.reset();
0073 m_unwind_complete = false;
0074 }
0075
0076 uint32_t DoGetFrameCount() override;
0077
0078 bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
0079 lldb::addr_t &start_pc,
0080 bool &behaves_like_zeroth_frame) override;
0081
0082 lldb::RegisterContextSP
0083 DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
0084
0085 typedef std::shared_ptr<RegisterContextUnwind> RegisterContextLLDBSP;
0086
0087
0088
0089
0090
0091 RegisterContextLLDBSP GetRegisterContextForFrameNum(uint32_t frame_num);
0092
0093
0094
0095 bool SearchForSavedLocationForRegister(
0096 uint32_t lldb_regnum,
0097 lldb_private::UnwindLLDB::ConcreteRegisterLocation ®loc,
0098 uint32_t starting_frame_num, bool pc_register);
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 const std::vector<ConstString> &GetUserSpecifiedTrapHandlerFunctionNames() {
0111 return m_user_supplied_trap_handler_functions;
0112 }
0113
0114 private:
0115 struct Cursor {
0116 lldb::addr_t start_pc =
0117 LLDB_INVALID_ADDRESS;
0118
0119 lldb::addr_t cfa = LLDB_INVALID_ADDRESS;
0120
0121 lldb_private::SymbolContext sctx;
0122
0123 RegisterContextLLDBSP
0124 reg_ctx_lldb_sp;
0125
0126 Cursor() = default;
0127
0128 private:
0129 Cursor(const Cursor &) = delete;
0130 const Cursor &operator=(const Cursor &) = delete;
0131 };
0132
0133 typedef std::shared_ptr<Cursor> CursorSP;
0134 std::vector<CursorSP> m_frames;
0135 CursorSP m_candidate_frame;
0136 bool m_unwind_complete;
0137
0138
0139
0140
0141
0142 std::vector<ConstString> m_user_supplied_trap_handler_functions;
0143
0144
0145
0146
0147
0148 void UpdateUnwindPlanForFirstFrameIfInvalid(ABI *abi);
0149
0150 CursorSP GetOneMoreFrame(ABI *abi);
0151
0152 bool AddOneMoreFrame(ABI *abi);
0153
0154 bool AddFirstFrame();
0155
0156
0157 UnwindLLDB(const UnwindLLDB &) = delete;
0158 const UnwindLLDB &operator=(const UnwindLLDB &) = delete;
0159 };
0160
0161 }
0162
0163 #endif