LLDB  mainline
RegisterContextDarwin_i386.h
Go to the documentation of this file.
1 //===-- RegisterContextDarwin_i386.h ----------------------------*- 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 
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_I386_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_I386_H
11 
13 #include "lldb/lldb-private.h"
14 
16 public:
18  uint32_t concrete_frame_idx);
19 
20  ~RegisterContextDarwin_i386() override;
21 
22  void InvalidateAllRegisters() override;
23 
24  size_t GetRegisterCount() override;
25 
26  const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
27 
28  size_t GetRegisterSetCount() override;
29 
30  const lldb_private::RegisterSet *GetRegisterSet(size_t set) override;
31 
32  bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
33  lldb_private::RegisterValue &value) override;
34 
35  bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
36  const lldb_private::RegisterValue &value) override;
37 
38  bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
39 
40  bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
41 
43  uint32_t num) override;
44 
45  bool HardwareSingleStep(bool enable) override;
46 
47  struct GPR {
64  };
65 
66  struct MMSReg {
67  uint8_t bytes[10];
68  uint8_t pad[6];
69  };
70 
71  struct XMMReg {
72  uint8_t bytes[16];
73  };
74 
75  struct FPU {
79  uint8_t ftw;
80  uint8_t pad1;
91  XMMReg xmm[8];
92  uint8_t pad4[14 * 16];
93  int pad5;
94  };
95 
96  struct EXC {
100  };
101 
102 protected:
103  enum { GPRRegSet = 1, FPURegSet = 2, EXCRegSet = 3 };
104 
105  enum {
106  GPRWordCount = sizeof(GPR) / sizeof(uint32_t),
107  FPUWordCount = sizeof(FPU) / sizeof(uint32_t),
108  EXCWordCount = sizeof(EXC) / sizeof(uint32_t)
109  };
110 
111  enum { Read = 0, Write = 1, kNumErrors = 2 };
112 
116  int gpr_errs[2]; // Read/Write errors
117  int fpu_errs[2]; // Read/Write errors
118  int exc_errs[2]; // Read/Write errors
119 
121  SetError(GPRRegSet, Read, -1);
122  SetError(FPURegSet, Read, -1);
123  SetError(EXCRegSet, Read, -1);
124  }
125 
126  int GetError(int flavor, uint32_t err_idx) const {
127  if (err_idx < kNumErrors) {
128  switch (flavor) {
129  // When getting all errors, just OR all values together to see if
130  // we got any kind of error.
131  case GPRRegSet:
132  return gpr_errs[err_idx];
133  case FPURegSet:
134  return fpu_errs[err_idx];
135  case EXCRegSet:
136  return exc_errs[err_idx];
137  default:
138  break;
139  }
140  }
141  return -1;
142  }
143 
144  bool SetError(int flavor, uint32_t err_idx, int err) {
145  if (err_idx < kNumErrors) {
146  switch (flavor) {
147  case GPRRegSet:
148  gpr_errs[err_idx] = err;
149  return true;
150 
151  case FPURegSet:
152  fpu_errs[err_idx] = err;
153  return true;
154 
155  case EXCRegSet:
156  exc_errs[err_idx] = err;
157  return true;
158 
159  default:
160  break;
161  }
162  }
163  return false;
164  }
165 
166  bool RegisterSetIsCached(int set) const { return GetError(set, Read) == 0; }
167 
168  void LogGPR(lldb_private::Log *log, const char *title);
169 
170  int ReadGPR(bool force);
171 
172  int ReadFPU(bool force);
173 
174  int ReadEXC(bool force);
175 
176  int WriteGPR();
177 
178  int WriteFPU();
179 
180  int WriteEXC();
181 
182  // Subclasses override these to do the actual reading.
183  virtual int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) = 0;
184 
185  virtual int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) = 0;
186 
187  virtual int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) = 0;
188 
189  virtual int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr) = 0;
190 
191  virtual int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu) = 0;
192 
193  virtual int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc) = 0;
194 
195  int ReadRegisterSet(uint32_t set, bool force);
196 
198 
199  static uint32_t GetRegisterNumber(uint32_t reg_kind, uint32_t reg_num);
200 
201  static int GetSetForNativeRegNum(int reg_num);
202 
203  static size_t GetRegisterInfosCount();
204 
205  static const lldb_private::RegisterInfo *GetRegisterInfos();
206 };
207 
208 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_I386_H
RegisterContextDarwin_i386::GPR::eflags
uint32_t eflags
Definition: RegisterContextDarwin_i386.h:57
RegisterContextDarwin_i386::FPU::pad4
uint8_t pad4[14 *16]
Definition: RegisterContextDarwin_i386.h:92
RegisterContextDarwin_i386::ReadRegister
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
Definition: RegisterContextDarwin_i386.cpp:561
RegisterContextDarwin_i386::GetRegisterCount
size_t GetRegisterCount() override
Definition: RegisterContextDarwin_i386.cpp:385
RegisterContextDarwin_i386::FPU::dp
uint32_t dp
Definition: RegisterContextDarwin_i386.h:85
RegisterContextDarwin_i386::EXC
Definition: RegisterContextDarwin_i386.h:96
RegisterContextDarwin_i386::RegisterContextDarwin_i386
RegisterContextDarwin_i386(lldb_private::Thread &thread, uint32_t concrete_frame_idx)
Definition: RegisterContextDarwin_i386.cpp:368
RegisterContextDarwin_i386::EXCRegSet
@ EXCRegSet
Definition: RegisterContextDarwin_i386.h:103
RegisterContextDarwin_i386::LogGPR
void LogGPR(lldb_private::Log *log, const char *title)
Definition: RegisterContextDarwin_i386.cpp:461
lldb_private::RegisterValue
Definition: RegisterValue.h:28
RegisterContextDarwin_i386::WriteEXC
int WriteEXC()
Definition: RegisterContextDarwin_i386.cpp:519
RegisterContextDarwin_i386::WriteFPU
int WriteFPU()
Definition: RegisterContextDarwin_i386.cpp:508
RegisterContextDarwin_i386::MMSReg::bytes
uint8_t bytes[10]
Definition: RegisterContextDarwin_i386.h:67
RegisterContextDarwin_i386::GetError
int GetError(int flavor, uint32_t err_idx) const
Definition: RegisterContextDarwin_i386.h:126
RegisterContextDarwin_i386::Read
@ Read
Definition: RegisterContextDarwin_i386.h:111
RegisterContextDarwin_i386::GPR
Definition: RegisterContextDarwin_i386.h:47
RegisterContextDarwin_i386::GPR::cs
uint32_t cs
Definition: RegisterContextDarwin_i386.h:59
RegisterContextDarwin_i386::FPU::pad
uint32_t pad[2]
Definition: RegisterContextDarwin_i386.h:76
RegisterContextDarwin_i386::kNumErrors
@ kNumErrors
Definition: RegisterContextDarwin_i386.h:111
RegisterContextDarwin_i386::HardwareSingleStep
bool HardwareSingleStep(bool enable) override
Definition: RegisterContextDarwin_i386.cpp:914
RegisterContextDarwin_i386::FPU::pad2
uint16_t pad2
Definition: RegisterContextDarwin_i386.h:84
RegisterContextDarwin_i386::FPU::pad1
uint8_t pad1
Definition: RegisterContextDarwin_i386.h:80
RegisterContextDarwin_i386::XMMReg::bytes
uint8_t bytes[16]
Definition: RegisterContextDarwin_i386.h:72
RegisterContextDarwin_i386::GPR::fs
uint32_t fs
Definition: RegisterContextDarwin_i386.h:62
RegisterContextDarwin_i386::WriteRegisterSet
int WriteRegisterSet(uint32_t set)
Definition: RegisterContextDarwin_i386.cpp:544
RegisterContextDarwin_i386::GetRegisterNumber
static uint32_t GetRegisterNumber(uint32_t reg_kind, uint32_t reg_num)
RegisterContextDarwin_i386::DoWriteEXC
virtual int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc)=0
RegisterContextDarwin_i386::FPU::fsw
uint16_t fsw
Definition: RegisterContextDarwin_i386.h:78
RegisterContextDarwin_i386::FPUWordCount
@ FPUWordCount
Definition: RegisterContextDarwin_i386.h:107
RegisterContextDarwin_i386::GPR::eax
uint32_t eax
Definition: RegisterContextDarwin_i386.h:48
RegisterContextDarwin_i386::GetRegisterInfosCount
static size_t GetRegisterInfosCount()
Definition: RegisterContextDarwin_i386.cpp:398
RegisterContextDarwin_i386::fpu_errs
int fpu_errs[2]
Definition: RegisterContextDarwin_i386.h:117
RegisterContextDarwin_i386::ReadFPU
int ReadFPU(bool force)
Definition: RegisterContextDarwin_i386.cpp:481
RegisterContextDarwin_i386::DoReadFPU
virtual int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu)=0
RegisterContextDarwin_i386::exc_errs
int exc_errs[2]
Definition: RegisterContextDarwin_i386.h:118
RegisterContextDarwin_i386::ConvertRegisterKindToRegisterNumber
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
Definition: RegisterContextDarwin_i386.cpp:835
RegisterContextDarwin_i386::EXC::err
uint32_t err
Definition: RegisterContextDarwin_i386.h:98
RegisterContextDarwin_i386::gpr
GPR gpr
Definition: RegisterContextDarwin_i386.h:113
RegisterContextDarwin_i386::~RegisterContextDarwin_i386
~RegisterContextDarwin_i386() override
RegisterContextDarwin_i386::FPU::fcw
uint16_t fcw
Definition: RegisterContextDarwin_i386.h:77
RegisterContextDarwin_i386::ReadAllRegisterValues
bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override
Definition: RegisterContextDarwin_i386.cpp:795
RegisterContextDarwin_i386::fpu
FPU fpu
Definition: RegisterContextDarwin_i386.h:114
RegisterContextDarwin_i386::GetRegisterInfoAtIndex
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: RegisterContextDarwin_i386.cpp:391
lldb_private::Thread
Definition: Thread.h:60
RegisterContextDarwin_i386::Write
@ Write
Definition: RegisterContextDarwin_i386.h:111
RegisterContextDarwin_i386::DoWriteGPR
virtual int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr)=0
RegisterContextDarwin_i386::GPR::edi
uint32_t edi
Definition: RegisterContextDarwin_i386.h:52
RegisterContextDarwin_i386::FPU
Definition: RegisterContextDarwin_i386.h:75
RegisterContextDarwin_i386::GPR::esp
uint32_t esp
Definition: RegisterContextDarwin_i386.h:55
RegisterContextDarwin_i386::FPU::cs
uint16_t cs
Definition: RegisterContextDarwin_i386.h:83
RegisterContextDarwin_i386::FPU::fop
uint16_t fop
Definition: RegisterContextDarwin_i386.h:81
RegisterContextDarwin_i386::GetRegisterInfos
static const lldb_private::RegisterInfo * GetRegisterInfos()
Definition: RegisterContextDarwin_i386.cpp:402
RegisterContextDarwin_i386::XMMReg
Definition: RegisterContextDarwin_i386.h:71
RegisterContextDarwin_i386::GPRRegSet
@ GPRRegSet
Definition: RegisterContextDarwin_i386.h:103
RegisterContextDarwin_i386::GPR::ebx
uint32_t ebx
Definition: RegisterContextDarwin_i386.h:49
RegisterContextDarwin_i386::GPR::es
uint32_t es
Definition: RegisterContextDarwin_i386.h:61
RegisterContextDarwin_i386::GPR::ecx
uint32_t ecx
Definition: RegisterContextDarwin_i386.h:50
RegisterContextDarwin_i386::DoReadGPR
virtual int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr)=0
set
set(option_framework FRAMEWORK) endif() if(LLDB_ENABLE_PYTHON) get_target_property(python_bindings_dir swig_wrapper_python BINARY_DIR) set(lldb_python_wrapper $
Definition: API/CMakeLists.txt:9
RegisterContextDarwin_i386::GPR::edx
uint32_t edx
Definition: RegisterContextDarwin_i386.h:51
RegisterContextDarwin_i386::GPR::gs
uint32_t gs
Definition: RegisterContextDarwin_i386.h:63
RegisterContextDarwin_i386::FPU::ip
uint32_t ip
Definition: RegisterContextDarwin_i386.h:82
RegisterContextDarwin_i386::WriteAllRegisterValues
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
Definition: RegisterContextDarwin_i386.cpp:812
RegisterContextDarwin_i386::FPU::ds
uint16_t ds
Definition: RegisterContextDarwin_i386.h:86
RegisterContextDarwin_i386::ReadGPR
int ReadGPR(bool force)
Definition: RegisterContextDarwin_i386.cpp:473
RegisterContextDarwin_i386::FPURegSet
@ FPURegSet
Definition: RegisterContextDarwin_i386.h:103
RegisterContextDarwin_i386::FPU::pad5
int pad5
Definition: RegisterContextDarwin_i386.h:93
RegisterContextDarwin_i386::ReadRegisterSet
int ReadRegisterSet(uint32_t set, bool force)
Definition: RegisterContextDarwin_i386.cpp:530
lldb_private::RegisterContext
Definition: RegisterContext.h:17
RegisterContextDarwin_i386::WriteGPR
int WriteGPR()
Definition: RegisterContextDarwin_i386.cpp:497
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
lldb-private.h
RegisterContextDarwin_i386::GetSetForNativeRegNum
static int GetSetForNativeRegNum(int reg_num)
Definition: RegisterContextDarwin_i386.cpp:451
RegisterContextDarwin_i386::GPR::eip
uint32_t eip
Definition: RegisterContextDarwin_i386.h:58
RegisterContextDarwin_i386::FPU::xmm
XMMReg xmm[8]
Definition: RegisterContextDarwin_i386.h:91
RegisterContextDarwin_i386
Definition: RegisterContextDarwin_i386.h:15
GPR
Definition: RegisterContextFreeBSD_i386.cpp:16
GPR
#define GPR(r16)
Definition: ABIX86.cpp:144
RegisterContextDarwin_i386::SetError
bool SetError(int flavor, uint32_t err_idx, int err)
Definition: RegisterContextDarwin_i386.h:144
uint32_t
RegisterContextDarwin_i386::RegisterSetIsCached
bool RegisterSetIsCached(int set) const
Definition: RegisterContextDarwin_i386.h:166
RegisterContextDarwin_i386::EXCWordCount
@ EXCWordCount
Definition: RegisterContextDarwin_i386.h:108
RegisterContextDarwin_i386::exc
EXC exc
Definition: RegisterContextDarwin_i386.h:115
RegisterContextDarwin_i386::FPU::mxcsr
uint32_t mxcsr
Definition: RegisterContextDarwin_i386.h:88
RegisterContextDarwin_i386::GPR::ebp
uint32_t ebp
Definition: RegisterContextDarwin_i386.h:54
uint16_t
RegisterContextDarwin_i386::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
Definition: RegisterContextDarwin_i386.cpp:444
RegisterContextDarwin_i386::DoWriteFPU
virtual int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu)=0
RegisterContextDarwin_i386::gpr_errs
int gpr_errs[2]
Definition: RegisterContextDarwin_i386.h:116
RegisterContextDarwin_i386::EXC::trapno
uint32_t trapno
Definition: RegisterContextDarwin_i386.h:97
RegisterContextDarwin_i386::GPRWordCount
@ GPRWordCount
Definition: RegisterContextDarwin_i386.h:106
RegisterContextDarwin_i386::GPR::ss
uint32_t ss
Definition: RegisterContextDarwin_i386.h:56
RegisterContextDarwin_i386::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: RegisterContextDarwin_i386.cpp:381
RegisterContextDarwin_i386::InvalidateAllRegisterStates
void InvalidateAllRegisterStates()
Definition: RegisterContextDarwin_i386.h:120
RegisterContextDarwin_i386::FPU::ftw
uint8_t ftw
Definition: RegisterContextDarwin_i386.h:79
RegisterContextDarwin_i386::FPU::mxcsrmask
uint32_t mxcsrmask
Definition: RegisterContextDarwin_i386.h:89
RegisterContextDarwin_i386::MMSReg
Definition: RegisterContextDarwin_i386.h:66
RegisterContextDarwin_i386::EXC::faultvaddr
uint32_t faultvaddr
Definition: RegisterContextDarwin_i386.h:99
RegisterContextDarwin_i386::DoReadEXC
virtual int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc)=0
RegisterContextDarwin_i386::ReadEXC
int ReadEXC(bool force)
Definition: RegisterContextDarwin_i386.cpp:489
RegisterContextDarwin_i386::FPU::pad3
uint16_t pad3
Definition: RegisterContextDarwin_i386.h:87
RegisterContextDarwin_i386::GPR::esi
uint32_t esi
Definition: RegisterContextDarwin_i386.h:53
RegisterContextDarwin_i386::MMSReg::pad
uint8_t pad[6]
Definition: RegisterContextDarwin_i386.h:68
RegisterContextDarwin_i386::GPR::ds
uint32_t ds
Definition: RegisterContextDarwin_i386.h:60
lldb_private::Log
Definition: Log.h:49
RegisterContextDarwin_i386::FPU::stmm
MMSReg stmm[8]
Definition: RegisterContextDarwin_i386.h:90
RegisterContext.h
RegisterContextDarwin_i386::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: RegisterContextDarwin_i386.cpp:440
RegisterContextDarwin_i386::WriteRegister
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
Definition: RegisterContextDarwin_i386.cpp:678
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86