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