| 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 "RegisterInfos_x86_64_with_base_shared.h" |
| 15 | #include "lldb-x86-register-enums.h" |
| 16 | #include "lldb/Target/RegisterContext.h" |
| 17 | #include "lldb/Utility/Log.h" |
| 18 | |
| 19 | class RegisterContextPOSIX_x86 : public lldb_private::RegisterContext { |
| 20 | public: |
| 21 | RegisterContextPOSIX_x86(lldb_private::Thread &thread, |
| 22 | uint32_t concrete_frame_idx, |
| 23 | lldb_private::RegisterInfoInterface *register_info); |
| 24 | |
| 25 | ~RegisterContextPOSIX_x86() override; |
| 26 | |
| 27 | void Invalidate(); |
| 28 | |
| 29 | void InvalidateAllRegisters() override; |
| 30 | |
| 31 | size_t GetRegisterCount() override; |
| 32 | |
| 33 | virtual size_t GetGPRSize(); |
| 34 | |
| 35 | virtual size_t GetFXSAVEOffset(); |
| 36 | |
| 37 | virtual unsigned GetRegisterSize(unsigned reg); |
| 38 | |
| 39 | virtual unsigned GetRegisterOffset(unsigned reg); |
| 40 | |
| 41 | const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; |
| 42 | |
| 43 | size_t GetRegisterSetCount() override; |
| 44 | |
| 45 | const lldb_private::RegisterSet *GetRegisterSet(size_t set) override; |
| 46 | |
| 47 | const char *GetRegisterName(unsigned reg); |
| 48 | |
| 49 | // Note: prefer kernel definitions over user-land |
| 50 | enum FPRType { |
| 51 | eNotValid = 0, |
| 52 | eFSAVE, // TODO |
| 53 | eFXSAVE, |
| 54 | eSOFT, // TODO |
| 55 | eXSAVE |
| 56 | }; |
| 57 | |
| 58 | static uint32_t g_contained_eax[]; |
| 59 | static uint32_t g_contained_ebx[]; |
| 60 | static uint32_t g_contained_ecx[]; |
| 61 | static uint32_t g_contained_edx[]; |
| 62 | static uint32_t g_contained_edi[]; |
| 63 | static uint32_t g_contained_esi[]; |
| 64 | static uint32_t g_contained_ebp[]; |
| 65 | static uint32_t g_contained_esp[]; |
| 66 | |
| 67 | static uint32_t g_invalidate_eax[]; |
| 68 | static uint32_t g_invalidate_ebx[]; |
| 69 | static uint32_t g_invalidate_ecx[]; |
| 70 | static uint32_t g_invalidate_edx[]; |
| 71 | static uint32_t g_invalidate_edi[]; |
| 72 | static uint32_t g_invalidate_esi[]; |
| 73 | static uint32_t g_invalidate_ebp[]; |
| 74 | static uint32_t g_invalidate_esp[]; |
| 75 | |
| 76 | static uint32_t g_contained_rax[]; |
| 77 | static uint32_t g_contained_rbx[]; |
| 78 | static uint32_t g_contained_rcx[]; |
| 79 | static uint32_t g_contained_rdx[]; |
| 80 | static uint32_t g_contained_rdi[]; |
| 81 | static uint32_t g_contained_rsi[]; |
| 82 | static uint32_t g_contained_rbp[]; |
| 83 | static uint32_t g_contained_rsp[]; |
| 84 | static uint32_t g_contained_r8[]; |
| 85 | static uint32_t g_contained_r9[]; |
| 86 | static uint32_t g_contained_r10[]; |
| 87 | static uint32_t g_contained_r11[]; |
| 88 | static uint32_t g_contained_r12[]; |
| 89 | static uint32_t g_contained_r13[]; |
| 90 | static uint32_t g_contained_r14[]; |
| 91 | static uint32_t g_contained_r15[]; |
| 92 | |
| 93 | static uint32_t g_invalidate_rax[]; |
| 94 | static uint32_t g_invalidate_rbx[]; |
| 95 | static uint32_t g_invalidate_rcx[]; |
| 96 | static uint32_t g_invalidate_rdx[]; |
| 97 | static uint32_t g_invalidate_rdi[]; |
| 98 | static uint32_t g_invalidate_rsi[]; |
| 99 | static uint32_t g_invalidate_rbp[]; |
| 100 | static uint32_t g_invalidate_rsp[]; |
| 101 | static uint32_t g_invalidate_r8[]; |
| 102 | static uint32_t g_invalidate_r9[]; |
| 103 | static uint32_t g_invalidate_r10[]; |
| 104 | static uint32_t g_invalidate_r11[]; |
| 105 | static uint32_t g_invalidate_r12[]; |
| 106 | static uint32_t g_invalidate_r13[]; |
| 107 | static uint32_t g_invalidate_r14[]; |
| 108 | static uint32_t g_invalidate_r15[]; |
| 109 | |
| 110 | static uint32_t g_contained_fip[]; |
| 111 | static uint32_t g_contained_fdp[]; |
| 112 | |
| 113 | static uint32_t g_invalidate_fip[]; |
| 114 | static uint32_t g_invalidate_fdp[]; |
| 115 | |
| 116 | static uint32_t g_contained_st0_32[]; |
| 117 | static uint32_t g_contained_st1_32[]; |
| 118 | static uint32_t g_contained_st2_32[]; |
| 119 | static uint32_t g_contained_st3_32[]; |
| 120 | static uint32_t g_contained_st4_32[]; |
| 121 | static uint32_t g_contained_st5_32[]; |
| 122 | static uint32_t g_contained_st6_32[]; |
| 123 | static uint32_t g_contained_st7_32[]; |
| 124 | |
| 125 | static uint32_t g_invalidate_st0_32[]; |
| 126 | static uint32_t g_invalidate_st1_32[]; |
| 127 | static uint32_t g_invalidate_st2_32[]; |
| 128 | static uint32_t g_invalidate_st3_32[]; |
| 129 | static uint32_t g_invalidate_st4_32[]; |
| 130 | static uint32_t g_invalidate_st5_32[]; |
| 131 | static uint32_t g_invalidate_st6_32[]; |
| 132 | static uint32_t g_invalidate_st7_32[]; |
| 133 | |
| 134 | static uint32_t g_contained_st0_64[]; |
| 135 | static uint32_t g_contained_st1_64[]; |
| 136 | static uint32_t g_contained_st2_64[]; |
| 137 | static uint32_t g_contained_st3_64[]; |
| 138 | static uint32_t g_contained_st4_64[]; |
| 139 | static uint32_t g_contained_st5_64[]; |
| 140 | static uint32_t g_contained_st6_64[]; |
| 141 | static uint32_t g_contained_st7_64[]; |
| 142 | |
| 143 | static uint32_t g_invalidate_st0_64[]; |
| 144 | static uint32_t g_invalidate_st1_64[]; |
| 145 | static uint32_t g_invalidate_st2_64[]; |
| 146 | static uint32_t g_invalidate_st3_64[]; |
| 147 | static uint32_t g_invalidate_st4_64[]; |
| 148 | static uint32_t g_invalidate_st5_64[]; |
| 149 | static uint32_t g_invalidate_st6_64[]; |
| 150 | static uint32_t g_invalidate_st7_64[]; |
| 151 | |
| 152 | protected: |
| 153 | FPRType |
| 154 | m_fpr_type; // determines the type of data stored by union FPR, if any. |
| 155 | lldb_private::FPR m_fpr; // floating-point registers including extended |
| 156 | // register sets. |
| 157 | lldb_private::YMM m_ymm_set; // copy of ymmh and xmm register halves. |
| 158 | std::unique_ptr<lldb_private::RegisterInfoInterface> |
| 159 | m_register_info_up; // Register Info Interface (FreeBSD or Linux) |
| 160 | |
| 161 | // Determines if an extended register set is supported on the processor |
| 162 | // running the inferior process. |
| 163 | virtual bool IsRegisterSetAvailable(size_t set_index); |
| 164 | |
| 165 | virtual const lldb_private::RegisterInfo *GetRegisterInfo(); |
| 166 | |
| 167 | bool IsGPR(unsigned reg); |
| 168 | |
| 169 | bool IsFPR(unsigned reg); |
| 170 | |
| 171 | bool IsAVX(unsigned reg); |
| 172 | |
| 173 | bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order); |
| 174 | bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order); |
| 175 | bool IsFPR(unsigned reg, FPRType fpr_type); |
| 176 | FPRType GetFPRType(); |
| 177 | |
| 178 | virtual bool ReadGPR() = 0; |
| 179 | virtual bool ReadFPR() = 0; |
| 180 | virtual bool WriteGPR() = 0; |
| 181 | virtual bool WriteFPR() = 0; |
| 182 | virtual lldb_private::RegInfo &GetRegInfo(); |
| 183 | }; |
| 184 | |
| 185 | #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_X86_H |
| 186 | |