| 1 | //===-- RegisterContextKDP_x86_64.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_x86_64.h" |
| 10 | #include "ProcessKDP.h" |
| 11 | #include "ThreadKDP.h" |
| 12 | |
| 13 | using namespace lldb; |
| 14 | using namespace lldb_private; |
| 15 | |
| 16 | RegisterContextKDP_x86_64::RegisterContextKDP_x86_64( |
| 17 | ThreadKDP &thread, uint32_t concrete_frame_idx) |
| 18 | : RegisterContextDarwin_x86_64(thread, concrete_frame_idx), |
| 19 | m_kdp_thread(thread) {} |
| 20 | |
| 21 | RegisterContextKDP_x86_64::~RegisterContextKDP_x86_64() = default; |
| 22 | |
| 23 | int RegisterContextKDP_x86_64::DoReadGPR(lldb::tid_t tid, int flavor, |
| 24 | 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_x86_64::DoReadFPU(lldb::tid_t tid, int flavor, |
| 40 | 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(cpu: tid, flavor: FPURegSet, dst: &fpu, dst_size: sizeof(fpu), |
| 47 | error)) { |
| 48 | if (error.Success()) |
| 49 | return 0; |
| 50 | } |
| 51 | } |
| 52 | return -1; |
| 53 | } |
| 54 | |
| 55 | int RegisterContextKDP_x86_64::DoReadEXC(lldb::tid_t tid, int flavor, |
| 56 | EXC &exc) { |
| 57 | ProcessSP process_sp(CalculateProcess()); |
| 58 | if (process_sp) { |
| 59 | Status error; |
| 60 | if (static_cast<ProcessKDP *>(process_sp.get()) |
| 61 | ->GetCommunication() |
| 62 | .SendRequestReadRegisters(cpu: tid, flavor: EXCRegSet, dst: &exc, dst_size: sizeof(exc), |
| 63 | error)) { |
| 64 | if (error.Success()) |
| 65 | return 0; |
| 66 | } |
| 67 | } |
| 68 | return -1; |
| 69 | } |
| 70 | |
| 71 | int RegisterContextKDP_x86_64::DoWriteGPR(lldb::tid_t tid, int flavor, |
| 72 | const GPR &gpr) { |
| 73 | ProcessSP process_sp(CalculateProcess()); |
| 74 | if (process_sp) { |
| 75 | Status error; |
| 76 | if (static_cast<ProcessKDP *>(process_sp.get()) |
| 77 | ->GetCommunication() |
| 78 | .SendRequestWriteRegisters(cpu: tid, flavor: GPRRegSet, src: &gpr, src_size: sizeof(gpr), |
| 79 | error)) { |
| 80 | if (error.Success()) |
| 81 | return 0; |
| 82 | } |
| 83 | } |
| 84 | return -1; |
| 85 | } |
| 86 | |
| 87 | int RegisterContextKDP_x86_64::DoWriteFPU(lldb::tid_t tid, int flavor, |
| 88 | const FPU &fpu) { |
| 89 | ProcessSP process_sp(CalculateProcess()); |
| 90 | if (process_sp) { |
| 91 | Status error; |
| 92 | if (static_cast<ProcessKDP *>(process_sp.get()) |
| 93 | ->GetCommunication() |
| 94 | .SendRequestWriteRegisters(cpu: tid, flavor: FPURegSet, src: &fpu, src_size: sizeof(fpu), |
| 95 | error)) { |
| 96 | if (error.Success()) |
| 97 | return 0; |
| 98 | } |
| 99 | } |
| 100 | return -1; |
| 101 | } |
| 102 | |
| 103 | int RegisterContextKDP_x86_64::DoWriteEXC(lldb::tid_t tid, int flavor, |
| 104 | const EXC &exc) { |
| 105 | ProcessSP process_sp(CalculateProcess()); |
| 106 | if (process_sp) { |
| 107 | Status error; |
| 108 | if (static_cast<ProcessKDP *>(process_sp.get()) |
| 109 | ->GetCommunication() |
| 110 | .SendRequestWriteRegisters(cpu: tid, flavor: EXCRegSet, src: &exc, src_size: sizeof(exc), |
| 111 | error)) { |
| 112 | if (error.Success()) |
| 113 | return 0; |
| 114 | } |
| 115 | } |
| 116 | return -1; |
| 117 | } |
| 118 | |