1 //===-- NativeRegisterContextNetBSD_x86_64.h --------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #if defined(__x86_64__)
11 
12 #ifndef lldb_NativeRegisterContextNetBSD_x86_64_h
13 #define lldb_NativeRegisterContextNetBSD_x86_64_h
14 
15 // clang-format off
16 #include <sys/param.h>
17 #include <sys/types.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/lldb-x86-register-enums.h"
24 
25 namespace lldb_private {
26 namespace process_netbsd {
27 
28 class NativeProcessNetBSD;
29 
30 class NativeRegisterContextNetBSD_x86_64 : public NativeRegisterContextNetBSD {
31 public:
32   NativeRegisterContextNetBSD_x86_64(const ArchSpec &target_arch,
33                                      NativeThreadProtocol &native_thread,
34                                      uint32_t concrete_frame_idx);
35   uint32_t GetRegisterSetCount() const override;
36 
37   const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
38 
39   Status ReadRegister(const RegisterInfo *reg_info,
40                       RegisterValue &reg_value) override;
41 
42   Status WriteRegister(const RegisterInfo *reg_info,
43                        const RegisterValue &reg_value) override;
44 
45   Status ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
46 
47   Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
48 
49   Status IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
50 
51   Status GetWatchpointHitIndex(uint32_t &wp_index,
52                                lldb::addr_t trap_addr) override;
53 
54   Status IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override;
55 
56   bool ClearHardwareWatchpoint(uint32_t wp_index) override;
57 
58   Status ClearAllHardwareWatchpoints() override;
59 
60   Status SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size,
61                                         uint32_t watch_flags,
62                                         uint32_t wp_index);
63 
64   uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
65                                  uint32_t watch_flags) override;
66 
67   lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
68 
69   uint32_t NumSupportedHardwareWatchpoints() override;
70 
71 protected:
72   void *GetGPRBuffer() override { return &m_gpr_x86_64; }
73   void *GetFPRBuffer() override { return &m_fpr_x86_64; }
74   void *GetDBRBuffer() override { return &m_dbr_x86_64; }
75 
76 private:
77   // Private member types.
78   enum { GPRegSet, FPRegSet, DBRegSet };
79 
80   // Private member variables.
81   struct reg m_gpr_x86_64;
82   struct fpreg m_fpr_x86_64;
83   struct dbreg m_dbr_x86_64;
84 
85   int GetSetForNativeRegNum(int reg_num) const;
86 
87   int ReadRegisterSet(uint32_t set);
88   int WriteRegisterSet(uint32_t set);
89 };
90 
91 } // namespace process_netbsd
92 } // namespace lldb_private
93 
94 #endif // #ifndef lldb_NativeRegisterContextNetBSD_x86_64_h
95 
96 #endif // defined(__x86_64__)
97