Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / source / Plugins / Process / Utility / RegisterContextWindows_i386.cpp
blobfaf4021aa49932c7084db190f2810386fae20864
1 //===-- RegisterContextWindows_i386.cpp -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "RegisterContextWindows_i386.h"
10 #include "RegisterContext_x86.h"
11 #include "lldb-x86-register-enums.h"
13 using namespace lldb_private;
14 using namespace lldb;
16 namespace {
17 // Declare our g_register_infos structure.
18 typedef struct _GPR {
19 uint32_t eax;
20 uint32_t ebx;
21 uint32_t ecx;
22 uint32_t edx;
23 uint32_t edi;
24 uint32_t esi;
25 uint32_t ebp;
26 uint32_t esp;
27 uint32_t eip;
28 uint32_t eflags;
29 uint32_t cs;
30 uint32_t fs;
31 uint32_t gs;
32 uint32_t ss;
33 uint32_t ds;
34 uint32_t es;
35 } GPR;
37 #define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR, regname))
39 #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
40 { \
41 #reg, alt, sizeof(((GPR *)nullptr)->reg), GPR_OFFSET(reg), eEncodingUint, \
42 eFormatHex, \
43 {kind1, kind2, kind3, kind4, lldb_##reg##_i386 }, nullptr, nullptr, \
44 nullptr, \
47 // clang-format off
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),
68 // clang-format on
69 } // namespace
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); }