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