1 //===-- RegisterContextLinux_i386.cpp --------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===---------------------------------------------------------------------===//
10 #include "RegisterContextPOSIX_x86.h"
11 #include "RegisterContextLinux_i386.h"
13 using namespace lldb_private;
39 uint16_t fctrl; // FPU Control Word (fcw)
40 uint16_t fstat; // FPU Status Word (fsw)
41 uint16_t ftag; // FPU Tag Word (ftw)
42 uint16_t fop; // Last Instruction Opcode (fop)
47 uint64_t fip; // Instruction Pointer
48 uint64_t fdp; // Data Pointer
52 uint32_t fioff; // FPU IP Offset (fip)
53 uint32_t fiseg; // FPU IP Selector (fcs)
54 uint32_t fooff; // FPU Operand Pointer Offset (foo)
55 uint32_t foseg; // FPU Operand Pointer Selector (fos)
56 } i386_;// Added _ in the end to avoid error with gcc defining i386 in some cases
58 uint32_t mxcsr; // MXCSR Register State
59 uint32_t mxcsrmask; // MXCSR Mask
60 MMSReg stmm[8]; // 8*16 bytes for each FP-reg = 128 bytes
61 XMMReg xmm[8]; // 8*16 bytes for each XMM-reg = 128 bytes
67 GPR regs; // General purpose registers.
68 int32_t fpvalid; // True if FPU is being used.
69 FPR_i386 i387; // FPU registers.
70 uint32_t tsize; // Text segment size.
71 uint32_t dsize; // Data segment size.
72 uint32_t ssize; // Stack segment size.
73 uint32_t start_code; // VM address of text.
74 uint32_t start_stack; // VM address of stack bottom (top in rsp).
75 int32_t signal; // Signal causing core dump.
76 int32_t reserved; // Unused.
77 uint32_t ar0; // Location of GPR's.
78 uint32_t fpstate; // Location of FPR's. Should be a FXSTATE *, but this
79 // has to be 32-bits even on 64-bit systems.
80 uint32_t magic; // Identifier for core dumps.
81 char u_comm[32]; // Command causing core dump.
82 uint32_t u_debugreg[8]; // Debug registers (DR0 - DR7).
85 #define DR_SIZE sizeof(((UserArea*)NULL)->u_debugreg[0])
86 #define DR_0_OFFSET 0xFC
87 #define DR_OFFSET(reg_index) \
88 (DR_0_OFFSET + (reg_index * 4))
89 #define FPR_SIZE(reg) sizeof(((FPR_i386*)NULL)->reg)
91 //---------------------------------------------------------------------------
92 // Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
93 //---------------------------------------------------------------------------
94 #define DECLARE_REGISTER_INFOS_I386_STRUCT
95 #include "RegisterInfos_i386.h"
96 #undef DECLARE_REGISTER_INFOS_I386_STRUCT
98 RegisterContextLinux_i386::RegisterContextLinux_i386(const ArchSpec &target_arch) :
99 RegisterInfoInterface(target_arch)
104 RegisterContextLinux_i386::GetGPRSize() const
110 RegisterContextLinux_i386::GetRegisterInfo() const
112 switch (m_target_arch.GetMachine())
114 case llvm::Triple::x86:
115 case llvm::Triple::x86_64:
116 return g_register_infos_i386;
118 assert(false && "Unhandled target architecture.");
124 RegisterContextLinux_i386::GetRegisterCount () const
126 return static_cast<uint32_t> (sizeof (g_register_infos_i386) / sizeof (g_register_infos_i386 [0]));
130 RegisterContextLinux_i386::GetUserRegisterCount () const
132 return static_cast<uint32_t> (k_num_user_registers_i386);