1 //===-- RegisterContextDarwin_i386.h ----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_RegisterContextDarwin_i386_h_
11 #define liblldb_RegisterContextDarwin_i386_h_
15 // Other libraries and framework includes
17 #include "lldb/Target/RegisterContext.h"
18 #include "lldb/lldb-private.h"
20 class RegisterContextDarwin_i386 : public lldb_private::RegisterContext {
22 RegisterContextDarwin_i386(lldb_private::Thread &thread,
23 uint32_t concrete_frame_idx);
25 ~RegisterContextDarwin_i386() override;
27 void InvalidateAllRegisters() override;
29 size_t GetRegisterCount() override;
31 const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
33 size_t GetRegisterSetCount() override;
35 const lldb_private::RegisterSet *GetRegisterSet(size_t set) override;
37 bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
38 lldb_private::RegisterValue &value) override;
40 bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
41 const lldb_private::RegisterValue &value) override;
43 bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
45 bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
47 uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
48 uint32_t num) override;
50 bool HardwareSingleStep(bool enable) override;
97 uint8_t pad4[14 * 16];
108 enum { GPRRegSet = 1, FPURegSet = 2, EXCRegSet = 3 };
111 GPRWordCount = sizeof(GPR) / sizeof(uint32_t),
112 FPUWordCount = sizeof(FPU) / sizeof(uint32_t),
113 EXCWordCount = sizeof(EXC) / sizeof(uint32_t)
116 enum { Read = 0, Write = 1, kNumErrors = 2 };
121 int gpr_errs[2]; // Read/Write errors
122 int fpu_errs[2]; // Read/Write errors
123 int exc_errs[2]; // Read/Write errors
125 void InvalidateAllRegisterStates() {
126 SetError(GPRRegSet, Read, -1);
127 SetError(FPURegSet, Read, -1);
128 SetError(EXCRegSet, Read, -1);
131 int GetError(int flavor, uint32_t err_idx) const {
132 if (err_idx < kNumErrors) {
134 // When getting all errors, just OR all values together to see if
135 // we got any kind of error.
137 return gpr_errs[err_idx];
139 return fpu_errs[err_idx];
141 return exc_errs[err_idx];
149 bool SetError(int flavor, uint32_t err_idx, int err) {
150 if (err_idx < kNumErrors) {
153 gpr_errs[err_idx] = err;
157 fpu_errs[err_idx] = err;
161 exc_errs[err_idx] = err;
171 bool RegisterSetIsCached(int set) const { return GetError(set, Read) == 0; }
173 void LogGPR(lldb_private::Log *log, const char *title);
175 int ReadGPR(bool force);
177 int ReadFPU(bool force);
179 int ReadEXC(bool force);
187 // Subclasses override these to do the actual reading.
188 virtual int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) = 0;
190 virtual int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) = 0;
192 virtual int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) = 0;
194 virtual int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr) = 0;
196 virtual int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu) = 0;
198 virtual int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc) = 0;
200 int ReadRegisterSet(uint32_t set, bool force);
202 int WriteRegisterSet(uint32_t set);
204 static uint32_t GetRegisterNumber(uint32_t reg_kind, uint32_t reg_num);
206 static int GetSetForNativeRegNum(int reg_num);
208 static size_t GetRegisterInfosCount();
210 static const lldb_private::RegisterInfo *GetRegisterInfos();
213 #endif // liblldb_RegisterContextDarwin_i386_h_