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