LLDB mainline
RegisterContextNetBSD_i386.cpp
Go to the documentation of this file.
1//===-- RegisterContextNetBSD_i386.cpp --------------------------*- C++ -*-===//
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
17// this needs to match 'struct reg'
18struct GPR {
19 uint32_t eax;
20 uint32_t ecx;
21 uint32_t edx;
22 uint32_t ebx;
23 uint32_t esp;
24 uint32_t ebp;
25 uint32_t esi;
26 uint32_t edi;
27 uint32_t eip;
28 uint32_t eflags;
29 uint32_t cs;
30 uint32_t ss;
31 uint32_t ds;
32 uint32_t es;
33 uint32_t fs;
34 uint32_t gs;
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 gpr;
65 uint32_t u_debugreg[8]; // Debug registers (DR0 - DR7).
66 uint32_t tlsbase;
67};
68
69#define DR_SIZE sizeof(((UserArea *)NULL)->u_debugreg[0])
70#define DR_OFFSET(reg_index) \
71 (LLVM_EXTENSION offsetof(UserArea, u_debugreg[reg_index]))
72
73// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
74#define DECLARE_REGISTER_INFOS_I386_STRUCT
75#include "RegisterInfos_i386.h"
76#undef DECLARE_REGISTER_INFOS_I386_STRUCT
77
81
82size_t RegisterContextNetBSD_i386::GetGPRSize() const { return sizeof(GPR); }
83
85 switch (GetTargetArchitecture().GetMachine()) {
86 case llvm::Triple::x86:
87 case llvm::Triple::x86_64:
88 return g_register_infos_i386;
89 default:
90 assert(false && "Unhandled target architecture.");
91 return nullptr;
92 }
93}
94
96 return static_cast<uint32_t>(sizeof(g_register_infos_i386) /
97 sizeof(g_register_infos_i386[0]));
98}
#define GPR(r16)
Definition ABIX86.cpp:145
struct _GPR GPR
const lldb_private::RegisterInfo * GetRegisterInfo() const override
uint32_t GetRegisterCount() const override
RegisterContextNetBSD_i386(const lldb_private::ArchSpec &target_arch)
An architecture specification class.
Definition ArchSpec.h:32
const lldb_private::ArchSpec & GetTargetArchitecture() const
RegisterInfoInterface(const lldb_private::ArchSpec &target_arch)
A class that represents a running process on the host machine.
union FPR_i386::@324145175110067056203311122160025310356250071220 ptr
struct FPR_i386::@324145175110067056203311122160025310356250071220::@142102242144035002063104136131155061226333024326 i386_
struct FPR_i386::@324145175110067056203311122160025310356250071220::@173043337111273306002071132361154377023232264005 x86_64
GPR_linux_mips gpr
Every register is described in detail including its name, alternate name (optional),...