RegisterContext_x86_64.h revision c73fedb63ab170d711fb73d198451eb8db710e8d
12341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen//===-- RegisterContext_x86_64.h ---------------------------*- C++ -*-===// 22341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen// 32341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen// The LLVM Compiler Infrastructure 42341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen// 52341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen// This file is distributed under the University of Illinois Open Source 62341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen// License. See LICENSE.TXT for details. 72341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen// 82341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen//===----------------------------------------------------------------------===// 92341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 102341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen#ifndef liblldb_RegisterContext_x86_64_H_ 112341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen#define liblldb_RegisterContext_x86_64_H_ 122341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 132341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen#include "lldb/Core/Log.h" 142341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen#include "RegisterContextPOSIX.h" 152341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 162341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chenclass ProcessMonitor; 172341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 18dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi// Internal codes for all x86_64 registers. 19dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthienum 20dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi{ 21dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_first_gpr, 22dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rax = k_first_gpr, 23dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rbx, 24dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rcx, 25dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rdx, 26dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rdi, 27dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rsi, 28dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rbp, 29dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rsp, 30dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_r8, 31dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_r9, 32dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_r10, 33dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_r11, 34dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_r12, 35dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_r13, 36dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_r14, 37dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_r15, 38dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rip, 39dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_rflags, 40dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_cs, 41dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_fs, 42dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_gs, 43dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_ss, 44dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_ds, 45dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_es, 46dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_eax, 47dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_ebx, 48dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_ecx, 49dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_edx, 50dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_edi, 51dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_esi, 52dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_ebp, 53dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_esp, 54dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_eip, 55dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi gpr_eflags, 56dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_last_gpr = gpr_eflags, // eRegisterKindLLDB == 33 57dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi 58dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_first_fpr, 59dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_fcw = k_first_fpr, 60dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_fsw, 61dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ftw, 62dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_fop, 63dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ip, 64dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_cs, 65dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_dp, 66dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ds, 67dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_mxcsr, 68dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_mxcsrmask, 69dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_stmm0, 70dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_stmm1, 71dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_stmm2, 72dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_stmm3, 73dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_stmm4, 74dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_stmm5, 75dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_stmm6, 76dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_stmm7, 77dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm0, 78dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm1, 79dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm2, 80dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm3, 81dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm4, 82dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm5, 83dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm6, 84dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm7, 85dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm8, 86dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm9, 87dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm10, 88dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm11, 89dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm12, 90dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm13, 91dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm14, 92dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_xmm15, 93dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_last_fpr = fpu_xmm15, 94dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_first_avx, 95dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm0 = k_first_avx, 96dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm1, 97dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm2, 98dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm3, 99dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm4, 100dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm5, 101dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm6, 102dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm7, 103dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm8, 104dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm9, 105dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm10, 106dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm11, 107dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm12, 108dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm13, 109dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm14, 110dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi fpu_ymm15, 111dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_last_avx = fpu_ymm15, 112dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi 1133d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec dr0, 1143d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec dr1, 1153d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec dr2, 1163d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec dr3, 1173d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec dr4, 1183d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec dr5, 1193d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec dr6, 1203d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec dr7, 1213d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 122dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_num_registers, 123dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_num_gpr_registers = k_last_gpr - k_first_gpr + 1, 124dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_num_fpr_registers = k_last_fpr - k_first_fpr + 1, 125dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi k_num_avx_registers = k_last_avx - k_first_avx + 1 126dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi}; 127dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi 1282341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chenclass RegisterContext_x86_64 1292341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen : public RegisterContextPOSIX 1302341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen{ 1312341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chenpublic: 1322341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen RegisterContext_x86_64 (lldb_private::Thread &thread, 133dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi uint32_t concrete_frame_idx); 1342341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1352341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen ~RegisterContext_x86_64(); 1362341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1372341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen void 1382341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen Invalidate(); 1392341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1402341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen void 1412341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen InvalidateAllRegisters(); 1422341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1432341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen size_t 1442341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen GetRegisterCount(); 1452341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 146dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi virtual size_t 147dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi GetGPRSize() = 0; 148dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi 149dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi virtual unsigned 150dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi GetRegisterSize(unsigned reg); 151dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi 152dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi virtual unsigned 153dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi GetRegisterOffset(unsigned reg); 154dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi 1552341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen const lldb_private::RegisterInfo * 1562989a5aec5b5e313e0885c215681c68151e7c4bbGreg Clayton GetRegisterInfoAtIndex(size_t reg); 1572341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1582341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen size_t 1592341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen GetRegisterSetCount(); 1602341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1612341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen const lldb_private::RegisterSet * 1622989a5aec5b5e313e0885c215681c68151e7c4bbGreg Clayton GetRegisterSet(size_t set); 1632341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 164c73fedb63ab170d711fb73d198451eb8db710e8dAshok Thirumurthi unsigned 1652341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen GetRegisterIndexFromOffset(unsigned offset); 1662341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 167c73fedb63ab170d711fb73d198451eb8db710e8dAshok Thirumurthi const char * 1682341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen GetRegisterName(unsigned reg); 1692341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1702341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen virtual bool 1712341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen ReadRegister(const lldb_private::RegisterInfo *reg_info, 1722341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen lldb_private::RegisterValue &value); 1732341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1742341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen bool 1752341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen ReadAllRegisterValues(lldb::DataBufferSP &data_sp); 1762341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1772341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen virtual bool 1782341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen WriteRegister(const lldb_private::RegisterInfo *reg_info, 1792341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen const lldb_private::RegisterValue &value); 1802341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1812341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen bool 1822341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen WriteAllRegisterValues(const lldb::DataBufferSP &data_sp); 1832341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1842341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint32_t 1852341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen ConvertRegisterKindToRegisterNumber(uint32_t kind, uint32_t num); 1862341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1873d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec uint32_t 1883d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec NumSupportedHardwareWatchpoints(); 1893d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 1903d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec uint32_t 1913d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec SetHardwareWatchpoint(lldb::addr_t, size_t size, bool read, bool write); 1923d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 1933d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec bool 1943d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec ClearHardwareWatchpoint(uint32_t hw_index); 1953d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 1962341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen bool 1972341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen HardwareSingleStep(bool enable); 1982341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 1992341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen bool 2002341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen UpdateAfterBreakpoint(); 2012341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 2023d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec bool 2033d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec IsWatchpointVacant(uint32_t hw_index); 2043d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 2053d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec bool 2063d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec IsWatchpointHit (uint32_t hw_index); 2073d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 2083d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec lldb::addr_t 2093d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec GetWatchpointAddress (uint32_t hw_index); 2103d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 2113d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec bool 2123d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec ClearWatchpointHits(); 2133d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 21466bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi //--------------------------------------------------------------------------- 21566bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi // Generic floating-point registers 21666bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi //--------------------------------------------------------------------------- 2173d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 2182341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen struct MMSReg 2192341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen { 2202341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint8_t bytes[10]; 2212341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint8_t pad[6]; 2222341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen }; 2232341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 2242341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen struct XMMReg 2252341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen { 22666bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi uint8_t bytes[16]; // 128-bits for each XMM register 2272341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen }; 2282341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 22966bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi struct FXSAVE 2302341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen { 2312341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint16_t fcw; 2322341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint16_t fsw; 2332341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint16_t ftw; 2342341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint16_t fop; 2352341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint64_t ip; 2362341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint64_t dp; 2372341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint32_t mxcsr; 2382341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint32_t mxcsrmask; 2392341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen MMSReg stmm[8]; 2402341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen XMMReg xmm[16]; 2412341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen uint32_t padding[24]; 2422341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen }; 2432341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 24466bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi //--------------------------------------------------------------------------- 24566bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi // Extended floating-point registers 24666bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi //--------------------------------------------------------------------------- 24766bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi struct YMMHReg 24866bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi { 24966bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi uint8_t bytes[16]; // 16 * 8 bits for the high bytes of each YMM register 25066bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi }; 25166bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi 25266bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi struct YMMReg 25366bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi { 25466bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi uint8_t bytes[32]; // 16 * 16 bits for each YMM register 25566bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi }; 25666bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi 25766bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi struct YMM 25866bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi { 25966bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi YMMReg ymm[16]; // assembled from ymmh and xmm registers 26066bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi }; 26166bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi 26266bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi struct XSAVE_HDR 26366bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi { 26466bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi uint64_t xstate_bv; // OS enabled xstate mask to determine the extended states supported by the processor 26566bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi uint64_t reserved1[2]; 26666bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi uint64_t reserved2[5]; 26766bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi } __attribute__((packed)); 26866bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi 26966bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi // x86 extensions to FXSAVE (i.e. for AVX processors) 27066bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi struct XSAVE 27166bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi { 27266bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi FXSAVE i387; // floating point registers typical in i387_fxsave_struct 27366bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi XSAVE_HDR header; // The xsave_hdr_struct can be used to determine if the following extensions are usable 27466bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi YMMHReg ymmh[16]; // High 16 bytes of each of 16 YMM registers (the low bytes are in FXSAVE.xmm for compatibility with SSE) 27566bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi // Slot any extensions to the register file here 27666bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi } __attribute__((packed, aligned (64))); 27766bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi 27866bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi struct IOVEC 27966bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi { 28066bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi void *iov_base; // pointer to XSAVE 28166bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi size_t iov_len; // sizeof(XSAVE) 28266bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi }; 28366bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi 28466bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi //--------------------------------------------------------------------------- 28566bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi // Note: prefer kernel definitions over user-land 28666bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi //--------------------------------------------------------------------------- 28766bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi enum FPRType 28866bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi { 28966bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi eNotValid = 0, 29066bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi eFSAVE, // TODO 29166bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi eFXSAVE, 29266bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi eSOFT, // TODO 29366bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi eXSAVE 29466bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi }; 29566bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi 29666bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi // Floating-point registers 29766bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi struct FPR 29866bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi { 29966bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi // Thread state for the floating-point unit of the processor read by ptrace. 30066bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi union XSTATE { 30166bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi FXSAVE fxsave; // Generic floating-point registers. 30266bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi XSAVE xsave; // x86 extended processor state. 30366bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi } xstate; 3042341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen }; 3052341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 3060852cbb9660c92a448468a8ec7c39fb7245eca57Ashok Thirumurthiprotected: 3070852cbb9660c92a448468a8ec7c39fb7245eca57Ashok Thirumurthi // Determines if an extended register set is supported on the processor running the inferior process. 3080852cbb9660c92a448468a8ec7c39fb7245eca57Ashok Thirumurthi virtual bool 3090852cbb9660c92a448468a8ec7c39fb7245eca57Ashok Thirumurthi IsRegisterSetAvailable(size_t set_index); 3100852cbb9660c92a448468a8ec7c39fb7245eca57Ashok Thirumurthi 311dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi virtual const lldb_private::RegisterInfo * 312dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi GetRegisterInfo(); 313dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthi 3143d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec virtual bool 3153d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec ReadRegister(const unsigned reg, lldb_private::RegisterValue &value); 3163d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 3173d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec virtual bool 3183d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec WriteRegister(const unsigned reg, const lldb_private::RegisterValue &value); 3193d4d51cd1bdef32ab61ba9e1de75d5a4f4c1dbedMatt Kopec 320dae196da3bf9c181405c9c0c1083069dc007e318Ashok Thirumurthiprivate: 32126aa43bcbccc89d7b52adfed26c545430c021635Ashok Thirumurthi uint64_t m_gpr[k_num_gpr_registers]; // general purpose registers. 32226aa43bcbccc89d7b52adfed26c545430c021635Ashok Thirumurthi FPRType m_fpr_type; // determines the type of data stored by union FPR, if any. 32326aa43bcbccc89d7b52adfed26c545430c021635Ashok Thirumurthi FPR m_fpr; // floating-point registers including extended register sets. 32426aa43bcbccc89d7b52adfed26c545430c021635Ashok Thirumurthi IOVEC m_iovec; // wrapper for xsave. 32526aa43bcbccc89d7b52adfed26c545430c021635Ashok Thirumurthi YMM m_ymm_set; // copy of ymmh and xmm register halves. 3262341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 3272341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen ProcessMonitor &GetMonitor(); 32866bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi lldb::ByteOrder GetByteOrder(); 32966bd7d7ed3f05ea14fe0630726835ddeb2d07be7Ashok Thirumurthi 33026aa43bcbccc89d7b52adfed26c545430c021635Ashok Thirumurthi bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order); 33126aa43bcbccc89d7b52adfed26c545430c021635Ashok Thirumurthi bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order); 332c73fedb63ab170d711fb73d198451eb8db710e8dAshok Thirumurthi bool IsFPR(unsigned reg, FPRType fpr_type); 3332341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 3342341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen bool ReadGPR(); 3352341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen bool ReadFPR(); 3362341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 3372341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen bool WriteGPR(); 3382341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen bool WriteFPR(); 3392341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen}; 3402341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen 3412341d35bc77ffa8597a85b1ffe50b5653a2ec46dJohnny Chen#endif // #ifndef liblldb_RegisterContext_x86_64_H_ 342