]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
Upgrade our copies of clang, llvm, lldb and compiler-rt to 3.8.0
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / RegisterContextPOSIX_x86.h
1 //===-- RegisterContextPOSIX_x86.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 #ifndef liblldb_RegisterContextPOSIX_x86_h_
11 #define liblldb_RegisterContextPOSIX_x86_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/Log.h"
18 #include "lldb/Target/RegisterContext.h"
19 #include "RegisterInfoInterface.h"
20 #include "RegisterContext_x86.h"
21 #include "lldb-x86-register-enums.h"
22
23 class ProcessMonitor;
24
25 class RegisterContextPOSIX_x86
26   : public lldb_private::RegisterContext
27 {
28 public:
29     RegisterContextPOSIX_x86 (lldb_private::Thread &thread,
30                             uint32_t concrete_frame_idx,
31                             lldb_private::RegisterInfoInterface *register_info);
32
33     ~RegisterContextPOSIX_x86() override;
34
35     void
36     Invalidate();
37
38     void
39     InvalidateAllRegisters() override;
40
41     size_t
42     GetRegisterCount() override;
43
44     virtual size_t
45     GetGPRSize();
46
47     virtual unsigned
48     GetRegisterSize(unsigned reg);
49
50     virtual unsigned
51     GetRegisterOffset(unsigned reg);
52
53     const lldb_private::RegisterInfo *
54     GetRegisterInfoAtIndex(size_t reg) override;
55
56     size_t
57     GetRegisterSetCount() override;
58
59     const lldb_private::RegisterSet *
60     GetRegisterSet(size_t set) override;
61
62     const char *
63     GetRegisterName(unsigned reg);
64
65     uint32_t
66     ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
67
68     //---------------------------------------------------------------------------
69     // Note: prefer kernel definitions over user-land
70     //---------------------------------------------------------------------------
71     enum FPRType
72     {
73         eNotValid = 0,
74         eFSAVE,  // TODO
75         eFXSAVE,
76         eSOFT,   // TODO
77         eXSAVE
78     };
79
80     static uint32_t g_contained_eax[];
81     static uint32_t g_contained_ebx[];
82     static uint32_t g_contained_ecx[];
83     static uint32_t g_contained_edx[];
84     static uint32_t g_contained_edi[];
85     static uint32_t g_contained_esi[];
86     static uint32_t g_contained_ebp[];
87     static uint32_t g_contained_esp[];
88
89     static uint32_t g_invalidate_eax[];
90     static uint32_t g_invalidate_ebx[];
91     static uint32_t g_invalidate_ecx[];
92     static uint32_t g_invalidate_edx[];
93     static uint32_t g_invalidate_edi[];
94     static uint32_t g_invalidate_esi[];
95     static uint32_t g_invalidate_ebp[];
96     static uint32_t g_invalidate_esp[];
97
98     static uint32_t g_contained_rax[];
99     static uint32_t g_contained_rbx[];
100     static uint32_t g_contained_rcx[];
101     static uint32_t g_contained_rdx[];
102     static uint32_t g_contained_rdi[];
103     static uint32_t g_contained_rsi[];
104     static uint32_t g_contained_rbp[];
105     static uint32_t g_contained_rsp[];
106     static uint32_t g_contained_r8[];
107     static uint32_t g_contained_r9[];
108     static uint32_t g_contained_r10[];
109     static uint32_t g_contained_r11[];
110     static uint32_t g_contained_r12[];
111     static uint32_t g_contained_r13[];
112     static uint32_t g_contained_r14[];
113     static uint32_t g_contained_r15[];
114
115     static uint32_t g_invalidate_rax[];
116     static uint32_t g_invalidate_rbx[];
117     static uint32_t g_invalidate_rcx[];
118     static uint32_t g_invalidate_rdx[];
119     static uint32_t g_invalidate_rdi[];
120     static uint32_t g_invalidate_rsi[];
121     static uint32_t g_invalidate_rbp[];
122     static uint32_t g_invalidate_rsp[];
123     static uint32_t g_invalidate_r8[];
124     static uint32_t g_invalidate_r9[];
125     static uint32_t g_invalidate_r10[];
126     static uint32_t g_invalidate_r11[];
127     static uint32_t g_invalidate_r12[];
128     static uint32_t g_invalidate_r13[];
129     static uint32_t g_invalidate_r14[];
130     static uint32_t g_invalidate_r15[];
131
132 protected:
133     struct RegInfo
134     {
135         uint32_t num_registers;
136         uint32_t num_gpr_registers;
137         uint32_t num_fpr_registers;
138         uint32_t num_avx_registers;
139
140         uint32_t last_gpr;
141         uint32_t first_fpr;
142         uint32_t last_fpr;
143
144         uint32_t first_st;
145         uint32_t last_st;
146         uint32_t first_mm;
147         uint32_t last_mm;
148         uint32_t first_xmm;
149         uint32_t last_xmm;
150         uint32_t first_ymm;
151         uint32_t last_ymm;
152
153         uint32_t first_dr;
154         uint32_t gpr_flags;
155     };
156
157     uint64_t m_gpr_x86_64[lldb_private::k_num_gpr_registers_x86_64];   // 64-bit general purpose registers.
158     RegInfo  m_reg_info;
159     FPRType  m_fpr_type;                                       // determines the type of data stored by union FPR, if any.
160     FPR      m_fpr;                                            // floating-point registers including extended register sets.
161     IOVEC    m_iovec;                                          // wrapper for xsave.
162     YMM      m_ymm_set;                                        // copy of ymmh and xmm register halves.
163     std::unique_ptr<lldb_private::RegisterInfoInterface> m_register_info_ap; // Register Info Interface (FreeBSD or Linux)
164
165     // Determines if an extended register set is supported on the processor running the inferior process.
166     virtual bool
167     IsRegisterSetAvailable(size_t set_index);
168
169     virtual const lldb_private::RegisterInfo *
170     GetRegisterInfo();
171
172     bool
173     IsGPR(unsigned reg);
174
175     bool
176     IsFPR(unsigned reg);
177
178     bool
179     IsAVX(unsigned reg);
180
181     lldb::ByteOrder GetByteOrder();
182
183     bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order);
184     bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order);
185     bool IsFPR(unsigned reg, FPRType fpr_type);
186     FPRType GetFPRType();
187
188     virtual bool ReadGPR() = 0;
189     virtual bool ReadFPR() = 0;
190     virtual bool WriteGPR() = 0;
191     virtual bool WriteFPR() = 0;
192 };
193
194 #endif // liblldb_RegisterContextPOSIX_x86_h_