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