diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp --- a/lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp @@ -162,10 +162,10 @@ uint32_t EHProgramBuilder::ConvertMachineToLLDBRegister(uint8_t machine_reg) { static uint32_t machine_to_lldb_register[] = { - lldb_rax_x86_64, lldb_rcx_x86_64, lldb_rdx_x86_64, lldb_rbx_x86_64, - lldb_rsp_x86_64, lldb_rbp_x86_64, lldb_rsi_x86_64, lldb_rdi_x86_64, - lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64, - lldb_r12_x86_64, lldb_r13_x86_64, lldb_r14_x86_64, lldb_r15_x86_64}; + x86_64::lldb_rax, x86_64::lldb_rcx, x86_64::lldb_rdx, x86_64::lldb_rbx, + x86_64::lldb_rsp, x86_64::lldb_rbp, x86_64::lldb_rsi, x86_64::lldb_rdi, + x86_64::lldb_r8, x86_64::lldb_r9, x86_64::lldb_r10, x86_64::lldb_r11, + x86_64::lldb_r12, x86_64::lldb_r13, x86_64::lldb_r14, x86_64::lldb_r15}; if (machine_reg >= std::size(machine_to_lldb_register)) return LLDB_INVALID_REGNUM; @@ -175,12 +175,12 @@ uint32_t EHProgramBuilder::ConvertXMMToLLDBRegister(uint8_t xmm_reg) { static uint32_t xmm_to_lldb_register[] = { - lldb_xmm0_x86_64, lldb_xmm1_x86_64, lldb_xmm2_x86_64, - lldb_xmm3_x86_64, lldb_xmm4_x86_64, lldb_xmm5_x86_64, - lldb_xmm6_x86_64, lldb_xmm7_x86_64, lldb_xmm8_x86_64, - lldb_xmm9_x86_64, lldb_xmm10_x86_64, lldb_xmm11_x86_64, - lldb_xmm12_x86_64, lldb_xmm13_x86_64, lldb_xmm14_x86_64, - lldb_xmm15_x86_64}; + x86_64::lldb_xmm0, x86_64::lldb_xmm1, x86_64::lldb_xmm2, + x86_64::lldb_xmm3, x86_64::lldb_xmm4, x86_64::lldb_xmm5, + x86_64::lldb_xmm6, x86_64::lldb_xmm7, x86_64::lldb_xmm8, + x86_64::lldb_xmm9, x86_64::lldb_xmm10, x86_64::lldb_xmm11, + x86_64::lldb_xmm12, x86_64::lldb_xmm13, x86_64::lldb_xmm14, + x86_64::lldb_xmm15}; if (xmm_reg >= std::size(xmm_to_lldb_register)) return LLDB_INVALID_REGNUM; @@ -281,15 +281,15 @@ m_program.emplace_back(EHInstruction{o, EHInstruction::Type::ALLOCATE, LLDB_INVALID_REGNUM, 8}); m_program.emplace_back(EHInstruction{o, EHInstruction::Type::PUSH_REGISTER, - lldb_rip_x86_64, 8}); + x86_64::lldb_rip, 8}); m_program.emplace_back(EHInstruction{o, EHInstruction::Type::PUSH_REGISTER, - lldb_cs_x86_64, 8}); + x86_64::lldb_cs, 8}); m_program.emplace_back(EHInstruction{o, EHInstruction::Type::PUSH_REGISTER, - lldb_rflags_x86_64, 8}); + x86_64::lldb_rflags, 8}); m_program.emplace_back(EHInstruction{o, EHInstruction::Type::PUSH_REGISTER, - lldb_rsp_x86_64, 8}); + x86_64::lldb_rsp, 8}); m_program.emplace_back(EHInstruction{o, EHInstruction::Type::PUSH_REGISTER, - lldb_ss_x86_64, 8}); + x86_64::lldb_ss, 8}); return true; } @@ -300,11 +300,11 @@ void EHProgramBuilder::Finalize() { for (const EHInstruction &i : m_program) - if (i.reg == lldb_rip_x86_64) + if (i.reg == x86_64::lldb_rip) return; m_program.emplace_back( - EHInstruction{0, EHInstruction::Type::PUSH_REGISTER, lldb_rip_x86_64, 8}); + EHInstruction{0, EHInstruction::Type::PUSH_REGISTER, x86_64::lldb_rip, 8}); } bool EHProgramBuilder::ParseBigOrScaledFrameOffset(uint32_t &result, bool big, @@ -387,7 +387,7 @@ break; } if (!frame_pointer_found) - row->GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, + row->GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, cfa_frame_offset); int32_t rsp_frame_offset = 0; @@ -410,7 +410,7 @@ } } - row->SetRegisterLocationToIsCFAPlusOffset(lldb_rsp_x86_64, 0, false); + row->SetRegisterLocationToIsCFAPlusOffset(x86_64::lldb_rsp, 0, false); return row; } diff --git a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.cpp b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.cpp --- a/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.cpp @@ -32,107 +32,114 @@ // x86 64-bit general purpose registers. static const uint32_t g_gpr_regnums_x86_64[] = { - lldb_rax_x86_64, lldb_rbx_x86_64, lldb_rcx_x86_64, lldb_rdx_x86_64, - lldb_rdi_x86_64, lldb_rsi_x86_64, lldb_rbp_x86_64, lldb_rsp_x86_64, - lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64, - lldb_r12_x86_64, lldb_r13_x86_64, lldb_r14_x86_64, lldb_r15_x86_64, - lldb_rip_x86_64, lldb_rflags_x86_64, lldb_cs_x86_64, lldb_fs_x86_64, - lldb_gs_x86_64, lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64, - lldb_eax_x86_64, lldb_ebx_x86_64, lldb_ecx_x86_64, lldb_edx_x86_64, - lldb_edi_x86_64, lldb_esi_x86_64, lldb_ebp_x86_64, lldb_esp_x86_64, - lldb_r8d_x86_64, // Low 32 bits or r8 - lldb_r9d_x86_64, // Low 32 bits or r9 - lldb_r10d_x86_64, // Low 32 bits or r10 - lldb_r11d_x86_64, // Low 32 bits or r11 - lldb_r12d_x86_64, // Low 32 bits or r12 - lldb_r13d_x86_64, // Low 32 bits or r13 - lldb_r14d_x86_64, // Low 32 bits or r14 - lldb_r15d_x86_64, // Low 32 bits or r15 - lldb_ax_x86_64, lldb_bx_x86_64, lldb_cx_x86_64, lldb_dx_x86_64, - lldb_di_x86_64, lldb_si_x86_64, lldb_bp_x86_64, lldb_sp_x86_64, - lldb_r8w_x86_64, // Low 16 bits or r8 - lldb_r9w_x86_64, // Low 16 bits or r9 - lldb_r10w_x86_64, // Low 16 bits or r10 - lldb_r11w_x86_64, // Low 16 bits or r11 - lldb_r12w_x86_64, // Low 16 bits or r12 - lldb_r13w_x86_64, // Low 16 bits or r13 - lldb_r14w_x86_64, // Low 16 bits or r14 - lldb_r15w_x86_64, // Low 16 bits or r15 - lldb_ah_x86_64, lldb_bh_x86_64, lldb_ch_x86_64, lldb_dh_x86_64, - lldb_al_x86_64, lldb_bl_x86_64, lldb_cl_x86_64, lldb_dl_x86_64, - lldb_dil_x86_64, lldb_sil_x86_64, lldb_bpl_x86_64, lldb_spl_x86_64, - lldb_r8l_x86_64, // Low 8 bits or r8 - lldb_r9l_x86_64, // Low 8 bits or r9 - lldb_r10l_x86_64, // Low 8 bits or r10 - lldb_r11l_x86_64, // Low 8 bits or r11 - lldb_r12l_x86_64, // Low 8 bits or r12 - lldb_r13l_x86_64, // Low 8 bits or r13 - lldb_r14l_x86_64, // Low 8 bits or r14 - lldb_r15l_x86_64, // Low 8 bits or r15 + x86_64::lldb_rax, x86_64::lldb_rbx, x86_64::lldb_rcx, + x86_64::lldb_rdx, x86_64::lldb_rdi, x86_64::lldb_rsi, + x86_64::lldb_rbp, x86_64::lldb_rsp, x86_64::lldb_r8, + x86_64::lldb_r9, x86_64::lldb_r10, x86_64::lldb_r11, + x86_64::lldb_r12, x86_64::lldb_r13, x86_64::lldb_r14, + x86_64::lldb_r15, x86_64::lldb_rip, x86_64::lldb_rflags, + x86_64::lldb_cs, x86_64::lldb_fs, x86_64::lldb_gs, + x86_64::lldb_ss, x86_64::lldb_ds, x86_64::lldb_es, + x86_64::lldb_eax, x86_64::lldb_ebx, x86_64::lldb_ecx, + x86_64::lldb_edx, x86_64::lldb_edi, x86_64::lldb_esi, + x86_64::lldb_ebp, x86_64::lldb_esp, + x86_64::lldb_r8d, // Low 32 bits or r8 + x86_64::lldb_r9d, // Low 32 bits or r9 + x86_64::lldb_r10d, // Low 32 bits or r10 + x86_64::lldb_r11d, // Low 32 bits or r11 + x86_64::lldb_r12d, // Low 32 bits or r12 + x86_64::lldb_r13d, // Low 32 bits or r13 + x86_64::lldb_r14d, // Low 32 bits or r14 + x86_64::lldb_r15d, // Low 32 bits or r15 + x86_64::lldb_ax, x86_64::lldb_bx, x86_64::lldb_cx, + x86_64::lldb_dx, x86_64::lldb_di, x86_64::lldb_si, + x86_64::lldb_bp, x86_64::lldb_sp, + x86_64::lldb_r8w, // Low 16 bits or r8 + x86_64::lldb_r9w, // Low 16 bits or r9 + x86_64::lldb_r10w, // Low 16 bits or r10 + x86_64::lldb_r11w, // Low 16 bits or r11 + x86_64::lldb_r12w, // Low 16 bits or r12 + x86_64::lldb_r13w, // Low 16 bits or r13 + x86_64::lldb_r14w, // Low 16 bits or r14 + x86_64::lldb_r15w, // Low 16 bits or r15 + x86_64::lldb_ah, x86_64::lldb_bh, x86_64::lldb_ch, + x86_64::lldb_dh, x86_64::lldb_al, x86_64::lldb_bl, + x86_64::lldb_cl, x86_64::lldb_dl, x86_64::lldb_dil, + x86_64::lldb_sil, x86_64::lldb_bpl, x86_64.x86_64::lldb_spl, + x86_64::lldb_r8l, // Low 8 bits or r8 + x86_64::lldb_r9l, // Low 8 bits or r9 + x86_64::lldb_r10l, // Low 8 bits or r10 + x86_64::lldb_r11l, // Low 8 bits or r11 + x86_64::lldb_r12l, // Low 8 bits or r12 + x86_64::lldb_r13l, // Low 8 bits or r13 + x86_64::lldb_r14l, // Low 8 bits or r14 + x86_64::lldb_r15l, // Low 8 bits or r15 LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) - 1 == - k_num_gpr_registers_x86_64, + x86_64::k_num_gpr_registers, "g_gpr_regnums_x86_64 has wrong number of register infos"); // x86 64-bit floating point registers. static const uint32_t g_fpu_regnums_x86_64[] = { - lldb_fctrl_x86_64, lldb_fstat_x86_64, lldb_ftag_x86_64, - lldb_fop_x86_64, lldb_fiseg_x86_64, lldb_fioff_x86_64, - lldb_fip_x86_64, lldb_foseg_x86_64, lldb_fooff_x86_64, - lldb_fdp_x86_64, lldb_mxcsr_x86_64, lldb_mxcsrmask_x86_64, - lldb_st0_x86_64, lldb_st1_x86_64, lldb_st2_x86_64, - lldb_st3_x86_64, lldb_st4_x86_64, lldb_st5_x86_64, - lldb_st6_x86_64, lldb_st7_x86_64, lldb_mm0_x86_64, - lldb_mm1_x86_64, lldb_mm2_x86_64, lldb_mm3_x86_64, - lldb_mm4_x86_64, lldb_mm5_x86_64, lldb_mm6_x86_64, - lldb_mm7_x86_64, lldb_xmm0_x86_64, lldb_xmm1_x86_64, - lldb_xmm2_x86_64, lldb_xmm3_x86_64, lldb_xmm4_x86_64, - lldb_xmm5_x86_64, lldb_xmm6_x86_64, lldb_xmm7_x86_64, - lldb_xmm8_x86_64, lldb_xmm9_x86_64, lldb_xmm10_x86_64, - lldb_xmm11_x86_64, lldb_xmm12_x86_64, lldb_xmm13_x86_64, - lldb_xmm14_x86_64, lldb_xmm15_x86_64, + x86_64::lldb_fctrl, x86_64::lldb_fstat, x86_64::lldb_ftag, + x86_64::lldb_fop, x86_64::lldb_fiseg, x86_64::lldb_fioff, + x86_64::lldb_fip, x86_64::lldb_foseg, x86_64::lldb_fooff, + x86_64::lldb_fdp, x86_64::lldb_mxcsr, x86_64::lldb_mxcsrmask, + x86_64::lldb_st0, x86_64::lldb_st1, x86_64::lldb_st2, + x86_64::lldb_st3, x86_64::lldb_st4, x86_64::lldb_st5, + x86_64::lldb_st6, x86_64::lldb_st7, x86_64::lldb_mm0, + x86_64::lldb_mm1, x86_64::lldb_mm2, x86_64::lldb_mm3, + x86_64::lldb_mm4, x86_64::lldb_mm5, x86_64::lldb_mm6, + x86_64::lldb_mm7, x86_64::lldb_xmm0, x86_64::lldb_xmm1, + x86_64::lldb_xmm2, x86_64::lldb_xmm3, x86_64::lldb_xmm4, + x86_64::lldb_xmm5, x86_64::lldb_xmm6, x86_64::lldb_xmm7, + x86_64::lldb_xmm8, x86_64::lldb_xmm9, x86_64::lldb_xmm10, + x86_64::lldb_xmm11, x86_64::lldb_xmm12, x86_64::lldb_xmm13, + x86_64::lldb_xmm14, x86_64::lldb_xmm15, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_fpu_regnums_x86_64) / sizeof(g_fpu_regnums_x86_64[0])) - 1 == - k_num_fpr_registers_x86_64, + x86_64::k_num_fpr_registers, "g_fpu_regnums_x86_64 has wrong number of register infos"); static const uint32_t g_avx_regnums_x86_64[] = { - lldb_ymm0_x86_64, lldb_ymm1_x86_64, lldb_ymm2_x86_64, lldb_ymm3_x86_64, - lldb_ymm4_x86_64, lldb_ymm5_x86_64, lldb_ymm6_x86_64, lldb_ymm7_x86_64, - lldb_ymm8_x86_64, lldb_ymm9_x86_64, lldb_ymm10_x86_64, lldb_ymm11_x86_64, - lldb_ymm12_x86_64, lldb_ymm13_x86_64, lldb_ymm14_x86_64, lldb_ymm15_x86_64, + x86_64::lldb_ymm0, x86_64::lldb_ymm1, x86_64::lldb_ymm2, + x86_64::lldb_ymm3, x86_64::lldb_ymm4, x86_64::lldb_ymm5, + x86_64::lldb_ymm6, x86_64::lldb_ymm7, x86_64::lldb_ymm8, + x86_64::lldb_ymm9, x86_64::lldb_ymm10, x86_64::lldb_ymm11, + x86_64::lldb_ymm12, x86_64::lldb_ymm13, x86_64::lldb_ymm14, + x86_64::lldb_ymm15, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) - 1 == - k_num_avx_registers_x86_64, + x86_64::k_num_avx_registers, "g_avx_regnums_x86_64 has wrong number of register infos"); static const uint32_t g_mpx_regnums_x86_64[] = { // Note: we currently do not provide them but this is needed to avoid // unnamed groups in SBFrame::GetRegisterContext(). - lldb_bnd0_x86_64, lldb_bnd1_x86_64, lldb_bnd2_x86_64, - lldb_bnd3_x86_64, lldb_bndcfgu_x86_64, lldb_bndstatus_x86_64, + x86_64::lldb_bnd0, x86_64::lldb_bnd1, x86_64::lldb_bnd2, + x86_64::lldb_bnd3, x86_64::lldb_bndcfgu, x86_64::lldb_bndstatus, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_mpx_regnums_x86_64) / sizeof(g_mpx_regnums_x86_64[0])) - 1 == - k_num_mpx_registers_x86_64, + x86_64::k_num_mpx_registers, "g_mpx_regnums_x86_64 has wrong number of register infos"); // x86 debug registers. static const uint32_t g_dbr_regnums_x86_64[] = { - lldb_dr0_x86_64, lldb_dr1_x86_64, lldb_dr2_x86_64, lldb_dr3_x86_64, - lldb_dr4_x86_64, lldb_dr5_x86_64, lldb_dr6_x86_64, lldb_dr7_x86_64, + x86_64::lldb_dr0, x86_64::lldb_dr1, x86_64::lldb_dr2, x86_64::lldb_dr3, + x86_64::lldb_dr4, x86_64::lldb_dr5, x86_64::lldb_dr6, x86_64::lldb_dr7, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_dbr_regnums_x86_64) / sizeof(g_dbr_regnums_x86_64[0])) - 1 == - k_num_dbr_registers_x86_64, + x86_64::k_num_dbr_registers, "g_dbr_regnums_x86_64 has wrong number of register infos"); // x86 32-bit general purpose registers. @@ -221,15 +228,15 @@ // Register sets for x86 64-bit. static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = { - {"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64, + {"General Purpose Registers", "gpr", x86_64::k_num_gpr_registers, g_gpr_regnums_x86_64}, - {"Floating Point Registers", "fpu", k_num_fpr_registers_x86_64, + {"Floating Point Registers", "fpu", x86_64::k_num_fpr_registers, g_fpu_regnums_x86_64}, - {"Debug Registers", "dbr", k_num_dbr_registers_x86_64, + {"Debug Registers", "dbr", x86_64::k_num_dbr_registers, g_dbr_regnums_x86_64}, - {"Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64, + {"Advanced Vector Extensions", "avx", x86_64::k_num_avx_registers, g_avx_regnums_x86_64}, - {"Memory Protection Extensions", "mpx", k_num_mpx_registers_x86_64, + {"Memory Protection Extensions", "mpx", x86_64::k_num_mpx_registers, g_mpx_regnums_x86_64}, }; @@ -271,8 +278,8 @@ first_regnos[DBRegSet] = lldb_dr0_i386; break; case llvm::Triple::x86_64: - first_regnos[FPRegSet] = lldb_fctrl_x86_64; - first_regnos[DBRegSet] = lldb_dr0_x86_64; + first_regnos[FPRegSet] = x86_64::lldb_fctrl; + first_regnos[DBRegSet] = x86_64::lldb_dr0; break; default: llvm_unreachable("Unhandled target architecture."); @@ -319,17 +326,17 @@ return DBRegSet; // DBR break; case llvm::Triple::x86_64: - if (reg_num >= k_first_gpr_x86_64 && reg_num <= k_last_gpr_x86_64) + if (reg_num >= x86_64::k_first_gpr && reg_num <= x86_64::k_last_gpr) return GPRegSet; - if (reg_num >= k_first_fpr_x86_64 && reg_num <= k_last_fpr_x86_64) + if (reg_num >= x86_64::k_first_fpr && reg_num <= x86_64::k_last_fpr) return FPRegSet; - if (reg_num >= k_first_avx_x86_64 && reg_num <= k_last_avx_x86_64) + if (reg_num >= x86_64::k_first_avx && reg_num <= x86_64::k_last_avx) return YMMRegSet; - if (reg_num >= k_first_mpxr_x86_64 && reg_num <= k_last_mpxr_x86_64) + if (reg_num >= x86_64::k_first_mpxr && reg_num <= x86_64::k_last_mpxr) return std::nullopt; // MPXR - if (reg_num >= k_first_mpxc_x86_64 && reg_num <= k_last_mpxc_x86_64) + if (reg_num >= x86_64::k_first_mpxc && reg_num <= x86_64::k_last_mpxc) return std::nullopt; // MPXC - if (reg_num >= k_first_dbr_x86_64 && reg_num <= k_last_dbr_x86_64) + if (reg_num >= x86_64::k_first_dbr && reg_num <= x86_64::k_last_dbr) return DBRegSet; // DBR break; default: @@ -642,7 +649,7 @@ reg_index = reg - lldb_ymm0_i386; break; case llvm::Triple::x86_64: - reg_index = reg - lldb_ymm0_x86_64; + reg_index = reg - x86_64::lldb_ymm0; break; default: llvm_unreachable("Unhandled target architecture."); diff --git a/lldb/source/Plugins/Process/FreeBSDKernel/RegisterContextFreeBSDKernel_x86_64.cpp b/lldb/source/Plugins/Process/FreeBSDKernel/RegisterContextFreeBSDKernel_x86_64.cpp --- a/lldb/source/Plugins/Process/FreeBSDKernel/RegisterContextFreeBSDKernel_x86_64.cpp +++ b/lldb/source/Plugins/Process/FreeBSDKernel/RegisterContextFreeBSDKernel_x86_64.cpp @@ -60,7 +60,7 @@ uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB]; switch (reg) { #define REG(x) \ - case lldb_##x##_x86_64: \ + case x86_64::lldb_##x: \ value = pcb.x; \ break; diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h @@ -51,6 +51,8 @@ std::optional GetMmapData() override; + const RegisterInfo *GetDR(int num) const override; + protected: void *GetGPRBuffer() override { return &m_gpr_x86_64; } @@ -104,7 +106,7 @@ YMM m_ymm_set; MPX m_mpx_set; RegInfo m_reg_info; - uint64_t m_gpr_x86_64[k_num_gpr_registers_x86_64]; + uint64_t m_gpr_x86_64[x86_64_with_base::k_num_gpr_registers]; uint32_t m_fctrl_offset_in_userarea; // Private member methods. diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp @@ -100,96 +100,97 @@ // x86 64-bit general purpose registers. static const uint32_t g_gpr_regnums_x86_64[] = { - lldb_rax_x86_64, lldb_rbx_x86_64, lldb_rcx_x86_64, lldb_rdx_x86_64, - lldb_rdi_x86_64, lldb_rsi_x86_64, lldb_rbp_x86_64, lldb_rsp_x86_64, - lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64, - lldb_r12_x86_64, lldb_r13_x86_64, lldb_r14_x86_64, lldb_r15_x86_64, - lldb_rip_x86_64, lldb_rflags_x86_64, lldb_cs_x86_64, lldb_fs_x86_64, - lldb_gs_x86_64, lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64, - lldb_eax_x86_64, lldb_ebx_x86_64, lldb_ecx_x86_64, lldb_edx_x86_64, - lldb_edi_x86_64, lldb_esi_x86_64, lldb_ebp_x86_64, lldb_esp_x86_64, - lldb_r8d_x86_64, // Low 32 bits or r8 - lldb_r9d_x86_64, // Low 32 bits or r9 - lldb_r10d_x86_64, // Low 32 bits or r10 - lldb_r11d_x86_64, // Low 32 bits or r11 - lldb_r12d_x86_64, // Low 32 bits or r12 - lldb_r13d_x86_64, // Low 32 bits or r13 - lldb_r14d_x86_64, // Low 32 bits or r14 - lldb_r15d_x86_64, // Low 32 bits or r15 - lldb_ax_x86_64, lldb_bx_x86_64, lldb_cx_x86_64, lldb_dx_x86_64, - lldb_di_x86_64, lldb_si_x86_64, lldb_bp_x86_64, lldb_sp_x86_64, - lldb_r8w_x86_64, // Low 16 bits or r8 - lldb_r9w_x86_64, // Low 16 bits or r9 - lldb_r10w_x86_64, // Low 16 bits or r10 - lldb_r11w_x86_64, // Low 16 bits or r11 - lldb_r12w_x86_64, // Low 16 bits or r12 - lldb_r13w_x86_64, // Low 16 bits or r13 - lldb_r14w_x86_64, // Low 16 bits or r14 - lldb_r15w_x86_64, // Low 16 bits or r15 - lldb_ah_x86_64, lldb_bh_x86_64, lldb_ch_x86_64, lldb_dh_x86_64, - lldb_al_x86_64, lldb_bl_x86_64, lldb_cl_x86_64, lldb_dl_x86_64, - lldb_dil_x86_64, lldb_sil_x86_64, lldb_bpl_x86_64, lldb_spl_x86_64, - lldb_r8l_x86_64, // Low 8 bits or r8 - lldb_r9l_x86_64, // Low 8 bits or r9 - lldb_r10l_x86_64, // Low 8 bits or r10 - lldb_r11l_x86_64, // Low 8 bits or r11 - lldb_r12l_x86_64, // Low 8 bits or r12 - lldb_r13l_x86_64, // Low 8 bits or r13 - lldb_r14l_x86_64, // Low 8 bits or r14 - lldb_r15l_x86_64, // Low 8 bits or r15 + x86_64_with_base::lldb_rax, x86_64_with_base::lldb_rbx, x86_64_with_base::lldb_rcx, x86_64_with_base::lldb_rdx, + x86_64_with_base::lldb_rdi, x86_64_with_base::lldb_rsi, x86_64_with_base::lldb_rbp, x86_64_with_base::lldb_rsp, + x86_64_with_base::lldb_r8, x86_64_with_base::lldb_r9, x86_64_with_base::lldb_r10, x86_64_with_base::lldb_r11, + x86_64_with_base::lldb_r12, x86_64_with_base::lldb_r13, x86_64_with_base::lldb_r14, x86_64_with_base::lldb_r15, + x86_64_with_base::lldb_rip, x86_64_with_base::lldb_rflags, x86_64_with_base::lldb_cs, x86_64_with_base::lldb_fs, + x86_64_with_base::lldb_gs, x86_64_with_base::lldb_ss, x86_64_with_base::lldb_fs_base, x86_64_with_base::lldb_gs_base, + x86_64_with_base::lldb_ds, x86_64_with_base::lldb_es, + x86_64_with_base::lldb_eax, x86_64_with_base::lldb_ebx, x86_64_with_base::lldb_ecx, x86_64_with_base::lldb_edx, + x86_64_with_base::lldb_edi, x86_64_with_base::lldb_esi, x86_64_with_base::lldb_ebp, x86_64_with_base::lldb_esp, + x86_64_with_base::lldb_r8d, // Low 32 bits or r8 + x86_64_with_base::lldb_r9d, // Low 32 bits or r9 + x86_64_with_base::lldb_r10d, // Low 32 bits or r10 + x86_64_with_base::lldb_r11d, // Low 32 bits or r11 + x86_64_with_base::lldb_r12d, // Low 32 bits or r12 + x86_64_with_base::lldb_r13d, // Low 32 bits or r13 + x86_64_with_base::lldb_r14d, // Low 32 bits or r14 + x86_64_with_base::lldb_r15d, // Low 32 bits or r15 + x86_64_with_base::lldb_ax, x86_64_with_base::lldb_bx, x86_64_with_base::lldb_cx, x86_64_with_base::lldb_dx, + x86_64_with_base::lldb_di, x86_64_with_base::lldb_si, x86_64_with_base::lldb_bp, x86_64_with_base::lldb_sp, + x86_64_with_base::lldb_r8w, // Low 16 bits or r8 + x86_64_with_base::lldb_r9w, // Low 16 bits or r9 + x86_64_with_base::lldb_r10w, // Low 16 bits or r10 + x86_64_with_base::lldb_r11w, // Low 16 bits or r11 + x86_64_with_base::lldb_r12w, // Low 16 bits or r12 + x86_64_with_base::lldb_r13w, // Low 16 bits or r13 + x86_64_with_base::lldb_r14w, // Low 16 bits or r14 + x86_64_with_base::lldb_r15w, // Low 16 bits or r15 + x86_64_with_base::lldb_ah, x86_64_with_base::lldb_bh, x86_64_with_base::lldb_ch, x86_64_with_base::lldb_dh, + x86_64_with_base::lldb_al, x86_64_with_base::lldb_bl, x86_64_with_base::lldb_cl, x86_64_with_base::lldb_dl, + x86_64_with_base::lldb_dil, x86_64_with_base::lldb_sil, x86_64_with_base::lldb_bpl, x86_64_with_base::lldb_spl, + x86_64_with_base::lldb_r8l, // Low 8 bits or r8 + x86_64_with_base::lldb_r9l, // Low 8 bits or r9 + x86_64_with_base::lldb_r10l, // Low 8 bits or r10 + x86_64_with_base::lldb_r11l, // Low 8 bits or r11 + x86_64_with_base::lldb_r12l, // Low 8 bits or r12 + x86_64_with_base::lldb_r13l, // Low 8 bits or r13 + x86_64_with_base::lldb_r14l, // Low 8 bits or r14 + x86_64_with_base::lldb_r15l, // Low 8 bits or r15 LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) - 1 == - k_num_gpr_registers_x86_64, + x86_64_with_base::k_num_gpr_registers, "g_gpr_regnums_x86_64 has wrong number of register infos"); // x86 64-bit floating point registers. static const uint32_t g_fpu_regnums_x86_64[] = { - lldb_fctrl_x86_64, lldb_fstat_x86_64, lldb_ftag_x86_64, - lldb_fop_x86_64, lldb_fiseg_x86_64, lldb_fioff_x86_64, - lldb_fip_x86_64, lldb_foseg_x86_64, lldb_fooff_x86_64, - lldb_fdp_x86_64, lldb_mxcsr_x86_64, lldb_mxcsrmask_x86_64, - lldb_st0_x86_64, lldb_st1_x86_64, lldb_st2_x86_64, - lldb_st3_x86_64, lldb_st4_x86_64, lldb_st5_x86_64, - lldb_st6_x86_64, lldb_st7_x86_64, lldb_mm0_x86_64, - lldb_mm1_x86_64, lldb_mm2_x86_64, lldb_mm3_x86_64, - lldb_mm4_x86_64, lldb_mm5_x86_64, lldb_mm6_x86_64, - lldb_mm7_x86_64, lldb_xmm0_x86_64, lldb_xmm1_x86_64, - lldb_xmm2_x86_64, lldb_xmm3_x86_64, lldb_xmm4_x86_64, - lldb_xmm5_x86_64, lldb_xmm6_x86_64, lldb_xmm7_x86_64, - lldb_xmm8_x86_64, lldb_xmm9_x86_64, lldb_xmm10_x86_64, - lldb_xmm11_x86_64, lldb_xmm12_x86_64, lldb_xmm13_x86_64, - lldb_xmm14_x86_64, lldb_xmm15_x86_64, + x86_64_with_base::lldb_fctrl, x86_64_with_base::lldb_fstat, x86_64_with_base::lldb_ftag, + x86_64_with_base::lldb_fop, x86_64_with_base::lldb_fiseg, x86_64_with_base::lldb_fioff, + x86_64_with_base::lldb_fip, x86_64_with_base::lldb_foseg, x86_64_with_base::lldb_fooff, + x86_64_with_base::lldb_fdp, x86_64_with_base::lldb_mxcsr, x86_64_with_base::lldb_mxcsrmask, + x86_64_with_base::lldb_st0, x86_64_with_base::lldb_st1, x86_64_with_base::lldb_st2, + x86_64_with_base::lldb_st3, x86_64_with_base::lldb_st4, x86_64_with_base::lldb_st5, + x86_64_with_base::lldb_st6, x86_64_with_base::lldb_st7, x86_64_with_base::lldb_mm0, + x86_64_with_base::lldb_mm1, x86_64_with_base::lldb_mm2, x86_64_with_base::lldb_mm3, + x86_64_with_base::lldb_mm4, x86_64_with_base::lldb_mm5, x86_64_with_base::lldb_mm6, + x86_64_with_base::lldb_mm7, x86_64_with_base::lldb_xmm0, x86_64_with_base::lldb_xmm1, + x86_64_with_base::lldb_xmm2, x86_64_with_base::lldb_xmm3, x86_64_with_base::lldb_xmm4, + x86_64_with_base::lldb_xmm5, x86_64_with_base::lldb_xmm6, x86_64_with_base::lldb_xmm7, + x86_64_with_base::lldb_xmm8, x86_64_with_base::lldb_xmm9, x86_64_with_base::lldb_xmm10, + x86_64_with_base::lldb_xmm11, x86_64_with_base::lldb_xmm12, x86_64_with_base::lldb_xmm13, + x86_64_with_base::lldb_xmm14, x86_64_with_base::lldb_xmm15, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_fpu_regnums_x86_64) / sizeof(g_fpu_regnums_x86_64[0])) - 1 == - k_num_fpr_registers_x86_64, + x86_64_with_base::k_num_fpr_registers, "g_fpu_regnums_x86_64 has wrong number of register infos"); // x86 64-bit AVX registers. static const uint32_t g_avx_regnums_x86_64[] = { - lldb_ymm0_x86_64, lldb_ymm1_x86_64, lldb_ymm2_x86_64, lldb_ymm3_x86_64, - lldb_ymm4_x86_64, lldb_ymm5_x86_64, lldb_ymm6_x86_64, lldb_ymm7_x86_64, - lldb_ymm8_x86_64, lldb_ymm9_x86_64, lldb_ymm10_x86_64, lldb_ymm11_x86_64, - lldb_ymm12_x86_64, lldb_ymm13_x86_64, lldb_ymm14_x86_64, lldb_ymm15_x86_64, + x86_64_with_base::lldb_ymm0, x86_64_with_base::lldb_ymm1, x86_64_with_base::lldb_ymm2, x86_64_with_base::lldb_ymm3, + x86_64_with_base::lldb_ymm4, x86_64_with_base::lldb_ymm5, x86_64_with_base::lldb_ymm6, x86_64_with_base::lldb_ymm7, + x86_64_with_base::lldb_ymm8, x86_64_with_base::lldb_ymm9, x86_64_with_base::lldb_ymm10, x86_64_with_base::lldb_ymm11, + x86_64_with_base::lldb_ymm12, x86_64_with_base::lldb_ymm13, x86_64_with_base::lldb_ymm14, x86_64_with_base::lldb_ymm15, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) - 1 == - k_num_avx_registers_x86_64, + x86_64_with_base::k_num_avx_registers, "g_avx_regnums_x86_64 has wrong number of register infos"); // x86 64-bit MPX registers. static const uint32_t g_mpx_regnums_x86_64[] = { - lldb_bnd0_x86_64, lldb_bnd1_x86_64, lldb_bnd2_x86_64, - lldb_bnd3_x86_64, lldb_bndcfgu_x86_64, lldb_bndstatus_x86_64, + x86_64_with_base::lldb_bnd0, x86_64_with_base::lldb_bnd1, x86_64_with_base::lldb_bnd2, + x86_64_with_base::lldb_bnd3, x86_64_with_base::lldb_bndcfgu, x86_64_with_base::lldb_bndstatus, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_mpx_regnums_x86_64) / sizeof(g_mpx_regnums_x86_64[0])) - 1 == - k_num_mpx_registers_x86_64, + x86_64_with_base::k_num_mpx_registers, "g_mpx_regnums_x86_64 has wrong number of register infos"); // Number of register sets provided by this context. @@ -208,13 +209,13 @@ // Register sets for x86 64-bit. static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = { - {"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64, + {"General Purpose Registers", "gpr", x86_64_with_base::k_num_gpr_registers, g_gpr_regnums_x86_64}, - {"Floating Point Registers", "fpu", k_num_fpr_registers_x86_64, + {"Floating Point Registers", "fpu", x86_64_with_base::k_num_fpr_registers, g_fpu_regnums_x86_64}, - {"Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64, + {"Advanced Vector Extensions", "avx", x86_64_with_base::k_num_avx_registers, g_avx_regnums_x86_64}, - { "Memory Protection Extensions", "mpx", k_num_mpx_registers_x86_64, + { "Memory Protection Extensions", "mpx", x86_64_with_base::k_num_mpx_registers, g_mpx_regnums_x86_64}}; #define REG_CONTEXT_SIZE (GetRegisterInfoInterface().GetGPRSize() + sizeof(FPR)) @@ -330,29 +331,29 @@ m_reg_info.gpr_flags = lldb_eflags_i386; break; case llvm::Triple::x86_64: - m_reg_info.num_registers = k_num_registers_x86_64; - m_reg_info.num_gpr_registers = k_num_gpr_registers_x86_64; - m_reg_info.num_fpr_registers = k_num_fpr_registers_x86_64; - m_reg_info.num_avx_registers = k_num_avx_registers_x86_64; - m_reg_info.num_mpx_registers = k_num_mpx_registers_x86_64; - m_reg_info.last_gpr = k_last_gpr_x86_64; - m_reg_info.first_fpr = k_first_fpr_x86_64; - m_reg_info.last_fpr = k_last_fpr_x86_64; - m_reg_info.first_st = lldb_st0_x86_64; - m_reg_info.last_st = lldb_st7_x86_64; - m_reg_info.first_mm = lldb_mm0_x86_64; - m_reg_info.last_mm = lldb_mm7_x86_64; - m_reg_info.first_xmm = lldb_xmm0_x86_64; - m_reg_info.last_xmm = lldb_xmm15_x86_64; - m_reg_info.first_ymm = lldb_ymm0_x86_64; - m_reg_info.last_ymm = lldb_ymm15_x86_64; - m_reg_info.first_mpxr = lldb_bnd0_x86_64; - m_reg_info.last_mpxr = lldb_bnd3_x86_64; - m_reg_info.first_mpxc = lldb_bndcfgu_x86_64; - m_reg_info.last_mpxc = lldb_bndstatus_x86_64; - m_reg_info.first_dr = lldb_dr0_x86_64; - m_reg_info.last_dr = lldb_dr7_x86_64; - m_reg_info.gpr_flags = lldb_rflags_x86_64; + m_reg_info.num_registers = x86_64_with_base::k_num_registers; + m_reg_info.num_gpr_registers = x86_64_with_base::k_num_gpr_registers; + m_reg_info.num_fpr_registers = x86_64_with_base::k_num_fpr_registers; + m_reg_info.num_avx_registers = x86_64_with_base::k_num_avx_registers; + m_reg_info.num_mpx_registers = x86_64_with_base::k_num_mpx_registers; + m_reg_info.last_gpr = x86_64_with_base::k_last_gpr; + m_reg_info.first_fpr = x86_64_with_base::k_first_fpr; + m_reg_info.last_fpr = x86_64_with_base::k_last_fpr; + m_reg_info.first_st = x86_64_with_base::lldb_st0; + m_reg_info.last_st = x86_64_with_base::lldb_st7; + m_reg_info.first_mm = x86_64_with_base::lldb_mm0; + m_reg_info.last_mm = x86_64_with_base::lldb_mm7; + m_reg_info.first_xmm = x86_64_with_base::lldb_xmm0; + m_reg_info.last_xmm = x86_64_with_base::lldb_xmm15; + m_reg_info.first_ymm = x86_64_with_base::lldb_ymm0; + m_reg_info.last_ymm = x86_64_with_base::lldb_ymm15; + m_reg_info.first_mpxr = x86_64_with_base::lldb_bnd0; + m_reg_info.last_mpxr = x86_64_with_base::lldb_bnd3; + m_reg_info.first_mpxc = x86_64_with_base::lldb_bndcfgu; + m_reg_info.last_mpxc = x86_64_with_base::lldb_bndstatus; + m_reg_info.first_dr = x86_64_with_base::lldb_dr0; + m_reg_info.last_dr = x86_64_with_base::lldb_dr7; + m_reg_info.gpr_flags = x86_64_with_base::lldb_rflags; break; default: assert(false && "Unhandled target architecture."); @@ -1048,9 +1049,9 @@ case llvm::Triple::x86_64: { static const uint8_t Syscall[] = {0x0f, 0x05}; static const uint32_t Args[] = { - lldb_rax_x86_64, lldb_rdi_x86_64, lldb_rsi_x86_64, lldb_rdx_x86_64, - lldb_r10_x86_64, lldb_r8_x86_64, lldb_r9_x86_64}; - return SyscallData{Syscall, Args, lldb_rax_x86_64}; + x86_64_with_base::lldb_rax, x86_64_with_base::lldb_rdi, x86_64_with_base::lldb_rsi, x86_64_with_base::lldb_rdx, + x86_64_with_base::lldb_r10, x86_64_with_base::lldb_r8, x86_64_with_base::lldb_r9}; + return SyscallData{Syscall, Args, x86_64_with_base::lldb_rax}; } default: llvm_unreachable("Unhandled architecture!"); @@ -1069,4 +1070,16 @@ } } +const RegisterInfo *NativeRegisterContextLinux_x86_64::GetDR(int num) const { + assert(num >= 0 && num <= 7); + switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) { + case llvm::Triple::x86: + return GetRegisterInfoAtIndex(lldb_dr0_i386 + num); + case llvm::Triple::x86_64: + return GetRegisterInfoAtIndex(x86_64_with_base::lldb_dr0 + num); + default: + llvm_unreachable("Unhandled target architecture."); + } +} + #endif // defined(__i386__) || defined(__x86_64__) diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp --- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp @@ -39,107 +39,107 @@ // x86 64-bit general purpose registers. static const uint32_t g_gpr_regnums_x86_64[] = { - lldb_rax_x86_64, lldb_rbx_x86_64, lldb_rcx_x86_64, lldb_rdx_x86_64, - lldb_rdi_x86_64, lldb_rsi_x86_64, lldb_rbp_x86_64, lldb_rsp_x86_64, - lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64, - lldb_r12_x86_64, lldb_r13_x86_64, lldb_r14_x86_64, lldb_r15_x86_64, - lldb_rip_x86_64, lldb_rflags_x86_64, lldb_cs_x86_64, lldb_fs_x86_64, - lldb_gs_x86_64, lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64, - lldb_eax_x86_64, lldb_ebx_x86_64, lldb_ecx_x86_64, lldb_edx_x86_64, - lldb_edi_x86_64, lldb_esi_x86_64, lldb_ebp_x86_64, lldb_esp_x86_64, - lldb_r8d_x86_64, // Low 32 bits or r8 - lldb_r9d_x86_64, // Low 32 bits or r9 - lldb_r10d_x86_64, // Low 32 bits or r10 - lldb_r11d_x86_64, // Low 32 bits or r11 - lldb_r12d_x86_64, // Low 32 bits or r12 - lldb_r13d_x86_64, // Low 32 bits or r13 - lldb_r14d_x86_64, // Low 32 bits or r14 - lldb_r15d_x86_64, // Low 32 bits or r15 - lldb_ax_x86_64, lldb_bx_x86_64, lldb_cx_x86_64, lldb_dx_x86_64, - lldb_di_x86_64, lldb_si_x86_64, lldb_bp_x86_64, lldb_sp_x86_64, - lldb_r8w_x86_64, // Low 16 bits or r8 - lldb_r9w_x86_64, // Low 16 bits or r9 - lldb_r10w_x86_64, // Low 16 bits or r10 - lldb_r11w_x86_64, // Low 16 bits or r11 - lldb_r12w_x86_64, // Low 16 bits or r12 - lldb_r13w_x86_64, // Low 16 bits or r13 - lldb_r14w_x86_64, // Low 16 bits or r14 - lldb_r15w_x86_64, // Low 16 bits or r15 - lldb_ah_x86_64, lldb_bh_x86_64, lldb_ch_x86_64, lldb_dh_x86_64, - lldb_al_x86_64, lldb_bl_x86_64, lldb_cl_x86_64, lldb_dl_x86_64, - lldb_dil_x86_64, lldb_sil_x86_64, lldb_bpl_x86_64, lldb_spl_x86_64, - lldb_r8l_x86_64, // Low 8 bits or r8 - lldb_r9l_x86_64, // Low 8 bits or r9 - lldb_r10l_x86_64, // Low 8 bits or r10 - lldb_r11l_x86_64, // Low 8 bits or r11 - lldb_r12l_x86_64, // Low 8 bits or r12 - lldb_r13l_x86_64, // Low 8 bits or r13 - lldb_r14l_x86_64, // Low 8 bits or r14 - lldb_r15l_x86_64, // Low 8 bits or r15 + x86_64::lldb_rax, x86_64::lldb_rbx, x86_64::lldb_rcx, x86_64::lldb_rdx, + x86_64::lldb_rdi, x86_64::lldb_rsi, x86_64::lldb_rbp, x86_64::lldb_rsp, + x86_64::lldb_r8, x86_64::lldb_r9, x86_64::lldb_r10, x86_64::lldb_r11, + x86_64::lldb_r12, x86_64::lldb_r13, x86_64::lldb_r14, x86_64::lldb_r15, + x86_64::lldb_rip, x86_64::lldb_rflags, x86_64::lldb_cs, x86_64::lldb_fs, + x86_64::lldb_gs, x86_64::lldb_ss, x86_64::lldb_ds, x86_64::lldb_es, + x86_64::lldb_eax, x86_64::lldb_ebx, x86_64::lldb_ecx, x86_64::lldb_edx, + x86_64::lldb_edi, x86_64::lldb_esi, x86_64::lldb_ebp, x86_64::lldb_esp, + x86_64::lldb_r8d, // Low 32 bits or r8 + x86_64::lldb_r9d, // Low 32 bits or r9 + x86_64::lldb_r10d, // Low 32 bits or r10 + x86_64::lldb_r11d, // Low 32 bits or r11 + x86_64::lldb_r12d, // Low 32 bits or r12 + x86_64::lldb_r13d, // Low 32 bits or r13 + x86_64::lldb_r14d, // Low 32 bits or r14 + x86_64::lldb_r15d, // Low 32 bits or r15 + x86_64::lldb_ax, x86_64::lldb_bx, x86_64::lldb_cx, x86_64::lldb_dx, + x86_64::lldb_di, x86_64::lldb_si, x86_64::lldb_bp, x86_64::lldb_sp, + x86_64::lldb_r8w, // Low 16 bits or r8 + x86_64::lldb_r9w, // Low 16 bits or r9 + x86_64::lldb_r10w, // Low 16 bits or r10 + x86_64::lldb_r11w, // Low 16 bits or r11 + x86_64::lldb_r12w, // Low 16 bits or r12 + x86_64::lldb_r13w, // Low 16 bits or r13 + x86_64::lldb_r14w, // Low 16 bits or r14 + x86_64::lldb_r15w, // Low 16 bits or r15 + x86_64::lldb_ah, x86_64::lldb_bh, x86_64::lldb_ch, x86_64::lldb_dh, + x86_64::lldb_al, x86_64::lldb_bl, x86_64::lldb_cl, x86_64::lldb_dl, + x86_64::lldb_dil, x86_64::lldb_sil, x86_64::lldb_bpl, x86_64.x86_64::lldb_spl, + x86_64::lldb_r8l, // Low 8 bits or r8 + x86_64::lldb_r9l, // Low 8 bits or r9 + x86_64::lldb_r10l, // Low 8 bits or r10 + x86_64::lldb_r11l, // Low 8 bits or r11 + x86_64::lldb_r12l, // Low 8 bits or r12 + x86_64::lldb_r13l, // Low 8 bits or r13 + x86_64::lldb_r14l, // Low 8 bits or r14 + x86_64::lldb_r15l, // Low 8 bits or r15 LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) - 1 == - k_num_gpr_registers_x86_64, + x86_64::k_num_gpr_registers, "g_gpr_regnums_x86_64 has wrong number of register infos"); // x86 64-bit floating point registers. static const uint32_t g_fpu_regnums_x86_64[] = { - lldb_fctrl_x86_64, lldb_fstat_x86_64, lldb_ftag_x86_64, - lldb_fop_x86_64, lldb_fiseg_x86_64, lldb_fioff_x86_64, - lldb_fip_x86_64, lldb_foseg_x86_64, lldb_fooff_x86_64, - lldb_fdp_x86_64, lldb_mxcsr_x86_64, lldb_mxcsrmask_x86_64, - lldb_st0_x86_64, lldb_st1_x86_64, lldb_st2_x86_64, - lldb_st3_x86_64, lldb_st4_x86_64, lldb_st5_x86_64, - lldb_st6_x86_64, lldb_st7_x86_64, lldb_mm0_x86_64, - lldb_mm1_x86_64, lldb_mm2_x86_64, lldb_mm3_x86_64, - lldb_mm4_x86_64, lldb_mm5_x86_64, lldb_mm6_x86_64, - lldb_mm7_x86_64, lldb_xmm0_x86_64, lldb_xmm1_x86_64, - lldb_xmm2_x86_64, lldb_xmm3_x86_64, lldb_xmm4_x86_64, - lldb_xmm5_x86_64, lldb_xmm6_x86_64, lldb_xmm7_x86_64, - lldb_xmm8_x86_64, lldb_xmm9_x86_64, lldb_xmm10_x86_64, - lldb_xmm11_x86_64, lldb_xmm12_x86_64, lldb_xmm13_x86_64, - lldb_xmm14_x86_64, lldb_xmm15_x86_64, + x86_64::lldb_fctrl, x86_64::lldb_fstat, x86_64::lldb_ftag, + x86_64::lldb_fop, x86_64::lldb_fiseg, x86_64::lldb_fioff, + x86_64::lldb_fip, x86_64::lldb_foseg, x86_64::lldb_fooff, + x86_64::lldb_fdp, x86_64::lldb_mxcsr, x86_64::lldb_mxcsrmask, + x86_64::lldb_st0, x86_64::lldb_st1, x86_64::lldb_st2, + x86_64::lldb_st3, x86_64::lldb_st4, x86_64::lldb_st5, + x86_64::lldb_st6, x86_64::lldb_st7, x86_64::lldb_mm0, + x86_64::lldb_mm1, x86_64::lldb_mm2, x86_64::lldb_mm3, + x86_64::lldb_mm4, x86_64::lldb_mm5, x86_64::lldb_mm6, + x86_64::lldb_mm7, x86_64::lldb_xmm0, x86_64::lldb_xmm1, + x86_64::lldb_xmm2, x86_64::lldb_xmm3, x86_64::lldb_xmm4, + x86_64::lldb_xmm5, x86_64::lldb_xmm6, x86_64::lldb_xmm7, + x86_64::lldb_xmm8, x86_64::lldb_xmm9, x86_64::lldb_xmm10, + x86_64::lldb_xmm11, x86_64::lldb_xmm12, x86_64::lldb_xmm13, + x86_64::lldb_xmm14, x86_64::lldb_xmm15, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_fpu_regnums_x86_64) / sizeof(g_fpu_regnums_x86_64[0])) - 1 == - k_num_fpr_registers_x86_64, + x86_64::k_num_fpr_registers, "g_fpu_regnums_x86_64 has wrong number of register infos"); static const uint32_t g_avx_regnums_x86_64[] = { - lldb_ymm0_x86_64, lldb_ymm1_x86_64, lldb_ymm2_x86_64, lldb_ymm3_x86_64, - lldb_ymm4_x86_64, lldb_ymm5_x86_64, lldb_ymm6_x86_64, lldb_ymm7_x86_64, - lldb_ymm8_x86_64, lldb_ymm9_x86_64, lldb_ymm10_x86_64, lldb_ymm11_x86_64, - lldb_ymm12_x86_64, lldb_ymm13_x86_64, lldb_ymm14_x86_64, lldb_ymm15_x86_64, + x86_64::lldb_ymm0, x86_64::lldb_ymm1, x86_64::lldb_ymm2, x86_64::lldb_ymm3, + x86_64::lldb_ymm4, x86_64::lldb_ymm5, x86_64::lldb_ymm6, x86_64::lldb_ymm7, + x86_64::lldb_ymm8, x86_64::lldb_ymm9, x86_64::lldb_ymm10, x86_64::lldb_ymm11, + x86_64::lldb_ymm12, x86_64::lldb_ymm13, x86_64::lldb_ymm14, x86_64::lldb_ymm15, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) - 1 == - k_num_avx_registers_x86_64, + x86_64::k_num_avx_registers, "g_avx_regnums_x86_64 has wrong number of register infos"); static const uint32_t g_mpx_regnums_x86_64[] = { // Note: we currently do not provide them but this is needed to avoid // unnamed groups in SBFrame::GetRegisterContext(). - lldb_bnd0_x86_64, lldb_bnd1_x86_64, lldb_bnd2_x86_64, - lldb_bnd3_x86_64, lldb_bndcfgu_x86_64, lldb_bndstatus_x86_64, + x86_64::lldb_bnd0, x86_64::lldb_bnd1, x86_64::lldb_bnd2, + x86_64::lldb_bnd3, x86_64::lldb_bndcfgu, x86_64::lldb_bndstatus, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_mpx_regnums_x86_64) / sizeof(g_mpx_regnums_x86_64[0])) - 1 == - k_num_mpx_registers_x86_64, + x86_64::k_num_mpx_registers, "g_mpx_regnums_x86_64 has wrong number of register infos"); // x86 debug registers. static const uint32_t g_dbr_regnums_x86_64[] = { - lldb_dr0_x86_64, lldb_dr1_x86_64, lldb_dr2_x86_64, lldb_dr3_x86_64, - lldb_dr4_x86_64, lldb_dr5_x86_64, lldb_dr6_x86_64, lldb_dr7_x86_64, + x86_64::lldb_dr0, x86_64::lldb_dr1, x86_64::lldb_dr2, x86_64::lldb_dr3, + x86_64::lldb_dr4, x86_64::lldb_dr5, x86_64::lldb_dr6, x86_64::lldb_dr7, LLDB_INVALID_REGNUM // register sets need to end with this flag }; static_assert((sizeof(g_dbr_regnums_x86_64) / sizeof(g_dbr_regnums_x86_64[0])) - 1 == - k_num_dbr_registers_x86_64, + x86_64::k_num_dbr_registers, "g_dbr_regnums_x86_64 has wrong number of register infos"); // x86 32-bit general purpose registers. @@ -228,15 +228,15 @@ // Register sets for x86 64-bit. static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = { - {"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64, + {"General Purpose Registers", "gpr", x86_64::k_num_gpr_registers, g_gpr_regnums_x86_64}, - {"Floating Point Registers", "fpu", k_num_fpr_registers_x86_64, + {"Floating Point Registers", "fpu", x86_64::k_num_fpr_registers, g_fpu_regnums_x86_64}, - {"Debug Registers", "dbr", k_num_dbr_registers_x86_64, + {"Debug Registers", "dbr", x86_64::k_num_dbr_registers, g_dbr_regnums_x86_64}, - {"Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64, + {"Advanced Vector Extensions", "avx", x86_64::k_num_avx_registers, g_avx_regnums_x86_64}, - {"Memory Protection Extensions", "mpx", k_num_mpx_registers_x86_64, + {"Memory Protection Extensions", "mpx", x86_64::k_num_mpx_registers, g_mpx_regnums_x86_64}, }; @@ -278,8 +278,8 @@ first_regnos[DBRegSet] = lldb_dr0_i386; break; case llvm::Triple::x86_64: - first_regnos[FPRegSet] = lldb_fctrl_x86_64; - first_regnos[DBRegSet] = lldb_dr0_x86_64; + first_regnos[FPRegSet] = x86_64::lldb_fctrl; + first_regnos[DBRegSet] = x86_64::lldb_dr0; break; default: llvm_unreachable("Unhandled target architecture."); @@ -326,17 +326,17 @@ return DBRegSet; // DBR break; case llvm::Triple::x86_64: - if (reg_num >= k_first_gpr_x86_64 && reg_num <= k_last_gpr_x86_64) + if (reg_num >= x86_64::k_first_gpr && reg_num <= x86_64::k_last_gpr) return GPRegSet; - if (reg_num >= k_first_fpr_x86_64 && reg_num <= k_last_fpr_x86_64) + if (reg_num >= x86_64::k_first_fpr && reg_num <= x86_64::k_last_fpr) return FPRegSet; - if (reg_num >= k_first_avx_x86_64 && reg_num <= k_last_avx_x86_64) + if (reg_num >= x86_64::k_first_avx && reg_num <= x86_64::k_last_avx) return YMMRegSet; - if (reg_num >= k_first_mpxr_x86_64 && reg_num <= k_last_mpxr_x86_64) + if (reg_num >= x86_64::k_first_mpxr && reg_num <= x86_64::k_last_mpxr) return std::nullopt; // MPXR - if (reg_num >= k_first_mpxc_x86_64 && reg_num <= k_last_mpxc_x86_64) + if (reg_num >= x86_64::k_first_mpxc && reg_num <= x86_64::k_last_mpxc) return std::nullopt; // MPXC - if (reg_num >= k_first_dbr_x86_64 && reg_num <= k_last_dbr_x86_64) + if (reg_num >= x86_64::k_first_dbr && reg_num <= x86_64::k_last_dbr) return DBRegSet; // DBR break; default: @@ -632,7 +632,7 @@ reg_index = reg - lldb_ymm0_i386; break; case llvm::Triple::x86_64: - reg_index = reg - lldb_ymm0_x86_64; + reg_index = reg - x86_64::lldb_ymm0; break; default: llvm_unreachable("Unhandled target architecture."); diff --git a/lldb/source/Plugins/Process/Utility/CMakeLists.txt b/lldb/source/Plugins/Process/Utility/CMakeLists.txt --- a/lldb/source/Plugins/Process/Utility/CMakeLists.txt +++ b/lldb/source/Plugins/Process/Utility/CMakeLists.txt @@ -47,6 +47,7 @@ RegisterContextThreadMemory.cpp RegisterContextWindows_i386.cpp RegisterContextWindows_x86_64.cpp + RegisterInfos_x86_64_with_base_shared.cpp RegisterInfoPOSIX_arm.cpp RegisterInfoPOSIX_arm64.cpp RegisterInfoPOSIX_loongarch64.cpp diff --git a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h --- a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h +++ b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h @@ -46,7 +46,7 @@ uint32_t NumSupportedHardwareWatchpoints() override; - const RegisterInfo *GetDR(int num) const; + virtual const RegisterInfo *GetDR(int num) const; }; } // namespace lldb_private diff --git a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.cpp b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.cpp --- a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.cpp +++ b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.cpp @@ -86,7 +86,7 @@ case llvm::Triple::x86: return GetRegisterInfoAtIndex(lldb_dr0_i386 + num); case llvm::Triple::x86_64: - return GetRegisterInfoAtIndex(lldb_dr0_x86_64 + num); + return GetRegisterInfoAtIndex(x86_64::lldb_dr0 + num); default: llvm_unreachable("Unhandled target architecture."); } diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp --- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp @@ -75,10 +75,10 @@ (LLVM_EXTENSION offsetof(UserArea, dbg) + \ LLVM_EXTENSION offsetof(DBG, dr[reg_index])) -// Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64 +// Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64_with_base // structure. #define DECLARE_REGISTER_INFOS_X86_64_STRUCT -#include "RegisterInfos_x86_64.h" +#include "RegisterInfos_x86_64_with_base.h" #undef DECLARE_REGISTER_INFOS_X86_64_STRUCT static std::vector &GetPrivateRegisterInfoVector() { @@ -103,7 +103,7 @@ // Include RegisterInfos_x86_64 to update the g_register_infos structure // with x86_64 offsets. #define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS -#include "RegisterInfos_x86_64.h" +#include "RegisterInfos_x86_64_with_base.h" #undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS } @@ -115,7 +115,7 @@ case llvm::Triple::x86: return GetRegisterInfo_i386(target_arch); case llvm::Triple::x86_64: - return g_register_infos_x86_64; + return g_register_infos_x86_64_with_base; default: assert(false && "Unhandled target architecture."); return nullptr; @@ -130,8 +130,8 @@ return static_cast(GetPrivateRegisterInfoVector().size()); } case llvm::Triple::x86_64: - return static_cast(sizeof(g_register_infos_x86_64) / - sizeof(g_register_infos_x86_64[0])); + return static_cast(sizeof(g_register_infos_x86_64_with_base) / + sizeof(g_register_infos_x86_64_with_base[0])); default: assert(false && "Unhandled target architecture."); return 0; @@ -143,7 +143,7 @@ case llvm::Triple::x86: return static_cast(k_num_user_registers_i386); case llvm::Triple::x86_64: - return static_cast(k_num_user_registers_x86_64); + return static_cast(x86_64_with_base::k_num_user_registers); default: assert(false && "Unhandled target architecture."); return 0; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp --- a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp @@ -149,7 +149,7 @@ case llvm::Triple::x86: return static_cast(k_num_user_registers_i386); case llvm::Triple::x86_64: - return static_cast(k_num_user_registers_x86_64); + return static_cast(x86_64::k_num_user_registers); default: assert(false && "Unhandled target architecture."); return 0; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h @@ -11,6 +11,7 @@ #include "RegisterContext_x86.h" #include "RegisterInfoInterface.h" +#include "RegisterInfos_x86_64_with_base_shared.h" #include "lldb-x86-register-enums.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Utility/Log.h" @@ -149,34 +150,6 @@ static uint32_t g_invalidate_st7_64[]; protected: - struct RegInfo { - uint32_t num_registers; - uint32_t num_gpr_registers; - uint32_t num_fpr_registers; - uint32_t num_avx_registers; - - uint32_t last_gpr; - uint32_t first_fpr; - uint32_t last_fpr; - - uint32_t first_st; - uint32_t last_st; - uint32_t first_mm; - uint32_t last_mm; - uint32_t first_xmm; - uint32_t last_xmm; - uint32_t first_ymm; - uint32_t last_ymm; - - uint32_t first_dr; - uint32_t gpr_flags; - }; - - uint64_t m_gpr_x86_64[lldb_private::k_num_gpr_registers_x86_64]; // 64-bit - // general - // purpose - // registers. - RegInfo m_reg_info; FPRType m_fpr_type; // determines the type of data stored by union FPR, if any. lldb_private::FPR m_fpr; // floating-point registers including extended @@ -206,6 +179,7 @@ virtual bool ReadFPR() = 0; virtual bool WriteGPR() = 0; virtual bool WriteFPR() = 0; + virtual lldb_private::RegInfo &GetRegInfo(); }; #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_X86_H diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp @@ -73,87 +73,88 @@ " g_avx_regnums_i386 has wrong number of register infos"); static const uint32_t g_gpr_regnums_x86_64[] = { - lldb_rax_x86_64, lldb_rbx_x86_64, lldb_rcx_x86_64, lldb_rdx_x86_64, - lldb_rdi_x86_64, lldb_rsi_x86_64, lldb_rbp_x86_64, lldb_rsp_x86_64, - lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64, - lldb_r12_x86_64, lldb_r13_x86_64, lldb_r14_x86_64, lldb_r15_x86_64, - lldb_rip_x86_64, lldb_rflags_x86_64, lldb_cs_x86_64, lldb_fs_x86_64, - lldb_gs_x86_64, lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64, - lldb_eax_x86_64, lldb_ebx_x86_64, lldb_ecx_x86_64, lldb_edx_x86_64, - lldb_edi_x86_64, lldb_esi_x86_64, lldb_ebp_x86_64, lldb_esp_x86_64, - lldb_r8d_x86_64, // Low 32 bits or r8 - lldb_r9d_x86_64, // Low 32 bits or r9 - lldb_r10d_x86_64, // Low 32 bits or r10 - lldb_r11d_x86_64, // Low 32 bits or r11 - lldb_r12d_x86_64, // Low 32 bits or r12 - lldb_r13d_x86_64, // Low 32 bits or r13 - lldb_r14d_x86_64, // Low 32 bits or r14 - lldb_r15d_x86_64, // Low 32 bits or r15 - lldb_ax_x86_64, lldb_bx_x86_64, lldb_cx_x86_64, lldb_dx_x86_64, - lldb_di_x86_64, lldb_si_x86_64, lldb_bp_x86_64, lldb_sp_x86_64, - lldb_r8w_x86_64, // Low 16 bits or r8 - lldb_r9w_x86_64, // Low 16 bits or r9 - lldb_r10w_x86_64, // Low 16 bits or r10 - lldb_r11w_x86_64, // Low 16 bits or r11 - lldb_r12w_x86_64, // Low 16 bits or r12 - lldb_r13w_x86_64, // Low 16 bits or r13 - lldb_r14w_x86_64, // Low 16 bits or r14 - lldb_r15w_x86_64, // Low 16 bits or r15 - lldb_ah_x86_64, lldb_bh_x86_64, lldb_ch_x86_64, lldb_dh_x86_64, - lldb_al_x86_64, lldb_bl_x86_64, lldb_cl_x86_64, lldb_dl_x86_64, - lldb_dil_x86_64, lldb_sil_x86_64, lldb_bpl_x86_64, lldb_spl_x86_64, - lldb_r8l_x86_64, // Low 8 bits or r8 - lldb_r9l_x86_64, // Low 8 bits or r9 - lldb_r10l_x86_64, // Low 8 bits or r10 - lldb_r11l_x86_64, // Low 8 bits or r11 - lldb_r12l_x86_64, // Low 8 bits or r12 - lldb_r13l_x86_64, // Low 8 bits or r13 - lldb_r14l_x86_64, // Low 8 bits or r14 - lldb_r15l_x86_64, // Low 8 bits or r15 + x86_64::lldb_rax, x86_64::lldb_rbx, x86_64::lldb_rcx, x86_64::lldb_rdx, + x86_64::lldb_rdi, x86_64::lldb_rsi, x86_64::lldb_rbp, x86_64::lldb_rsp, + x86_64::lldb_r8, x86_64::lldb_r9, x86_64::lldb_r10, x86_64::lldb_r11, + x86_64::lldb_r12, x86_64::lldb_r13, x86_64::lldb_r14, x86_64::lldb_r15, + x86_64::lldb_rip, x86_64::lldb_rflags, x86_64::lldb_cs, x86_64::lldb_fs, + x86_64::lldb_gs, x86_64::lldb_ss, x86_64::lldb_ds, x86_64::lldb_es, + x86_64::lldb_eax, x86_64::lldb_ebx, x86_64::lldb_ecx, x86_64::lldb_edx, + x86_64::lldb_edi, x86_64::lldb_esi, x86_64::lldb_ebp, x86_64::lldb_esp, + x86_64::lldb_r8d, // Low 32 bits or r8 + x86_64::lldb_r9d, // Low 32 bits or r9 + x86_64::lldb_r10d, // Low 32 bits or r10 + x86_64::lldb_r11d, // Low 32 bits or r11 + x86_64::lldb_r12d, // Low 32 bits or r12 + x86_64::lldb_r13d, // Low 32 bits or r13 + x86_64::lldb_r14d, // Low 32 bits or r14 + x86_64::lldb_r15d, // Low 32 bits or r15 + x86_64::lldb_ax, x86_64::lldb_bx, x86_64::lldb_cx, x86_64::lldb_dx, + x86_64::lldb_di, x86_64::lldb_si, x86_64::lldb_bp, x86_64::lldb_sp, + x86_64::lldb_r8w, // Low 16 bits or r8 + x86_64::lldb_r9w, // Low 16 bits or r9 + x86_64::lldb_r10w, // Low 16 bits or r10 + x86_64::lldb_r11w, // Low 16 bits or r11 + x86_64::lldb_r12w, // Low 16 bits or r12 + x86_64::lldb_r13w, // Low 16 bits or r13 + x86_64::lldb_r14w, // Low 16 bits or r14 + x86_64::lldb_r15w, // Low 16 bits or r15 + x86_64::lldb_ah, x86_64::lldb_bh, x86_64::lldb_ch, x86_64::lldb_dh, + x86_64::lldb_al, x86_64::lldb_bl, x86_64::lldb_cl, x86_64::lldb_dl, + x86_64::lldb_dil, x86_64::lldb_sil, x86_64::lldb_bpl, x86_64::lldb_spl, + x86_64::lldb_r8l, // Low 8 bits or r8 + x86_64::lldb_r9l, // Low 8 bits or r9 + x86_64::lldb_r10l, // Low 8 bits or r10 + x86_64::lldb_r11l, // Low 8 bits or r11 + x86_64::lldb_r12l, // Low 8 bits or r12 + x86_64::lldb_r13l, // Low 8 bits or r13 + x86_64::lldb_r14l, // Low 8 bits or r14 + x86_64::lldb_r15l, // Low 8 bits or r15 LLDB_INVALID_REGNUM // Register sets must be terminated with // LLDB_INVALID_REGNUM. }; static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) - 1 == - k_num_gpr_registers_x86_64, + x86_64::k_num_gpr_registers, "g_gpr_regnums_x86_64 has wrong number of register infos"); static const uint32_t g_lldb_regnums_x86_64[] = { - lldb_fctrl_x86_64, lldb_fstat_x86_64, lldb_ftag_x86_64, - lldb_fop_x86_64, lldb_fiseg_x86_64, lldb_fioff_x86_64, - lldb_fip_x86_64, lldb_foseg_x86_64, lldb_fooff_x86_64, - lldb_fdp_x86_64, lldb_mxcsr_x86_64, lldb_mxcsrmask_x86_64, - lldb_st0_x86_64, lldb_st1_x86_64, lldb_st2_x86_64, - lldb_st3_x86_64, lldb_st4_x86_64, lldb_st5_x86_64, - lldb_st6_x86_64, lldb_st7_x86_64, lldb_mm0_x86_64, - lldb_mm1_x86_64, lldb_mm2_x86_64, lldb_mm3_x86_64, - lldb_mm4_x86_64, lldb_mm5_x86_64, lldb_mm6_x86_64, - lldb_mm7_x86_64, lldb_xmm0_x86_64, lldb_xmm1_x86_64, - lldb_xmm2_x86_64, lldb_xmm3_x86_64, lldb_xmm4_x86_64, - lldb_xmm5_x86_64, lldb_xmm6_x86_64, lldb_xmm7_x86_64, - lldb_xmm8_x86_64, lldb_xmm9_x86_64, lldb_xmm10_x86_64, - lldb_xmm11_x86_64, lldb_xmm12_x86_64, lldb_xmm13_x86_64, - lldb_xmm14_x86_64, lldb_xmm15_x86_64, + x86_64::lldb_fctrl, x86_64::lldb_fstat, x86_64::lldb_ftag, + x86_64::lldb_fop, x86_64::lldb_fiseg, x86_64::lldb_fioff, + x86_64::lldb_fip, x86_64::lldb_foseg, x86_64::lldb_fooff, + x86_64::lldb_fdp, x86_64::lldb_mxcsr, x86_64::lldb_mxcsrmask, + x86_64::lldb_st0, x86_64::lldb_st1, x86_64::lldb_st2, + x86_64::lldb_st3, x86_64::lldb_st4, x86_64::lldb_st5, + x86_64::lldb_st6, x86_64::lldb_st7, x86_64::lldb_mm0, + x86_64::lldb_mm1, x86_64::lldb_mm2, x86_64::lldb_mm3, + x86_64::lldb_mm4, x86_64::lldb_mm5, x86_64::lldb_mm6, + x86_64::lldb_mm7, x86_64::lldb_xmm0, x86_64::lldb_xmm1, + x86_64::lldb_xmm2, x86_64::lldb_xmm3, x86_64::lldb_xmm4, + x86_64::lldb_xmm5, x86_64::lldb_xmm6, x86_64::lldb_xmm7, + x86_64::lldb_xmm8, x86_64::lldb_xmm9, x86_64::lldb_xmm10, + x86_64::lldb_xmm11, x86_64::lldb_xmm12, x86_64::lldb_xmm13, + x86_64::lldb_xmm14, x86_64::lldb_xmm15, LLDB_INVALID_REGNUM // Register sets must be terminated with // LLDB_INVALID_REGNUM. }; -static_assert((sizeof(g_lldb_regnums_x86_64) / - sizeof(g_lldb_regnums_x86_64[0])) - - 1 == - k_num_fpr_registers_x86_64, - "g_lldb_regnums_x86_64 has wrong number of register infos"); +static_assert( + (sizeof(g_lldb_regnums_x86_64) / sizeof(g_lldb_regnums_x86_64[0])) - 1 == + x86_64::k_num_fpr_registers, + "g_lldb_regnums_x86_64 has wrong number of register infos"); static const uint32_t g_avx_regnums_x86_64[] = { - lldb_ymm0_x86_64, lldb_ymm1_x86_64, lldb_ymm2_x86_64, lldb_ymm3_x86_64, - lldb_ymm4_x86_64, lldb_ymm5_x86_64, lldb_ymm6_x86_64, lldb_ymm7_x86_64, - lldb_ymm8_x86_64, lldb_ymm9_x86_64, lldb_ymm10_x86_64, lldb_ymm11_x86_64, - lldb_ymm12_x86_64, lldb_ymm13_x86_64, lldb_ymm14_x86_64, lldb_ymm15_x86_64, + x86_64::lldb_ymm0, x86_64::lldb_ymm1, x86_64::lldb_ymm2, + x86_64::lldb_ymm3, x86_64::lldb_ymm4, x86_64::lldb_ymm5, + x86_64::lldb_ymm6, x86_64::lldb_ymm7, x86_64::lldb_ymm8, + x86_64::lldb_ymm9, x86_64::lldb_ymm10, x86_64::lldb_ymm11, + x86_64::lldb_ymm12, x86_64::lldb_ymm13, x86_64::lldb_ymm14, + x86_64::lldb_ymm15, LLDB_INVALID_REGNUM // Register sets must be terminated with // LLDB_INVALID_REGNUM. }; static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) - 1 == - k_num_avx_registers_x86_64, + x86_64::k_num_avx_registers, "g_avx_regnums_x86_64 has wrong number of register infos"); uint32_t RegisterContextPOSIX_x86::g_contained_eax[] = {lldb_eax_i386, @@ -194,97 +195,99 @@ uint32_t RegisterContextPOSIX_x86::g_invalidate_esp[] = { lldb_esp_i386, lldb_sp_i386, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_rax[] = {lldb_rax_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_rax[] = {x86_64::lldb_rax, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_rbx[] = {lldb_rbx_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_rbx[] = {x86_64::lldb_rbx, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_rcx[] = {lldb_rcx_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_rcx[] = {x86_64::lldb_rcx, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_rdx[] = {lldb_rdx_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_rdx[] = {x86_64::lldb_rdx, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_rdi[] = {lldb_rdi_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_rdi[] = {x86_64::lldb_rdi, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_rsi[] = {lldb_rsi_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_rsi[] = {x86_64::lldb_rsi, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_rbp[] = {lldb_rbp_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_rbp[] = {x86_64::lldb_rbp, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_rsp[] = {lldb_rsp_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_rsp[] = {x86_64::lldb_rsp, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_r8[] = {lldb_r8_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_r8[] = {x86_64::lldb_r8, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_r9[] = {lldb_r9_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_r9[] = {x86_64::lldb_r9, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_r10[] = {lldb_r10_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_r10[] = {x86_64::lldb_r10, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_r11[] = {lldb_r11_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_r11[] = {x86_64::lldb_r11, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_r12[] = {lldb_r12_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_r12[] = {x86_64::lldb_r12, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_r13[] = {lldb_r13_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_r13[] = {x86_64::lldb_r13, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_r14[] = {lldb_r14_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_r14[] = {x86_64::lldb_r14, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_r15[] = {lldb_r15_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_r15[] = {x86_64::lldb_r15, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_rax[] = { - lldb_rax_x86_64, lldb_eax_x86_64, lldb_ax_x86_64, - lldb_ah_x86_64, lldb_al_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_rax, x86_64::lldb_eax, x86_64::lldb_ax, + x86_64::lldb_ah, x86_64::lldb_al, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_rbx[] = { - lldb_rbx_x86_64, lldb_ebx_x86_64, lldb_bx_x86_64, - lldb_bh_x86_64, lldb_bl_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_rbx, x86_64::lldb_ebx, x86_64::lldb_bx, + x86_64::lldb_bh, x86_64::lldb_bl, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_rcx[] = { - lldb_rcx_x86_64, lldb_ecx_x86_64, lldb_cx_x86_64, - lldb_ch_x86_64, lldb_cl_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_rcx, x86_64::lldb_ecx, x86_64::lldb_cx, + x86_64::lldb_ch, x86_64::lldb_cl, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_rdx[] = { - lldb_rdx_x86_64, lldb_edx_x86_64, lldb_dx_x86_64, - lldb_dh_x86_64, lldb_dl_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_rdx, x86_64::lldb_edx, x86_64::lldb_dx, + x86_64::lldb_dh, x86_64::lldb_dl, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_rdi[] = { - lldb_rdi_x86_64, lldb_edi_x86_64, lldb_di_x86_64, lldb_dil_x86_64, + x86_64::lldb_rdi, x86_64::lldb_edi, x86_64::lldb_di, x86_64::lldb_dil, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_rsi[] = { - lldb_rsi_x86_64, lldb_esi_x86_64, lldb_si_x86_64, lldb_sil_x86_64, + x86_64::lldb_rsi, x86_64::lldb_esi, x86_64::lldb_si, x86_64::lldb_sil, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_rbp[] = { - lldb_rbp_x86_64, lldb_ebp_x86_64, lldb_bp_x86_64, lldb_bpl_x86_64, + x86_64::lldb_rbp, x86_64::lldb_ebp, x86_64::lldb_bp, x86_64::lldb_bpl, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_rsp[] = { - lldb_rsp_x86_64, lldb_esp_x86_64, lldb_sp_x86_64, lldb_spl_x86_64, + x86_64::lldb_rsp, x86_64::lldb_esp, x86_64::lldb_sp, x86_64::lldb_spl, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_r8[] = { - lldb_r8_x86_64, lldb_r8d_x86_64, lldb_r8w_x86_64, lldb_r8l_x86_64, + x86_64::lldb_r8, x86_64::lldb_r8d, x86_64::lldb_r8w, x86_64::lldb_r8l, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_r9[] = { - lldb_r9_x86_64, lldb_r9d_x86_64, lldb_r9w_x86_64, lldb_r9l_x86_64, + x86_64::lldb_r9, x86_64::lldb_r9d, x86_64::lldb_r9w, x86_64::lldb_r9l, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_r10[] = { - lldb_r10_x86_64, lldb_r10d_x86_64, lldb_r10w_x86_64, lldb_r10l_x86_64, + x86_64::lldb_r10, x86_64::lldb_r10d, x86_64::lldb_r10w, x86_64::lldb_r10l, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_r11[] = { - lldb_r11_x86_64, lldb_r11d_x86_64, lldb_r11w_x86_64, lldb_r11l_x86_64, + x86_64::lldb_r11, x86_64::lldb_r11d, x86_64::lldb_r11w, x86_64::lldb_r11l, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_r12[] = { - lldb_r12_x86_64, lldb_r12d_x86_64, lldb_r12w_x86_64, lldb_r12l_x86_64, + x86_64::lldb_r12, x86_64::lldb_r12d, x86_64::lldb_r12w, x86_64::lldb_r12l, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_r13[] = { - lldb_r13_x86_64, lldb_r13d_x86_64, lldb_r13w_x86_64, lldb_r13l_x86_64, + x86_64::lldb_r13, x86_64::lldb_r13d, x86_64::lldb_r13w, x86_64::lldb_r13l, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_r14[] = { - lldb_r14_x86_64, lldb_r14d_x86_64, lldb_r14w_x86_64, lldb_r14l_x86_64, + x86_64::lldb_r14, x86_64::lldb_r14d, x86_64::lldb_r14w, x86_64::lldb_r14l, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_r15[] = { - lldb_r15_x86_64, lldb_r15d_x86_64, lldb_r15w_x86_64, lldb_r15l_x86_64, + x86_64::lldb_r15, x86_64::lldb_r15d, x86_64::lldb_r15w, x86_64::lldb_r15l, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_fip[] = {lldb_fip_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_fip[] = {x86_64::lldb_fip, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_fdp[] = {lldb_fdp_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_fdp[] = {x86_64::lldb_fdp, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_fip[] = { - lldb_fip_x86_64, lldb_fioff_x86_64, lldb_fiseg_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_fip, x86_64::lldb_fioff, x86_64::lldb_fiseg, + LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_fdp[] = { - lldb_fdp_x86_64, lldb_fooff_x86_64, lldb_foseg_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_fdp, x86_64::lldb_fooff, x86_64::lldb_foseg, + LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_contained_st0_32[] = {lldb_st0_i386, LLDB_INVALID_REGNUM}; @@ -320,39 +323,39 @@ uint32_t RegisterContextPOSIX_x86::g_invalidate_st7_32[] = { lldb_st7_i386, lldb_mm7_i386, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_st0_64[] = {lldb_st0_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_st0_64[] = {x86_64::lldb_st0, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_st1_64[] = {lldb_st1_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_st1_64[] = {x86_64::lldb_st1, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_st2_64[] = {lldb_st2_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_st2_64[] = {x86_64::lldb_st2, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_st3_64[] = {lldb_st3_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_st3_64[] = {x86_64::lldb_st3, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_st4_64[] = {lldb_st4_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_st4_64[] = {x86_64::lldb_st4, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_st5_64[] = {lldb_st5_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_st5_64[] = {x86_64::lldb_st5, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_st6_64[] = {lldb_st6_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_st6_64[] = {x86_64::lldb_st6, LLDB_INVALID_REGNUM}; -uint32_t RegisterContextPOSIX_x86::g_contained_st7_64[] = {lldb_st7_x86_64, +uint32_t RegisterContextPOSIX_x86::g_contained_st7_64[] = {x86_64::lldb_st7, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_st0_64[] = { - lldb_st0_x86_64, lldb_mm0_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_st0, x86_64::lldb_mm0, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_st1_64[] = { - lldb_st1_x86_64, lldb_mm1_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_st1, x86_64::lldb_mm1, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_st2_64[] = { - lldb_st2_x86_64, lldb_mm2_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_st2, x86_64::lldb_mm2, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_st3_64[] = { - lldb_st3_x86_64, lldb_mm3_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_st3, x86_64::lldb_mm3, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_st4_64[] = { - lldb_st4_x86_64, lldb_mm4_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_st4, x86_64::lldb_mm4, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_st5_64[] = { - lldb_st5_x86_64, lldb_mm5_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_st5, x86_64::lldb_mm5, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_st6_64[] = { - lldb_st6_x86_64, lldb_mm6_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_st6, x86_64::lldb_mm6, LLDB_INVALID_REGNUM}; uint32_t RegisterContextPOSIX_x86::g_invalidate_st7_64[] = { - lldb_st7_x86_64, lldb_mm7_x86_64, LLDB_INVALID_REGNUM}; + x86_64::lldb_st7, x86_64::lldb_mm7, LLDB_INVALID_REGNUM}; // Number of register sets provided by this context. enum { k_num_extended_register_sets = 1, k_num_register_sets = 3 }; @@ -366,23 +369,23 @@ g_avx_regnums_i386}}; static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = { - {"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64, + {"General Purpose Registers", "gpr", x86_64::k_num_gpr_registers, g_gpr_regnums_x86_64}, - {"Floating Point Registers", "fpu", k_num_fpr_registers_x86_64, + {"Floating Point Registers", "fpu", x86_64::k_num_fpr_registers, g_lldb_regnums_x86_64}, - {"Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64, + {"Advanced Vector Extensions", "avx", x86_64::k_num_avx_registers, g_avx_regnums_x86_64}}; bool RegisterContextPOSIX_x86::IsGPR(unsigned reg) { - return reg <= m_reg_info.last_gpr; // GPR's come first. + return reg <= GetRegInfo().last_gpr; // GPR's come first. } bool RegisterContextPOSIX_x86::IsFPR(unsigned reg) { - return (m_reg_info.first_fpr <= reg && reg <= m_reg_info.last_fpr); + return (GetRegInfo().first_fpr <= reg && reg <= GetRegInfo().last_fpr); } bool RegisterContextPOSIX_x86::IsAVX(unsigned reg) { - return (m_reg_info.first_ymm <= reg && reg <= m_reg_info.last_ymm); + return (GetRegInfo().first_ymm <= reg && reg <= GetRegInfo().last_ymm); } bool RegisterContextPOSIX_x86::IsFPR(unsigned reg, FPRType fpr_type) { @@ -399,50 +402,6 @@ : RegisterContext(thread, concrete_frame_idx) { m_register_info_up.reset(register_info); - switch (register_info->GetTargetArchitecture().GetMachine()) { - case llvm::Triple::x86: - m_reg_info.num_registers = k_num_registers_i386; - m_reg_info.num_gpr_registers = k_num_gpr_registers_i386; - m_reg_info.num_fpr_registers = k_num_fpr_registers_i386; - m_reg_info.num_avx_registers = k_num_avx_registers_i386; - m_reg_info.last_gpr = k_last_gpr_i386; - m_reg_info.first_fpr = k_first_fpr_i386; - m_reg_info.last_fpr = k_last_fpr_i386; - m_reg_info.first_st = lldb_st0_i386; - m_reg_info.last_st = lldb_st7_i386; - m_reg_info.first_mm = lldb_mm0_i386; - m_reg_info.last_mm = lldb_mm7_i386; - m_reg_info.first_xmm = lldb_xmm0_i386; - m_reg_info.last_xmm = lldb_xmm7_i386; - m_reg_info.first_ymm = lldb_ymm0_i386; - m_reg_info.last_ymm = lldb_ymm7_i386; - m_reg_info.first_dr = lldb_dr0_i386; - m_reg_info.gpr_flags = lldb_eflags_i386; - break; - case llvm::Triple::x86_64: - m_reg_info.num_registers = k_num_registers_x86_64; - m_reg_info.num_gpr_registers = k_num_gpr_registers_x86_64; - m_reg_info.num_fpr_registers = k_num_fpr_registers_x86_64; - m_reg_info.num_avx_registers = k_num_avx_registers_x86_64; - m_reg_info.last_gpr = k_last_gpr_x86_64; - m_reg_info.first_fpr = k_first_fpr_x86_64; - m_reg_info.last_fpr = k_last_fpr_x86_64; - m_reg_info.first_st = lldb_st0_x86_64; - m_reg_info.last_st = lldb_st7_x86_64; - m_reg_info.first_mm = lldb_mm0_x86_64; - m_reg_info.last_mm = lldb_mm7_x86_64; - m_reg_info.first_xmm = lldb_xmm0_x86_64; - m_reg_info.last_xmm = lldb_xmm15_x86_64; - m_reg_info.first_ymm = lldb_ymm0_x86_64; - m_reg_info.last_ymm = lldb_ymm15_x86_64; - m_reg_info.first_dr = lldb_dr0_x86_64; - m_reg_info.gpr_flags = lldb_rflags_x86_64; - break; - default: - assert(false && "Unhandled target architecture."); - break; - } - ::memset(&m_fpr, 0, sizeof(FPR)); ::memset(&m_ymm_set, 0, sizeof(YMM)); @@ -466,20 +425,26 @@ void RegisterContextPOSIX_x86::InvalidateAllRegisters() {} unsigned RegisterContextPOSIX_x86::GetRegisterOffset(unsigned reg) { - assert(reg < m_reg_info.num_registers && "Invalid register number."); + assert(reg < GetRegInfo().num_registers && "Invalid register number."); return GetRegisterInfo()[reg].byte_offset; } +RegInfo &RegisterContextPOSIX_x86::GetRegInfo() { + return GetRegInfoShared( + m_register_info_up->GetTargetArchitecture().GetMachine(), + /*with_base=*/false); +} + unsigned RegisterContextPOSIX_x86::GetRegisterSize(unsigned reg) { - assert(reg < m_reg_info.num_registers && "Invalid register number."); + assert(reg < GetRegInfo().num_registers && "Invalid register number."); return GetRegisterInfo()[reg].byte_size; } size_t RegisterContextPOSIX_x86::GetRegisterCount() { size_t num_registers = - m_reg_info.num_gpr_registers + m_reg_info.num_fpr_registers; + GetRegInfo().num_gpr_registers + GetRegInfo().num_fpr_registers; if (GetFPRType() == eXSAVE) - return num_registers + m_reg_info.num_avx_registers; + return num_registers + GetRegInfo().num_avx_registers; return num_registers; } @@ -488,7 +453,7 @@ } size_t RegisterContextPOSIX_x86::GetFXSAVEOffset() { - return GetRegisterInfo()[m_reg_info.first_fpr].byte_offset; + return GetRegisterInfo()[GetRegInfo().first_fpr].byte_offset; } const RegisterInfo *RegisterContextPOSIX_x86::GetRegisterInfo() { @@ -500,7 +465,7 @@ const RegisterInfo * RegisterContextPOSIX_x86::GetRegisterInfoAtIndex(size_t reg) { - if (reg < m_reg_info.num_registers) + if (reg < GetRegInfo().num_registers) return &GetRegisterInfo()[reg]; else return nullptr; @@ -532,7 +497,7 @@ } const char *RegisterContextPOSIX_x86::GetRegisterName(unsigned reg) { - assert(reg < m_reg_info.num_registers && "Invalid register offset."); + assert(reg < GetRegInfo().num_registers && "Invalid register offset."); return GetRegisterInfo()[reg].name; } @@ -543,10 +508,9 @@ return false; if (byte_order == eByteOrderLittle) { - uint32_t reg_no = reg - m_reg_info.first_ymm; - YMMToXState(m_ymm_set.ymm[reg_no], - m_fpr.fxsave.xmm[reg_no].bytes, - m_fpr.xsave.ymmh[reg_no].bytes); + uint32_t reg_no = reg - GetRegInfo().first_ymm; + YMMToXState(m_ymm_set.ymm[reg_no], m_fpr.fxsave.xmm[reg_no].bytes, + m_fpr.xsave.ymmh[reg_no].bytes); return true; } @@ -560,10 +524,9 @@ return false; if (byte_order == eByteOrderLittle) { - uint32_t reg_no = reg - m_reg_info.first_ymm; - m_ymm_set.ymm[reg_no] = XStateToYMM( - m_fpr.fxsave.xmm[reg_no].bytes, - m_fpr.xsave.ymmh[reg_no].bytes); + uint32_t reg_no = reg - GetRegInfo().first_ymm; + m_ymm_set.ymm[reg_no] = XStateToYMM(m_fpr.fxsave.xmm[reg_no].bytes, + m_fpr.xsave.ymmh[reg_no].bytes); return true; } diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp --- a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp @@ -46,10 +46,9 @@ #define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR, regname)) #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \ { \ -#reg, alt, sizeof(((GPR *)nullptr)->reg), GPR_OFFSET(reg), eEncodingUint, \ - eFormatHex, \ - {kind1, kind2, kind3, kind4, lldb_##reg##_x86_64 }, nullptr, nullptr, \ - nullptr, \ + #reg, alt, sizeof(((GPR *)nullptr)->reg), GPR_OFFSET(reg), eEncodingUint, \ + eFormatHex, {kind1, kind2, kind3, kind4, x86_64::lldb_##reg}, nullptr, \ + nullptr, nullptr, \ } typedef struct _FPReg { @@ -76,11 +75,11 @@ #define DEFINE_XMM(reg) \ { \ -#reg, NULL, sizeof(((FPReg *)nullptr)->reg), FPR_OFFSET(reg), \ + #reg, NULL, sizeof(((FPReg *)nullptr)->reg), FPR_OFFSET(reg), \ eEncodingUint, eFormatVectorOfUInt64, \ {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \ - nullptr, nullptr, nullptr, \ + LLDB_INVALID_REGNUM, x86_64::lldb_##reg}, \ + nullptr, nullptr, nullptr, \ } // clang-format off diff --git a/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h b/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h --- a/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h @@ -201,6 +201,9 @@ dwarf_ds_x86_64, dwarf_fs_x86_64, dwarf_gs_x86_64, + // Base registers + dwarf_fs_base_x86_64 = 58, + dwarf_gs_base_x86_64 = 59, // Floating point control registers dwarf_mxcsr_x86_64 = 64, // Media Control and Status dwarf_fctrl_x86_64, // x87 control word diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h --- a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h @@ -66,7 +66,7 @@ #reg, alt, sizeof(((GPR *)nullptr)->reg), \ GPR_OFFSET(reg), eEncodingUint, eFormatHex, \ {kind1, kind2, kind3, kind4, \ - lldb_##reg##_x86_64 }, \ + x86_64::lldb_##reg }, \ nullptr, nullptr, nullptr, \ } @@ -74,7 +74,7 @@ { \ #name, nullptr, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, eFormatHex, \ {kind1, kind2, kind3, kind4, \ - lldb_##name##_x86_64 }, \ + x86_64::lldb_##name }, \ nullptr, nullptr, nullptr, \ } @@ -84,7 +84,7 @@ LLVM_EXTENSION FPR_OFFSET( \ stmm[i]), eEncodingVector, eFormatVectorOfUInt8, \ {dwarf_st##i##_x86_64, dwarf_st##i##_x86_64, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_st##i##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64::lldb_st##i }, \ nullptr, nullptr, nullptr, \ } @@ -93,7 +93,7 @@ #reg #i, nullptr, sizeof(uint64_t), LLVM_EXTENSION FPR_OFFSET(stmm[i]), \ eEncodingUint, eFormatHex, \ {dwarf_mm##i##_x86_64, dwarf_mm##i##_x86_64, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_mm##i##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64::lldb_mm##i }, \ RegisterContextPOSIX_x86::g_contained_##streg##_64, \ RegisterContextPOSIX_x86::g_invalidate_##streg##_64, \ nullptr, \ @@ -106,7 +106,7 @@ reg[i]), eEncodingVector, eFormatVectorOfUInt8, \ {dwarf_##reg##i##_x86_64, dwarf_##reg##i##_x86_64, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg##i##_x86_64 }, \ + x86_64::lldb_##reg##i }, \ nullptr, nullptr, nullptr, \ } @@ -117,7 +117,7 @@ {dwarf_##reg##i##h_x86_64, \ dwarf_##reg##i##h_x86_64, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg##i##_x86_64 }, \ + x86_64::lldb_##reg##i }, \ nullptr, nullptr, nullptr, \ } @@ -128,7 +128,7 @@ {dwarf_##reg##i##_x86_64, \ dwarf_##reg##i##_x86_64, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg##i##_x86_64 }, \ + x86_64::lldb_##reg##i }, \ nullptr, nullptr, nullptr, \ } @@ -137,7 +137,7 @@ #name, nullptr, BNDC_SIZE, \ LLVM_EXTENSION BNDC_OFFSET(i), eEncodingVector, eFormatVectorOfUInt8, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_##name##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64::lldb_##name }, \ nullptr, nullptr, nullptr, \ } @@ -147,7 +147,7 @@ DR_OFFSET(i), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg##i##_x86_64 }, \ + x86_64::lldb_##reg##i }, \ nullptr, nullptr, nullptr, \ } @@ -157,7 +157,7 @@ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg32##_x86_64 }, \ + x86_64::lldb_##reg32 }, \ RegisterContextPOSIX_x86::g_contained_##reg64, \ RegisterContextPOSIX_x86::g_invalidate_##reg64, \ nullptr, \ @@ -169,7 +169,7 @@ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg16##_x86_64 }, \ + x86_64::lldb_##reg16 }, \ RegisterContextPOSIX_x86::g_contained_##reg64, \ RegisterContextPOSIX_x86::g_invalidate_##reg64, \ nullptr, \ @@ -181,7 +181,7 @@ GPR_OFFSET(reg64) + 1, eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg8##_x86_64 }, \ + x86_64::lldb_##reg8 }, \ RegisterContextPOSIX_x86::g_contained_##reg64, \ RegisterContextPOSIX_x86::g_invalidate_##reg64, \ nullptr, \ @@ -193,7 +193,7 @@ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg8##_x86_64 }, \ + x86_64::lldb_##reg8 }, \ RegisterContextPOSIX_x86::g_contained_##reg64, \ RegisterContextPOSIX_x86::g_invalidate_##reg64, \ nullptr \ @@ -202,7 +202,7 @@ #define DEFINE_FPR_32(name, reg, kind1, kind2, kind3, kind4, reg64) \ { \ #name, nullptr, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, eFormatHex, \ - {kind1, kind2, kind3, kind4, lldb_##name##_x86_64 }, \ + {kind1, kind2, kind3, kind4, x86_64::lldb_##name }, \ RegisterContextPOSIX_x86::g_contained_##reg64, \ RegisterContextPOSIX_x86::g_invalidate_##reg64, \ nullptr, \ @@ -321,7 +321,7 @@ // clang-format on static_assert((sizeof(g_register_infos_x86_64) / - sizeof(g_register_infos_x86_64[0])) == k_num_registers_x86_64, + sizeof(g_register_infos_x86_64[0])) == x86_64::k_num_registers, "g_register_infos_x86_64 has wrong number of register infos"); #undef FPR_SIZE diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base.h copy from lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h copy to lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base.h --- a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base.h @@ -1,4 +1,4 @@ -//===-- RegisterInfos_x86_64.h ----------------------------------*- C++ -*-===// +//===-- RegisterInfos_x86_64_with_base.h ------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +#include "RegisterInfos_x86_64_with_base_shared.h" + // This file is meant to be textually included. Do not #include modular // headers here. @@ -66,7 +68,17 @@ #reg, alt, sizeof(((GPR *)nullptr)->reg), \ GPR_OFFSET(reg), eEncodingUint, eFormatHex, \ {kind1, kind2, kind3, kind4, \ - lldb_##reg##_x86_64 }, \ + x86_64_with_base::lldb_##reg }, \ + nullptr, nullptr, nullptr, \ + } + +// Note that the size and offset will be updated by platform-specific classes. +#define DEFINE_GPR_WITH_BASE(reg, alt, kind1, kind2, kind3, kind4) \ + { \ + #reg, alt, sizeof(((GPR *)nullptr)->reg), \ + GPR_OFFSET(reg), eEncodingUint, eFormatHex, \ + {kind1, kind2, kind3, kind4, \ + x86_64_with_base::lldb_##reg }, \ nullptr, nullptr, nullptr, \ } @@ -74,7 +86,7 @@ { \ #name, nullptr, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, eFormatHex, \ {kind1, kind2, kind3, kind4, \ - lldb_##name##_x86_64 }, \ + x86_64_with_base::lldb_##name }, \ nullptr, nullptr, nullptr, \ } @@ -84,7 +96,7 @@ LLVM_EXTENSION FPR_OFFSET( \ stmm[i]), eEncodingVector, eFormatVectorOfUInt8, \ {dwarf_st##i##_x86_64, dwarf_st##i##_x86_64, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_st##i##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64_with_base::lldb_st##i }, \ nullptr, nullptr, nullptr, \ } @@ -93,9 +105,9 @@ #reg #i, nullptr, sizeof(uint64_t), LLVM_EXTENSION FPR_OFFSET(stmm[i]), \ eEncodingUint, eFormatHex, \ {dwarf_mm##i##_x86_64, dwarf_mm##i##_x86_64, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_mm##i##_x86_64 }, \ - RegisterContextPOSIX_x86::g_contained_##streg##_64, \ - RegisterContextPOSIX_x86::g_invalidate_##streg##_64, \ + LLDB_INVALID_REGNUM, x86_64_with_base::lldb_mm##i }, \ + RegisterInfos_x86_64_with_base_shared::g_contained_##streg##_64, \ + RegisterInfos_x86_64_with_base_shared::g_invalidate_##streg##_64, \ nullptr, \ } @@ -106,7 +118,7 @@ reg[i]), eEncodingVector, eFormatVectorOfUInt8, \ {dwarf_##reg##i##_x86_64, dwarf_##reg##i##_x86_64, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg##i##_x86_64 }, \ + x86_64_with_base::lldb_##reg##i }, \ nullptr, nullptr, nullptr, \ } @@ -117,7 +129,7 @@ {dwarf_##reg##i##h_x86_64, \ dwarf_##reg##i##h_x86_64, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg##i##_x86_64 }, \ + x86_64_with_base::lldb_##reg##i }, \ nullptr, nullptr, nullptr, \ } @@ -128,7 +140,7 @@ {dwarf_##reg##i##_x86_64, \ dwarf_##reg##i##_x86_64, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg##i##_x86_64 }, \ + x86_64_with_base::lldb_##reg##i }, \ nullptr, nullptr, nullptr, \ } @@ -137,7 +149,7 @@ #name, nullptr, BNDC_SIZE, \ LLVM_EXTENSION BNDC_OFFSET(i), eEncodingVector, eFormatVectorOfUInt8, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_##name##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64_with_base::lldb_##name }, \ nullptr, nullptr, nullptr, \ } @@ -147,7 +159,7 @@ DR_OFFSET(i), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg##i##_x86_64 }, \ + x86_64_with_base::lldb_##reg##i }, \ nullptr, nullptr, nullptr, \ } @@ -157,9 +169,9 @@ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg32##_x86_64 }, \ - RegisterContextPOSIX_x86::g_contained_##reg64, \ - RegisterContextPOSIX_x86::g_invalidate_##reg64, \ + x86_64_with_base::lldb_##reg32 }, \ + RegisterInfos_x86_64_with_base_shared::g_contained_##reg64, \ + RegisterInfos_x86_64_with_base_shared::g_invalidate_##reg64, \ nullptr, \ } @@ -169,9 +181,9 @@ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg16##_x86_64 }, \ - RegisterContextPOSIX_x86::g_contained_##reg64, \ - RegisterContextPOSIX_x86::g_invalidate_##reg64, \ + x86_64_with_base::lldb_##reg16 }, \ + RegisterInfos_x86_64_with_base_shared::g_contained_##reg64, \ + RegisterInfos_x86_64_with_base_shared::g_invalidate_##reg64, \ nullptr, \ } @@ -181,9 +193,9 @@ GPR_OFFSET(reg64) + 1, eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg8##_x86_64 }, \ - RegisterContextPOSIX_x86::g_contained_##reg64, \ - RegisterContextPOSIX_x86::g_invalidate_##reg64, \ + x86_64_with_base::lldb_##reg8 }, \ + RegisterInfos_x86_64_with_base_shared::g_contained_##reg64, \ + RegisterInfos_x86_64_with_base_shared::g_invalidate_##reg64, \ nullptr, \ } @@ -193,23 +205,23 @@ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - lldb_##reg8##_x86_64 }, \ - RegisterContextPOSIX_x86::g_contained_##reg64, \ - RegisterContextPOSIX_x86::g_invalidate_##reg64, \ + x86_64_with_base::lldb_##reg8 }, \ + RegisterInfos_x86_64_with_base_shared::g_contained_##reg64, \ + RegisterInfos_x86_64_with_base_shared::g_invalidate_##reg64, \ nullptr \ } #define DEFINE_FPR_32(name, reg, kind1, kind2, kind3, kind4, reg64) \ { \ #name, nullptr, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, eFormatHex, \ - {kind1, kind2, kind3, kind4, lldb_##name##_x86_64 }, \ - RegisterContextPOSIX_x86::g_contained_##reg64, \ - RegisterContextPOSIX_x86::g_invalidate_##reg64, \ + {kind1, kind2, kind3, kind4, x86_64_with_base::lldb_##name }, \ + RegisterInfos_x86_64_with_base_shared::g_contained_##reg64, \ + RegisterInfos_x86_64_with_base_shared::g_invalidate_##reg64, \ nullptr, \ } // clang-format off -static RegisterInfo g_register_infos_x86_64[] = { +static RegisterInfo g_register_infos_x86_64_with_base[] = { // General purpose registers EH_Frame DWARF Generic Process Plugin // =========================== ================== ================ ========================= ==================== DEFINE_GPR(rax, nullptr, dwarf_rax_x86_64, dwarf_rax_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), @@ -234,6 +246,8 @@ DEFINE_GPR(fs, nullptr, dwarf_fs_x86_64, dwarf_fs_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), DEFINE_GPR(gs, nullptr, dwarf_gs_x86_64, dwarf_gs_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), DEFINE_GPR(ss, nullptr, dwarf_ss_x86_64, dwarf_ss_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), + DEFINE_GPR(fs_base, nullptr, dwarf_fs_base_x86_64, dwarf_fs_base_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), + DEFINE_GPR(gs_base, nullptr, dwarf_gs_base_x86_64, dwarf_gs_base_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), DEFINE_GPR(ds, nullptr, dwarf_ds_x86_64, dwarf_ds_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), DEFINE_GPR(es, nullptr, dwarf_es_x86_64, dwarf_es_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), @@ -320,9 +334,9 @@ // clang-format on -static_assert((sizeof(g_register_infos_x86_64) / - sizeof(g_register_infos_x86_64[0])) == k_num_registers_x86_64, - "g_register_infos_x86_64 has wrong number of register infos"); +static_assert((sizeof(g_register_infos_x86_64_with_base) / + sizeof(g_register_infos_x86_64_with_base[0])) == x86_64_with_base::k_num_registers, + "g_register_infos_x86_64_with_base has wrong number of register infos"); #undef FPR_SIZE #undef FP_SIZE diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.h copy from lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h copy to lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.h --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h +++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.h @@ -1,4 +1,4 @@ -//===-- RegisterContextPOSIX_x86.h ------------------------------*- C++ -*-===// +//===-- RegisterInfos_x86_64_with_base_shared.h -----------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,54 +6,17 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_X86_H -#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_X86_H +#include "Plugins/Process/Utility/lldb-x86-register-enums.h" +#include -#include "RegisterContext_x86.h" -#include "RegisterInfoInterface.h" -#include "lldb-x86-register-enums.h" -#include "lldb/Target/RegisterContext.h" -#include "lldb/Utility/Log.h" +#ifndef lldb_RegisterInfos_x86_64_with_base_shared_h +#define lldb_RegisterInfos_x86_64_with_base_shared_h -class RegisterContextPOSIX_x86 : public lldb_private::RegisterContext { -public: - RegisterContextPOSIX_x86(lldb_private::Thread &thread, - uint32_t concrete_frame_idx, - lldb_private::RegisterInfoInterface *register_info); +#include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h" - ~RegisterContextPOSIX_x86() override; - - void Invalidate(); - - void InvalidateAllRegisters() override; - - size_t GetRegisterCount() override; - - virtual size_t GetGPRSize(); - - virtual size_t GetFXSAVEOffset(); - - virtual unsigned GetRegisterSize(unsigned reg); - - virtual unsigned GetRegisterOffset(unsigned reg); - - const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; - - size_t GetRegisterSetCount() override; - - const lldb_private::RegisterSet *GetRegisterSet(size_t set) override; - - const char *GetRegisterName(unsigned reg); - - // Note: prefer kernel definitions over user-land - enum FPRType { - eNotValid = 0, - eFSAVE, // TODO - eFXSAVE, - eSOFT, // TODO - eXSAVE - }; +namespace lldb_private { +struct RegisterInfos_x86_64_with_base_shared { static uint32_t g_contained_eax[]; static uint32_t g_contained_ebx[]; static uint32_t g_contained_ecx[]; @@ -147,65 +110,33 @@ static uint32_t g_invalidate_st5_64[]; static uint32_t g_invalidate_st6_64[]; static uint32_t g_invalidate_st7_64[]; +}; -protected: - struct RegInfo { - uint32_t num_registers; - uint32_t num_gpr_registers; - uint32_t num_fpr_registers; - uint32_t num_avx_registers; - - uint32_t last_gpr; - uint32_t first_fpr; - uint32_t last_fpr; - - uint32_t first_st; - uint32_t last_st; - uint32_t first_mm; - uint32_t last_mm; - uint32_t first_xmm; - uint32_t last_xmm; - uint32_t first_ymm; - uint32_t last_ymm; - - uint32_t first_dr; - uint32_t gpr_flags; - }; - - uint64_t m_gpr_x86_64[lldb_private::k_num_gpr_registers_x86_64]; // 64-bit - // general - // purpose - // registers. - RegInfo m_reg_info; - FPRType - m_fpr_type; // determines the type of data stored by union FPR, if any. - lldb_private::FPR m_fpr; // floating-point registers including extended - // register sets. - lldb_private::YMM m_ymm_set; // copy of ymmh and xmm register halves. - std::unique_ptr - m_register_info_up; // Register Info Interface (FreeBSD or Linux) - - // Determines if an extended register set is supported on the processor - // running the inferior process. - virtual bool IsRegisterSetAvailable(size_t set_index); - - virtual const lldb_private::RegisterInfo *GetRegisterInfo(); - - bool IsGPR(unsigned reg); - - bool IsFPR(unsigned reg); - - bool IsAVX(unsigned reg); - - bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order); - bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order); - bool IsFPR(unsigned reg, FPRType fpr_type); - FPRType GetFPRType(); - - virtual bool ReadGPR() = 0; - virtual bool ReadFPR() = 0; - virtual bool WriteGPR() = 0; - virtual bool WriteFPR() = 0; +struct RegInfo { + uint32_t num_registers; + uint32_t num_gpr_registers; + uint32_t num_fpr_registers; + uint32_t num_avx_registers; + + uint32_t last_gpr; + uint32_t first_fpr; + uint32_t last_fpr; + + uint32_t first_st; + uint32_t last_st; + uint32_t first_mm; + uint32_t last_mm; + uint32_t first_xmm; + uint32_t last_xmm; + uint32_t first_ymm; + uint32_t last_ymm; + + uint32_t first_dr; + uint32_t gpr_flags; }; -#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_X86_H +RegInfo &GetRegInfoShared(llvm::Triple::ArchType arch_type, bool with_base); + +} // namespace lldb_private + +#endif // ifndef lldb_RegisterInfos_x86_64_with_base_shared_h diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp new file mode 100644 --- /dev/null +++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp @@ -0,0 +1,322 @@ +//===-- RegisterInfos_x86_64_with_base_shared.cpp +//--------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "RegisterInfos_x86_64_with_base_shared.h" + +#include "lldb/lldb-defines.h" +#include + +using namespace lldb; + +namespace lldb_private { + +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_eax[] = { + lldb_eax_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_ebx[] = { + lldb_ebx_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_ecx[] = { + lldb_ecx_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_edx[] = { + lldb_edx_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_edi[] = { + lldb_edi_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_esi[] = { + lldb_esi_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_ebp[] = { + lldb_ebp_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_esp[] = { + lldb_esp_i386, LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_eax[] = { + lldb_eax_i386, lldb_ax_i386, lldb_ah_i386, lldb_al_i386, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_ebx[] = { + lldb_ebx_i386, lldb_bx_i386, lldb_bh_i386, lldb_bl_i386, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_ecx[] = { + lldb_ecx_i386, lldb_cx_i386, lldb_ch_i386, lldb_cl_i386, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_edx[] = { + lldb_edx_i386, lldb_dx_i386, lldb_dh_i386, lldb_dl_i386, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_edi[] = { + lldb_edi_i386, lldb_di_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_esi[] = { + lldb_esi_i386, lldb_si_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_ebp[] = { + lldb_ebp_i386, lldb_bp_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_esp[] = { + lldb_esp_i386, lldb_sp_i386, LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_rax[] = { + x86_64_with_base::lldb_rax, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_rbx[] = { + x86_64_with_base::lldb_rbx, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_rcx[] = { + x86_64_with_base::lldb_rcx, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_rdx[] = { + x86_64_with_base::lldb_rdx, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_rdi[] = { + x86_64_with_base::lldb_rdi, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_rsi[] = { + x86_64_with_base::lldb_rsi, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_rbp[] = { + x86_64_with_base::lldb_rbp, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_rsp[] = { + x86_64_with_base::lldb_rsp, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_r8[] = { + x86_64_with_base::lldb_r8, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_r9[] = { + x86_64_with_base::lldb_r9, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_r10[] = { + x86_64_with_base::lldb_r10, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_r11[] = { + x86_64_with_base::lldb_r11, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_r12[] = { + x86_64_with_base::lldb_r12, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_r13[] = { + x86_64_with_base::lldb_r13, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_r14[] = { + x86_64_with_base::lldb_r14, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_r15[] = { + x86_64_with_base::lldb_r15, LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_rax[] = { + x86_64_with_base::lldb_rax, x86_64_with_base::lldb_eax, + x86_64_with_base::lldb_ax, x86_64_with_base::lldb_ah, + x86_64_with_base::lldb_al, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_rbx[] = { + x86_64_with_base::lldb_rbx, x86_64_with_base::lldb_ebx, + x86_64_with_base::lldb_bx, x86_64_with_base::lldb_bh, + x86_64_with_base::lldb_bl, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_rcx[] = { + x86_64_with_base::lldb_rcx, x86_64_with_base::lldb_ecx, + x86_64_with_base::lldb_cx, x86_64_with_base::lldb_ch, + x86_64_with_base::lldb_cl, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_rdx[] = { + x86_64_with_base::lldb_rdx, x86_64_with_base::lldb_edx, + x86_64_with_base::lldb_dx, x86_64_with_base::lldb_dh, + x86_64_with_base::lldb_dl, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_rdi[] = { + x86_64_with_base::lldb_rdi, x86_64_with_base::lldb_edi, + x86_64_with_base::lldb_di, x86_64_with_base::lldb_dil, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_rsi[] = { + x86_64_with_base::lldb_rsi, x86_64_with_base::lldb_esi, + x86_64_with_base::lldb_si, x86_64_with_base::lldb_sil, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_rbp[] = { + x86_64_with_base::lldb_rbp, x86_64_with_base::lldb_ebp, + x86_64_with_base::lldb_bp, x86_64_with_base::lldb_bpl, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_rsp[] = { + x86_64_with_base::lldb_rsp, x86_64_with_base::lldb_esp, + x86_64_with_base::lldb_sp, x86_64_with_base::lldb_spl, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_r8[] = { + x86_64_with_base::lldb_r8, x86_64_with_base::lldb_r8d, + x86_64_with_base::lldb_r8w, x86_64_with_base::lldb_r8l, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_r9[] = { + x86_64_with_base::lldb_r9, x86_64_with_base::lldb_r9d, + x86_64_with_base::lldb_r9w, x86_64_with_base::lldb_r9l, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_r10[] = { + x86_64_with_base::lldb_r10, x86_64_with_base::lldb_r10d, + x86_64_with_base::lldb_r10w, x86_64_with_base::lldb_r10l, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_r11[] = { + x86_64_with_base::lldb_r11, x86_64_with_base::lldb_r11d, + x86_64_with_base::lldb_r11w, x86_64_with_base::lldb_r11l, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_r12[] = { + x86_64_with_base::lldb_r12, x86_64_with_base::lldb_r12d, + x86_64_with_base::lldb_r12w, x86_64_with_base::lldb_r12l, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_r13[] = { + x86_64_with_base::lldb_r13, x86_64_with_base::lldb_r13d, + x86_64_with_base::lldb_r13w, x86_64_with_base::lldb_r13l, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_r14[] = { + x86_64_with_base::lldb_r14, x86_64_with_base::lldb_r14d, + x86_64_with_base::lldb_r14w, x86_64_with_base::lldb_r14l, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_r15[] = { + x86_64_with_base::lldb_r15, x86_64_with_base::lldb_r15d, + x86_64_with_base::lldb_r15w, x86_64_with_base::lldb_r15l, + LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_fip[] = { + x86_64_with_base::lldb_fip, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_fdp[] = { + x86_64_with_base::lldb_fdp, LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_fip[] = { + x86_64_with_base::lldb_fip, x86_64_with_base::lldb_fioff, + x86_64_with_base::lldb_fiseg, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_fdp[] = { + x86_64_with_base::lldb_fdp, x86_64_with_base::lldb_fooff, + x86_64_with_base::lldb_foseg, LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st0_32[] = { + lldb_st0_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st1_32[] = { + lldb_st1_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st2_32[] = { + lldb_st2_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st3_32[] = { + lldb_st3_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st4_32[] = { + lldb_st4_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st5_32[] = { + lldb_st5_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st6_32[] = { + lldb_st6_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st7_32[] = { + lldb_st7_i386, LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st0_32[] = { + lldb_st0_i386, lldb_mm0_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st1_32[] = { + lldb_st1_i386, lldb_mm1_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st2_32[] = { + lldb_st2_i386, lldb_mm2_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st3_32[] = { + lldb_st3_i386, lldb_mm3_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st4_32[] = { + lldb_st4_i386, lldb_mm4_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st5_32[] = { + lldb_st5_i386, lldb_mm5_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st6_32[] = { + lldb_st6_i386, lldb_mm6_i386, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st7_32[] = { + lldb_st7_i386, lldb_mm7_i386, LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st0_64[] = { + x86_64_with_base::lldb_st0, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st1_64[] = { + x86_64_with_base::lldb_st1, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st2_64[] = { + x86_64_with_base::lldb_st2, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st3_64[] = { + x86_64_with_base::lldb_st3, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st4_64[] = { + x86_64_with_base::lldb_st4, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st5_64[] = { + x86_64_with_base::lldb_st5, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st6_64[] = { + x86_64_with_base::lldb_st6, LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_contained_st7_64[] = { + x86_64_with_base::lldb_st7, LLDB_INVALID_REGNUM}; + +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st0_64[] = { + x86_64_with_base::lldb_st0, x86_64_with_base::lldb_mm0, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st1_64[] = { + x86_64_with_base::lldb_st1, x86_64_with_base::lldb_mm1, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st2_64[] = { + x86_64_with_base::lldb_st2, x86_64_with_base::lldb_mm2, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st3_64[] = { + x86_64_with_base::lldb_st3, x86_64_with_base::lldb_mm3, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st4_64[] = { + x86_64_with_base::lldb_st4, x86_64_with_base::lldb_mm4, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st5_64[] = { + x86_64_with_base::lldb_st5, x86_64_with_base::lldb_mm5, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st6_64[] = { + x86_64_with_base::lldb_st6, x86_64_with_base::lldb_mm6, + LLDB_INVALID_REGNUM}; +uint32_t RegisterInfos_x86_64_with_base_shared::g_invalidate_st7_64[] = { + x86_64_with_base::lldb_st7, x86_64_with_base::lldb_mm7, + LLDB_INVALID_REGNUM}; + +RegInfo &GetRegInfoShared(llvm::Triple::ArchType arch_type, bool with_base) { + static std::once_flag once_flag_x86, once_flag_x86_64, + once_flag_x86_64_with_base; + static RegInfo reg_info_x86, reg_info_x86_64, reg_info_x86_64_with_base; + + switch (arch_type) { + case llvm::Triple::x86: + std::call_once(once_flag_x86, []() { + reg_info_x86.num_registers = k_num_registers_i386; + reg_info_x86.num_gpr_registers = k_num_gpr_registers_i386; + reg_info_x86.num_fpr_registers = k_num_fpr_registers_i386; + reg_info_x86.num_avx_registers = k_num_avx_registers_i386; + reg_info_x86.last_gpr = k_last_gpr_i386; + reg_info_x86.first_fpr = k_first_fpr_i386; + reg_info_x86.last_fpr = k_last_fpr_i386; + reg_info_x86.first_st = lldb_st0_i386; + reg_info_x86.last_st = lldb_st7_i386; + reg_info_x86.first_mm = lldb_mm0_i386; + reg_info_x86.last_mm = lldb_mm7_i386; + reg_info_x86.first_xmm = lldb_xmm0_i386; + reg_info_x86.last_xmm = lldb_xmm7_i386; + reg_info_x86.first_ymm = lldb_ymm0_i386; + reg_info_x86.last_ymm = lldb_ymm7_i386; + reg_info_x86.first_dr = lldb_dr0_i386; + reg_info_x86.gpr_flags = lldb_eflags_i386; + }); + + return reg_info_x86; + case llvm::Triple::x86_64: + if (with_base) { + std::call_once(once_flag_x86_64_with_base, []() { + reg_info_x86_64_with_base.num_registers = + x86_64_with_base::k_num_registers; + reg_info_x86_64_with_base.num_gpr_registers = + x86_64_with_base::k_num_gpr_registers; + reg_info_x86_64_with_base.num_fpr_registers = + x86_64_with_base::k_num_fpr_registers; + reg_info_x86_64_with_base.num_avx_registers = + x86_64_with_base::k_num_avx_registers; + reg_info_x86_64_with_base.last_gpr = x86_64_with_base::k_last_gpr; + reg_info_x86_64_with_base.first_fpr = x86_64_with_base::k_first_fpr; + reg_info_x86_64_with_base.last_fpr = x86_64_with_base::k_last_fpr; + reg_info_x86_64_with_base.first_st = x86_64_with_base::lldb_st0; + reg_info_x86_64_with_base.last_st = x86_64_with_base::lldb_st7; + reg_info_x86_64_with_base.first_mm = x86_64_with_base::lldb_mm0; + reg_info_x86_64_with_base.last_mm = x86_64_with_base::lldb_mm7; + reg_info_x86_64_with_base.first_xmm = x86_64_with_base::lldb_xmm0; + reg_info_x86_64_with_base.last_xmm = x86_64_with_base::lldb_xmm15; + reg_info_x86_64_with_base.first_ymm = x86_64_with_base::lldb_ymm0; + reg_info_x86_64_with_base.last_ymm = x86_64_with_base::lldb_ymm15; + reg_info_x86_64_with_base.first_dr = x86_64_with_base::lldb_dr0; + reg_info_x86_64_with_base.gpr_flags = x86_64_with_base::lldb_rflags; + }); + + return reg_info_x86_64_with_base; + } else { + std::call_once(once_flag_x86_64, []() { + reg_info_x86_64.num_registers = x86_64::k_num_registers; + reg_info_x86_64.num_gpr_registers = x86_64::k_num_gpr_registers; + reg_info_x86_64.num_fpr_registers = x86_64::k_num_fpr_registers; + reg_info_x86_64.num_avx_registers = x86_64::k_num_avx_registers; + reg_info_x86_64.last_gpr = x86_64::k_last_gpr; + reg_info_x86_64.first_fpr = x86_64::k_first_fpr; + reg_info_x86_64.last_fpr = x86_64::k_last_fpr; + reg_info_x86_64.first_st = x86_64::lldb_st0; + reg_info_x86_64.last_st = x86_64::lldb_st7; + reg_info_x86_64.first_mm = x86_64::lldb_mm0; + reg_info_x86_64.last_mm = x86_64::lldb_mm7; + reg_info_x86_64.first_xmm = x86_64::lldb_xmm0; + reg_info_x86_64.last_xmm = x86_64::lldb_xmm15; + reg_info_x86_64.first_ymm = x86_64::lldb_ymm0; + reg_info_x86_64.last_ymm = x86_64::lldb_ymm15; + reg_info_x86_64.first_dr = x86_64::lldb_dr0; + reg_info_x86_64.gpr_flags = x86_64::lldb_rflags; + }); + return reg_info_x86_64; + } + default: + assert(false && "Unhandled target architecture."); + break; + } +} + +} // namespace lldb_private diff --git a/lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h --- a/lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h +++ b/lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h @@ -136,191 +136,382 @@ k_num_dbr_registers_i386 = k_last_dbr_i386 - k_first_dbr_i386 + 1, }; -// Internal codes for all x86_64 registers. +namespace x86_64 { enum { - k_first_gpr_x86_64, - lldb_rax_x86_64 = k_first_gpr_x86_64, - lldb_rbx_x86_64, - lldb_rcx_x86_64, - lldb_rdx_x86_64, - lldb_rdi_x86_64, - lldb_rsi_x86_64, - lldb_rbp_x86_64, - lldb_rsp_x86_64, - lldb_r8_x86_64, - lldb_r9_x86_64, - lldb_r10_x86_64, - lldb_r11_x86_64, - lldb_r12_x86_64, - lldb_r13_x86_64, - lldb_r14_x86_64, - lldb_r15_x86_64, - lldb_rip_x86_64, - lldb_rflags_x86_64, - lldb_cs_x86_64, - lldb_fs_x86_64, - lldb_gs_x86_64, - lldb_ss_x86_64, - lldb_ds_x86_64, - lldb_es_x86_64, + k_first_gpr, + lldb_rax = k_first_gpr, + lldb_rbx, + lldb_rcx, + lldb_rdx, + lldb_rdi, + lldb_rsi, + lldb_rbp, + lldb_rsp, + lldb_r8, + lldb_r9, + lldb_r10, + lldb_r11, + lldb_r12, + lldb_r13, + lldb_r14, + lldb_r15, + lldb_rip, + lldb_rflags, + lldb_cs, + lldb_fs, + lldb_gs, + lldb_ss, + lldb_ds, + lldb_es, - k_first_alias_x86_64, - lldb_eax_x86_64 = k_first_alias_x86_64, - lldb_ebx_x86_64, - lldb_ecx_x86_64, - lldb_edx_x86_64, - lldb_edi_x86_64, - lldb_esi_x86_64, - lldb_ebp_x86_64, - lldb_esp_x86_64, - lldb_r8d_x86_64, // Low 32 bits of r8 - lldb_r9d_x86_64, // Low 32 bits of r9 - lldb_r10d_x86_64, // Low 32 bits of r10 - lldb_r11d_x86_64, // Low 32 bits of r11 - lldb_r12d_x86_64, // Low 32 bits of r12 - lldb_r13d_x86_64, // Low 32 bits of r13 - lldb_r14d_x86_64, // Low 32 bits of r14 - lldb_r15d_x86_64, // Low 32 bits of r15 - lldb_ax_x86_64, - lldb_bx_x86_64, - lldb_cx_x86_64, - lldb_dx_x86_64, - lldb_di_x86_64, - lldb_si_x86_64, - lldb_bp_x86_64, - lldb_sp_x86_64, - lldb_r8w_x86_64, // Low 16 bits of r8 - lldb_r9w_x86_64, // Low 16 bits of r9 - lldb_r10w_x86_64, // Low 16 bits of r10 - lldb_r11w_x86_64, // Low 16 bits of r11 - lldb_r12w_x86_64, // Low 16 bits of r12 - lldb_r13w_x86_64, // Low 16 bits of r13 - lldb_r14w_x86_64, // Low 16 bits of r14 - lldb_r15w_x86_64, // Low 16 bits of r15 - lldb_ah_x86_64, - lldb_bh_x86_64, - lldb_ch_x86_64, - lldb_dh_x86_64, - lldb_al_x86_64, - lldb_bl_x86_64, - lldb_cl_x86_64, - lldb_dl_x86_64, - lldb_dil_x86_64, - lldb_sil_x86_64, - lldb_bpl_x86_64, - lldb_spl_x86_64, - lldb_r8l_x86_64, // Low 8 bits of r8 - lldb_r9l_x86_64, // Low 8 bits of r9 - lldb_r10l_x86_64, // Low 8 bits of r10 - lldb_r11l_x86_64, // Low 8 bits of r11 - lldb_r12l_x86_64, // Low 8 bits of r12 - lldb_r13l_x86_64, // Low 8 bits of r13 - lldb_r14l_x86_64, // Low 8 bits of r14 - lldb_r15l_x86_64, // Low 8 bits of r15 - k_last_alias_x86_64 = lldb_r15l_x86_64, + k_first_alias, + lldb_eax = k_first_alias, + lldb_ebx, + lldb_ecx, + lldb_edx, + lldb_edi, + lldb_esi, + lldb_ebp, + lldb_esp, + lldb_r8d, // Low 32 bits of r8 + lldb_r9d, // Low 32 bits of r9 + lldb_r10d, // Low 32 bits of r10 + lldb_r11d, // Low 32 bits of r11 + lldb_r12d, // Low 32 bits of r12 + lldb_r13d, // Low 32 bits of r13 + lldb_r14d, // Low 32 bits of r14 + lldb_r15d, // Low 32 bits of r15 + lldb_ax, + lldb_bx, + lldb_cx, + lldb_dx, + lldb_di, + lldb_si, + lldb_bp, + lldb_sp, + lldb_r8w, // Low 16 bits of r8 + lldb_r9w, // Low 16 bits of r9 + lldb_r10w, // Low 16 bits of r10 + lldb_r11w, // Low 16 bits of r11 + lldb_r12w, // Low 16 bits of r12 + lldb_r13w, // Low 16 bits of r13 + lldb_r14w, // Low 16 bits of r14 + lldb_r15w, // Low 16 bits of r15 + lldb_ah, + lldb_bh, + lldb_ch, + lldb_dh, + lldb_al, + lldb_bl, + lldb_cl, + lldb_dl, + lldb_dil, + lldb_sil, + lldb_bpl, + lldb_spl, + lldb_r8l, // Low 8 bits of r8 + lldb_r9l, // Low 8 bits of r9 + lldb_r10l, // Low 8 bits of r10 + lldb_r11l, // Low 8 bits of r11 + lldb_r12l, // Low 8 bits of r12 + lldb_r13l, // Low 8 bits of r13 + lldb_r14l, // Low 8 bits of r14 + lldb_r15l, // Low 8 bits of r15 + k_last_alias = lldb_r15l, - k_last_gpr_x86_64 = k_last_alias_x86_64, + k_last_gpr = k_last_alias, - k_first_fpr_x86_64, - lldb_fctrl_x86_64 = k_first_fpr_x86_64, - lldb_fstat_x86_64, - lldb_ftag_x86_64, - lldb_fop_x86_64, - lldb_fiseg_x86_64, - lldb_fioff_x86_64, - lldb_fip_x86_64, - lldb_foseg_x86_64, - lldb_fooff_x86_64, - lldb_fdp_x86_64, - lldb_mxcsr_x86_64, - lldb_mxcsrmask_x86_64, - lldb_st0_x86_64, - lldb_st1_x86_64, - lldb_st2_x86_64, - lldb_st3_x86_64, - lldb_st4_x86_64, - lldb_st5_x86_64, - lldb_st6_x86_64, - lldb_st7_x86_64, - lldb_mm0_x86_64, - lldb_mm1_x86_64, - lldb_mm2_x86_64, - lldb_mm3_x86_64, - lldb_mm4_x86_64, - lldb_mm5_x86_64, - lldb_mm6_x86_64, - lldb_mm7_x86_64, - lldb_xmm0_x86_64, - lldb_xmm1_x86_64, - lldb_xmm2_x86_64, - lldb_xmm3_x86_64, - lldb_xmm4_x86_64, - lldb_xmm5_x86_64, - lldb_xmm6_x86_64, - lldb_xmm7_x86_64, - lldb_xmm8_x86_64, - lldb_xmm9_x86_64, - lldb_xmm10_x86_64, - lldb_xmm11_x86_64, - lldb_xmm12_x86_64, - lldb_xmm13_x86_64, - lldb_xmm14_x86_64, - lldb_xmm15_x86_64, - k_last_fpr_x86_64 = lldb_xmm15_x86_64, + k_first_fpr, + lldb_fctrl = k_first_fpr, + lldb_fstat, + lldb_ftag, + lldb_fop, + lldb_fiseg, + lldb_fioff, + lldb_fip, + lldb_foseg, + lldb_fooff, + lldb_fdp, + lldb_mxcsr, + lldb_mxcsrmask, + lldb_st0, + lldb_st1, + lldb_st2, + lldb_st3, + lldb_st4, + lldb_st5, + lldb_st6, + lldb_st7, + lldb_mm0, + lldb_mm1, + lldb_mm2, + lldb_mm3, + lldb_mm4, + lldb_mm5, + lldb_mm6, + lldb_mm7, + lldb_xmm0, + lldb_xmm1, + lldb_xmm2, + lldb_xmm3, + lldb_xmm4, + lldb_xmm5, + lldb_xmm6, + lldb_xmm7, + lldb_xmm8, + lldb_xmm9, + lldb_xmm10, + lldb_xmm11, + lldb_xmm12, + lldb_xmm13, + lldb_xmm14, + lldb_xmm15, + k_last_fpr = lldb_xmm15, - k_first_avx_x86_64, - lldb_ymm0_x86_64 = k_first_avx_x86_64, - lldb_ymm1_x86_64, - lldb_ymm2_x86_64, - lldb_ymm3_x86_64, - lldb_ymm4_x86_64, - lldb_ymm5_x86_64, - lldb_ymm6_x86_64, - lldb_ymm7_x86_64, - lldb_ymm8_x86_64, - lldb_ymm9_x86_64, - lldb_ymm10_x86_64, - lldb_ymm11_x86_64, - lldb_ymm12_x86_64, - lldb_ymm13_x86_64, - lldb_ymm14_x86_64, - lldb_ymm15_x86_64, - k_last_avx_x86_64 = lldb_ymm15_x86_64, + k_first_avx, + lldb_ymm0 = k_first_avx, + lldb_ymm1, + lldb_ymm2, + lldb_ymm3, + lldb_ymm4, + lldb_ymm5, + lldb_ymm6, + lldb_ymm7, + lldb_ymm8, + lldb_ymm9, + lldb_ymm10, + lldb_ymm11, + lldb_ymm12, + lldb_ymm13, + lldb_ymm14, + lldb_ymm15, + k_last_avx = lldb_ymm15, - k_first_mpxr_x86_64, - lldb_bnd0_x86_64 = k_first_mpxr_x86_64, - lldb_bnd1_x86_64, - lldb_bnd2_x86_64, - lldb_bnd3_x86_64, - k_last_mpxr_x86_64 = lldb_bnd3_x86_64, + k_first_mpxr, + lldb_bnd0 = k_first_mpxr, + lldb_bnd1, + lldb_bnd2, + lldb_bnd3, + k_last_mpxr = lldb_bnd3, - k_first_mpxc_x86_64, - lldb_bndcfgu_x86_64 = k_first_mpxc_x86_64, - lldb_bndstatus_x86_64, - k_last_mpxc_x86_64 = lldb_bndstatus_x86_64, + k_first_mpxc, + lldb_bndcfgu = k_first_mpxc, + lldb_bndstatus, + k_last_mpxc = lldb_bndstatus, - k_first_dbr_x86_64, - lldb_dr0_x86_64 = k_first_dbr_x86_64, - lldb_dr1_x86_64, - lldb_dr2_x86_64, - lldb_dr3_x86_64, - lldb_dr4_x86_64, - lldb_dr5_x86_64, - lldb_dr6_x86_64, - lldb_dr7_x86_64, - k_last_dbr_x86_64 = lldb_dr7_x86_64, + k_first_dbr, + lldb_dr0 = k_first_dbr, + lldb_dr1, + lldb_dr2, + lldb_dr3, + lldb_dr4, + lldb_dr5, + lldb_dr6, + lldb_dr7, + k_last_dbr = lldb_dr7, - k_num_registers_x86_64, - k_num_gpr_registers_x86_64 = k_last_gpr_x86_64 - k_first_gpr_x86_64 + 1, - k_num_fpr_registers_x86_64 = k_last_fpr_x86_64 - k_first_fpr_x86_64 + 1, - k_num_avx_registers_x86_64 = k_last_avx_x86_64 - k_first_avx_x86_64 + 1, - k_num_mpx_registers_x86_64 = k_last_mpxc_x86_64 - k_first_mpxr_x86_64 + 1, - k_num_user_registers_x86_64 = k_num_gpr_registers_x86_64 + - k_num_fpr_registers_x86_64 + - k_num_avx_registers_x86_64 + - k_num_mpx_registers_x86_64, - k_num_dbr_registers_x86_64 = k_last_dbr_x86_64 - k_first_dbr_x86_64 + 1, + k_num_registers, + k_num_gpr_registers = k_last_gpr - k_first_gpr + 1, + k_num_fpr_registers = k_last_fpr - k_first_fpr + 1, + k_num_avx_registers = k_last_avx - k_first_avx + 1, + k_num_mpx_registers = k_last_mpxc - k_first_mpxr + 1, + k_num_user_registers = k_num_gpr_registers + + k_num_fpr_registers + + k_num_avx_registers + + k_num_mpx_registers, + k_num_dbr_registers = k_last_dbr - k_first_dbr + 1, }; +} // namespace x86_64 + +namespace x86_64_with_base { +enum { + k_first_gpr, + lldb_rax = k_first_gpr, + lldb_rbx, + lldb_rcx, + lldb_rdx, + lldb_rdi, + lldb_rsi, + lldb_rbp, + lldb_rsp, + lldb_r8, + lldb_r9, + lldb_r10, + lldb_r11, + lldb_r12, + lldb_r13, + lldb_r14, + lldb_r15, + lldb_rip, + lldb_rflags, + lldb_cs, + lldb_fs, + lldb_gs, + lldb_ss, + lldb_fs_base, + lldb_gs_base, + lldb_ds, + lldb_es, + + k_first_alias, + lldb_eax = k_first_alias, + lldb_ebx, + lldb_ecx, + lldb_edx, + lldb_edi, + lldb_esi, + lldb_ebp, + lldb_esp, + lldb_r8d, // Low 32 bits of r8 + lldb_r9d, // Low 32 bits of r9 + lldb_r10d, // Low 32 bits of r10 + lldb_r11d, // Low 32 bits of r11 + lldb_r12d, // Low 32 bits of r12 + lldb_r13d, // Low 32 bits of r13 + lldb_r14d, // Low 32 bits of r14 + lldb_r15d, // Low 32 bits of r15 + lldb_ax, + lldb_bx, + lldb_cx, + lldb_dx, + lldb_di, + lldb_si, + lldb_bp, + lldb_sp, + lldb_r8w, // Low 16 bits of r8 + lldb_r9w, // Low 16 bits of r9 + lldb_r10w, // Low 16 bits of r10 + lldb_r11w, // Low 16 bits of r11 + lldb_r12w, // Low 16 bits of r12 + lldb_r13w, // Low 16 bits of r13 + lldb_r14w, // Low 16 bits of r14 + lldb_r15w, // Low 16 bits of r15 + lldb_ah, + lldb_bh, + lldb_ch, + lldb_dh, + lldb_al, + lldb_bl, + lldb_cl, + lldb_dl, + lldb_dil, + lldb_sil, + lldb_bpl, + lldb_spl, + lldb_r8l, // Low 8 bits of r8 + lldb_r9l, // Low 8 bits of r9 + lldb_r10l, // Low 8 bits of r10 + lldb_r11l, // Low 8 bits of r11 + lldb_r12l, // Low 8 bits of r12 + lldb_r13l, // Low 8 bits of r13 + lldb_r14l, // Low 8 bits of r14 + lldb_r15l, // Low 8 bits of r15 + k_last_alias = lldb_r15l, + + k_last_gpr = k_last_alias, + + k_first_fpr, + lldb_fctrl = k_first_fpr, + lldb_fstat, + lldb_ftag, + lldb_fop, + lldb_fiseg, + lldb_fioff, + lldb_fip, + lldb_foseg, + lldb_fooff, + lldb_fdp, + lldb_mxcsr, + lldb_mxcsrmask, + lldb_st0, + lldb_st1, + lldb_st2, + lldb_st3, + lldb_st4, + lldb_st5, + lldb_st6, + lldb_st7, + lldb_mm0, + lldb_mm1, + lldb_mm2, + lldb_mm3, + lldb_mm4, + lldb_mm5, + lldb_mm6, + lldb_mm7, + lldb_xmm0, + lldb_xmm1, + lldb_xmm2, + lldb_xmm3, + lldb_xmm4, + lldb_xmm5, + lldb_xmm6, + lldb_xmm7, + lldb_xmm8, + lldb_xmm9, + lldb_xmm10, + lldb_xmm11, + lldb_xmm12, + lldb_xmm13, + lldb_xmm14, + lldb_xmm15, + k_last_fpr = lldb_xmm15, + + k_first_avx, + lldb_ymm0 = k_first_avx, + lldb_ymm1, + lldb_ymm2, + lldb_ymm3, + lldb_ymm4, + lldb_ymm5, + lldb_ymm6, + lldb_ymm7, + lldb_ymm8, + lldb_ymm9, + lldb_ymm10, + lldb_ymm11, + lldb_ymm12, + lldb_ymm13, + lldb_ymm14, + lldb_ymm15, + k_last_avx = lldb_ymm15, + + k_first_mpxr, + lldb_bnd0 = k_first_mpxr, + lldb_bnd1, + lldb_bnd2, + lldb_bnd3, + k_last_mpxr = lldb_bnd3, + + k_first_mpxc, + lldb_bndcfgu = k_first_mpxc, + lldb_bndstatus, + k_last_mpxc = lldb_bndstatus, + + k_first_dbr, + lldb_dr0 = k_first_dbr, + lldb_dr1, + lldb_dr2, + lldb_dr3, + lldb_dr4, + lldb_dr5, + lldb_dr6, + lldb_dr7, + k_last_dbr = lldb_dr7, + + k_num_registers, + k_num_gpr_registers = k_last_gpr - k_first_gpr + 1, + k_num_fpr_registers = k_last_fpr - k_first_fpr + 1, + k_num_avx_registers = k_last_avx - k_first_avx + 1, + k_num_mpx_registers = k_last_mpxc - k_first_mpxr + 1, + k_num_user_registers = k_num_gpr_registers + + k_num_fpr_registers + + k_num_avx_registers + + k_num_mpx_registers, + k_num_dbr_registers = k_last_dbr - k_first_dbr + 1, +}; +} // namespace x86_64_with_base + } #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_X86_REGISTER_ENUMS_H diff --git a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp --- a/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp @@ -30,20 +30,20 @@ namespace { static const uint32_t g_gpr_regnums_x86_64[] = { - lldb_rax_x86_64, lldb_rbx_x86_64, lldb_rcx_x86_64, lldb_rdx_x86_64, - lldb_rdi_x86_64, lldb_rsi_x86_64, lldb_rbp_x86_64, lldb_rsp_x86_64, - lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64, - lldb_r12_x86_64, lldb_r13_x86_64, lldb_r14_x86_64, lldb_r15_x86_64, - lldb_rip_x86_64, lldb_rflags_x86_64, lldb_cs_x86_64, lldb_fs_x86_64, - lldb_gs_x86_64, lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64, + x86_64::lldb_rax, x86_64::lldb_rbx, x86_64::lldb_rcx, x86_64::lldb_rdx, + x86_64::lldb_rdi, x86_64::lldb_rsi, x86_64::lldb_rbp, x86_64::lldb_rsp, + x86_64::lldb_r8, x86_64::lldb_r9, x86_64::lldb_r10, x86_64::lldb_r11, + x86_64::lldb_r12, x86_64::lldb_r13, x86_64::lldb_r14, x86_64::lldb_r15, + x86_64::lldb_rip, x86_64::lldb_rflags, x86_64::lldb_cs, x86_64::lldb_fs, + x86_64::lldb_gs, x86_64::lldb_ss, x86_64::lldb_ds, x86_64::lldb_es, LLDB_INVALID_REGNUM // Register set must be terminated with this flag }; static const uint32_t g_fpr_regnums_x86_64[] = { - lldb_xmm0_x86_64, lldb_xmm1_x86_64, lldb_xmm2_x86_64, lldb_xmm3_x86_64, - lldb_xmm4_x86_64, lldb_xmm5_x86_64, lldb_xmm6_x86_64, lldb_xmm7_x86_64, - lldb_xmm8_x86_64, lldb_xmm9_x86_64, lldb_xmm10_x86_64, lldb_xmm11_x86_64, - lldb_xmm12_x86_64, lldb_xmm13_x86_64, lldb_xmm14_x86_64, lldb_xmm15_x86_64, + x86_64::lldb_xmm0, x86_64::lldb_xmm1, x86_64::lldb_xmm2, x86_64::lldb_xmm3, + x86_64::lldb_xmm4, x86_64::lldb_xmm5, x86_64::lldb_xmm6, x86_64::lldb_xmm7, + x86_64::lldb_xmm8, x86_64::lldb_xmm9, x86_64::lldb_xmm10, x86_64::lldb_xmm11, + x86_64::lldb_xmm12, x86_64::lldb_xmm13, x86_64::lldb_xmm14, x86_64::lldb_xmm15, LLDB_INVALID_REGNUM // Register set must be terminated with this flag }; @@ -114,15 +114,15 @@ CreateRegisterInfoInterface(target_arch)) {} bool NativeRegisterContextWindows_x86_64::IsGPR(uint32_t reg_index) const { - return (reg_index >= k_first_gpr_x86_64 && reg_index < k_first_alias_x86_64); + return (reg_index >= x86_64::k_first_gpr && reg_index < x86_64::k_first_alias); } bool NativeRegisterContextWindows_x86_64::IsFPR(uint32_t reg_index) const { - return (reg_index >= lldb_xmm0_x86_64 && reg_index <= k_last_fpr_x86_64); + return (reg_index >= x86_64::lldb_xmm0 && reg_index <= x86_64::k_last_fpr); } bool NativeRegisterContextWindows_x86_64::IsDR(uint32_t reg_index) const { - return (reg_index >= lldb_dr0_x86_64 && reg_index <= lldb_dr7_x86_64); + return (reg_index >= x86_64::lldb_dr0 && reg_index <= x86_64::lldb_dr7); } uint32_t NativeRegisterContextWindows_x86_64::GetRegisterSetCount() const { @@ -146,76 +146,76 @@ return error; switch (reg) { - case lldb_rax_x86_64: + case x86_64::lldb_rax: reg_value.SetUInt64(tls_context.Rax); break; - case lldb_rbx_x86_64: + case x86_64::lldb_rbx: reg_value.SetUInt64(tls_context.Rbx); break; - case lldb_rcx_x86_64: + case x86_64::lldb_rcx: reg_value.SetUInt64(tls_context.Rcx); break; - case lldb_rdx_x86_64: + case x86_64::lldb_rdx: reg_value.SetUInt64(tls_context.Rdx); break; - case lldb_rdi_x86_64: + case x86_64::lldb_rdi: reg_value.SetUInt64(tls_context.Rdi); break; - case lldb_rsi_x86_64: + case x86_64::lldb_rsi: reg_value.SetUInt64(tls_context.Rsi); break; - case lldb_rbp_x86_64: + case x86_64::lldb_rbp: reg_value.SetUInt64(tls_context.Rbp); break; - case lldb_rsp_x86_64: + case x86_64::lldb_rsp: reg_value.SetUInt64(tls_context.Rsp); break; - case lldb_r8_x86_64: + case x86_64::lldb_r8: reg_value.SetUInt64(tls_context.R8); break; - case lldb_r9_x86_64: + case x86_64::lldb_r9: reg_value.SetUInt64(tls_context.R9); break; - case lldb_r10_x86_64: + case x86_64::lldb_r10: reg_value.SetUInt64(tls_context.R10); break; - case lldb_r11_x86_64: + case x86_64::lldb_r11: reg_value.SetUInt64(tls_context.R11); break; - case lldb_r12_x86_64: + case x86_64::lldb_r12: reg_value.SetUInt64(tls_context.R12); break; - case lldb_r13_x86_64: + case x86_64::lldb_r13: reg_value.SetUInt64(tls_context.R13); break; - case lldb_r14_x86_64: + case x86_64::lldb_r14: reg_value.SetUInt64(tls_context.R14); break; - case lldb_r15_x86_64: + case x86_64::lldb_r15: reg_value.SetUInt64(tls_context.R15); break; - case lldb_rip_x86_64: + case x86_64::lldb_rip: reg_value.SetUInt64(tls_context.Rip); break; - case lldb_rflags_x86_64: + case x86_64::lldb_rflags: reg_value.SetUInt64(tls_context.EFlags | 0x2); // Bit #1 always 1 break; - case lldb_cs_x86_64: + case x86_64::lldb_cs: reg_value.SetUInt16(tls_context.SegCs); break; - case lldb_fs_x86_64: + case x86_64::lldb_fs: reg_value.SetUInt16(tls_context.SegFs); break; - case lldb_gs_x86_64: + case x86_64::lldb_gs: reg_value.SetUInt16(tls_context.SegGs); break; - case lldb_ss_x86_64: + case x86_64::lldb_ss: reg_value.SetUInt16(tls_context.SegSs); break; - case lldb_ds_x86_64: + case x86_64::lldb_ds: reg_value.SetUInt16(tls_context.SegDs); break; - case lldb_es_x86_64: + case x86_64::lldb_es: reg_value.SetUInt16(tls_context.SegEs); break; } @@ -235,76 +235,76 @@ return error; switch (reg) { - case lldb_rax_x86_64: + case x86_64::lldb_rax: tls_context.Rax = reg_value.GetAsUInt64(); break; - case lldb_rbx_x86_64: + case x86_64::lldb_rbx: tls_context.Rbx = reg_value.GetAsUInt64(); break; - case lldb_rcx_x86_64: + case x86_64::lldb_rcx: tls_context.Rcx = reg_value.GetAsUInt64(); break; - case lldb_rdx_x86_64: + case x86_64::lldb_rdx: tls_context.Rdx = reg_value.GetAsUInt64(); break; - case lldb_rdi_x86_64: + case x86_64::lldb_rdi: tls_context.Rdi = reg_value.GetAsUInt64(); break; - case lldb_rsi_x86_64: + case x86_64::lldb_rsi: tls_context.Rsi = reg_value.GetAsUInt64(); break; - case lldb_rbp_x86_64: + case x86_64::lldb_rbp: tls_context.Rbp = reg_value.GetAsUInt64(); break; - case lldb_rsp_x86_64: + case x86_64::lldb_rsp: tls_context.Rsp = reg_value.GetAsUInt64(); break; - case lldb_r8_x86_64: + case x86_64::lldb_r8: tls_context.R8 = reg_value.GetAsUInt64(); break; - case lldb_r9_x86_64: + case x86_64::lldb_r9: tls_context.R9 = reg_value.GetAsUInt64(); break; - case lldb_r10_x86_64: + case x86_64::lldb_r10: tls_context.R10 = reg_value.GetAsUInt64(); break; - case lldb_r11_x86_64: + case x86_64::lldb_r11: tls_context.R11 = reg_value.GetAsUInt64(); break; - case lldb_r12_x86_64: + case x86_64::lldb_r12: tls_context.R12 = reg_value.GetAsUInt64(); break; - case lldb_r13_x86_64: + case x86_64::lldb_r13: tls_context.R13 = reg_value.GetAsUInt64(); break; - case lldb_r14_x86_64: + case x86_64::lldb_r14: tls_context.R14 = reg_value.GetAsUInt64(); break; - case lldb_r15_x86_64: + case x86_64::lldb_r15: tls_context.R15 = reg_value.GetAsUInt64(); break; - case lldb_rip_x86_64: + case x86_64::lldb_rip: tls_context.Rip = reg_value.GetAsUInt64(); break; - case lldb_rflags_x86_64: + case x86_64::lldb_rflags: tls_context.EFlags = reg_value.GetAsUInt64(); break; - case lldb_cs_x86_64: + case x86_64::lldb_cs: tls_context.SegCs = reg_value.GetAsUInt16(); break; - case lldb_fs_x86_64: + case x86_64::lldb_fs: tls_context.SegFs = reg_value.GetAsUInt16(); break; - case lldb_gs_x86_64: + case x86_64::lldb_gs: tls_context.SegGs = reg_value.GetAsUInt16(); break; - case lldb_ss_x86_64: + case x86_64::lldb_ss: tls_context.SegSs = reg_value.GetAsUInt16(); break; - case lldb_ds_x86_64: + case x86_64::lldb_ds: tls_context.SegDs = reg_value.GetAsUInt16(); break; - case lldb_es_x86_64: + case x86_64::lldb_es: tls_context.SegEs = reg_value.GetAsUInt16(); break; } @@ -322,52 +322,52 @@ return error; switch (reg) { - case lldb_xmm0_x86_64: + case x86_64::lldb_xmm0: reg_value.SetBytes(&tls_context.Xmm0, 16, endian::InlHostByteOrder()); break; - case lldb_xmm1_x86_64: + case x86_64::lldb_xmm1: reg_value.SetBytes(&tls_context.Xmm1, 16, endian::InlHostByteOrder()); break; - case lldb_xmm2_x86_64: + case x86_64::lldb_xmm2: reg_value.SetBytes(&tls_context.Xmm2, 16, endian::InlHostByteOrder()); break; - case lldb_xmm3_x86_64: + case x86_64::lldb_xmm3: reg_value.SetBytes(&tls_context.Xmm3, 16, endian::InlHostByteOrder()); break; - case lldb_xmm4_x86_64: + case x86_64::lldb_xmm4: reg_value.SetBytes(&tls_context.Xmm4, 16, endian::InlHostByteOrder()); break; - case lldb_xmm5_x86_64: + case x86_64::lldb_xmm5: reg_value.SetBytes(&tls_context.Xmm5, 16, endian::InlHostByteOrder()); break; - case lldb_xmm6_x86_64: + case x86_64::lldb_xmm6: reg_value.SetBytes(&tls_context.Xmm6, 16, endian::InlHostByteOrder()); break; - case lldb_xmm7_x86_64: + case x86_64::lldb_xmm7: reg_value.SetBytes(&tls_context.Xmm7, 16, endian::InlHostByteOrder()); break; - case lldb_xmm8_x86_64: + case x86_64::lldb_xmm8: reg_value.SetBytes(&tls_context.Xmm8, 16, endian::InlHostByteOrder()); break; - case lldb_xmm9_x86_64: + case x86_64::lldb_xmm9: reg_value.SetBytes(&tls_context.Xmm9, 16, endian::InlHostByteOrder()); break; - case lldb_xmm10_x86_64: + case x86_64::lldb_xmm10: reg_value.SetBytes(&tls_context.Xmm10, 16, endian::InlHostByteOrder()); break; - case lldb_xmm11_x86_64: + case x86_64::lldb_xmm11: reg_value.SetBytes(&tls_context.Xmm11, 16, endian::InlHostByteOrder()); break; - case lldb_xmm12_x86_64: + case x86_64::lldb_xmm12: reg_value.SetBytes(&tls_context.Xmm12, 16, endian::InlHostByteOrder()); break; - case lldb_xmm13_x86_64: + case x86_64::lldb_xmm13: reg_value.SetBytes(&tls_context.Xmm13, 16, endian::InlHostByteOrder()); break; - case lldb_xmm14_x86_64: + case x86_64::lldb_xmm14: reg_value.SetBytes(&tls_context.Xmm14, 16, endian::InlHostByteOrder()); break; - case lldb_xmm15_x86_64: + case x86_64::lldb_xmm15: reg_value.SetBytes(&tls_context.Xmm15, 16, endian::InlHostByteOrder()); break; } @@ -387,52 +387,52 @@ return error; switch (reg) { - case lldb_xmm0_x86_64: + case x86_64::lldb_xmm0: memcpy(&tls_context.Xmm0, reg_value.GetBytes(), 16); break; - case lldb_xmm1_x86_64: + case x86_64::lldb_xmm1: memcpy(&tls_context.Xmm1, reg_value.GetBytes(), 16); break; - case lldb_xmm2_x86_64: + case x86_64::lldb_xmm2: memcpy(&tls_context.Xmm2, reg_value.GetBytes(), 16); break; - case lldb_xmm3_x86_64: + case x86_64::lldb_xmm3: memcpy(&tls_context.Xmm3, reg_value.GetBytes(), 16); break; - case lldb_xmm4_x86_64: + case x86_64::lldb_xmm4: memcpy(&tls_context.Xmm4, reg_value.GetBytes(), 16); break; - case lldb_xmm5_x86_64: + case x86_64::lldb_xmm5: memcpy(&tls_context.Xmm5, reg_value.GetBytes(), 16); break; - case lldb_xmm6_x86_64: + case x86_64::lldb_xmm6: memcpy(&tls_context.Xmm6, reg_value.GetBytes(), 16); break; - case lldb_xmm7_x86_64: + case x86_64::lldb_xmm7: memcpy(&tls_context.Xmm7, reg_value.GetBytes(), 16); break; - case lldb_xmm8_x86_64: + case x86_64::lldb_xmm8: memcpy(&tls_context.Xmm8, reg_value.GetBytes(), 16); break; - case lldb_xmm9_x86_64: + case x86_64::lldb_xmm9: memcpy(&tls_context.Xmm9, reg_value.GetBytes(), 16); break; - case lldb_xmm10_x86_64: + case x86_64::lldb_xmm10: memcpy(&tls_context.Xmm10, reg_value.GetBytes(), 16); break; - case lldb_xmm11_x86_64: + case x86_64::lldb_xmm11: memcpy(&tls_context.Xmm11, reg_value.GetBytes(), 16); break; - case lldb_xmm12_x86_64: + case x86_64::lldb_xmm12: memcpy(&tls_context.Xmm12, reg_value.GetBytes(), 16); break; - case lldb_xmm13_x86_64: + case x86_64::lldb_xmm13: memcpy(&tls_context.Xmm13, reg_value.GetBytes(), 16); break; - case lldb_xmm14_x86_64: + case x86_64::lldb_xmm14: memcpy(&tls_context.Xmm14, reg_value.GetBytes(), 16); break; - case lldb_xmm15_x86_64: + case x86_64::lldb_xmm15: memcpy(&tls_context.Xmm15, reg_value.GetBytes(), 16); break; } @@ -450,26 +450,26 @@ return error; switch (reg) { - case lldb_dr0_x86_64: + case x86_64::lldb_dr0: reg_value.SetUInt64(tls_context.Dr0); break; - case lldb_dr1_x86_64: + case x86_64::lldb_dr1: reg_value.SetUInt64(tls_context.Dr1); break; - case lldb_dr2_x86_64: + case x86_64::lldb_dr2: reg_value.SetUInt64(tls_context.Dr2); break; - case lldb_dr3_x86_64: + case x86_64::lldb_dr3: reg_value.SetUInt64(tls_context.Dr3); break; - case lldb_dr4_x86_64: + case x86_64::lldb_dr4: return Status("register DR4 is obsolete"); - case lldb_dr5_x86_64: + case x86_64::lldb_dr5: return Status("register DR5 is obsolete"); - case lldb_dr6_x86_64: + case x86_64::lldb_dr6: reg_value.SetUInt64(tls_context.Dr6); break; - case lldb_dr7_x86_64: + case x86_64::lldb_dr7: reg_value.SetUInt64(tls_context.Dr7); break; } @@ -489,26 +489,26 @@ return error; switch (reg) { - case lldb_dr0_x86_64: + case x86_64::lldb_dr0: tls_context.Dr0 = reg_value.GetAsUInt64(); break; - case lldb_dr1_x86_64: + case x86_64::lldb_dr1: tls_context.Dr1 = reg_value.GetAsUInt64(); break; - case lldb_dr2_x86_64: + case x86_64::lldb_dr2: tls_context.Dr2 = reg_value.GetAsUInt64(); break; - case lldb_dr3_x86_64: + case x86_64::lldb_dr3: tls_context.Dr3 = reg_value.GetAsUInt64(); break; - case lldb_dr4_x86_64: + case x86_64::lldb_dr4: return Status("register DR4 is obsolete"); - case lldb_dr5_x86_64: + case x86_64::lldb_dr5: return Status("register DR5 is obsolete"); - case lldb_dr6_x86_64: + case x86_64::lldb_dr6: tls_context.Dr6 = reg_value.GetAsUInt64(); break; - case lldb_dr7_x86_64: + case x86_64::lldb_dr7: tls_context.Dr7 = reg_value.GetAsUInt64(); break; } @@ -624,7 +624,7 @@ return Status("watchpoint index out of range"); RegisterValue reg_value; - Status error = DRRead(lldb_dr6_x86_64, reg_value); + Status error = DRRead(x86_64::lldb_dr6, reg_value); if (error.Fail()) return error; @@ -661,7 +661,7 @@ return Status("Watchpoint index out of range"); RegisterValue reg_value; - Status error = DRRead(lldb_dr7_x86_64, reg_value); + Status error = DRRead(x86_64::lldb_dr7, reg_value); if (error.Fail()) return error; @@ -679,13 +679,13 @@ // the debug status register (DR6) RegisterValue reg_value; - Status error = DRRead(lldb_dr6_x86_64, reg_value); + Status error = DRRead(x86_64::lldb_dr6, reg_value); if (error.Fail()) return false; uint64_t bit_mask = 1ULL << wp_index; uint64_t status_bits = reg_value.GetAsUInt64() & ~bit_mask; - error = DRWrite(lldb_dr6_x86_64, RegisterValue(status_bits)); + error = DRWrite(x86_64::lldb_dr6, RegisterValue(status_bits)); if (error.Fail()) return false; @@ -693,13 +693,13 @@ // {2-3,20-23}, {4-5,24-27}, or {6-7,28-31} of the debug control register // (DR7) - error = DRRead(lldb_dr7_x86_64, reg_value); + error = DRRead(x86_64::lldb_dr7, reg_value); if (error.Fail()) return false; bit_mask = (0x3 << (2 * wp_index)) | (0xF << (16 + 4 * wp_index)); uint64_t control_bits = reg_value.GetAsUInt64() & ~bit_mask; - return DRWrite(lldb_dr7_x86_64, RegisterValue(control_bits)).Success(); + return DRWrite(x86_64::lldb_dr7, RegisterValue(control_bits)).Success(); } Status NativeRegisterContextWindows_x86_64::ClearAllHardwareWatchpoints() { @@ -707,23 +707,23 @@ // clear bits {0-4} of the debug status register (DR6) - Status error = DRRead(lldb_dr6_x86_64, reg_value); + Status error = DRRead(x86_64::lldb_dr6, reg_value); if (error.Fail()) return error; uint64_t status_bits = reg_value.GetAsUInt64() & ~0xFULL; - error = DRWrite(lldb_dr6_x86_64, RegisterValue(status_bits)); + error = DRWrite(x86_64::lldb_dr6, RegisterValue(status_bits)); if (error.Fail()) return error; // clear bits {0-7,16-31} of the debug control register (DR7) - error = DRRead(lldb_dr7_x86_64, reg_value); + error = DRRead(x86_64::lldb_dr7, reg_value); if (error.Fail()) return error; uint64_t control_bits = reg_value.GetAsUInt64() & ~0xFFFF00FFULL; - return DRWrite(lldb_dr7_x86_64, RegisterValue(control_bits)); + return DRWrite(x86_64::lldb_dr7, RegisterValue(control_bits)); } uint32_t NativeRegisterContextWindows_x86_64::SetHardwareWatchpoint( @@ -766,7 +766,7 @@ Status NativeRegisterContextWindows_x86_64::ApplyHardwareBreakpoint( uint32_t wp_index, lldb::addr_t addr, size_t size, uint32_t flags) { RegisterValue reg_value; - auto error = DRRead(lldb_dr7_x86_64, reg_value); + auto error = DRRead(x86_64::lldb_dr7, reg_value); if (error.Fail()) return error; @@ -787,11 +787,11 @@ uint64_t control_bits = reg_value.GetAsUInt64() & ~bit_mask; control_bits |= enable_bit | rw_bits | size_bits; - error = DRWrite(lldb_dr7_x86_64, RegisterValue(control_bits)); + error = DRWrite(x86_64::lldb_dr7, RegisterValue(control_bits)); if (error.Fail()) return error; - error = DRWrite(lldb_dr0_x86_64 + wp_index, RegisterValue(addr)); + error = DRWrite(x86_64::lldb_dr0 + wp_index, RegisterValue(addr)); if (error.Fail()) return error; @@ -804,7 +804,7 @@ return LLDB_INVALID_ADDRESS; RegisterValue reg_value; - if (DRRead(lldb_dr0_x86_64 + wp_index, reg_value).Fail()) + if (DRRead(x86_64::lldb_dr0 + wp_index, reg_value).Fail()) return LLDB_INVALID_ADDRESS; return reg_value.GetAsUInt64(); diff --git a/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp b/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp --- a/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp @@ -28,7 +28,7 @@ { \ #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase, \ {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, generic, \ - LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64::lldb_##reg }, \ nullptr, nullptr, \ } @@ -36,14 +36,14 @@ #define DEFINE_FPU_XMM(reg) \ #reg, NULL, 16, 0, eEncodingUint, eFormatVectorOfUInt64, \ {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_##reg##_x86_64}, \ + LLDB_INVALID_REGNUM, x86_64::lldb_##reg}, \ nullptr, nullptr #define DEFINE_GPR_PSEUDO_32(reg) \ { \ #reg, nullptr, 4, 0, eEncodingUint, eFormatHexUppercase, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64::lldb_##reg }, \ nullptr, nullptr \ } @@ -51,7 +51,7 @@ { \ #reg, nullptr, 2, 0, eEncodingUint, eFormatHexUppercase, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64::lldb_##reg }, \ nullptr, nullptr \ } @@ -59,7 +59,7 @@ { \ #reg, nullptr, 1, 0, eEncodingUint, eFormatHexUppercase, \ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \ - LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \ + LLDB_INVALID_REGNUM, x86_64::lldb_##reg }, \ nullptr, nullptr \ } @@ -189,7 +189,7 @@ { DEFINE_GPR_BIN(eflags, "flags"), {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, - LLDB_INVALID_REGNUM, lldb_rflags_x86_64}, + LLDB_INVALID_REGNUM, x86_64::lldb_rflags}, nullptr, nullptr, }, @@ -351,138 +351,138 @@ reg_value.SetUInt##size(reg_val); \ break; - GPR_CASE(64, lldb_rax_x86_64, m_context.Rax); - GPR_CASE(64, lldb_rbx_x86_64, m_context.Rbx); - GPR_CASE(64, lldb_rcx_x86_64, m_context.Rcx); - GPR_CASE(64, lldb_rdx_x86_64, m_context.Rdx); - GPR_CASE(64, lldb_rdi_x86_64, m_context.Rdi); - GPR_CASE(64, lldb_rsi_x86_64, m_context.Rsi); - GPR_CASE(64, lldb_r8_x86_64, m_context.R8); - GPR_CASE(64, lldb_r9_x86_64, m_context.R9); - GPR_CASE(64, lldb_r10_x86_64, m_context.R10); - GPR_CASE(64, lldb_r11_x86_64, m_context.R11); - GPR_CASE(64, lldb_r12_x86_64, m_context.R12); - GPR_CASE(64, lldb_r13_x86_64, m_context.R13); - GPR_CASE(64, lldb_r14_x86_64, m_context.R14); - GPR_CASE(64, lldb_r15_x86_64, m_context.R15); - GPR_CASE(64, lldb_rbp_x86_64, m_context.Rbp); - GPR_CASE(64, lldb_rsp_x86_64, m_context.Rsp); - GPR_CASE(64, lldb_rip_x86_64, m_context.Rip); - GPR_CASE(64, lldb_rflags_x86_64, m_context.EFlags); - GPR_CASE(32, lldb_eax_x86_64, static_cast(m_context.Rax)); - GPR_CASE(32, lldb_ebx_x86_64, static_cast(m_context.Rbx)); - GPR_CASE(32, lldb_ecx_x86_64, static_cast(m_context.Rcx)); - GPR_CASE(32, lldb_edx_x86_64, static_cast(m_context.Rdx)); - GPR_CASE(32, lldb_edi_x86_64, static_cast(m_context.Rdi)); - GPR_CASE(32, lldb_esi_x86_64, static_cast(m_context.Rsi)); - GPR_CASE(32, lldb_ebp_x86_64, static_cast(m_context.Rbp)); - GPR_CASE(32, lldb_esp_x86_64, static_cast(m_context.Rsp)); - GPR_CASE(32, lldb_r8d_x86_64, static_cast(m_context.R8)); - GPR_CASE(32, lldb_r9d_x86_64, static_cast(m_context.R9)); - GPR_CASE(32, lldb_r10d_x86_64, static_cast(m_context.R10)); - GPR_CASE(32, lldb_r11d_x86_64, static_cast(m_context.R11)); - GPR_CASE(32, lldb_r12d_x86_64, static_cast(m_context.R12)); - GPR_CASE(32, lldb_r13d_x86_64, static_cast(m_context.R13)); - GPR_CASE(32, lldb_r14d_x86_64, static_cast(m_context.R14)); - GPR_CASE(32, lldb_r15d_x86_64, static_cast(m_context.R15)); - GPR_CASE(16, lldb_ax_x86_64, static_cast(m_context.Rax)); - GPR_CASE(16, lldb_bx_x86_64, static_cast(m_context.Rbx)); - GPR_CASE(16, lldb_cx_x86_64, static_cast(m_context.Rcx)); - GPR_CASE(16, lldb_dx_x86_64, static_cast(m_context.Rdx)); - GPR_CASE(16, lldb_di_x86_64, static_cast(m_context.Rdi)); - GPR_CASE(16, lldb_si_x86_64, static_cast(m_context.Rsi)); - GPR_CASE(16, lldb_bp_x86_64, static_cast(m_context.Rbp)); - GPR_CASE(16, lldb_sp_x86_64, static_cast(m_context.Rsp)); - GPR_CASE(16, lldb_r8w_x86_64, static_cast(m_context.R8)); - GPR_CASE(16, lldb_r9w_x86_64, static_cast(m_context.R9)); - GPR_CASE(16, lldb_r10w_x86_64, static_cast(m_context.R10)); - GPR_CASE(16, lldb_r11w_x86_64, static_cast(m_context.R11)); - GPR_CASE(16, lldb_r12w_x86_64, static_cast(m_context.R12)); - GPR_CASE(16, lldb_r13w_x86_64, static_cast(m_context.R13)); - GPR_CASE(16, lldb_r14w_x86_64, static_cast(m_context.R14)); - GPR_CASE(16, lldb_r15w_x86_64, static_cast(m_context.R15)); - GPR_CASE(8, lldb_ah_x86_64, static_cast(m_context.Rax) >> 8); - GPR_CASE(8, lldb_bh_x86_64, static_cast(m_context.Rbx) >> 8); - GPR_CASE(8, lldb_ch_x86_64, static_cast(m_context.Rcx) >> 8); - GPR_CASE(8, lldb_dh_x86_64, static_cast(m_context.Rdx) >> 8); - GPR_CASE(8, lldb_al_x86_64, static_cast(m_context.Rax)); - GPR_CASE(8, lldb_bl_x86_64, static_cast(m_context.Rbx)); - GPR_CASE(8, lldb_cl_x86_64, static_cast(m_context.Rcx)); - GPR_CASE(8, lldb_dl_x86_64, static_cast(m_context.Rdx)); - GPR_CASE(8, lldb_dil_x86_64, static_cast(m_context.Rdi)); - GPR_CASE(8, lldb_sil_x86_64, static_cast(m_context.Rsi)); - GPR_CASE(8, lldb_bpl_x86_64, static_cast(m_context.Rbp)); - GPR_CASE(8, lldb_spl_x86_64, static_cast(m_context.Rsp)); - GPR_CASE(8, lldb_r8l_x86_64, static_cast(m_context.R8)); - GPR_CASE(8, lldb_r9l_x86_64, static_cast(m_context.R9)); - GPR_CASE(8, lldb_r10l_x86_64, static_cast(m_context.R10)); - GPR_CASE(8, lldb_r11l_x86_64, static_cast(m_context.R11)); - GPR_CASE(8, lldb_r12l_x86_64, static_cast(m_context.R12)); - GPR_CASE(8, lldb_r13l_x86_64, static_cast(m_context.R13)); - GPR_CASE(8, lldb_r14l_x86_64, static_cast(m_context.R14)); - GPR_CASE(8, lldb_r15l_x86_64, static_cast(m_context.R15)); - - case lldb_xmm0_x86_64: + GPR_CASE(64, x86_64::lldb_rax, m_context.Rax); + GPR_CASE(64, x86_64::lldb_rbx, m_context.Rbx); + GPR_CASE(64, x86_64::lldb_rcx, m_context.Rcx); + GPR_CASE(64, x86_64::lldb_rdx, m_context.Rdx); + GPR_CASE(64, x86_64::lldb_rdi, m_context.Rdi); + GPR_CASE(64, x86_64::lldb_rsi, m_context.Rsi); + GPR_CASE(64, x86_64::lldb_r8, m_context.R8); + GPR_CASE(64, x86_64::lldb_r9, m_context.R9); + GPR_CASE(64, x86_64::lldb_r10, m_context.R10); + GPR_CASE(64, x86_64::lldb_r11, m_context.R11); + GPR_CASE(64, x86_64::lldb_r12, m_context.R12); + GPR_CASE(64, x86_64::lldb_r13, m_context.R13); + GPR_CASE(64, x86_64::lldb_r14, m_context.R14); + GPR_CASE(64, x86_64::lldb_r15, m_context.R15); + GPR_CASE(64, x86_64::lldb_rbp, m_context.Rbp); + GPR_CASE(64, x86_64::lldb_rsp, m_context.Rsp); + GPR_CASE(64, x86_64::lldb_rip, m_context.Rip); + GPR_CASE(64, x86_64::lldb_rflags, m_context.EFlags); + GPR_CASE(32, x86_64::lldb_eax, static_cast(m_context.Rax)); + GPR_CASE(32, x86_64::lldb_ebx, static_cast(m_context.Rbx)); + GPR_CASE(32, x86_64::lldb_ecx, static_cast(m_context.Rcx)); + GPR_CASE(32, x86_64::lldb_edx, static_cast(m_context.Rdx)); + GPR_CASE(32, x86_64::lldb_edi, static_cast(m_context.Rdi)); + GPR_CASE(32, x86_64::lldb_esi, static_cast(m_context.Rsi)); + GPR_CASE(32, x86_64::lldb_ebp, static_cast(m_context.Rbp)); + GPR_CASE(32, x86_64::lldb_esp, static_cast(m_context.Rsp)); + GPR_CASE(32, x86_64::lldb_r8d, static_cast(m_context.R8)); + GPR_CASE(32, x86_64::lldb_r9d, static_cast(m_context.R9)); + GPR_CASE(32, x86_64::lldb_r10d, static_cast(m_context.R10)); + GPR_CASE(32, x86_64::lldb_r11d, static_cast(m_context.R11)); + GPR_CASE(32, x86_64::lldb_r12d, static_cast(m_context.R12)); + GPR_CASE(32, x86_64::lldb_r13d, static_cast(m_context.R13)); + GPR_CASE(32, x86_64::lldb_r14d, static_cast(m_context.R14)); + GPR_CASE(32, x86_64::lldb_r15d, static_cast(m_context.R15)); + GPR_CASE(16, x86_64::lldb_ax, static_cast(m_context.Rax)); + GPR_CASE(16, x86_64::lldb_bx, static_cast(m_context.Rbx)); + GPR_CASE(16, x86_64::lldb_cx, static_cast(m_context.Rcx)); + GPR_CASE(16, x86_64::lldb_dx, static_cast(m_context.Rdx)); + GPR_CASE(16, x86_64::lldb_di, static_cast(m_context.Rdi)); + GPR_CASE(16, x86_64::lldb_si, static_cast(m_context.Rsi)); + GPR_CASE(16, x86_64::lldb_bp, static_cast(m_context.Rbp)); + GPR_CASE(16, x86_64::lldb_sp, static_cast(m_context.Rsp)); + GPR_CASE(16, x86_64::lldb_r8w, static_cast(m_context.R8)); + GPR_CASE(16, x86_64::lldb_r9w, static_cast(m_context.R9)); + GPR_CASE(16, x86_64::lldb_r10w, static_cast(m_context.R10)); + GPR_CASE(16, x86_64::lldb_r11w, static_cast(m_context.R11)); + GPR_CASE(16, x86_64::lldb_r12w, static_cast(m_context.R12)); + GPR_CASE(16, x86_64::lldb_r13w, static_cast(m_context.R13)); + GPR_CASE(16, x86_64::lldb_r14w, static_cast(m_context.R14)); + GPR_CASE(16, x86_64::lldb_r15w, static_cast(m_context.R15)); + GPR_CASE(8, x86_64::lldb_ah, static_cast(m_context.Rax) >> 8); + GPR_CASE(8, x86_64::lldb_bh, static_cast(m_context.Rbx) >> 8); + GPR_CASE(8, x86_64::lldb_ch, static_cast(m_context.Rcx) >> 8); + GPR_CASE(8, x86_64::lldb_dh, static_cast(m_context.Rdx) >> 8); + GPR_CASE(8, x86_64::lldb_al, static_cast(m_context.Rax)); + GPR_CASE(8, x86_64::lldb_bl, static_cast(m_context.Rbx)); + GPR_CASE(8, x86_64::lldb_cl, static_cast(m_context.Rcx)); + GPR_CASE(8, x86_64::lldb_dl, static_cast(m_context.Rdx)); + GPR_CASE(8, x86_64::lldb_dil, static_cast(m_context.Rdi)); + GPR_CASE(8, x86_64::lldb_sil, static_cast(m_context.Rsi)); + GPR_CASE(8, x86_64::lldb_bpl, static_cast(m_context.Rbp)); + GPR_CASE(8, x86_64.x86_64::lldb_spl, static_cast(m_context.Rsp)); + GPR_CASE(8, x86_64::lldb_r8l, static_cast(m_context.R8)); + GPR_CASE(8, x86_64::lldb_r9l, static_cast(m_context.R9)); + GPR_CASE(8, x86_64::lldb_r10l, static_cast(m_context.R10)); + GPR_CASE(8, x86_64::lldb_r11l, static_cast(m_context.R11)); + GPR_CASE(8, x86_64::lldb_r12l, static_cast(m_context.R12)); + GPR_CASE(8, x86_64::lldb_r13l, static_cast(m_context.R13)); + GPR_CASE(8, x86_64::lldb_r14l, static_cast(m_context.R14)); + GPR_CASE(8, x86_64::lldb_r15l, static_cast(m_context.R15)); + + case x86_64::lldb_xmm0: reg_value.SetBytes(&m_context.Xmm0, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm1_x86_64: + case x86_64::lldb_xmm1: reg_value.SetBytes(&m_context.Xmm1, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm2_x86_64: + case x86_64::lldb_xmm2: reg_value.SetBytes(&m_context.Xmm2, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm3_x86_64: + case x86_64::lldb_xmm3: reg_value.SetBytes(&m_context.Xmm3, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm4_x86_64: + case x86_64::lldb_xmm4: reg_value.SetBytes(&m_context.Xmm4, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm5_x86_64: + case x86_64::lldb_xmm5: reg_value.SetBytes(&m_context.Xmm5, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm6_x86_64: + case x86_64::lldb_xmm6: reg_value.SetBytes(&m_context.Xmm6, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm7_x86_64: + case x86_64::lldb_xmm7: reg_value.SetBytes(&m_context.Xmm7, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm8_x86_64: + case x86_64::lldb_xmm8: reg_value.SetBytes(&m_context.Xmm8, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm9_x86_64: + case x86_64::lldb_xmm9: reg_value.SetBytes(&m_context.Xmm9, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm10_x86_64: + case x86_64::lldb_xmm10: reg_value.SetBytes(&m_context.Xmm10, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm11_x86_64: + case x86_64::lldb_xmm11: reg_value.SetBytes(&m_context.Xmm11, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm12_x86_64: + case x86_64::lldb_xmm12: reg_value.SetBytes(&m_context.Xmm12, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm13_x86_64: + case x86_64::lldb_xmm13: reg_value.SetBytes(&m_context.Xmm13, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm14_x86_64: + case x86_64::lldb_xmm14: reg_value.SetBytes(&m_context.Xmm14, reg_info->byte_size, endian::InlHostByteOrder()); break; - case lldb_xmm15_x86_64: + case x86_64::lldb_xmm15: reg_value.SetBytes(&m_context.Xmm15, reg_info->byte_size, endian::InlHostByteOrder()); break; @@ -500,106 +500,106 @@ return false; switch (reg_info->kinds[eRegisterKindLLDB]) { - case lldb_rax_x86_64: + case x86_64::lldb_rax: m_context.Rax = reg_value.GetAsUInt64(); break; - case lldb_rbx_x86_64: + case x86_64::lldb_rbx: m_context.Rbx = reg_value.GetAsUInt64(); break; - case lldb_rcx_x86_64: + case x86_64::lldb_rcx: m_context.Rcx = reg_value.GetAsUInt64(); break; - case lldb_rdx_x86_64: + case x86_64::lldb_rdx: m_context.Rdx = reg_value.GetAsUInt64(); break; - case lldb_rdi_x86_64: + case x86_64::lldb_rdi: m_context.Rdi = reg_value.GetAsUInt64(); break; - case lldb_rsi_x86_64: + case x86_64::lldb_rsi: m_context.Rsi = reg_value.GetAsUInt64(); break; - case lldb_r8_x86_64: + case x86_64::lldb_r8: m_context.R8 = reg_value.GetAsUInt64(); break; - case lldb_r9_x86_64: + case x86_64::lldb_r9: m_context.R9 = reg_value.GetAsUInt64(); break; - case lldb_r10_x86_64: + case x86_64::lldb_r10: m_context.R10 = reg_value.GetAsUInt64(); break; - case lldb_r11_x86_64: + case x86_64::lldb_r11: m_context.R11 = reg_value.GetAsUInt64(); break; - case lldb_r12_x86_64: + case x86_64::lldb_r12: m_context.R12 = reg_value.GetAsUInt64(); break; - case lldb_r13_x86_64: + case x86_64::lldb_r13: m_context.R13 = reg_value.GetAsUInt64(); break; - case lldb_r14_x86_64: + case x86_64::lldb_r14: m_context.R14 = reg_value.GetAsUInt64(); break; - case lldb_r15_x86_64: + case x86_64::lldb_r15: m_context.R15 = reg_value.GetAsUInt64(); break; - case lldb_rbp_x86_64: + case x86_64::lldb_rbp: m_context.Rbp = reg_value.GetAsUInt64(); break; - case lldb_rsp_x86_64: + case x86_64::lldb_rsp: m_context.Rsp = reg_value.GetAsUInt64(); break; - case lldb_rip_x86_64: + case x86_64::lldb_rip: m_context.Rip = reg_value.GetAsUInt64(); break; - case lldb_rflags_x86_64: + case x86_64::lldb_rflags: m_context.EFlags = reg_value.GetAsUInt64(); break; - case lldb_xmm0_x86_64: + case x86_64::lldb_xmm0: memcpy(&m_context.Xmm0, reg_value.GetBytes(), 16); break; - case lldb_xmm1_x86_64: + case x86_64::lldb_xmm1: memcpy(&m_context.Xmm1, reg_value.GetBytes(), 16); break; - case lldb_xmm2_x86_64: + case x86_64::lldb_xmm2: memcpy(&m_context.Xmm2, reg_value.GetBytes(), 16); break; - case lldb_xmm3_x86_64: + case x86_64::lldb_xmm3: memcpy(&m_context.Xmm3, reg_value.GetBytes(), 16); break; - case lldb_xmm4_x86_64: + case x86_64::lldb_xmm4: memcpy(&m_context.Xmm4, reg_value.GetBytes(), 16); break; - case lldb_xmm5_x86_64: + case x86_64::lldb_xmm5: memcpy(&m_context.Xmm5, reg_value.GetBytes(), 16); break; - case lldb_xmm6_x86_64: + case x86_64::lldb_xmm6: memcpy(&m_context.Xmm6, reg_value.GetBytes(), 16); break; - case lldb_xmm7_x86_64: + case x86_64::lldb_xmm7: memcpy(&m_context.Xmm7, reg_value.GetBytes(), 16); break; - case lldb_xmm8_x86_64: + case x86_64::lldb_xmm8: memcpy(&m_context.Xmm8, reg_value.GetBytes(), 16); break; - case lldb_xmm9_x86_64: + case x86_64::lldb_xmm9: memcpy(&m_context.Xmm9, reg_value.GetBytes(), 16); break; - case lldb_xmm10_x86_64: + case x86_64::lldb_xmm10: memcpy(&m_context.Xmm10, reg_value.GetBytes(), 16); break; - case lldb_xmm11_x86_64: + case x86_64::lldb_xmm11: memcpy(&m_context.Xmm11, reg_value.GetBytes(), 16); break; - case lldb_xmm12_x86_64: + case x86_64::lldb_xmm12: memcpy(&m_context.Xmm12, reg_value.GetBytes(), 16); break; - case lldb_xmm13_x86_64: + case x86_64::lldb_xmm13: memcpy(&m_context.Xmm13, reg_value.GetBytes(), 16); break; - case lldb_xmm14_x86_64: + case x86_64::lldb_xmm14: memcpy(&m_context.Xmm14, reg_value.GetBytes(), 16); break; - case lldb_xmm15_x86_64: + case x86_64::lldb_xmm15: memcpy(&m_context.Xmm15, reg_value.GetBytes(), 16); break; } diff --git a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt --- a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt +++ b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt @@ -1,6 +1,7 @@ add_lldb_library(lldbPluginProcessElfCore PLUGIN ProcessElfCore.cpp ThreadElfCore.cpp + RegisterContextLinuxCore_x86_64.cpp RegisterContextPOSIXCore_arm.cpp RegisterContextPOSIXCore_arm64.cpp RegisterContextPOSIXCore_mips64.cpp diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.h b/lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.h new file mode 100644 --- /dev/null +++ b/lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.h @@ -0,0 +1,28 @@ +//===-- RegisterContextLinuxCore_x86_64.h -----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTLINUXCORE_X86_64_H +#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTLINUXCORE_X86_64_H + +#include "Plugins/Process/elf-core/RegisterUtilities.h" +#include "RegisterContextPOSIXCore_x86_64.h" + +class RegisterContextLinuxCore_x86_64 : public RegisterContextCorePOSIX_x86_64 { +public: + RegisterContextLinuxCore_x86_64( + lldb_private::Thread &thread, + lldb_private::RegisterInfoInterface *register_info, + const lldb_private::DataExtractor &gpregset, + llvm::ArrayRef notes); + + const lldb_private::RegisterSet *GetRegisterSet(size_t set) override; + + lldb_private::RegInfo &GetRegInfo() override; +}; + +#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTLINUXCORE_X86_64_H diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.cpp new file mode 100644 --- /dev/null +++ b/lldb/source/Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.cpp @@ -0,0 +1,237 @@ +//===-- RegisterContextLinuxCore_x86_64.cpp -------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "RegisterContextLinuxCore_x86_64.h" +#include "lldb/Target/Thread.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RegisterValue.h" + +using namespace lldb_private; + +const uint32_t g_gpr_regnums_i386[] = { + lldb_eax_i386, lldb_ebx_i386, lldb_ecx_i386, lldb_edx_i386, + lldb_edi_i386, lldb_esi_i386, lldb_ebp_i386, lldb_esp_i386, + lldb_eip_i386, lldb_eflags_i386, lldb_cs_i386, lldb_fs_i386, + lldb_gs_i386, lldb_ss_i386, lldb_ds_i386, lldb_es_i386, + lldb_ax_i386, lldb_bx_i386, lldb_cx_i386, lldb_dx_i386, + lldb_di_i386, lldb_si_i386, lldb_bp_i386, lldb_sp_i386, + lldb_ah_i386, lldb_bh_i386, lldb_ch_i386, lldb_dh_i386, + lldb_al_i386, lldb_bl_i386, lldb_cl_i386, lldb_dl_i386, + LLDB_INVALID_REGNUM, // Register sets must be terminated with + // LLDB_INVALID_REGNUM. +}; +static_assert((sizeof(g_gpr_regnums_i386) / sizeof(g_gpr_regnums_i386[0])) - + 1 == + k_num_gpr_registers_i386, + "g_gpr_regnums_i386 has wrong number of register infos"); + +const uint32_t g_lldb_regnums_i386[] = { + lldb_fctrl_i386, lldb_fstat_i386, lldb_ftag_i386, lldb_fop_i386, + lldb_fiseg_i386, lldb_fioff_i386, lldb_foseg_i386, lldb_fooff_i386, + lldb_mxcsr_i386, lldb_mxcsrmask_i386, lldb_st0_i386, lldb_st1_i386, + lldb_st2_i386, lldb_st3_i386, lldb_st4_i386, lldb_st5_i386, + lldb_st6_i386, lldb_st7_i386, lldb_mm0_i386, lldb_mm1_i386, + lldb_mm2_i386, lldb_mm3_i386, lldb_mm4_i386, lldb_mm5_i386, + lldb_mm6_i386, lldb_mm7_i386, lldb_xmm0_i386, lldb_xmm1_i386, + lldb_xmm2_i386, lldb_xmm3_i386, lldb_xmm4_i386, lldb_xmm5_i386, + lldb_xmm6_i386, lldb_xmm7_i386, + LLDB_INVALID_REGNUM // Register sets must be terminated with + // LLDB_INVALID_REGNUM. +}; +static_assert((sizeof(g_lldb_regnums_i386) / sizeof(g_lldb_regnums_i386[0])) - + 1 == + k_num_fpr_registers_i386, + "g_lldb_regnums_i386 has wrong number of register infos"); + +const uint32_t g_avx_regnums_i386[] = { + lldb_ymm0_i386, lldb_ymm1_i386, lldb_ymm2_i386, lldb_ymm3_i386, + lldb_ymm4_i386, lldb_ymm5_i386, lldb_ymm6_i386, lldb_ymm7_i386, + LLDB_INVALID_REGNUM // Register sets must be terminated with + // LLDB_INVALID_REGNUM. +}; +static_assert((sizeof(g_avx_regnums_i386) / sizeof(g_avx_regnums_i386[0])) - + 1 == + k_num_avx_registers_i386, + " g_avx_regnums_i386 has wrong number of register infos"); + +static const uint32_t g_gpr_regnums_x86_64[] = { + x86_64_with_base::lldb_rax, + x86_64_with_base::lldb_rbx, + x86_64_with_base::lldb_rcx, + x86_64_with_base::lldb_rdx, + x86_64_with_base::lldb_rdi, + x86_64_with_base::lldb_rsi, + x86_64_with_base::lldb_rbp, + x86_64_with_base::lldb_rsp, + x86_64_with_base::lldb_r8, + x86_64_with_base::lldb_r9, + x86_64_with_base::lldb_r10, + x86_64_with_base::lldb_r11, + x86_64_with_base::lldb_r12, + x86_64_with_base::lldb_r13, + x86_64_with_base::lldb_r14, + x86_64_with_base::lldb_r15, + x86_64_with_base::lldb_rip, + x86_64_with_base::lldb_rflags, + x86_64_with_base::lldb_cs, + x86_64_with_base::lldb_fs, + x86_64_with_base::lldb_gs, + x86_64_with_base::lldb_ss, + x86_64_with_base::lldb_fs_base, + x86_64_with_base::lldb_gs_base, + x86_64_with_base::lldb_ds, + x86_64_with_base::lldb_es, + x86_64_with_base::lldb_eax, + x86_64_with_base::lldb_ebx, + x86_64_with_base::lldb_ecx, + x86_64_with_base::lldb_edx, + x86_64_with_base::lldb_edi, + x86_64_with_base::lldb_esi, + x86_64_with_base::lldb_ebp, + x86_64_with_base::lldb_esp, + x86_64_with_base::lldb_r8d, // Low 32 bits or r8 + x86_64_with_base::lldb_r9d, // Low 32 bits or r9 + x86_64_with_base::lldb_r10d, // Low 32 bits or r10 + x86_64_with_base::lldb_r11d, // Low 32 bits or r11 + x86_64_with_base::lldb_r12d, // Low 32 bits or r12 + x86_64_with_base::lldb_r13d, // Low 32 bits or r13 + x86_64_with_base::lldb_r14d, // Low 32 bits or r14 + x86_64_with_base::lldb_r15d, // Low 32 bits or r15 + x86_64_with_base::lldb_ax, + x86_64_with_base::lldb_bx, + x86_64_with_base::lldb_cx, + x86_64_with_base::lldb_dx, + x86_64_with_base::lldb_di, + x86_64_with_base::lldb_si, + x86_64_with_base::lldb_bp, + x86_64_with_base::lldb_sp, + x86_64_with_base::lldb_r8w, // Low 16 bits or r8 + x86_64_with_base::lldb_r9w, // Low 16 bits or r9 + x86_64_with_base::lldb_r10w, // Low 16 bits or r10 + x86_64_with_base::lldb_r11w, // Low 16 bits or r11 + x86_64_with_base::lldb_r12w, // Low 16 bits or r12 + x86_64_with_base::lldb_r13w, // Low 16 bits or r13 + x86_64_with_base::lldb_r14w, // Low 16 bits or r14 + x86_64_with_base::lldb_r15w, // Low 16 bits or r15 + x86_64_with_base::lldb_ah, + x86_64_with_base::lldb_bh, + x86_64_with_base::lldb_ch, + x86_64_with_base::lldb_dh, + x86_64_with_base::lldb_al, + x86_64_with_base::lldb_bl, + x86_64_with_base::lldb_cl, + x86_64_with_base::lldb_dl, + x86_64_with_base::lldb_dil, + x86_64_with_base::lldb_sil, + x86_64_with_base::lldb_bpl, + x86_64_with_base::lldb_spl, + x86_64_with_base::lldb_r8l, // Low 8 bits or r8 + x86_64_with_base::lldb_r9l, // Low 8 bits or r9 + x86_64_with_base::lldb_r10l, // Low 8 bits or r10 + x86_64_with_base::lldb_r11l, // Low 8 bits or r11 + x86_64_with_base::lldb_r12l, // Low 8 bits or r12 + x86_64_with_base::lldb_r13l, // Low 8 bits or r13 + x86_64_with_base::lldb_r14l, // Low 8 bits or r14 + x86_64_with_base::lldb_r15l, // Low 8 bits or r15 + LLDB_INVALID_REGNUM // Register sets must be terminated with + // LLDB_INVALID_REGNUM. +}; +static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) - + 1 == + x86_64_with_base::k_num_gpr_registers, + "g_gpr_regnums_x86_64 has wrong number of register infos"); + +static const uint32_t g_lldb_regnums_x86_64[] = { + x86_64_with_base::lldb_fctrl, x86_64_with_base::lldb_fstat, + x86_64_with_base::lldb_ftag, x86_64_with_base::lldb_fop, + x86_64_with_base::lldb_fiseg, x86_64_with_base::lldb_fioff, + x86_64_with_base::lldb_fip, x86_64_with_base::lldb_foseg, + x86_64_with_base::lldb_fooff, x86_64_with_base::lldb_fdp, + x86_64_with_base::lldb_mxcsr, x86_64_with_base::lldb_mxcsrmask, + x86_64_with_base::lldb_st0, x86_64_with_base::lldb_st1, + x86_64_with_base::lldb_st2, x86_64_with_base::lldb_st3, + x86_64_with_base::lldb_st4, x86_64_with_base::lldb_st5, + x86_64_with_base::lldb_st6, x86_64_with_base::lldb_st7, + x86_64_with_base::lldb_mm0, x86_64_with_base::lldb_mm1, + x86_64_with_base::lldb_mm2, x86_64_with_base::lldb_mm3, + x86_64_with_base::lldb_mm4, x86_64_with_base::lldb_mm5, + x86_64_with_base::lldb_mm6, x86_64_with_base::lldb_mm7, + x86_64_with_base::lldb_xmm0, x86_64_with_base::lldb_xmm1, + x86_64_with_base::lldb_xmm2, x86_64_with_base::lldb_xmm3, + x86_64_with_base::lldb_xmm4, x86_64_with_base::lldb_xmm5, + x86_64_with_base::lldb_xmm6, x86_64_with_base::lldb_xmm7, + x86_64_with_base::lldb_xmm8, x86_64_with_base::lldb_xmm9, + x86_64_with_base::lldb_xmm10, x86_64_with_base::lldb_xmm11, + x86_64_with_base::lldb_xmm12, x86_64_with_base::lldb_xmm13, + x86_64_with_base::lldb_xmm14, x86_64_with_base::lldb_xmm15, + LLDB_INVALID_REGNUM // Register sets must be terminated with + // LLDB_INVALID_REGNUM. +}; +static_assert( + (sizeof(g_lldb_regnums_x86_64) / sizeof(g_lldb_regnums_x86_64[0])) - 1 == + x86_64_with_base::k_num_fpr_registers, + "g_lldb_regnums_x86_64 has wrong number of register infos"); + +static const uint32_t g_avx_regnums_x86_64[] = { + x86_64_with_base::lldb_ymm0, x86_64_with_base::lldb_ymm1, + x86_64_with_base::lldb_ymm2, x86_64_with_base::lldb_ymm3, + x86_64_with_base::lldb_ymm4, x86_64_with_base::lldb_ymm5, + x86_64_with_base::lldb_ymm6, x86_64_with_base::lldb_ymm7, + x86_64_with_base::lldb_ymm8, x86_64_with_base::lldb_ymm9, + x86_64_with_base::lldb_ymm10, x86_64_with_base::lldb_ymm11, + x86_64_with_base::lldb_ymm12, x86_64_with_base::lldb_ymm13, + x86_64_with_base::lldb_ymm14, x86_64_with_base::lldb_ymm15, + LLDB_INVALID_REGNUM // Register sets must be terminated with + // LLDB_INVALID_REGNUM. +}; +static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) - + 1 == + x86_64_with_base::k_num_avx_registers, + "g_avx_regnums_x86_64 has wrong number of register infos"); + +static const RegisterSet g_reg_sets_i386[] = { + {"General Purpose Registers", "gpr", k_num_gpr_registers_i386, + g_gpr_regnums_i386}, + {"Floating Point Registers", "fpu", k_num_fpr_registers_i386, + g_lldb_regnums_i386}, + {"Advanced Vector Extensions", "avx", k_num_avx_registers_i386, + g_avx_regnums_i386}}; + +static const RegisterSet g_reg_sets_x86_64[] = { + {"General Purpose Registers", "gpr", x86_64_with_base::k_num_gpr_registers, + g_gpr_regnums_x86_64}, + {"Floating Point Registers", "fpu", x86_64_with_base::k_num_fpr_registers, + g_lldb_regnums_x86_64}, + {"Advanced Vector Extensions", "avx", x86_64_with_base::k_num_avx_registers, + g_avx_regnums_x86_64}}; + +RegisterContextLinuxCore_x86_64::RegisterContextLinuxCore_x86_64( + Thread &thread, RegisterInfoInterface *register_info, + const DataExtractor &gpregset, llvm::ArrayRef notes) + : RegisterContextCorePOSIX_x86_64(thread, register_info, gpregset, notes) {} + +const RegisterSet *RegisterContextLinuxCore_x86_64::GetRegisterSet(size_t set) { + if (IsRegisterSetAvailable(set)) { + switch (m_register_info_up->GetTargetArchitecture().GetMachine()) { + case llvm::Triple::x86: + return &g_reg_sets_i386[set]; + case llvm::Triple::x86_64: + return &g_reg_sets_x86_64[set]; + default: + assert(false && "Unhandled target architecture."); + return nullptr; + } + } + return nullptr; +} + +RegInfo &RegisterContextLinuxCore_x86_64::GetRegInfo() { + return GetRegInfoShared( + m_register_info_up->GetTargetArchitecture().GetMachine(), + /*with_base=*/true); +} diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp --- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -29,6 +29,7 @@ #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h" #include "Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h" #include "ProcessElfCore.h" +#include "RegisterContextLinuxCore_x86_64.h" #include "RegisterContextPOSIXCore_arm.h" #include "RegisterContextPOSIXCore_arm64.h" #include "RegisterContextPOSIXCore_mips64.h" @@ -71,6 +72,7 @@ if (frame) concrete_frame_idx = frame->GetConcreteFrameIndex(); + bool is_linux = false; if (concrete_frame_idx == 0) { if (m_thread_reg_ctx_sp) return m_thread_reg_ctx_sp; @@ -123,6 +125,7 @@ } case llvm::Triple::Linux: { + is_linux = true; switch (arch.GetMachine()) { case llvm::Triple::aarch64: break; @@ -206,8 +209,13 @@ break; case llvm::Triple::x86: case llvm::Triple::x86_64: - m_thread_reg_ctx_sp = std::make_shared( - *this, reg_interface, m_gpregset_data, m_notes); + if (is_linux) { + m_thread_reg_ctx_sp = std::make_shared( + *this, reg_interface, m_gpregset_data, m_notes); + } else { + m_thread_reg_ctx_sp = std::make_shared( + *this, reg_interface, m_gpregset_data, m_notes); + } break; default: break; diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp --- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp +++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp @@ -8,6 +8,7 @@ #include "RegisterContextMinidump_x86_64.h" +#include "Plugins/Process/Utility/lldb-x86-register-enums.h" #include "lldb/Utility/DataBufferHeap.h" // C includes @@ -21,15 +22,15 @@ auto bytes = reg.mutable_data(context); switch (reg.kinds[lldb::eRegisterKindLLDB]) { - case lldb_cs_x86_64: - case lldb_ds_x86_64: - case lldb_es_x86_64: - case lldb_fs_x86_64: - case lldb_gs_x86_64: - case lldb_ss_x86_64: + case x86_64::lldb_cs: + case x86_64::lldb_ds: + case x86_64::lldb_es: + case x86_64::lldb_fs: + case x86_64::lldb_gs: + case x86_64::lldb_ss: return bytes.take_front(2); break; - case lldb_rflags_x86_64: + case x86_64::lldb_rflags: return bytes.take_front(4); break; default: @@ -72,36 +73,36 @@ return nullptr; if ((context_flags & ControlFlag) == ControlFlag) { - writeRegister(&context->cs, result_base, reg_info[lldb_cs_x86_64]); - writeRegister(&context->ss, result_base, reg_info[lldb_ss_x86_64]); - writeRegister(&context->eflags, result_base, reg_info[lldb_rflags_x86_64]); - writeRegister(&context->rsp, result_base, reg_info[lldb_rsp_x86_64]); - writeRegister(&context->rip, result_base, reg_info[lldb_rip_x86_64]); + writeRegister(&context->cs, result_base, reg_info[x86_64::lldb_cs]); + writeRegister(&context->ss, result_base, reg_info[x86_64::lldb_ss]); + writeRegister(&context->eflags, result_base, reg_info[x86_64::lldb_rflags]); + writeRegister(&context->rsp, result_base, reg_info[x86_64::lldb_rsp]); + writeRegister(&context->rip, result_base, reg_info[x86_64::lldb_rip]); } if ((context_flags & SegmentsFlag) == SegmentsFlag) { - writeRegister(&context->ds, result_base, reg_info[lldb_ds_x86_64]); - writeRegister(&context->es, result_base, reg_info[lldb_es_x86_64]); - writeRegister(&context->fs, result_base, reg_info[lldb_fs_x86_64]); - writeRegister(&context->gs, result_base, reg_info[lldb_gs_x86_64]); + writeRegister(&context->ds, result_base, reg_info[x86_64::lldb_ds]); + writeRegister(&context->es, result_base, reg_info[x86_64::lldb_es]); + writeRegister(&context->fs, result_base, reg_info[x86_64::lldb_fs]); + writeRegister(&context->gs, result_base, reg_info[x86_64::lldb_gs]); } if ((context_flags & IntegerFlag) == IntegerFlag) { - writeRegister(&context->rax, result_base, reg_info[lldb_rax_x86_64]); - writeRegister(&context->rcx, result_base, reg_info[lldb_rcx_x86_64]); - writeRegister(&context->rdx, result_base, reg_info[lldb_rdx_x86_64]); - writeRegister(&context->rbx, result_base, reg_info[lldb_rbx_x86_64]); - writeRegister(&context->rbp, result_base, reg_info[lldb_rbp_x86_64]); - writeRegister(&context->rsi, result_base, reg_info[lldb_rsi_x86_64]); - writeRegister(&context->rdi, result_base, reg_info[lldb_rdi_x86_64]); - writeRegister(&context->r8, result_base, reg_info[lldb_r8_x86_64]); - writeRegister(&context->r9, result_base, reg_info[lldb_r9_x86_64]); - writeRegister(&context->r10, result_base, reg_info[lldb_r10_x86_64]); - writeRegister(&context->r11, result_base, reg_info[lldb_r11_x86_64]); - writeRegister(&context->r12, result_base, reg_info[lldb_r12_x86_64]); - writeRegister(&context->r13, result_base, reg_info[lldb_r13_x86_64]); - writeRegister(&context->r14, result_base, reg_info[lldb_r14_x86_64]); - writeRegister(&context->r15, result_base, reg_info[lldb_r15_x86_64]); + writeRegister(&context->rax, result_base, reg_info[x86_64::lldb_rax]); + writeRegister(&context->rcx, result_base, reg_info[x86_64::lldb_rcx]); + writeRegister(&context->rdx, result_base, reg_info[x86_64::lldb_rdx]); + writeRegister(&context->rbx, result_base, reg_info[x86_64::lldb_rbx]); + writeRegister(&context->rbp, result_base, reg_info[x86_64::lldb_rbp]); + writeRegister(&context->rsi, result_base, reg_info[x86_64::lldb_rsi]); + writeRegister(&context->rdi, result_base, reg_info[x86_64::lldb_rdi]); + writeRegister(&context->r8, result_base, reg_info[x86_64::lldb_r8]); + writeRegister(&context->r9, result_base, reg_info[x86_64::lldb_r9]); + writeRegister(&context->r10, result_base, reg_info[x86_64::lldb_r10]); + writeRegister(&context->r11, result_base, reg_info[x86_64::lldb_r11]); + writeRegister(&context->r12, result_base, reg_info[x86_64::lldb_r12]); + writeRegister(&context->r13, result_base, reg_info[x86_64::lldb_r13]); + writeRegister(&context->r14, result_base, reg_info[x86_64::lldb_r14]); + writeRegister(&context->r15, result_base, reg_info[x86_64::lldb_r15]); } // TODO parse the floating point registers diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp --- a/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp @@ -330,36 +330,36 @@ static const uint32_t g_code_view_to_lldb_registers_x86_64[] = { LLDB_INVALID_REGNUM, // NONE - lldb_al_x86_64, // AL - lldb_cl_x86_64, // CL - lldb_dl_x86_64, // DL - lldb_bl_x86_64, // BL - lldb_ah_x86_64, // AH - lldb_ch_x86_64, // CH - lldb_dh_x86_64, // DH - lldb_bh_x86_64, // BH - lldb_ax_x86_64, // AX - lldb_cx_x86_64, // CX - lldb_dx_x86_64, // DX - lldb_bx_x86_64, // BX - lldb_sp_x86_64, // SP - lldb_bp_x86_64, // BP - lldb_si_x86_64, // SI - lldb_di_x86_64, // DI - lldb_eax_x86_64, // EAX - lldb_ecx_x86_64, // ECX - lldb_edx_x86_64, // EDX - lldb_ebx_x86_64, // EBX - lldb_esp_x86_64, // ESP - lldb_ebp_x86_64, // EBP - lldb_esi_x86_64, // ESI - lldb_edi_x86_64, // EDI - lldb_es_x86_64, // ES - lldb_cs_x86_64, // CS - lldb_ss_x86_64, // SS - lldb_ds_x86_64, // DS - lldb_fs_x86_64, // FS - lldb_gs_x86_64, // GS + x86_64::lldb_al, // AL + x86_64::lldb_cl, // CL + x86_64::lldb_dl, // DL + x86_64::lldb_bl, // BL + x86_64::lldb_ah, // AH + x86_64::lldb_ch, // CH + x86_64::lldb_dh, // DH + x86_64::lldb_bh, // BH + x86_64::lldb_ax, // AX + x86_64::lldb_cx, // CX + x86_64::lldb_dx, // DX + x86_64::lldb_bx, // BX + x86_64::lldb_sp, // SP + x86_64::lldb_bp, // BP + x86_64::lldb_si, // SI + x86_64::lldb_di, // DI + x86_64::lldb_eax, // EAX + x86_64::lldb_ecx, // ECX + x86_64::lldb_edx, // EDX + x86_64::lldb_ebx, // EBX + x86_64::lldb_esp, // ESP + x86_64::lldb_ebp, // EBP + x86_64::lldb_esi, // ESI + x86_64::lldb_edi, // EDI + x86_64::lldb_es, // ES + x86_64::lldb_cs, // CS + x86_64::lldb_ss, // SS + x86_64::lldb_ds, // DS + x86_64::lldb_fs, // FS + x86_64::lldb_gs, // GS LLDB_INVALID_REGNUM, // IP LLDB_INVALID_REGNUM, // FLAGS LLDB_INVALID_REGNUM, // EIP @@ -392,14 +392,14 @@ LLDB_INVALID_REGNUM, // CR4 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_dr0_x86_64, // DR0 - lldb_dr1_x86_64, // DR1 - lldb_dr2_x86_64, // DR2 - lldb_dr3_x86_64, // DR3 - lldb_dr4_x86_64, // DR4 - lldb_dr5_x86_64, // DR5 - lldb_dr6_x86_64, // DR6 - lldb_dr7_x86_64, // DR7 + x86_64::lldb_dr0, // DR0 + x86_64::lldb_dr1, // DR1 + x86_64::lldb_dr2, // DR2 + x86_64::lldb_dr3, // DR3 + x86_64::lldb_dr4, // DR4 + x86_64::lldb_dr5, // DR5 + x86_64::lldb_dr6, // DR6 + x86_64::lldb_dr7, // DR7 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, @@ -420,14 +420,14 @@ LLDB_INVALID_REGNUM, // PSEUDO8 LLDB_INVALID_REGNUM, // PSEUDO9 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_st0_x86_64, // ST0 - lldb_st1_x86_64, // ST1 - lldb_st2_x86_64, // ST2 - lldb_st3_x86_64, // ST3 - lldb_st4_x86_64, // ST4 - lldb_st5_x86_64, // ST5 - lldb_st6_x86_64, // ST6 - lldb_st7_x86_64, // ST7 + x86_64::lldb_st0, // ST0 + x86_64::lldb_st1, // ST1 + x86_64::lldb_st2, // ST2 + x86_64::lldb_st3, // ST3 + x86_64::lldb_st4, // ST4 + x86_64::lldb_st5, // ST5 + x86_64::lldb_st6, // ST6 + x86_64::lldb_st7, // ST7 LLDB_INVALID_REGNUM, // CTRL LLDB_INVALID_REGNUM, // STAT LLDB_INVALID_REGNUM, // TAG @@ -438,22 +438,22 @@ LLDB_INVALID_REGNUM, // ISEM LLDB_INVALID_REGNUM, // FPEIP LLDB_INVALID_REGNUM, // FPEDO - lldb_mm0_x86_64, // MM0 - lldb_mm1_x86_64, // MM1 - lldb_mm2_x86_64, // MM2 - lldb_mm3_x86_64, // MM3 - lldb_mm4_x86_64, // MM4 - lldb_mm5_x86_64, // MM5 - lldb_mm6_x86_64, // MM6 - lldb_mm7_x86_64, // MM7 - lldb_xmm0_x86_64, // XMM0 - lldb_xmm1_x86_64, // XMM1 - lldb_xmm2_x86_64, // XMM2 - lldb_xmm3_x86_64, // XMM3 - lldb_xmm4_x86_64, // XMM4 - lldb_xmm5_x86_64, // XMM5 - lldb_xmm6_x86_64, // XMM6 - lldb_xmm7_x86_64, // XMM7 + x86_64::lldb_mm0, // MM0 + x86_64::lldb_mm1, // MM1 + x86_64::lldb_mm2, // MM2 + x86_64::lldb_mm3, // MM3 + x86_64::lldb_mm4, // MM4 + x86_64::lldb_mm5, // MM5 + x86_64::lldb_mm6, // MM6 + x86_64::lldb_mm7, // MM7 + x86_64::lldb_xmm0, // XMM0 + x86_64::lldb_xmm1, // XMM1 + x86_64::lldb_xmm2, // XMM2 + x86_64::lldb_xmm3, // XMM3 + x86_64::lldb_xmm4, // XMM4 + x86_64::lldb_xmm5, // XMM5 + x86_64::lldb_xmm6, // XMM6 + x86_64::lldb_xmm7, // XMM7 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, @@ -471,7 +471,7 @@ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_mxcsr_x86_64, // MXCSR + x86_64::lldb_mxcsr, // MXCSR LLDB_INVALID_REGNUM, // EDXEAX LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, @@ -508,14 +508,14 @@ LLDB_INVALID_REGNUM, // MM61 LLDB_INVALID_REGNUM, // MM70 LLDB_INVALID_REGNUM, // MM71 - lldb_xmm8_x86_64, // XMM8 - lldb_xmm9_x86_64, // XMM9 - lldb_xmm10_x86_64, // XMM10 - lldb_xmm11_x86_64, // XMM11 - lldb_xmm12_x86_64, // XMM12 - lldb_xmm13_x86_64, // XMM13 - lldb_xmm14_x86_64, // XMM14 - lldb_xmm15_x86_64, // XMM15 + x86_64::lldb_xmm8, // XMM8 + x86_64::lldb_xmm9, // XMM9 + x86_64::lldb_xmm10, // XMM10 + x86_64::lldb_xmm11, // XMM11 + x86_64::lldb_xmm12, // XMM12 + x86_64::lldb_xmm13, // XMM13 + x86_64::lldb_xmm14, // XMM14 + x86_64::lldb_xmm15, // XMM15 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, @@ -538,73 +538,73 @@ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_sil_x86_64, // SIL - lldb_dil_x86_64, // DIL - lldb_bpl_x86_64, // BPL - lldb_spl_x86_64, // SPL - lldb_rax_x86_64, // RAX - lldb_rbx_x86_64, // RBX - lldb_rcx_x86_64, // RCX - lldb_rdx_x86_64, // RDX - lldb_rsi_x86_64, // RSI - lldb_rdi_x86_64, // RDI - lldb_rbp_x86_64, // RBP - lldb_rsp_x86_64, // RSP - lldb_r8_x86_64, // R8 - lldb_r9_x86_64, // R9 - lldb_r10_x86_64, // R10 - lldb_r11_x86_64, // R11 - lldb_r12_x86_64, // R12 - lldb_r13_x86_64, // R13 - lldb_r14_x86_64, // R14 - lldb_r15_x86_64, // R15 - lldb_r8l_x86_64, // R8B - lldb_r9l_x86_64, // R9B - lldb_r10l_x86_64, // R10B - lldb_r11l_x86_64, // R11B - lldb_r12l_x86_64, // R12B - lldb_r13l_x86_64, // R13B - lldb_r14l_x86_64, // R14B - lldb_r15l_x86_64, // R15B - lldb_r8w_x86_64, // R8W - lldb_r9w_x86_64, // R9W - lldb_r10w_x86_64, // R10W - lldb_r11w_x86_64, // R11W - lldb_r12w_x86_64, // R12W - lldb_r13w_x86_64, // R13W - lldb_r14w_x86_64, // R14W - lldb_r15w_x86_64, // R15W - lldb_r8d_x86_64, // R8D - lldb_r9d_x86_64, // R9D - lldb_r10d_x86_64, // R10D - lldb_r11d_x86_64, // R11D - lldb_r12d_x86_64, // R12D - lldb_r13d_x86_64, // R13D - lldb_r14d_x86_64, // R14D - lldb_r15d_x86_64, // R15D - lldb_ymm0_x86_64, // AMD64_YMM0 - lldb_ymm1_x86_64, // AMD64_YMM1 - lldb_ymm2_x86_64, // AMD64_YMM2 - lldb_ymm3_x86_64, // AMD64_YMM3 - lldb_ymm4_x86_64, // AMD64_YMM4 - lldb_ymm5_x86_64, // AMD64_YMM5 - lldb_ymm6_x86_64, // AMD64_YMM6 - lldb_ymm7_x86_64, // AMD64_YMM7 - lldb_ymm8_x86_64, // AMD64_YMM8 - lldb_ymm9_x86_64, // AMD64_YMM9 - lldb_ymm10_x86_64, // AMD64_YMM10 - lldb_ymm11_x86_64, // AMD64_YMM11 - lldb_ymm12_x86_64, // AMD64_YMM12 - lldb_ymm13_x86_64, // AMD64_YMM13 - lldb_ymm14_x86_64, // AMD64_YMM14 - lldb_ymm15_x86_64, // AMD64_YMM15 - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, - lldb_bnd0_x86_64, // BND0 - lldb_bnd1_x86_64, // BND1 - lldb_bnd2_x86_64 // BND2 + x86_64::lldb_sil, // SIL + x86_64::lldb_dil, // DIL + x86_64::lldb_bpl, // BPL + x86_64::lldb_spl, // SPL + x86_64::lldb_rax, // RAX + x86_64::lldb_rbx, // RBX + x86_64::lldb_rcx, // RCX + x86_64::lldb_rdx, // RDX + x86_64::lldb_rsi, // RSI + x86_64::lldb_rdi, // RDI + x86_64::lldb_rbp, // RBP + x86_64::lldb_rsp, // RSP + x86_64::lldb_r8, // R8 + x86_64::lldb_r9, // R9 + x86_64::lldb_r10, // R10 + x86_64::lldb_r11, // R11 + x86_64::lldb_r12, // R12 + x86_64::lldb_r13, // R13 + x86_64::lldb_r14, // R14 + x86_64::lldb_r15, // R15 + x86_64::lldb_r8l, // R8B + x86_64::lldb_r9l, // R9B + x86_64::lldb_r10l, // R10B + x86_64::lldb_r11l, // R11B + x86_64::lldb_r12l, // R12B + x86_64::lldb_r13l, // R13B + x86_64::lldb_r14l, // R14B + x86_64::lldb_r15l, // R15B + x86_64::lldb_r8w, // R8W + x86_64::lldb_r9w, // R9W + x86_64::lldb_r10w, // R10W + x86_64::lldb_r11w, // R11W + x86_64::lldb_r12w, // R12W + x86_64::lldb_r13w, // R13W + x86_64::lldb_r14w, // R14W + x86_64::lldb_r15w, // R15W + x86_64::lldb_r8d, // R8D + x86_64::lldb_r9d, // R9D + x86_64::lldb_r10d, // R10D + x86_64::lldb_r11d, // R11D + x86_64::lldb_r12d, // R12D + x86_64::lldb_r13d, // R13D + x86_64::lldb_r14d, // R14D + x86_64::lldb_r15d, // R15D + x86_64::lldb_ymm0, // AMD64_YMM0 + x86_64::lldb_ymm1, // AMD64_YMM1 + x86_64::lldb_ymm2, // AMD64_YMM2 + x86_64::lldb_ymm3, // AMD64_YMM3 + x86_64::lldb_ymm4, // AMD64_YMM4 + x86_64::lldb_ymm5, // AMD64_YMM5 + x86_64::lldb_ymm6, // AMD64_YMM6 + x86_64::lldb_ymm7, // AMD64_YMM7 + x86_64::lldb_ymm8, // AMD64_YMM8 + x86_64::lldb_ymm9, // AMD64_YMM9 + x86_64::lldb_ymm10, // AMD64_YMM10 + x86_64::lldb_ymm11, // AMD64_YMM11 + x86_64::lldb_ymm12, // AMD64_YMM12 + x86_64::lldb_ymm13, // AMD64_YMM13 + x86_64::lldb_ymm14, // AMD64_YMM14 + x86_64::lldb_ymm15, // AMD64_YMM15 + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + x86_64::lldb_bnd0, // BND0 + x86_64::lldb_bnd1, // BND1 + x86_64::lldb_bnd2 // BND2 }; uint32_t lldb_private::npdb::GetLLDBRegisterNumber( diff --git a/lldb/test/API/commands/register/register/register_command/TestRegisters.py b/lldb/test/API/commands/register/register/register_command/TestRegisters.py --- a/lldb/test/API/commands/register/register/register_command/TestRegisters.py +++ b/lldb/test/API/commands/register/register/register_command/TestRegisters.py @@ -606,3 +606,39 @@ # This has an alternative name according to the ABI. self.expect("register info x30", substrs=["Name: lr (x30)"]) + + @skipUnlessPlatform(["linux"]) + @skipIf(archs=no_match(["x86_64"])) + def test_fs_base(self): + """Tests fs_base register can be read and equals to pthread_self() return value.""" + self.build() + target = self.createTestTarget() + # Launch the process and stop. + self.expect("run", PROCESS_STOPPED, substrs=["stopped"]) + + process = target.GetProcess() + + thread = process.GetThreadAtIndex(0) + self.assertTrue(thread.IsValid(), "current thread is valid") + + current_frame = thread.GetFrameAtIndex(0) + self.assertTrue(current_frame.IsValid(), "current frame is valid") + + reg_fs_base = current_frame.FindRegister("fs_base") + self.assertTrue(reg_fs_base.IsValid(), "fs_base is not available") + + # Evaluate pthread_self() and compare against fs_base register read. + pthread_self_code = "(uint64_t)pthread_self()" + pthread_self_val = current_frame.EvaluateExpression(pthread_self_code) + self.assertTrue( + pthread_self_val.IsValid(), f"{pthread_self_code} evaluation has failed" + ) + self.assertNotEqual( + reg_fs_base.GetValueAsSigned(-1), 0, f"fs_base returned zero which is wrong" + ) + + self.assertEqual( + reg_fs_base.GetValueAsUnsigned(0), + pthread_self_val.GetValueAsUnsigned(0), + "fs_base does not equal to pthread_self() value.", + ) diff --git a/lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp b/lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp --- a/lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp +++ b/lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp @@ -33,7 +33,7 @@ llvm::Expected ExpectedFile = TestFile::fromYaml( R"( --- !COFF -OptionalHeader: +OptionalHeader: AddressOfEntryPoint: 0 ImageBase: 16777216 SectionAlignment: 4096 @@ -50,55 +50,55 @@ SizeOfStackCommit: 4096 SizeOfHeapReserve: 1048576 SizeOfHeapCommit: 4096 - ExportTable: + ExportTable: RelativeVirtualAddress: 0 Size: 0 - ImportTable: + ImportTable: RelativeVirtualAddress: 0 Size: 0 - ResourceTable: + ResourceTable: RelativeVirtualAddress: 0 Size: 0 - ExceptionTable: + ExceptionTable: RelativeVirtualAddress: 12288 Size: 60 - CertificateTable: + CertificateTable: RelativeVirtualAddress: 0 Size: 0 - BaseRelocationTable: + BaseRelocationTable: RelativeVirtualAddress: 0 Size: 0 - Debug: + Debug: RelativeVirtualAddress: 0 Size: 0 - Architecture: + Architecture: RelativeVirtualAddress: 0 Size: 0 - GlobalPtr: + GlobalPtr: RelativeVirtualAddress: 0 Size: 0 - TlsTable: + TlsTable: RelativeVirtualAddress: 0 Size: 0 - LoadConfigTable: + LoadConfigTable: RelativeVirtualAddress: 0 Size: 0 - BoundImport: + BoundImport: RelativeVirtualAddress: 0 Size: 0 - IAT: + IAT: RelativeVirtualAddress: 0 Size: 0 - DelayImportDescriptor: + DelayImportDescriptor: RelativeVirtualAddress: 0 Size: 0 - ClrRuntimeHeader: + ClrRuntimeHeader: RelativeVirtualAddress: 0 Size: 0 -header: +header: Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ] -sections: +sections: - Name: .text Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] VirtualAddress: 4096 @@ -212,38 +212,38 @@ UnwindPlan::Row row; row.SetOffset(0); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 8); - row.SetRegisterLocationToIsCFAPlusOffset(lldb_rsp_x86_64, 0, true); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rip_x86_64, -8, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 8); + row.SetRegisterLocationToIsCFAPlusOffset(x86_64::lldb_rsp, 0, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rip, -8, true); EXPECT_EQ(*plan.GetRowAtIndex(0), row); row.SetOffset(2); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x10); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rbx_x86_64, -0x10, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x10); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rbx, -0x10, true); EXPECT_EQ(*plan.GetRowAtIndex(1), row); row.SetOffset(3); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x18); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rsi_x86_64, -0x18, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x18); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rsi, -0x18, true); EXPECT_EQ(*plan.GetRowAtIndex(2), row); row.SetOffset(4); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x20); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rdi_x86_64, -0x20, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x20); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rdi, -0x20, true); EXPECT_EQ(*plan.GetRowAtIndex(3), row); row.SetOffset(6); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x28); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_r14_x86_64, -0x28, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x28); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_r14, -0x28, true); EXPECT_EQ(*plan.GetRowAtIndex(4), row); row.SetOffset(8); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x30); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_r15_x86_64, -0x30, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x30); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_r15, -0x30, true); EXPECT_EQ(*plan.GetRowAtIndex(5), row); row.SetOffset(0xC); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x50); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x50); EXPECT_EQ(*plan.GetRowAtIndex(6), row); } @@ -254,18 +254,18 @@ UnwindPlan::Row row; row.SetOffset(0); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x50); - row.SetRegisterLocationToIsCFAPlusOffset(lldb_rsp_x86_64, 0, true); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rip_x86_64, -8, true); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rbx_x86_64, -0x10, true); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rsi_x86_64, -0x18, true); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rdi_x86_64, -0x20, true); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_r14_x86_64, -0x28, true); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_r15_x86_64, -0x30, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x50); + row.SetRegisterLocationToIsCFAPlusOffset(x86_64::lldb_rsp, 0, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rip, -8, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rbx, -0x10, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rsi, -0x18, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rdi, -0x20, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_r14, -0x28, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_r15, -0x30, true); EXPECT_EQ(*plan.GetRowAtIndex(0), row); row.SetOffset(5); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rbp_x86_64, 0x18, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rbp, 0x18, true); EXPECT_EQ(*plan.GetRowAtIndex(1), row); } @@ -276,53 +276,53 @@ UnwindPlan::Row row; row.SetOffset(0); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 8); - row.SetRegisterLocationToIsCFAPlusOffset(lldb_rsp_x86_64, 0, true); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rip_x86_64, -8, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 8); + row.SetRegisterLocationToIsCFAPlusOffset(x86_64::lldb_rsp, 0, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rip, -8, true); EXPECT_EQ(*plan.GetRowAtIndex(0), row); row.SetOffset(6); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x10); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rbp_x86_64, -0x10, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x10); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rbp, -0x10, true); EXPECT_EQ(*plan.GetRowAtIndex(1), row); row.SetOffset(8); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x18); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_r12_x86_64, -0x18, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x18); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_r12, -0x18, true); EXPECT_EQ(*plan.GetRowAtIndex(2), row); row.SetOffset(0xA); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x20); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_r13_x86_64, -0x20, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x20); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_r13, -0x20, true); EXPECT_EQ(*plan.GetRowAtIndex(3), row); row.SetOffset(0xC); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x28); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_r14_x86_64, -0x28, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x28); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_r14, -0x28, true); EXPECT_EQ(*plan.GetRowAtIndex(4), row); row.SetOffset(0xE); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x30); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_r15_x86_64, -0x30, true); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x30); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_r15, -0x30, true); EXPECT_EQ(*plan.GetRowAtIndex(5), row); row.SetOffset(0x15); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64, 0x320); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rsp, 0x320); EXPECT_EQ(*plan.GetRowAtIndex(6), row); row.SetOffset(0x1A); - row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rbp_x86_64, 0x2F0); + row.GetCFAValue().SetIsRegisterPlusOffset(x86_64::lldb_rbp, 0x2F0); EXPECT_EQ(*plan.GetRowAtIndex(7), row); row.SetOffset(0x21); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rbx_x86_64, 8, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rbx, 8, true); EXPECT_EQ(*plan.GetRowAtIndex(8), row); row.SetOffset(0x28); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rsi_x86_64, 0x10, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rsi, 0x10, true); EXPECT_EQ(*plan.GetRowAtIndex(9), row); row.SetOffset(0x2F); - row.SetRegisterLocationToAtCFAPlusOffset(lldb_rdi_x86_64, 0x18, true); + row.SetRegisterLocationToAtCFAPlusOffset(x86_64::lldb_rdi, 0x18, true); EXPECT_EQ(*plan.GetRowAtIndex(10), row); } diff --git a/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp b/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp --- a/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp +++ b/lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp @@ -46,7 +46,7 @@ #define EXPECT_GPR_X86_64(regname) \ EXPECT_THAT( \ - GetRegParams(reg_ctx, lldb_##regname##_x86_64), \ + GetRegParams(reg_ctx, x86_64::lldb_##regname), \ ::testing::Pair(offsetof(reg, r_##regname), sizeof(reg::r_##regname))) #define EXPECT_DBR_X86_64(num) \ EXPECT_OFF(dr##num##_x86_64, offsetof(dbreg, dr[num]), sizeof(dbreg::dr[num])) @@ -82,7 +82,7 @@ // fctrl is the first FPR field, it is used to determine offset of the whole // FPR struct - size_t base_offset = reg_ctx.GetRegisterInfo()[lldb_fctrl_x86_64].byte_offset; + size_t base_offset = reg_ctx.GetRegisterInfo()[x86_64::lldb_fctrl].byte_offset; // assert against FXSAVE struct EXPECT_OFF(fctrl_x86_64, 0x00, 2); @@ -135,7 +135,7 @@ EXPECT_OFF(xmm14_x86_64, 0x180, 16); EXPECT_OFF(xmm15_x86_64, 0x190, 16); - base_offset = reg_ctx.GetRegisterInfo()[lldb_dr0_x86_64].byte_offset; + base_offset = reg_ctx.GetRegisterInfo()[x86_64::lldb_dr0].byte_offset; EXPECT_DBR_X86_64(0); EXPECT_DBR_X86_64(1); EXPECT_DBR_X86_64(2); diff --git a/lldb/unittests/Process/Utility/RegisterContextNetBSDTest_x86_64.cpp b/lldb/unittests/Process/Utility/RegisterContextNetBSDTest_x86_64.cpp --- a/lldb/unittests/Process/Utility/RegisterContextNetBSDTest_x86_64.cpp +++ b/lldb/unittests/Process/Utility/RegisterContextNetBSDTest_x86_64.cpp @@ -34,10 +34,9 @@ ::testing::Pair(offset + base_offset, size)) #define EXPECT_GPR_X86_64(regname, regconst) \ - EXPECT_THAT( \ - GetRegParams(reg_ctx, lldb_##regname##_x86_64), \ - ::testing::Pair(offsetof(reg, regs[regconst]), \ - sizeof(reg::regs[regconst]))) + EXPECT_THAT(GetRegParams(reg_ctx, x86_64::lldb_##regname), \ + ::testing::Pair(offsetof(reg, regs[regconst]), \ + sizeof(reg::regs[regconst]))) #define EXPECT_DBR_X86_64(num) \ EXPECT_OFF(dr##num##_x86_64, offsetof(dbreg, dr[num]), sizeof(dbreg::dr[num])) @@ -72,7 +71,8 @@ // fctrl is the first FPR field, it is used to determine offset of the whole // FPR struct - size_t base_offset = reg_ctx.GetRegisterInfo()[lldb_fctrl_x86_64].byte_offset; + size_t base_offset = + reg_ctx.GetRegisterInfo()[x86_64::lldb_fctrl].byte_offset; // assert against FXSAVE struct EXPECT_OFF(fctrl_x86_64, 0x00, 2); @@ -125,7 +125,7 @@ EXPECT_OFF(xmm14_x86_64, 0x180, 16); EXPECT_OFF(xmm15_x86_64, 0x190, 16); - base_offset = reg_ctx.GetRegisterInfo()[lldb_dr0_x86_64].byte_offset; + base_offset = reg_ctx.GetRegisterInfo()[x86_64::lldb_dr0].byte_offset; EXPECT_DBR_X86_64(0); EXPECT_DBR_X86_64(1); EXPECT_DBR_X86_64(2); diff --git a/lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp b/lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp --- a/lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp +++ b/lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp @@ -120,30 +120,30 @@ ASSERT_EQ(RegInterface->GetGPRSize(), Buf->GetByteSize()); const RegisterInfo *Info = RegInterface->GetRegisterInfo(); - EXPECT_EQ(Context.rax, reg64(*Buf, Info[lldb_rax_x86_64])); - EXPECT_EQ(Context.rbx, reg64(*Buf, Info[lldb_rbx_x86_64])); - EXPECT_EQ(Context.rcx, reg64(*Buf, Info[lldb_rcx_x86_64])); - EXPECT_EQ(Context.rdx, reg64(*Buf, Info[lldb_rdx_x86_64])); - EXPECT_EQ(Context.rdi, reg64(*Buf, Info[lldb_rdi_x86_64])); - EXPECT_EQ(Context.rsi, reg64(*Buf, Info[lldb_rsi_x86_64])); - EXPECT_EQ(Context.rbp, reg64(*Buf, Info[lldb_rbp_x86_64])); - EXPECT_EQ(Context.rsp, reg64(*Buf, Info[lldb_rsp_x86_64])); - EXPECT_EQ(Context.r8, reg64(*Buf, Info[lldb_r8_x86_64])); - EXPECT_EQ(Context.r9, reg64(*Buf, Info[lldb_r9_x86_64])); - EXPECT_EQ(Context.r10, reg64(*Buf, Info[lldb_r10_x86_64])); - EXPECT_EQ(Context.r11, reg64(*Buf, Info[lldb_r11_x86_64])); - EXPECT_EQ(Context.r12, reg64(*Buf, Info[lldb_r12_x86_64])); - EXPECT_EQ(Context.r13, reg64(*Buf, Info[lldb_r13_x86_64])); - EXPECT_EQ(Context.r14, reg64(*Buf, Info[lldb_r14_x86_64])); - EXPECT_EQ(Context.r15, reg64(*Buf, Info[lldb_r15_x86_64])); - EXPECT_EQ(Context.rip, reg64(*Buf, Info[lldb_rip_x86_64])); - EXPECT_EQ(Context.eflags, reg64(*Buf, Info[lldb_rflags_x86_64])); - EXPECT_EQ(Context.cs, reg64(*Buf, Info[lldb_cs_x86_64])); - EXPECT_EQ(Context.fs, reg64(*Buf, Info[lldb_fs_x86_64])); - EXPECT_EQ(Context.gs, reg64(*Buf, Info[lldb_gs_x86_64])); - EXPECT_EQ(Context.ss, reg64(*Buf, Info[lldb_ss_x86_64])); - EXPECT_EQ(Context.ds, reg64(*Buf, Info[lldb_ds_x86_64])); - EXPECT_EQ(Context.es, reg64(*Buf, Info[lldb_es_x86_64])); + EXPECT_EQ(Context.rax, reg64(*Buf, Info[x86_64::lldb_rax])); + EXPECT_EQ(Context.rbx, reg64(*Buf, Info[x86_64::lldb_rbx])); + EXPECT_EQ(Context.rcx, reg64(*Buf, Info[x86_64::lldb_rcx])); + EXPECT_EQ(Context.rdx, reg64(*Buf, Info[x86_64::lldb_rdx])); + EXPECT_EQ(Context.rdi, reg64(*Buf, Info[x86_64::lldb_rdi])); + EXPECT_EQ(Context.rsi, reg64(*Buf, Info[x86_64::lldb_rsi])); + EXPECT_EQ(Context.rbp, reg64(*Buf, Info[x86_64::lldb_rbp])); + EXPECT_EQ(Context.rsp, reg64(*Buf, Info[x86_64::lldb_rsp])); + EXPECT_EQ(Context.r8, reg64(*Buf, Info[x86_64::lldb_r8])); + EXPECT_EQ(Context.r9, reg64(*Buf, Info[x86_64::lldb_r9])); + EXPECT_EQ(Context.r10, reg64(*Buf, Info[x86_64::lldb_r10])); + EXPECT_EQ(Context.r11, reg64(*Buf, Info[x86_64::lldb_r11])); + EXPECT_EQ(Context.r12, reg64(*Buf, Info[x86_64::lldb_r12])); + EXPECT_EQ(Context.r13, reg64(*Buf, Info[x86_64::lldb_r13])); + EXPECT_EQ(Context.r14, reg64(*Buf, Info[x86_64::lldb_r14])); + EXPECT_EQ(Context.r15, reg64(*Buf, Info[x86_64::lldb_r15])); + EXPECT_EQ(Context.rip, reg64(*Buf, Info[x86_64::lldb_rip])); + EXPECT_EQ(Context.eflags, reg64(*Buf, Info[x86_64::lldb_rflags])); + EXPECT_EQ(Context.cs, reg64(*Buf, Info[x86_64::lldb_cs])); + EXPECT_EQ(Context.fs, reg64(*Buf, Info[x86_64::lldb_fs])); + EXPECT_EQ(Context.gs, reg64(*Buf, Info[x86_64::lldb_gs])); + EXPECT_EQ(Context.ss, reg64(*Buf, Info[x86_64::lldb_ss])); + EXPECT_EQ(Context.ds, reg64(*Buf, Info[x86_64::lldb_ds])); + EXPECT_EQ(Context.es, reg64(*Buf, Info[x86_64::lldb_es])); } static void TestARMRegInfo(const lldb_private::RegisterInfo *info) {