1 //===-- NativeRegisterContextLinux_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 
11 #ifndef lldb_NativeRegisterContextLinux_x86_64_h
12 #define lldb_NativeRegisterContextLinux_x86_64_h
13 
14 #include "lldb/Target/NativeRegisterContextRegisterInfo.h"
15 #include "Plugins/Process/Utility/RegisterContext_x86.h"
16 #include "Plugins/Process/Utility/lldb-x86-register-enums.h"
17 
18 namespace lldb_private
19 {
20     class NativeProcessLinux;
21 
22     class NativeRegisterContextLinux_x86_64 : public NativeRegisterContextRegisterInfo
23     {
24     public:
25         NativeRegisterContextLinux_x86_64 (NativeThreadProtocol &native_thread, uint32_t concrete_frame_idx, RegisterInfoInterface *reg_info_interface_p);
26 
27         uint32_t
28         GetRegisterSetCount () const override;
29 
30         const RegisterSet *
31         GetRegisterSet (uint32_t set_index) const override;
32 
33         Error
34         ReadRegister (const RegisterInfo *reg_info, RegisterValue &reg_value) override;
35 
36         Error
37         WriteRegister (const RegisterInfo *reg_info, const RegisterValue &reg_value) override;
38 
39         Error
40         ReadAllRegisterValues (lldb::DataBufferSP &data_sp) override;
41 
42         Error
43         WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) override;
44 
45     private:
46 
47         // Private member types.
48         enum FPRType
49         {
50             eFPRTypeNotValid = 0,
51             eFPRTypeFXSAVE,
52             eFPRTypeXSAVE
53         };
54 
55         // Info about register ranges.
56         struct RegInfo
57         {
58             uint32_t num_registers;
59             uint32_t num_gpr_registers;
60             uint32_t num_fpr_registers;
61             uint32_t num_avx_registers;
62 
63             uint32_t last_gpr;
64             uint32_t first_fpr;
65             uint32_t last_fpr;
66 
67             uint32_t first_st;
68             uint32_t last_st;
69             uint32_t first_mm;
70             uint32_t last_mm;
71             uint32_t first_xmm;
72             uint32_t last_xmm;
73             uint32_t first_ymm;
74             uint32_t last_ymm;
75 
76             uint32_t first_dr;
77             uint32_t gpr_flags;
78         };
79 
80         // Private member variables.
81         mutable FPRType m_fpr_type;
82         FPR m_fpr;
83         IOVEC m_iovec;
84         YMM m_ymm_set;
85         RegInfo m_reg_info;
86         uint64_t m_gpr_x86_64[k_num_gpr_registers_x86_64];
87 
88         // Private member methods.
89         lldb_private::Error
90         WriteRegister(const uint32_t reg, const RegisterValue &value);
91 
92         bool IsRegisterSetAvailable (uint32_t set_index) const;
93 
94         lldb::ByteOrder
95         GetByteOrder() const;
96 
97         bool
98         IsGPR(uint32_t reg_index) const;
99 
100         FPRType
101         GetFPRType () const;
102 
103         bool
104         IsFPR(uint32_t reg_index) const;
105 
106         bool
107         WriteFPR();
108 
109         bool IsFPR(uint32_t reg_index, FPRType fpr_type) const;
110 
111         bool
112         CopyXSTATEtoYMM (uint32_t reg_index, lldb::ByteOrder byte_order);
113 
114         bool
115         CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order);
116 
117         bool
118         IsAVX (uint32_t reg_index) const;
119 
120         bool
121         ReadFPR ();
122 
123         lldb_private::Error
124         ReadRegisterRaw (uint32_t reg_index, RegisterValue &reg_value);
125 
126         bool
127         ReadGPR();
128 
129         bool
130         WriteGPR();
131     };
132 }
133 
134 #endif // #ifndef lldb_NativeRegisterContextLinux_x86_64_h
135 
136