1 //===-- NativeRegisterContextLinux_s390x.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(__s390x__) && defined(__linux__)
11 
12 #ifndef lldb_NativeRegisterContextLinux_s390x_h
13 #define lldb_NativeRegisterContextLinux_s390x_h
14 
15 #include "Plugins/Process/Linux/NativeRegisterContextLinux.h"
16 #include "Plugins/Process/Utility/RegisterContext_s390x.h"
17 #include "Plugins/Process/Utility/lldb-s390x-register-enums.h"
18 
19 namespace lldb_private {
20 namespace process_linux {
21 
22 class NativeProcessLinux;
23 
24 class NativeRegisterContextLinux_s390x : public NativeRegisterContextLinux {
25 public:
26   NativeRegisterContextLinux_s390x(const ArchSpec &target_arch,
27                                    NativeThreadProtocol &native_thread,
28                                    uint32_t concrete_frame_idx);
29 
30   uint32_t GetRegisterSetCount() const override;
31 
32   const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
33 
34   uint32_t GetUserRegisterCount() const override;
35 
36   Error ReadRegister(const RegisterInfo *reg_info,
37                      RegisterValue &reg_value) override;
38 
39   Error WriteRegister(const RegisterInfo *reg_info,
40                       const RegisterValue &reg_value) override;
41 
42   Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
43 
44   Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
45 
46   Error IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
47 
48   Error GetWatchpointHitIndex(uint32_t &wp_index,
49                               lldb::addr_t trap_addr) override;
50 
51   Error IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override;
52 
53   bool ClearHardwareWatchpoint(uint32_t wp_index) override;
54 
55   Error ClearAllHardwareWatchpoints() override;
56 
57   uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
58                                  uint32_t watch_flags) override;
59 
60   lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
61 
62   uint32_t NumSupportedHardwareWatchpoints() override;
63 
64 protected:
65   Error DoReadRegisterValue(uint32_t offset, const char *reg_name,
66                             uint32_t size, RegisterValue &value) override;
67 
68   Error DoWriteRegisterValue(uint32_t offset, const char *reg_name,
69                              const RegisterValue &value) override;
70 
71   Error DoReadGPR(void *buf, size_t buf_size) override;
72 
73   Error DoWriteGPR(void *buf, size_t buf_size) override;
74 
75   Error DoReadFPR(void *buf, size_t buf_size) override;
76 
77   Error DoWriteFPR(void *buf, size_t buf_size) override;
78 
79 private:
80   // Info about register ranges.
81   struct RegInfo {
82     uint32_t num_registers;
83     uint32_t num_gpr_registers;
84     uint32_t num_fpr_registers;
85 
86     uint32_t last_gpr;
87     uint32_t first_fpr;
88     uint32_t last_fpr;
89   };
90 
91   // Private member variables.
92   RegInfo m_reg_info;
93   lldb::addr_t m_watchpoint_addr;
94 
95   // Private member methods.
96   bool IsRegisterSetAvailable(uint32_t set_index) const;
97 
98   bool IsGPR(uint32_t reg_index) const;
99 
100   bool IsFPR(uint32_t reg_index) const;
101 
102   Error PeekUserArea(uint32_t offset, void *buf, size_t buf_size);
103 
104   Error PokeUserArea(uint32_t offset, const void *buf, size_t buf_size);
105 
106   Error DoReadRegisterSet(uint32_t regset, void *buf, size_t buf_size);
107 
108   Error DoWriteRegisterSet(uint32_t regset, const void *buf, size_t buf_size);
109 };
110 
111 } // namespace process_linux
112 } // namespace lldb_private
113 
114 #endif // #ifndef lldb_NativeRegisterContextLinux_s390x_h
115 
116 #endif // defined(__s390x__) && defined(__linux__)
117