1 //===-- RegisterContextLinux_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 "RegisterContextLinux_i386.h"
10 #include "RegisterContextPOSIX_x86.h"
12 using namespace lldb_private
;
36 uint16_t fctrl
; // FPU Control Word (fcw)
37 uint16_t fstat
; // FPU Status Word (fsw)
38 uint16_t ftag
; // FPU Tag Word (ftw)
39 uint16_t fop
; // Last Instruction Opcode (fop)
42 uint64_t fip
; // Instruction Pointer
43 uint64_t fdp
; // Data Pointer
46 uint32_t fioff
; // FPU IP Offset (fip)
47 uint32_t fiseg
; // FPU IP Selector (fcs)
48 uint32_t fooff
; // FPU Operand Pointer Offset (foo)
49 uint32_t foseg
; // FPU Operand Pointer Selector (fos)
50 } i386_
; // Added _ in the end to avoid error with gcc defining i386 in some
53 uint32_t mxcsr
; // MXCSR Register State
54 uint32_t mxcsrmask
; // MXCSR Mask
55 MMSReg stmm
[8]; // 8*16 bytes for each FP-reg = 128 bytes
56 XMMReg xmm
[8]; // 8*16 bytes for each XMM-reg = 128 bytes
61 GPR regs
; // General purpose registers.
62 int32_t fpvalid
; // True if FPU is being used.
63 FPR_i386 i387
; // FPU registers.
64 uint32_t tsize
; // Text segment size.
65 uint32_t dsize
; // Data segment size.
66 uint32_t ssize
; // Stack segment size.
67 uint32_t start_code
; // VM address of text.
68 uint32_t start_stack
; // VM address of stack bottom (top in rsp).
69 int32_t signal
; // Signal causing core dump.
70 int32_t reserved
; // Unused.
71 uint32_t ar0
; // Location of GPR's.
72 uint32_t fpstate
; // Location of FPR's. Should be a FXSTATE *, but this
73 // has to be 32-bits even on 64-bit systems.
74 uint32_t magic
; // Identifier for core dumps.
75 char u_comm
[32]; // Command causing core dump.
76 uint32_t u_debugreg
[8]; // Debug registers (DR0 - DR7).
79 #define DR_SIZE sizeof(((UserArea *)NULL)->u_debugreg[0])
80 #define DR_0_OFFSET 0xFC
81 #define DR_OFFSET(reg_index) (DR_0_OFFSET + (reg_index * 4))
82 #define FPR_SIZE(reg) sizeof(((FPR_i386 *)NULL)->reg)
84 // Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
85 #define DECLARE_REGISTER_INFOS_I386_STRUCT
86 #include "RegisterInfos_i386.h"
87 #undef DECLARE_REGISTER_INFOS_I386_STRUCT
89 RegisterContextLinux_i386::RegisterContextLinux_i386(
90 const ArchSpec
&target_arch
)
91 : RegisterContextLinux_x86(
95 sizeof(((GPR
*)nullptr)->orig_eax
),
96 (LLVM_EXTENSION
offsetof(GPR
, orig_eax
)),
99 {LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
,
100 LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
},
105 size_t RegisterContextLinux_i386::GetGPRSizeStatic() { return sizeof(GPR
); }
107 const RegisterInfo
*RegisterContextLinux_i386::GetRegisterInfo() const {
108 switch (GetTargetArchitecture().GetMachine()) {
109 case llvm::Triple::x86
:
110 case llvm::Triple::x86_64
:
111 return g_register_infos_i386
;
113 assert(false && "Unhandled target architecture.");
118 uint32_t RegisterContextLinux_i386::GetRegisterCount() const {
119 return static_cast<uint32_t>(sizeof(g_register_infos_i386
) /
120 sizeof(g_register_infos_i386
[0]));
123 uint32_t RegisterContextLinux_i386::GetUserRegisterCount() const {
124 return static_cast<uint32_t>(k_num_user_registers_i386
);