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