1 //===-- NativeRegisterContextLinux.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_NativeRegisterContextLinux_h 10 #define lldb_NativeRegisterContextLinux_h 11 12 #include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h" 13 #include "lldb/Host/common/NativeThreadProtocol.h" 14 15 namespace lldb_private { 16 namespace process_linux { 17 18 class NativeRegisterContextLinux : public NativeRegisterContextRegisterInfo { 19 public: 20 NativeRegisterContextLinux(NativeThreadProtocol &native_thread, 21 RegisterInfoInterface *reg_info_interface_p); 22 23 // This function is implemented in the NativeRegisterContextLinux_* subclasses 24 // to create a new instance of the host specific NativeRegisterContextLinux. 25 // The implementations can't collide as only one NativeRegisterContextLinux_* 26 // variant should be compiled into the final executable. 27 static std::unique_ptr<NativeRegisterContextLinux> 28 CreateHostNativeRegisterContextLinux(const ArchSpec &target_arch, 29 NativeThreadProtocol &native_thread); 30 31 // Invalidates cached values in register context data structures InvalidateAllRegisters()32 virtual void InvalidateAllRegisters(){} 33 34 protected: 35 lldb::ByteOrder GetByteOrder() const; 36 37 virtual Status ReadRegisterRaw(uint32_t reg_index, RegisterValue ®_value); 38 39 virtual Status WriteRegisterRaw(uint32_t reg_index, 40 const RegisterValue ®_value); 41 42 virtual Status ReadRegisterSet(void *buf, size_t buf_size, 43 unsigned int regset); 44 45 virtual Status WriteRegisterSet(void *buf, size_t buf_size, 46 unsigned int regset); 47 48 virtual Status ReadGPR(); 49 50 virtual Status WriteGPR(); 51 52 virtual Status ReadFPR(); 53 54 virtual Status WriteFPR(); 55 56 virtual void *GetGPRBuffer() = 0; 57 GetGPRSize()58 virtual size_t GetGPRSize() { 59 return GetRegisterInfoInterface().GetGPRSize(); 60 } 61 62 virtual void *GetFPRBuffer() = 0; 63 64 virtual size_t GetFPRSize() = 0; 65 GetPtraceOffset(uint32_t reg_index)66 virtual uint32_t GetPtraceOffset(uint32_t reg_index) { 67 return GetRegisterInfoAtIndex(reg_index)->byte_offset; 68 } 69 70 // The Do*** functions are executed on the privileged thread and can perform 71 // ptrace 72 // operations directly. 73 virtual Status DoReadRegisterValue(uint32_t offset, const char *reg_name, 74 uint32_t size, RegisterValue &value); 75 76 virtual Status DoWriteRegisterValue(uint32_t offset, const char *reg_name, 77 const RegisterValue &value); 78 }; 79 80 } // namespace process_linux 81 } // namespace lldb_private 82 83 #endif // #ifndef lldb_NativeRegisterContextLinux_h 84