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 
11 
12 using namespace lldb_private;
13 using namespace lldb;
14 
15 // this needs to match 'struct reg'
16 struct GPR {
17  uint32_t eax;
18  uint32_t ecx;
19  uint32_t edx;
20  uint32_t ebx;
21  uint32_t esp;
22  uint32_t ebp;
23  uint32_t esi;
24  uint32_t edi;
25  uint32_t eip;
26  uint32_t eflags;
27  uint32_t cs;
28  uint32_t ss;
29  uint32_t ds;
30  uint32_t es;
31  uint32_t fs;
32  uint32_t gs;
33 };
34 
35 struct FPR_i386 {
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)
40  union {
41  struct {
42  uint64_t fip; // Instruction Pointer
43  uint64_t fdp; // Data Pointer
44  } x86_64;
45  struct {
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
51  // cases
52  } ptr;
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
57  uint32_t padding[56];
58 };
59 
60 struct UserArea {
61  GPR gpr;
62  FPR_i386 i387;
63  uint32_t u_debugreg[8]; // Debug registers (DR0 - DR7).
65 };
66 
67 #define DR_SIZE sizeof(((UserArea *)NULL)->u_debugreg[0])
68 #define DR_OFFSET(reg_index) \
69  (LLVM_EXTENSION offsetof(UserArea, u_debugreg[reg_index]))
70 
71 // Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
72 #define DECLARE_REGISTER_INFOS_I386_STRUCT
73 #include "RegisterInfos_i386.h"
74 #undef DECLARE_REGISTER_INFOS_I386_STRUCT
75 
77  const ArchSpec &target_arch)
78  : RegisterInfoInterface(target_arch) {}
79 
80 size_t RegisterContextNetBSD_i386::GetGPRSize() const { return sizeof(GPR); }
81 
82 const RegisterInfo *RegisterContextNetBSD_i386::GetRegisterInfo() const {
83  switch (m_target_arch.GetMachine()) {
84  case llvm::Triple::x86:
85  case llvm::Triple::x86_64:
86  return g_register_infos_i386;
87  default:
88  assert(false && "Unhandled target architecture.");
89  return nullptr;
90  }
91 }
92 
94  return static_cast<uint32_t>(sizeof(g_register_infos_i386) /
95  sizeof(g_register_infos_i386[0]));
96 }
lldb_private::RegisterInfoInterface::m_target_arch
lldb_private::ArchSpec m_target_arch
Definition: RegisterInfoInterface.h:65
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:667
lldb_private::MMSReg
Definition: RegisterContext_x86.h:249
esp
@ esp
Definition: CompactUnwindInfo.cpp:978
lldb_private::RegisterInfoInterface
Definition: RegisterInfoInterface.h:21
ebp
@ ebp
Definition: CompactUnwindInfo.cpp:977
ebx
@ ebx
Definition: CompactUnwindInfo.cpp:976
RegisterContextNetBSD_i386::RegisterContextNetBSD_i386
RegisterContextNetBSD_i386(const lldb_private::ArchSpec &target_arch)
Definition: RegisterContextNetBSD_i386.cpp:76
edx
@ edx
Definition: CompactUnwindInfo.cpp:975
UserArea
Definition: RegisterContext_mips.h:368
RegisterContextPOSIX_x86.h
RegisterContextNetBSD_i386.h
GPR
Definition: RegisterContextFreeBSD_i386.cpp:16
ecx
@ ecx
Definition: CompactUnwindInfo.cpp:974
GPR
#define GPR(r16)
Definition: ABIX86.cpp:144
uint32_t
lldb_private::XMMReg
Definition: RegisterContext_x86.h:261
RegisterContextNetBSD_i386::GetRegisterCount
uint32_t GetRegisterCount() const override
Definition: RegisterContextNetBSD_i386.cpp:93
edi
@ edi
Definition: CompactUnwindInfo.cpp:980
eax
@ eax
Definition: CompactUnwindInfo.cpp:973
uint16_t
UserArea::tlsbase
uint32_t tlsbase
Definition: RegisterContextNetBSD_i386.cpp:64
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
RegisterInfos_i386.h
esi
@ esi
Definition: CompactUnwindInfo.cpp:979
lldb
Definition: SBAddress.h:15
RegisterContextNetBSD_i386::GetRegisterInfo
const lldb_private::RegisterInfo * GetRegisterInfo() const override
Definition: RegisterContextNetBSD_i386.cpp:82
RegisterContextNetBSD_i386::GetGPRSize
size_t GetGPRSize() const override
Definition: RegisterContextNetBSD_i386.cpp:80
FPR_i386
Definition: RegisterContextLinux_i386.cpp:35
eip
@ eip
Definition: CompactUnwindInfo.cpp:981