1 //===-- NativeRegisterContextNetBSD_x86_64.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 #if defined(__i386__) || defined(__x86_64__) 10 11 #ifndef lldb_NativeRegisterContextNetBSD_x86_64_h 12 #define lldb_NativeRegisterContextNetBSD_x86_64_h 13 14 // clang-format off 15 #include <sys/param.h> 16 #include <sys/types.h> 17 #include <sys/ptrace.h> 18 #include <machine/reg.h> 19 // clang-format on 20 21 #include <array> 22 #include <optional> 23 24 #include "Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h" 25 #include "Plugins/Process/Utility/RegisterContext_x86.h" 26 #include "Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h" 27 #include "Plugins/Process/Utility/lldb-x86-register-enums.h" 28 29 namespace lldb_private { 30 namespace process_netbsd { 31 32 class NativeProcessNetBSD; 33 34 class NativeRegisterContextNetBSD_x86_64 35 : public NativeRegisterContextNetBSD, 36 public NativeRegisterContextDBReg_x86 { 37 public: 38 NativeRegisterContextNetBSD_x86_64(const ArchSpec &target_arch, 39 NativeThreadProtocol &native_thread); 40 uint32_t GetRegisterSetCount() const override; 41 42 const RegisterSet *GetRegisterSet(uint32_t set_index) const override; 43 44 Status ReadRegister(const RegisterInfo *reg_info, 45 RegisterValue ®_value) override; 46 47 Status WriteRegister(const RegisterInfo *reg_info, 48 const RegisterValue ®_value) override; 49 50 Status ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override; 51 52 Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; 53 54 llvm::Error 55 CopyHardwareWatchpointsFrom(NativeRegisterContextNetBSD &source) override; 56 57 private: 58 // Private member types. 59 enum RegSetKind { 60 GPRegSet, 61 FPRegSet, 62 DBRegSet, 63 MaxRegularRegSet = DBRegSet, 64 YMMRegSet, 65 MPXRegSet, 66 MaxRegSet = MPXRegSet, 67 }; 68 69 // Private member variables. 70 std::array<uint8_t, sizeof(struct reg)> m_gpr; 71 std::array<uint8_t, sizeof(struct xstate)> m_xstate; 72 std::array<uint8_t, sizeof(struct dbreg)> m_dbr; 73 std::array<size_t, MaxRegularRegSet + 1> m_regset_offsets; 74 75 std::optional<RegSetKind> GetSetForNativeRegNum(uint32_t reg_num) const; 76 77 Status ReadRegisterSet(RegSetKind set); 78 Status WriteRegisterSet(RegSetKind set); 79 80 uint8_t *GetOffsetRegSetData(RegSetKind set, size_t reg_offset); 81 82 struct YMMSplitPtr { 83 void *xmm; 84 void *ymm_hi; 85 }; 86 std::optional<YMMSplitPtr> GetYMMSplitReg(uint32_t reg); 87 }; 88 89 } // namespace process_netbsd 90 } // namespace lldb_private 91 92 #endif // #ifndef lldb_NativeRegisterContextNetBSD_x86_64_h 93 94 #endif // defined(__x86_64__) 95