1 | //===-- RegisterContextMach_arm.cpp ---------------------------------------===// |
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 | #if defined(__APPLE__) |
10 | |
11 | #include "RegisterContextMach_arm.h" |
12 | |
13 | #include <mach/mach_types.h> |
14 | #include <mach/thread_act.h> |
15 | |
16 | |
17 | using namespace lldb; |
18 | using namespace lldb_private; |
19 | |
20 | RegisterContextMach_arm::RegisterContextMach_arm(Thread &thread, |
21 | uint32_t concrete_frame_idx) |
22 | : RegisterContextDarwin_arm(thread, concrete_frame_idx) {} |
23 | |
24 | RegisterContextMach_arm::~RegisterContextMach_arm() = default; |
25 | |
26 | int RegisterContextMach_arm::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) { |
27 | mach_msg_type_number_t count = GPRWordCount; |
28 | return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count); |
29 | } |
30 | |
31 | int RegisterContextMach_arm::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) { |
32 | mach_msg_type_number_t count = FPUWordCount; |
33 | return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count); |
34 | } |
35 | |
36 | int RegisterContextMach_arm::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) { |
37 | mach_msg_type_number_t count = EXCWordCount; |
38 | return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count); |
39 | } |
40 | |
41 | int RegisterContextMach_arm::DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg) { |
42 | mach_msg_type_number_t count = DBGWordCount; |
43 | return ::thread_get_state(tid, flavor, (thread_state_t)&dbg, &count); |
44 | } |
45 | |
46 | int RegisterContextMach_arm::DoWriteGPR(lldb::tid_t tid, int flavor, |
47 | const GPR &gpr) { |
48 | return ::thread_set_state( |
49 | tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)), |
50 | GPRWordCount); |
51 | } |
52 | |
53 | int RegisterContextMach_arm::DoWriteFPU(lldb::tid_t tid, int flavor, |
54 | const FPU &fpu) { |
55 | return ::thread_set_state( |
56 | tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)), |
57 | FPUWordCount); |
58 | } |
59 | |
60 | int RegisterContextMach_arm::DoWriteEXC(lldb::tid_t tid, int flavor, |
61 | const EXC &exc) { |
62 | return ::thread_set_state( |
63 | tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)), |
64 | EXCWordCount); |
65 | } |
66 | |
67 | int RegisterContextMach_arm::DoWriteDBG(lldb::tid_t tid, int flavor, |
68 | const DBG &dbg) { |
69 | return ::thread_set_state( |
70 | tid, flavor, reinterpret_cast<thread_state_t>(const_cast<DBG *>(&dbg)), |
71 | DBGWordCount); |
72 | } |
73 | |
74 | #endif |
75 | |