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