LLDB mainline
RegisterContextLinux_i386.cpp
Go to the documentation of this file.
1//===-- RegisterContextLinux_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//===---------------------------------------------------------------------===//
8
10#include "RegisterContext_x86.h"
12#include "lldb/lldb-defines.h"
13
14using namespace lldb_private;
15using namespace lldb;
16
17struct GPR {
18 uint32_t ebx;
19 uint32_t ecx;
20 uint32_t edx;
21 uint32_t esi;
22 uint32_t edi;
23 uint32_t ebp;
24 uint32_t eax;
25 uint32_t ds;
26 uint32_t es;
27 uint32_t fs;
28 uint32_t gs;
29 uint32_t orig_eax;
30 uint32_t eip;
31 uint32_t cs;
32 uint32_t eflags;
33 uint32_t esp;
34 uint32_t ss;
35};
36
37struct FPR_i386 {
38 uint16_t fctrl; // FPU Control Word (fcw)
39 uint16_t fstat; // FPU Status Word (fsw)
40 uint16_t ftag; // FPU Tag Word (ftw)
41 uint16_t fop; // Last Instruction Opcode (fop)
42 union {
43 struct {
44 uint64_t fip; // Instruction Pointer
45 uint64_t fdp; // Data Pointer
47 struct {
48 uint32_t fioff; // FPU IP Offset (fip)
49 uint32_t fiseg; // FPU IP Selector (fcs)
50 uint32_t fooff; // FPU Operand Pointer Offset (foo)
51 uint32_t foseg; // FPU Operand Pointer Selector (fos)
52 } i386_; // Added _ in the end to avoid error with gcc defining i386 in some
53 // cases
54 } ptr;
55 uint32_t mxcsr; // MXCSR Register State
56 uint32_t mxcsrmask; // MXCSR Mask
57 MMSReg stmm[8]; // 8*16 bytes for each FP-reg = 128 bytes
58 XMMReg xmm[8]; // 8*16 bytes for each XMM-reg = 128 bytes
59 uint32_t padding[56];
60};
61
62struct UserArea {
63 GPR regs; // General purpose registers.
64 int32_t fpvalid; // True if FPU is being used.
65 FPR_i386 i387; // FPU registers.
66 uint32_t tsize; // Text segment size.
67 uint32_t dsize; // Data segment size.
68 uint32_t ssize; // Stack segment size.
69 uint32_t start_code; // VM address of text.
70 uint32_t start_stack; // VM address of stack bottom (top in rsp).
71 int32_t signal; // Signal causing core dump.
72 int32_t reserved; // Unused.
73 uint32_t ar0; // Location of GPR's.
74 uint32_t fpstate; // Location of FPR's. Should be a FXSTATE *, but this
75 // has to be 32-bits even on 64-bit systems.
76 uint32_t magic; // Identifier for core dumps.
77 char u_comm[32]; // Command causing core dump.
78 uint32_t u_debugreg[8]; // Debug registers (DR0 - DR7).
79};
80
81#define DR_SIZE sizeof(((UserArea *)NULL)->u_debugreg[0])
82#define DR_0_OFFSET 0xFC
83#define DR_OFFSET(reg_index) (DR_0_OFFSET + (reg_index * 4))
84#define FPR_SIZE(reg) sizeof(((FPR_i386 *)NULL)->reg)
85
86// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
87#define DECLARE_REGISTER_INFOS_I386_STRUCT
88#include "RegisterInfos_i386.h"
89#undef DECLARE_REGISTER_INFOS_I386_STRUCT
90
92 const ArchSpec &target_arch)
94 target_arch,
95 {"orig_eax",
96 nullptr,
97 sizeof(((GPR *)nullptr)->orig_eax),
98 (LLVM_EXTENSION offsetof(GPR, orig_eax)),
103 nullptr,
104 nullptr,
105 nullptr}) {}
106
108
110 switch (GetTargetArchitecture().GetMachine()) {
111 case llvm::Triple::x86:
112 case llvm::Triple::x86_64:
113 return g_register_infos_i386;
114 default:
115 assert(false && "Unhandled target architecture.");
116 return nullptr;
117 }
118}
119
121 return static_cast<uint32_t>(sizeof(g_register_infos_i386) /
122 sizeof(g_register_infos_i386[0]));
123}
124
126 return static_cast<uint32_t>(k_num_user_registers_i386);
127}
#define GPR(r16)
Definition ABIX86.cpp:145
struct _GPR GPR
uint32_t GetRegisterCount() const override
uint32_t GetUserRegisterCount() const override
const lldb_private::RegisterInfo * GetRegisterInfo() const override
RegisterContextLinux_i386(const lldb_private::ArchSpec &target_arch)
An architecture specification class.
Definition ArchSpec.h:32
RegisterContextLinux_x86(const ArchSpec &target_arch, RegisterInfo orig_ax_info)
const lldb_private::ArchSpec & GetTargetArchitecture() const
#define LLDB_INVALID_REGNUM
A class that represents a running process on the host machine.
@ eEncodingUint
unsigned integer
union FPR_i386::@324145175110067056203311122160025310356250071220 ptr
struct FPR_i386::@324145175110067056203311122160025310356250071220::@142102242144035002063104136131155061226333024326 i386_
struct FPR_i386::@324145175110067056203311122160025310356250071220::@173043337111273306002071132361154377023232264005 x86_64
Every register is described in detail including its name, alternate name (optional),...