1d409305fSDimitry Andric //===-- NativeRegisterContextFreeBSD_arm64.h --------------------*- C++ -*-===//
2d409305fSDimitry Andric //
3d409305fSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4d409305fSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5d409305fSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d409305fSDimitry Andric //
7d409305fSDimitry Andric //===----------------------------------------------------------------------===//
8d409305fSDimitry Andric 
9d409305fSDimitry Andric #if defined(__aarch64__)
10d409305fSDimitry Andric 
11d409305fSDimitry Andric #ifndef lldb_NativeRegisterContextFreeBSD_arm64_h
12d409305fSDimitry Andric #define lldb_NativeRegisterContextFreeBSD_arm64_h
13d409305fSDimitry Andric 
14d409305fSDimitry Andric // clang-format off
15d409305fSDimitry Andric #include <sys/types.h>
16d409305fSDimitry Andric #include <sys/param.h>
17d409305fSDimitry Andric #include <machine/reg.h>
18d409305fSDimitry Andric // clang-format on
19d409305fSDimitry Andric 
20d409305fSDimitry Andric #include "Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h"
21d409305fSDimitry Andric #include "Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h"
22d409305fSDimitry Andric #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
23d409305fSDimitry Andric 
24d409305fSDimitry Andric #include <array>
25d409305fSDimitry Andric 
26d409305fSDimitry Andric #if __FreeBSD_version >= 1300139
27d409305fSDimitry Andric #  define LLDB_HAS_FREEBSD_WATCHPOINT 1
28d409305fSDimitry Andric #endif
29d409305fSDimitry Andric 
30d409305fSDimitry Andric namespace lldb_private {
31d409305fSDimitry Andric namespace process_freebsd {
32d409305fSDimitry Andric 
33d409305fSDimitry Andric class NativeProcessFreeBSD;
34d409305fSDimitry Andric 
35d409305fSDimitry Andric class NativeRegisterContextFreeBSD_arm64
36d409305fSDimitry Andric     : public NativeRegisterContextFreeBSD,
37d409305fSDimitry Andric       public NativeRegisterContextDBReg_arm64 {
38d409305fSDimitry Andric public:
39d409305fSDimitry Andric   NativeRegisterContextFreeBSD_arm64(const ArchSpec &target_arch,
40*0fca6ea1SDimitry Andric                                      NativeThreadFreeBSD &native_thread);
41d409305fSDimitry Andric 
42d409305fSDimitry Andric   uint32_t GetRegisterSetCount() const override;
43d409305fSDimitry Andric 
44d409305fSDimitry Andric   uint32_t GetUserRegisterCount() const override;
45d409305fSDimitry Andric 
46d409305fSDimitry Andric   const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
47d409305fSDimitry Andric 
48d409305fSDimitry Andric   Status ReadRegister(const RegisterInfo *reg_info,
49d409305fSDimitry Andric                       RegisterValue &reg_value) override;
50d409305fSDimitry Andric 
51d409305fSDimitry Andric   Status WriteRegister(const RegisterInfo *reg_info,
52d409305fSDimitry Andric                        const RegisterValue &reg_value) override;
53d409305fSDimitry Andric 
5481ad6265SDimitry Andric   Status ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override;
55d409305fSDimitry Andric 
56d409305fSDimitry Andric   Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
57d409305fSDimitry Andric 
58d409305fSDimitry Andric   llvm::Error
59d409305fSDimitry Andric   CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD &source) override;
60d409305fSDimitry Andric 
61d409305fSDimitry Andric private:
62d409305fSDimitry Andric   // Due to alignment, FreeBSD reg/fpreg are a few bytes larger than
63d409305fSDimitry Andric   // LLDB's GPR/FPU structs.  However, all fields have matching offsets
64d409305fSDimitry Andric   // and sizes, so we do not have to worry about these (and we have
65d409305fSDimitry Andric   // a unittest to assert that).
66d409305fSDimitry Andric   std::array<uint8_t, sizeof(reg) + sizeof(fpreg)> m_reg_data;
67d409305fSDimitry Andric #ifdef LLDB_HAS_FREEBSD_WATCHPOINT
68d409305fSDimitry Andric   dbreg m_dbreg;
69d409305fSDimitry Andric   bool m_read_dbreg;
70d409305fSDimitry Andric #endif
71d409305fSDimitry Andric 
72d409305fSDimitry Andric   Status ReadRegisterSet(uint32_t set);
73d409305fSDimitry Andric   Status WriteRegisterSet(uint32_t set);
74d409305fSDimitry Andric 
75d409305fSDimitry Andric   llvm::Error ReadHardwareDebugInfo() override;
76d409305fSDimitry Andric   llvm::Error WriteHardwareDebugRegs(DREGType hwbType) override;
77d409305fSDimitry Andric 
78d409305fSDimitry Andric   RegisterInfoPOSIX_arm64 &GetRegisterInfo() const;
79d409305fSDimitry Andric };
80d409305fSDimitry Andric 
81d409305fSDimitry Andric } // namespace process_freebsd
82d409305fSDimitry Andric } // namespace lldb_private
83d409305fSDimitry Andric 
84d409305fSDimitry Andric #endif // #ifndef lldb_NativeRegisterContextFreeBSD_arm64_h
85d409305fSDimitry Andric 
86d409305fSDimitry Andric #endif // defined (__aarch64__)
87