RegisterContext.h revision 8280cbe80c79bc206335831dd732e0f9fb69c519
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, StackFrame *frame); 30 31 RegisterContext (Thread &thread); 32 33 virtual 34 ~RegisterContext (); 35 36 //------------------------------------------------------------------ 37 // Subclasses must override these functions 38 //------------------------------------------------------------------ 39 virtual void 40 Invalidate () = 0; 41 42 virtual size_t 43 GetRegisterCount () = 0; 44 45 virtual const lldb::RegisterInfo * 46 GetRegisterInfoAtIndex (uint32_t reg) = 0; 47 48 virtual size_t 49 GetRegisterSetCount () = 0; 50 51 virtual const lldb::RegisterSet * 52 GetRegisterSet (uint32_t reg_set) = 0; 53 54 virtual bool 55 ReadRegisterBytes (uint32_t reg, DataExtractor &data) = 0; 56 57 virtual bool 58 ReadAllRegisterValues (lldb::DataBufferSP &data_sp) = 0; 59 60 virtual bool 61 WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset = 0) = 0; 62 63 virtual bool 64 WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) = 0; 65 66 virtual uint32_t 67 ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) = 0; 68 69 //------------------------------------------------------------------ 70 // Subclasses can override these functions if desired 71 //------------------------------------------------------------------ 72 virtual bool 73 ReadRegisterValue (uint32_t reg, Scalar &value); 74 75 virtual bool 76 WriteRegisterValue (uint32_t reg, const Scalar &value); 77 78 virtual uint32_t 79 NumSupportedHardwareBreakpoints (); 80 81 virtual uint32_t 82 SetHardwareBreakpoint (lldb::addr_t addr, size_t size); 83 84 virtual bool 85 ClearHardwareBreakpoint (uint32_t hw_idx); 86 87 virtual uint32_t 88 NumSupportedHardwareWatchpoints (); 89 90 virtual uint32_t 91 SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write); 92 93 virtual bool 94 ClearHardwareWatchpoint (uint32_t hw_index); 95 96 virtual bool 97 HardwareSingleStep (bool enable); 98 99 //------------------------------------------------------------------ 100 // Subclasses should not override these 101 //------------------------------------------------------------------ 102 lldb::tid_t 103 GetThreadID() const; 104 105 Thread & 106 GetThread () 107 { 108 return m_thread; 109 } 110 111 const lldb::RegisterInfo * 112 GetRegisterInfoByName (const char *reg_name, uint32_t start_idx = 0); 113 114 uint64_t 115 GetPC (uint64_t fail_value = LLDB_INVALID_ADDRESS); 116 117 bool 118 SetPC (uint64_t pc); 119 120 uint64_t 121 GetSP (uint64_t fail_value = LLDB_INVALID_ADDRESS); 122 123 bool 124 SetSP (uint64_t sp); 125 126 uint64_t 127 GetFP (uint64_t fail_value = LLDB_INVALID_ADDRESS); 128 129 bool 130 SetFP (uint64_t fp); 131 132 const char * 133 GetRegisterName (uint32_t reg); 134 135 uint64_t 136 GetReturnAddress (uint64_t fail_value = LLDB_INVALID_ADDRESS); 137 138 uint64_t 139 GetFlags (uint64_t fail_value = 0); 140 141 uint64_t 142 ReadRegisterAsUnsigned (uint32_t reg, uint64_t fail_value); 143 144 bool 145 WriteRegisterFromUnsigned (uint32_t reg, uint64_t uval); 146 147 bool 148 ConvertBetweenRegisterKinds (int source_rk, uint32_t source_regnum, int target_rk, uint32_t& target_regnum); 149 150 void 151 SetStackFrame (StackFrame *frame); 152 153 //------------------------------------------------------------------ 154 // lldb::ExecutionContextScope pure virtual functions 155 //------------------------------------------------------------------ 156 virtual Target * 157 CalculateTarget (); 158 159 virtual Process * 160 CalculateProcess (); 161 162 virtual Thread * 163 CalculateThread (); 164 165 virtual StackFrame * 166 CalculateStackFrame (); 167 168 virtual void 169 CalculateExecutionContext (ExecutionContext &exe_ctx); 170 171protected: 172 //------------------------------------------------------------------ 173 // Classes that inherit from RegisterContext can see and modify these 174 //------------------------------------------------------------------ 175 Thread &m_thread; // The thread that this register context belongs to. 176 StackFrame *m_frame; // The stack frame for this context, or NULL if this is the root context 177private: 178 //------------------------------------------------------------------ 179 // For RegisterContext only 180 //------------------------------------------------------------------ 181 DISALLOW_COPY_AND_ASSIGN (RegisterContext); 182}; 183 184} // namespace lldb_private 185 186#endif // liblldb_RegisterContext_h_ 187