1 //===-- NativeRegisterContextNetBSD.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 "NativeRegisterContextNetBSD.h" 11 12 #include "lldb/Host/common/NativeProcessProtocol.h" 13 14 using namespace lldb_private; 15 using namespace lldb_private::process_netbsd; 16 17 // clang-format off 18 #include <sys/types.h> 19 #include <sys/ptrace.h> 20 // clang-format on 21 22 NativeRegisterContextNetBSD::NativeRegisterContextNetBSD( 23 NativeThreadProtocol &native_thread, uint32_t concrete_frame_idx, 24 RegisterInfoInterface *reg_info_interface_p) 25 : NativeRegisterContextRegisterInfo(native_thread, concrete_frame_idx, 26 reg_info_interface_p) {} 27 28 Status NativeRegisterContextNetBSD::ReadGPR() { 29 void *buf = GetGPRBuffer(); 30 if (!buf) 31 return Status("GPR buffer is NULL"); 32 33 return DoReadGPR(buf); 34 } 35 36 Status NativeRegisterContextNetBSD::WriteGPR() { 37 void *buf = GetGPRBuffer(); 38 if (!buf) 39 return Status("GPR buffer is NULL"); 40 41 return DoWriteGPR(buf); 42 } 43 44 Status NativeRegisterContextNetBSD::ReadFPR() { 45 void *buf = GetFPRBuffer(); 46 if (!buf) 47 return Status("FPR buffer is NULL"); 48 49 return DoReadFPR(buf); 50 } 51 52 Status NativeRegisterContextNetBSD::WriteFPR() { 53 void *buf = GetFPRBuffer(); 54 if (!buf) 55 return Status("FPR buffer is NULL"); 56 57 return DoWriteFPR(buf); 58 } 59 60 Status NativeRegisterContextNetBSD::ReadDBR() { 61 void *buf = GetDBRBuffer(); 62 if (!buf) 63 return Status("DBR buffer is NULL"); 64 65 return DoReadDBR(buf); 66 } 67 68 Status NativeRegisterContextNetBSD::WriteDBR() { 69 void *buf = GetDBRBuffer(); 70 if (!buf) 71 return Status("DBR buffer is NULL"); 72 73 return DoWriteDBR(buf); 74 } 75 76 Status NativeRegisterContextNetBSD::DoReadGPR(void *buf) { 77 return NativeProcessNetBSD::PtraceWrapper(PT_GETREGS, GetProcessPid(), buf, 78 m_thread.GetID()); 79 } 80 81 Status NativeRegisterContextNetBSD::DoWriteGPR(void *buf) { 82 return NativeProcessNetBSD::PtraceWrapper(PT_SETREGS, GetProcessPid(), buf, 83 m_thread.GetID()); 84 } 85 86 Status NativeRegisterContextNetBSD::DoReadFPR(void *buf) { 87 return NativeProcessNetBSD::PtraceWrapper(PT_GETFPREGS, GetProcessPid(), buf, 88 m_thread.GetID()); 89 } 90 91 Status NativeRegisterContextNetBSD::DoWriteFPR(void *buf) { 92 return NativeProcessNetBSD::PtraceWrapper(PT_SETFPREGS, GetProcessPid(), buf, 93 m_thread.GetID()); 94 } 95 96 Status NativeRegisterContextNetBSD::DoReadDBR(void *buf) { 97 return NativeProcessNetBSD::PtraceWrapper(PT_GETDBREGS, GetProcessPid(), buf, 98 m_thread.GetID()); 99 } 100 101 Status NativeRegisterContextNetBSD::DoWriteDBR(void *buf) { 102 return NativeProcessNetBSD::PtraceWrapper(PT_SETDBREGS, GetProcessPid(), buf, 103 m_thread.GetID()); 104 } 105 106 NativeProcessNetBSD &NativeRegisterContextNetBSD::GetProcess() { 107 return static_cast<NativeProcessNetBSD &>(m_thread.GetProcess()); 108 } 109 110 ::pid_t NativeRegisterContextNetBSD::GetProcessPid() { 111 return GetProcess().GetID(); 112 } 113