1 //===-- RegisterContextMach_arm.cpp -----------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #if defined(__APPLE__)
11 
12 #include "RegisterContextMach_arm.h"
13 
14 // C Includes
15 #include <mach/mach_types.h>
16 #include <mach/thread_act.h>
17 
18 // C++ Includes
19 // Other libraries and framework includes
20 // Project includes
21 
22 using namespace lldb;
23 using namespace lldb_private;
24 
25 RegisterContextMach_arm::RegisterContextMach_arm(Thread &thread,
26                                                  uint32_t concrete_frame_idx)
27     : RegisterContextDarwin_arm(thread, concrete_frame_idx) {}
28 
29 RegisterContextMach_arm::~RegisterContextMach_arm() {}
30 
31 int RegisterContextMach_arm::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
32   mach_msg_type_number_t count = GPRWordCount;
33   return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
34 }
35 
36 int RegisterContextMach_arm::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
37   mach_msg_type_number_t count = FPUWordCount;
38   return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
39 }
40 
41 int RegisterContextMach_arm::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
42   mach_msg_type_number_t count = EXCWordCount;
43   return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
44 }
45 
46 int RegisterContextMach_arm::DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg) {
47   mach_msg_type_number_t count = DBGWordCount;
48   return ::thread_get_state(tid, flavor, (thread_state_t)&dbg, &count);
49 }
50 
51 int RegisterContextMach_arm::DoWriteGPR(lldb::tid_t tid, int flavor,
52                                         const GPR &gpr) {
53   return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
54 }
55 
56 int RegisterContextMach_arm::DoWriteFPU(lldb::tid_t tid, int flavor,
57                                         const FPU &fpu) {
58   return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
59 }
60 
61 int RegisterContextMach_arm::DoWriteEXC(lldb::tid_t tid, int flavor,
62                                         const EXC &exc) {
63   return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
64 }
65 
66 int RegisterContextMach_arm::DoWriteDBG(lldb::tid_t tid, int flavor,
67                                         const DBG &dbg) {
68   return ::thread_set_state(tid, flavor, (thread_state_t)&dbg, DBGWordCount);
69 }
70 
71 #endif
72