1 //===-- RegisterContextWindows_i386.cpp -----------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "RegisterContextWindows_i386.h"
10 #include "RegisterContext_x86.h"
11 #include "lldb-x86-register-enums.h"
13 using namespace lldb_private
;
17 // Declare our g_register_infos structure.
37 #define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR, regname))
39 #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
41 #reg, alt, sizeof(((GPR *)nullptr)->reg), GPR_OFFSET(reg), eEncodingUint, \
43 {kind1, kind2, kind3, kind4, lldb_##reg##_i386 }, nullptr, nullptr, \
48 static RegisterInfo g_register_infos_i386
[] = {
49 // General purpose registers EH_Frame DWARF Generic Process Plugin
50 // =========================== ================== ================ ========================= ====================
51 DEFINE_GPR(eax
, nullptr, ehframe_eax_i386
, dwarf_eax_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
52 DEFINE_GPR(ebx
, nullptr, ehframe_ebx_i386
, dwarf_ebx_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
53 DEFINE_GPR(ecx
, nullptr, ehframe_ecx_i386
, dwarf_ecx_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
54 DEFINE_GPR(edx
, nullptr, ehframe_edx_i386
, dwarf_edx_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
55 DEFINE_GPR(edi
, nullptr, ehframe_edi_i386
, dwarf_edi_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
56 DEFINE_GPR(esi
, nullptr, ehframe_esi_i386
, dwarf_esi_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
57 DEFINE_GPR(ebp
, "fp", ehframe_ebp_i386
, dwarf_ebp_i386
, LLDB_REGNUM_GENERIC_FP
, LLDB_INVALID_REGNUM
),
58 DEFINE_GPR(esp
, "sp", ehframe_esp_i386
, dwarf_esp_i386
, LLDB_REGNUM_GENERIC_SP
, LLDB_INVALID_REGNUM
),
59 DEFINE_GPR(eip
, "pc", ehframe_eip_i386
, dwarf_eip_i386
, LLDB_REGNUM_GENERIC_PC
, LLDB_INVALID_REGNUM
),
60 DEFINE_GPR(eflags
, "flags", ehframe_eflags_i386
, dwarf_eflags_i386
, LLDB_REGNUM_GENERIC_FLAGS
, LLDB_INVALID_REGNUM
),
61 DEFINE_GPR(cs
, nullptr, LLDB_INVALID_REGNUM
, dwarf_cs_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
62 DEFINE_GPR(fs
, nullptr, LLDB_INVALID_REGNUM
, dwarf_fs_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
63 DEFINE_GPR(gs
, nullptr, LLDB_INVALID_REGNUM
, dwarf_gs_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
64 DEFINE_GPR(ss
, nullptr, LLDB_INVALID_REGNUM
, dwarf_ss_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
65 DEFINE_GPR(ds
, nullptr, LLDB_INVALID_REGNUM
, dwarf_ds_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
66 DEFINE_GPR(es
, nullptr, LLDB_INVALID_REGNUM
, dwarf_es_i386
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
71 RegisterContextWindows_i386::RegisterContextWindows_i386(
72 const ArchSpec
&target_arch
)
73 : lldb_private::RegisterInfoInterface(target_arch
) {
74 assert(target_arch
.GetMachine() == llvm::Triple::x86
);
77 const RegisterInfo
*RegisterContextWindows_i386::GetRegisterInfo() const {
78 return g_register_infos_i386
;
81 uint32_t RegisterContextWindows_i386::GetRegisterCount() const {
82 return std::size(g_register_infos_i386
);
85 uint32_t RegisterContextWindows_i386::GetUserRegisterCount() const {
86 return std::size(g_register_infos_i386
);
89 size_t RegisterContextWindows_i386::GetGPRSize() const { return sizeof(GPR
); }