RegisterContext.h revision 061b79dbf1fefaf157d414747e98a463a0f32eda
1//===-- RegisterContext.h ---------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_RegisterContext_h_ 11#define liblldb_RegisterContext_h_ 12 13// C Includes 14// C++ Includes 15// Other libraries and framework includes 16// Project includes 17#include "lldb/lldb-private.h" 18#include "lldb/Target/ExecutionContextScope.h" 19 20namespace lldb_private { 21 22class RegisterContext : 23 public ExecutionContextScope 24{ 25public: 26 //------------------------------------------------------------------ 27 // Constructors and Destructors 28 //------------------------------------------------------------------ 29 RegisterContext (Thread &thread, uint32_t concrete_frame_idx); 30 31 virtual 32 ~RegisterContext (); 33 34 void 35 InvalidateIfNeeded (bool force); 36 37 //------------------------------------------------------------------ 38 // Subclasses must override these functions 39 //------------------------------------------------------------------ 40 virtual void 41 InvalidateAllRegisters () = 0; 42 43 virtual size_t 44 GetRegisterCount () = 0; 45 46 virtual const RegisterInfo * 47 GetRegisterInfoAtIndex (uint32_t reg) = 0; 48 49 virtual size_t 50 GetRegisterSetCount () = 0; 51 52 virtual const RegisterSet * 53 GetRegisterSet (uint32_t reg_set) = 0; 54 55 virtual bool 56 ReadRegister (const RegisterInfo *reg_info, RegisterValue ®_value) = 0; 57 58 virtual bool 59 WriteRegister (const RegisterInfo *reg_info, const RegisterValue ®_value) = 0; 60 61 virtual bool 62 ReadAllRegisterValues (lldb::DataBufferSP &data_sp) = 0; 63 64 virtual bool 65 WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) = 0; 66 67 virtual uint32_t 68 ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) = 0; 69 70 //------------------------------------------------------------------ 71 // Subclasses can override these functions if desired 72 //------------------------------------------------------------------ 73 virtual uint32_t 74 NumSupportedHardwareBreakpoints (); 75 76 virtual uint32_t 77 SetHardwareBreakpoint (lldb::addr_t addr, size_t size); 78 79 virtual bool 80 ClearHardwareBreakpoint (uint32_t hw_idx); 81 82 virtual uint32_t 83 NumSupportedHardwareWatchpoints (); 84 85 virtual uint32_t 86 SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write); 87 88 virtual bool 89 ClearHardwareWatchpoint (uint32_t hw_index); 90 91 virtual bool 92 HardwareSingleStep (bool enable); 93 94 virtual Error 95 ReadRegisterValueFromMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue ®_value); 96 97 virtual Error 98 WriteRegisterValueToMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue ®_value); 99 100 //------------------------------------------------------------------ 101 // Subclasses should not override these 102 //------------------------------------------------------------------ 103 lldb::tid_t 104 GetThreadID() const; 105 106 Thread & 107 GetThread () 108 { 109 return m_thread; 110 } 111 112 const RegisterInfo * 113 GetRegisterInfoByName (const char *reg_name, uint32_t start_idx = 0); 114 115 uint64_t 116 GetPC (uint64_t fail_value = LLDB_INVALID_ADDRESS); 117 118 bool 119 SetPC (uint64_t pc); 120 121 uint64_t 122 GetSP (uint64_t fail_value = LLDB_INVALID_ADDRESS); 123 124 bool 125 SetSP (uint64_t sp); 126 127 uint64_t 128 GetFP (uint64_t fail_value = LLDB_INVALID_ADDRESS); 129 130 bool 131 SetFP (uint64_t fp); 132 133 const char * 134 GetRegisterName (uint32_t reg); 135 136 uint64_t 137 GetReturnAddress (uint64_t fail_value = LLDB_INVALID_ADDRESS); 138 139 uint64_t 140 GetFlags (uint64_t fail_value = 0); 141 142 uint64_t 143 ReadRegisterAsUnsigned (uint32_t reg, uint64_t fail_value); 144 145 bool 146 WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval); 147 148 bool 149 ConvertBetweenRegisterKinds (int source_rk, uint32_t source_regnum, int target_rk, uint32_t& target_regnum); 150 151 //------------------------------------------------------------------ 152 // lldb::ExecutionContextScope pure virtual functions 153 //------------------------------------------------------------------ 154 virtual Target * 155 CalculateTarget (); 156 157 virtual Process * 158 CalculateProcess (); 159 160 virtual Thread * 161 CalculateThread (); 162 163 virtual StackFrame * 164 CalculateStackFrame (); 165 166 virtual void 167 CalculateExecutionContext (ExecutionContext &exe_ctx); 168 169 uint32_t 170 GetStopID () const 171 { 172 return m_stop_id; 173 } 174 175 void 176 SetStopID (uint32_t stop_id) 177 { 178 m_stop_id = stop_id; 179 } 180 181protected: 182 //------------------------------------------------------------------ 183 // Classes that inherit from RegisterContext can see and modify these 184 //------------------------------------------------------------------ 185 Thread &m_thread; // The thread that this register context belongs to. 186 uint32_t m_concrete_frame_idx; // The concrete frame index for this register context 187 uint32_t m_stop_id; // The stop ID that any data in this context is valid for 188private: 189 //------------------------------------------------------------------ 190 // For RegisterContext only 191 //------------------------------------------------------------------ 192 DISALLOW_COPY_AND_ASSIGN (RegisterContext); 193}; 194 195} // namespace lldb_private 196 197#endif // liblldb_RegisterContext_h_ 198