1 //===-- RegisterContextDarwin_arm.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_arm_h_
11 #define liblldb_RegisterContextDarwin_arm_h_
15 // Other libraries and framework includes
17 #include "lldb/lldb-private.h"
18 #include "lldb/Target/RegisterContext.h"
20 // BCR address match type
21 #define BCR_M_IMVA_MATCH ((uint32_t)(0u << 21))
22 #define BCR_M_CONTEXT_ID_MATCH ((uint32_t)(1u << 21))
23 #define BCR_M_IMVA_MISMATCH ((uint32_t)(2u << 21))
24 #define BCR_M_RESERVED ((uint32_t)(3u << 21))
26 // Link a BVR/BCR or WVR/WCR pair to another
27 #define E_ENABLE_LINKING ((uint32_t)(1u << 20))
29 // Byte Address Select
30 #define BAS_IMVA_PLUS_0 ((uint32_t)(1u << 5))
31 #define BAS_IMVA_PLUS_1 ((uint32_t)(1u << 6))
32 #define BAS_IMVA_PLUS_2 ((uint32_t)(1u << 7))
33 #define BAS_IMVA_PLUS_3 ((uint32_t)(1u << 8))
34 #define BAS_IMVA_0_1 ((uint32_t)(3u << 5))
35 #define BAS_IMVA_2_3 ((uint32_t)(3u << 7))
36 #define BAS_IMVA_ALL ((uint32_t)(0xfu << 5))
38 // Break only in privileged or user mode
39 #define S_RSVD ((uint32_t)(0u << 1))
40 #define S_PRIV ((uint32_t)(1u << 1))
41 #define S_USER ((uint32_t)(2u << 1))
42 #define S_PRIV_USER ((S_PRIV) | (S_USER))
44 #define BCR_ENABLE ((uint32_t)(1u))
45 #define WCR_ENABLE ((uint32_t)(1u))
47 // Watchpoint load/store
48 #define WCR_LOAD ((uint32_t)(1u << 3))
49 #define WCR_STORE ((uint32_t)(1u << 4))
51 class RegisterContextDarwin_arm : public lldb_private::RegisterContext
55 RegisterContextDarwin_arm(lldb_private::Thread &thread, uint32_t concrete_frame_idx);
58 ~RegisterContextDarwin_arm();
61 InvalidateAllRegisters ();
66 virtual const lldb_private::RegisterInfo *
67 GetRegisterInfoAtIndex (size_t reg);
70 GetRegisterSetCount ();
72 virtual const lldb_private::RegisterSet *
73 GetRegisterSet (size_t set);
76 ReadRegister (const lldb_private::RegisterInfo *reg_info,
77 lldb_private::RegisterValue ®_value);
80 WriteRegister (const lldb_private::RegisterInfo *reg_info,
81 const lldb_private::RegisterValue ®_value);
84 ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
87 WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
90 ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num);
93 NumSupportedHardwareBreakpoints ();
96 SetHardwareBreakpoint (lldb::addr_t addr, size_t size);
99 ClearHardwareBreakpoint (uint32_t hw_idx);
102 NumSupportedHardwareWatchpoints ();
105 SetHardwareWatchpoint (lldb::addr_t addr, size_t size, bool read, bool write);
108 ClearHardwareWatchpoint (uint32_t hw_index);
112 uint32_t r[16]; // R0-R15
113 uint32_t cpsr; // CPSR
127 QReg q[16]; // the 128-bit NEON registers
134 // uint8_t bytes[16];
150 uint32_t fsr; /* Fault status */
151 uint32_t far; /* Virtual Fault Address */
163 LogDBGRegisters (lldb_private::Log *log, const DBG& dbg);
169 GPRRegSet = 1, // ARM_THREAD_STATE
170 FPURegSet = 2, // ARM_VFP_STATE
171 EXCRegSet = 3, // ARM_EXCEPTION_STATE
172 DBGRegSet = 4 // ARM_DEBUG_STATE
177 GPRWordCount = sizeof(GPR)/sizeof(uint32_t),
178 FPUWordCount = sizeof(FPU)/sizeof(uint32_t),
179 EXCWordCount = sizeof(EXC)/sizeof(uint32_t),
180 DBGWordCount = sizeof(DBG)/sizeof(uint32_t)
194 int gpr_errs[2]; // Read/Write errors
195 int fpu_errs[2]; // Read/Write errors
196 int exc_errs[2]; // Read/Write errors
197 int dbg_errs[2]; // Read/Write errors
200 InvalidateAllRegisterStates()
202 SetError (GPRRegSet, Read, -1);
203 SetError (FPURegSet, Read, -1);
204 SetError (EXCRegSet, Read, -1);
208 GetError (int flavor, uint32_t err_idx) const
210 if (err_idx < kNumErrors)
214 // When getting all errors, just OR all values together to see if
215 // we got any kind of error.
216 case GPRRegSet: return gpr_errs[err_idx];
217 case FPURegSet: return fpu_errs[err_idx];
218 case EXCRegSet: return exc_errs[err_idx];
219 case DBGRegSet: return dbg_errs[err_idx];
227 SetError (int flavor, uint32_t err_idx, int err)
229 if (err_idx < kNumErrors)
234 gpr_errs[err_idx] = err;
238 fpu_errs[err_idx] = err;
242 exc_errs[err_idx] = err;
246 exc_errs[err_idx] = err;
256 RegisterSetIsCached (int set) const
258 return GetError(set, Read) == 0;
262 ReadGPR (bool force);
265 ReadFPU (bool force);
268 ReadEXC (bool force);
271 ReadDBG (bool force);
286 // Subclasses override these to do the actual reading.
288 DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
294 DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu) = 0;
297 DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc) = 0;
300 DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg) = 0;
303 DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr) = 0;
306 DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu) = 0;
309 DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc) = 0;
312 DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg) = 0;
315 ReadRegisterSet (uint32_t set, bool force);
318 WriteRegisterSet (uint32_t set);
321 GetRegisterNumber (uint32_t reg_kind, uint32_t reg_num);
324 GetSetForNativeRegNum (int reg_num);
327 GetRegisterInfosCount ();
329 static const lldb_private::RegisterInfo *
333 #endif // liblldb_RegisterContextDarwin_arm_h_