1 //===-- RegisterContextKDP_i386.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_i386.h" 11 #include "ProcessKDP.h" 12 #include "ThreadKDP.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 17 RegisterContextKDP_i386::RegisterContextKDP_i386(ThreadKDP &thread, 18 uint32_t concrete_frame_idx) 19 : RegisterContextDarwin_i386(thread, concrete_frame_idx), 20 m_kdp_thread(thread) {} 21 22 RegisterContextKDP_i386::~RegisterContextKDP_i386() {} 23 24 int RegisterContextKDP_i386::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(tid, GPRRegSet, &gpr, sizeof(gpr), 31 error)) { 32 if (error.Success()) 33 return 0; 34 } 35 } 36 return -1; 37 } 38 39 int RegisterContextKDP_i386::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(tid, FPURegSet, &fpu, sizeof(fpu), 46 error)) { 47 if (error.Success()) 48 return 0; 49 } 50 } 51 return -1; 52 } 53 54 int RegisterContextKDP_i386::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(tid, EXCRegSet, &exc, sizeof(exc), 61 error)) { 62 if (error.Success()) 63 return 0; 64 } 65 } 66 return -1; 67 } 68 69 int RegisterContextKDP_i386::DoWriteGPR(lldb::tid_t tid, int flavor, 70 const GPR &gpr) { 71 ProcessSP process_sp(CalculateProcess()); 72 if (process_sp) { 73 Status error; 74 if (static_cast<ProcessKDP *>(process_sp.get()) 75 ->GetCommunication() 76 .SendRequestWriteRegisters(tid, GPRRegSet, &gpr, sizeof(gpr), 77 error)) { 78 if (error.Success()) 79 return 0; 80 } 81 } 82 return -1; 83 } 84 85 int RegisterContextKDP_i386::DoWriteFPU(lldb::tid_t tid, int flavor, 86 const FPU &fpu) { 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, FPURegSet, &fpu, sizeof(fpu), 93 error)) { 94 if (error.Success()) 95 return 0; 96 } 97 } 98 return -1; 99 } 100 101 int RegisterContextKDP_i386::DoWriteEXC(lldb::tid_t tid, int flavor, 102 const EXC &exc) { 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, EXCRegSet, &exc, sizeof(exc), 109 error)) { 110 if (error.Success()) 111 return 0; 112 } 113 } 114 return -1; 115 } 116