1 //===-- RegisterContextThreadMemory.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 lldb_RegisterContextThreadMemory_h_ 11 #define lldb_RegisterContextThreadMemory_h_ 12 13 #include <vector> 14 15 #include "lldb/lldb-private.h" 16 #include "lldb/Target/RegisterContext.h" 17 #include "lldb/Symbol/SymbolContext.h" 18 19 namespace lldb_private { 20 21 class RegisterContextThreadMemory : public lldb_private::RegisterContext 22 { 23 public: 24 RegisterContextThreadMemory (Thread &thread, 25 lldb::addr_t register_data_addr); 26 27 virtual ~RegisterContextThreadMemory(); 28 //------------------------------------------------------------------ 29 // Subclasses must override these functions 30 //------------------------------------------------------------------ 31 virtual void 32 InvalidateAllRegisters (); 33 34 virtual size_t 35 GetRegisterCount (); 36 37 virtual const RegisterInfo * 38 GetRegisterInfoAtIndex (size_t reg); 39 40 virtual size_t 41 GetRegisterSetCount (); 42 43 virtual const RegisterSet * 44 GetRegisterSet (size_t reg_set); 45 46 virtual bool 47 ReadRegister (const RegisterInfo *reg_info, RegisterValue ®_value); 48 49 virtual bool 50 WriteRegister (const RegisterInfo *reg_info, const RegisterValue ®_value); 51 52 // These two functions are used to implement "push" and "pop" of register states. They are used primarily 53 // for expression evaluation, where we need to push a new state (storing the old one in data_sp) and then 54 // restoring the original state by passing the data_sp we got from ReadAllRegisters to WriteAllRegisterValues. 55 // ReadAllRegisters will do what is necessary to return a coherent set of register values for this thread, which 56 // may mean e.g. interrupting a thread that is sitting in a kernel trap. That is a somewhat disruptive operation, 57 // so these API's should only be used when this behavior is needed. 58 59 virtual bool 60 ReadAllRegisterValues (lldb::DataBufferSP &data_sp); 61 62 virtual bool 63 WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); 64 65 bool 66 CopyFromRegisterContext (lldb::RegisterContextSP context); 67 68 virtual uint32_t 69 ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num); 70 71 //------------------------------------------------------------------ 72 // Subclasses can override these functions if desired 73 //------------------------------------------------------------------ 74 virtual uint32_t 75 NumSupportedHardwareBreakpoints (); 76 77 virtual uint32_t 78 SetHardwareBreakpoint (lldb::addr_t addr, size_t size); 79 80 virtual bool 81 ClearHardwareBreakpoint (uint32_t hw_idx); 82 83 virtual uint32_t 84 NumSupportedHardwareWatchpoints (); 85 86 virtual uint32_t 87 SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write); 88 89 virtual bool 90 ClearHardwareWatchpoint (uint32_t hw_index); 91 92 virtual bool 93 HardwareSingleStep (bool enable); 94 95 virtual Error 96 ReadRegisterValueFromMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue ®_value); 97 98 virtual Error 99 WriteRegisterValueToMemory (const lldb_private::RegisterInfo *reg_info, lldb::addr_t dst_addr, uint32_t dst_len, const RegisterValue ®_value); 100 101 protected: 102 void 103 UpdateRegisterContext (); 104 105 lldb::ThreadWP m_thread_wp; 106 lldb::RegisterContextSP m_reg_ctx_sp; 107 lldb::addr_t m_register_data_addr; 108 uint32_t m_stop_id; 109 private: 110 DISALLOW_COPY_AND_ASSIGN (RegisterContextThreadMemory); 111 }; 112 } // namespace lldb_private 113 114 #endif // lldb_RegisterContextThreadMemory_h_ 115