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 
26 RegisterContextMach_arm::RegisterContextMach_arm(Thread &thread, uint32_t concrete_frame_idx) :
27     RegisterContextDarwin_arm (thread, concrete_frame_idx)
28 {
29 }
30 
31 RegisterContextMach_arm::~RegisterContextMach_arm()
32 {
33 }
34 
35 int
36 RegisterContextMach_arm::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr)
37 {
38     mach_msg_type_number_t count = GPRWordCount;
39     return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
40 }
41 
42 int
43 RegisterContextMach_arm::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu)
44 {
45     mach_msg_type_number_t count = FPUWordCount;
46     return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
47 }
48 
49 int
50 RegisterContextMach_arm::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc)
51 {
52     mach_msg_type_number_t count = EXCWordCount;
53     return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
54 }
55 
56 int
57 RegisterContextMach_arm::DoReadDBG (lldb::tid_t tid, int flavor, DBG &dbg)
58 {
59     mach_msg_type_number_t count = DBGWordCount;
60     return ::thread_get_state(tid, flavor, (thread_state_t)&dbg, &count);
61 }
62 
63 int
64 RegisterContextMach_arm::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr)
65 {
66     return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
67 }
68 
69 int
70 RegisterContextMach_arm::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu)
71 {
72     return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
73 }
74 
75 int
76 RegisterContextMach_arm::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc)
77 {
78     return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
79 }
80 
81 int
82 RegisterContextMach_arm::DoWriteDBG (lldb::tid_t tid, int flavor, const DBG &dbg)
83 {
84     return ::thread_set_state(tid, flavor, (thread_state_t)&dbg, DBGWordCount);
85 }
86 
87 #endif
88