1 | //===-- RegisterContextKDP_arm64.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 | #include "RegisterContextKDP_arm64.h" |
10 | |
11 | #include "ProcessKDP.h" |
12 | #include "ThreadKDP.h" |
13 | |
14 | using namespace lldb; |
15 | using namespace lldb_private; |
16 | |
17 | RegisterContextKDP_arm64::RegisterContextKDP_arm64(ThreadKDP &thread, |
18 | uint32_t concrete_frame_idx) |
19 | : RegisterContextDarwin_arm64(thread, concrete_frame_idx), |
20 | m_kdp_thread(thread) {} |
21 | |
22 | RegisterContextKDP_arm64::~RegisterContextKDP_arm64() = default; |
23 | |
24 | int RegisterContextKDP_arm64::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) { |
25 | ProcessSP process_sp(CalculateProcess()); |
26 | if (process_sp) { |
27 | Status error; |
28 | if (static_cast<ProcessKDP *>(process_sp.get()) |
29 | ->GetCommunication() |
30 | .SendRequestReadRegisters(cpu: tid, flavor: GPRRegSet, dst: &gpr, dst_size: sizeof(gpr), |
31 | error)) { |
32 | if (error.Success()) |
33 | return 0; |
34 | } |
35 | } |
36 | return -1; |
37 | } |
38 | |
39 | int RegisterContextKDP_arm64::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) { |
40 | ProcessSP process_sp(CalculateProcess()); |
41 | if (process_sp) { |
42 | Status error; |
43 | if (static_cast<ProcessKDP *>(process_sp.get()) |
44 | ->GetCommunication() |
45 | .SendRequestReadRegisters(cpu: tid, flavor: FPURegSet, dst: &fpu, dst_size: sizeof(fpu), |
46 | error)) { |
47 | if (error.Success()) |
48 | return 0; |
49 | } |
50 | } |
51 | return -1; |
52 | } |
53 | |
54 | int RegisterContextKDP_arm64::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) { |
55 | ProcessSP process_sp(CalculateProcess()); |
56 | if (process_sp) { |
57 | Status error; |
58 | if (static_cast<ProcessKDP *>(process_sp.get()) |
59 | ->GetCommunication() |
60 | .SendRequestReadRegisters(cpu: tid, flavor: EXCRegSet, dst: &exc, dst_size: sizeof(exc), |
61 | error)) { |
62 | if (error.Success()) |
63 | return 0; |
64 | } |
65 | } |
66 | return -1; |
67 | } |
68 | |
69 | int RegisterContextKDP_arm64::DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg) { |
70 | ProcessSP process_sp(CalculateProcess()); |
71 | if (process_sp) { |
72 | Status error; |
73 | if (static_cast<ProcessKDP *>(process_sp.get()) |
74 | ->GetCommunication() |
75 | .SendRequestReadRegisters(cpu: tid, flavor: DBGRegSet, dst: &dbg, dst_size: sizeof(dbg), |
76 | error)) { |
77 | if (error.Success()) |
78 | return 0; |
79 | } |
80 | } |
81 | return -1; |
82 | } |
83 | |
84 | int RegisterContextKDP_arm64::DoWriteGPR(lldb::tid_t tid, int flavor, |
85 | const GPR &gpr) { |
86 | ProcessSP process_sp(CalculateProcess()); |
87 | if (process_sp) { |
88 | Status error; |
89 | if (static_cast<ProcessKDP *>(process_sp.get()) |
90 | ->GetCommunication() |
91 | .SendRequestWriteRegisters(cpu: tid, flavor: GPRRegSet, src: &gpr, src_size: sizeof(gpr), |
92 | error)) { |
93 | if (error.Success()) |
94 | return 0; |
95 | } |
96 | } |
97 | return -1; |
98 | } |
99 | |
100 | int RegisterContextKDP_arm64::DoWriteFPU(lldb::tid_t tid, int flavor, |
101 | const FPU &fpu) { |
102 | ProcessSP process_sp(CalculateProcess()); |
103 | if (process_sp) { |
104 | Status error; |
105 | if (static_cast<ProcessKDP *>(process_sp.get()) |
106 | ->GetCommunication() |
107 | .SendRequestWriteRegisters(cpu: tid, flavor: FPURegSet, src: &fpu, src_size: sizeof(fpu), |
108 | error)) { |
109 | if (error.Success()) |
110 | return 0; |
111 | } |
112 | } |
113 | return -1; |
114 | } |
115 | |
116 | int RegisterContextKDP_arm64::DoWriteEXC(lldb::tid_t tid, int flavor, |
117 | const EXC &exc) { |
118 | ProcessSP process_sp(CalculateProcess()); |
119 | if (process_sp) { |
120 | Status error; |
121 | if (static_cast<ProcessKDP *>(process_sp.get()) |
122 | ->GetCommunication() |
123 | .SendRequestWriteRegisters(cpu: tid, flavor: EXCRegSet, src: &exc, src_size: sizeof(exc), |
124 | error)) { |
125 | if (error.Success()) |
126 | return 0; |
127 | } |
128 | } |
129 | return -1; |
130 | } |
131 | |
132 | int RegisterContextKDP_arm64::DoWriteDBG(lldb::tid_t tid, int flavor, |
133 | const DBG &dbg) { |
134 | ProcessSP process_sp(CalculateProcess()); |
135 | if (process_sp) { |
136 | Status error; |
137 | if (static_cast<ProcessKDP *>(process_sp.get()) |
138 | ->GetCommunication() |
139 | .SendRequestWriteRegisters(cpu: tid, flavor: DBGRegSet, src: &dbg, src_size: sizeof(dbg), |
140 | error)) { |
141 | if (error.Success()) |
142 | return 0; |
143 | } |
144 | } |
145 | return -1; |
146 | } |
147 | |