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 "Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h"
22 #include "Plugins/Process/Utility/RegisterContext_x86.h"
23 #include "Plugins/Process/Utility/NativeRegisterContextWatchpoint_x86.h"
24 #include "Plugins/Process/Utility/lldb-x86-register-enums.h"
25 
26 namespace lldb_private {
27 namespace process_netbsd {
28 
29 class NativeProcessNetBSD;
30 
31 class NativeRegisterContextNetBSD_x86_64
32     : public NativeRegisterContextNetBSD,
33       public NativeRegisterContextWatchpoint_x86 {
34 public:
35   NativeRegisterContextNetBSD_x86_64(const ArchSpec &target_arch,
36                                      NativeThreadProtocol &native_thread);
37   uint32_t GetRegisterSetCount() const override;
38 
39   const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
40 
41   Status ReadRegister(const RegisterInfo *reg_info,
42                       RegisterValue &reg_value) override;
43 
44   Status WriteRegister(const RegisterInfo *reg_info,
45                        const RegisterValue &reg_value) override;
46 
47   Status ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
48 
49   Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
50 
51   llvm::Error
52   CopyHardwareWatchpointsFrom(NativeRegisterContextNetBSD &source) override;
53 
54 private:
55   // Private member types.
56   enum { GPRegSet, XStateRegSet, DBRegSet };
57 
58   // Private member variables.
59   struct reg m_gpr;
60   struct xstate m_xstate;
61   struct dbreg m_dbr;
62 
63   int GetSetForNativeRegNum(int reg_num) const;
64   int GetDR(int num) const;
65 
66   Status ReadRegisterSet(uint32_t set);
67   Status WriteRegisterSet(uint32_t set);
68 };
69 
70 } // namespace process_netbsd
71 } // namespace lldb_private
72 
73 #endif // #ifndef lldb_NativeRegisterContextNetBSD_x86_64_h
74 
75 #endif // defined(__x86_64__)
76