File indexing completed on 2026-05-10 08:42:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_TARGET_REGISTERCONTEXT_H
0010 #define LLDB_TARGET_REGISTERCONTEXT_H
0011
0012 #include "lldb/Target/ExecutionContextScope.h"
0013 #include "lldb/lldb-private.h"
0014
0015 namespace lldb_private {
0016
0017 class RegisterContext : public std::enable_shared_from_this<RegisterContext>,
0018 public ExecutionContextScope {
0019 public:
0020
0021 RegisterContext(Thread &thread, uint32_t concrete_frame_idx);
0022
0023 ~RegisterContext() override;
0024
0025 void InvalidateIfNeeded(bool force);
0026
0027
0028 virtual void InvalidateAllRegisters() = 0;
0029
0030 virtual size_t GetRegisterCount() = 0;
0031
0032 virtual const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) = 0;
0033
0034 virtual size_t GetRegisterSetCount() = 0;
0035
0036 virtual const RegisterSet *GetRegisterSet(size_t reg_set) = 0;
0037
0038 virtual lldb::ByteOrder GetByteOrder();
0039
0040 virtual bool ReadRegister(const RegisterInfo *reg_info,
0041 RegisterValue ®_value) = 0;
0042
0043 virtual bool WriteRegister(const RegisterInfo *reg_info,
0044 const RegisterValue ®_value) = 0;
0045
0046 virtual bool ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) {
0047 return false;
0048 }
0049
0050 virtual bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) {
0051 return false;
0052 }
0053
0054 virtual bool RegisterWriteCausesReconfigure(const llvm::StringRef name) {
0055 return false;
0056 }
0057
0058 virtual bool ReconfigureRegisterInfo() { return false; }
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 virtual bool
0071 ReadAllRegisterValues(lldb_private::RegisterCheckpoint ®_checkpoint);
0072
0073 virtual bool WriteAllRegisterValues(
0074 const lldb_private::RegisterCheckpoint ®_checkpoint);
0075
0076 bool CopyFromRegisterContext(lldb::RegisterContextSP context);
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111 virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
0112 uint32_t num);
0113
0114
0115 virtual uint32_t NumSupportedHardwareBreakpoints();
0116
0117 virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size);
0118
0119 virtual bool ClearHardwareBreakpoint(uint32_t hw_idx);
0120
0121 virtual uint32_t NumSupportedHardwareWatchpoints();
0122
0123 virtual uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
0124 bool read, bool write);
0125
0126 virtual bool ClearHardwareWatchpoint(uint32_t hw_index);
0127
0128 virtual bool HardwareSingleStep(bool enable);
0129
0130 virtual Status
0131 ReadRegisterValueFromMemory(const lldb_private::RegisterInfo *reg_info,
0132 lldb::addr_t src_addr, uint32_t src_len,
0133 RegisterValue ®_value);
0134
0135 virtual Status
0136 WriteRegisterValueToMemory(const lldb_private::RegisterInfo *reg_info,
0137 lldb::addr_t dst_addr, uint32_t dst_len,
0138 const RegisterValue ®_value);
0139
0140
0141 virtual lldb::tid_t GetThreadID() const;
0142
0143 virtual Thread &GetThread() { return m_thread; }
0144
0145 const RegisterInfo *GetRegisterInfoByName(llvm::StringRef reg_name,
0146 uint32_t start_idx = 0);
0147
0148 const RegisterInfo *GetRegisterInfo(lldb::RegisterKind reg_kind,
0149 uint32_t reg_num);
0150
0151 uint64_t GetPC(uint64_t fail_value = LLDB_INVALID_ADDRESS);
0152
0153
0154
0155 uint64_t GetThreadPointer(uint64_t fail_value = LLDB_INVALID_ADDRESS);
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 bool GetPCForSymbolication(Address &address);
0181
0182 bool SetPC(uint64_t pc);
0183
0184 bool SetPC(Address addr);
0185
0186 uint64_t GetSP(uint64_t fail_value = LLDB_INVALID_ADDRESS);
0187
0188 bool SetSP(uint64_t sp);
0189
0190 uint64_t GetFP(uint64_t fail_value = LLDB_INVALID_ADDRESS);
0191
0192 bool SetFP(uint64_t fp);
0193
0194 const char *GetRegisterName(uint32_t reg);
0195
0196 uint64_t GetReturnAddress(uint64_t fail_value = LLDB_INVALID_ADDRESS);
0197
0198 uint64_t GetFlags(uint64_t fail_value = 0);
0199
0200 uint64_t ReadRegisterAsUnsigned(uint32_t reg, uint64_t fail_value);
0201
0202 uint64_t ReadRegisterAsUnsigned(const RegisterInfo *reg_info,
0203 uint64_t fail_value);
0204
0205 bool WriteRegisterFromUnsigned(uint32_t reg, uint64_t uval);
0206
0207 bool WriteRegisterFromUnsigned(const RegisterInfo *reg_info, uint64_t uval);
0208
0209 bool ConvertBetweenRegisterKinds(lldb::RegisterKind source_rk,
0210 uint32_t source_regnum,
0211 lldb::RegisterKind target_rk,
0212 uint32_t &target_regnum);
0213
0214
0215 lldb::TargetSP CalculateTarget() override;
0216
0217 lldb::ProcessSP CalculateProcess() override;
0218
0219 lldb::ThreadSP CalculateThread() override;
0220
0221 lldb::StackFrameSP CalculateStackFrame() override;
0222
0223 void CalculateExecutionContext(ExecutionContext &exe_ctx) override;
0224
0225 uint32_t GetStopID() const { return m_stop_id; }
0226
0227 void SetStopID(uint32_t stop_id) { m_stop_id = stop_id; }
0228
0229 protected:
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239 virtual bool BehavesLikeZerothFrame() const {
0240 return m_concrete_frame_idx == 0;
0241 }
0242
0243
0244 Thread &m_thread;
0245 uint32_t m_concrete_frame_idx;
0246
0247 uint32_t m_stop_id;
0248 private:
0249
0250 RegisterContext(const RegisterContext &) = delete;
0251 const RegisterContext &operator=(const RegisterContext &) = delete;
0252 };
0253
0254 }
0255
0256 #endif