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