1 //===-- NativeRegisterContextNetBSD.cpp -------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "NativeRegisterContextNetBSD.h"
12 #include "lldb/Host/common/NativeProcessProtocol.h"
14 using namespace lldb_private;
15 using namespace lldb_private::process_netbsd;
18 #include <sys/types.h>
19 #include <sys/ptrace.h>
22 NativeRegisterContextNetBSD::NativeRegisterContextNetBSD(
23 NativeThreadProtocol &native_thread,
24 RegisterInfoInterface *reg_info_interface_p)
25 : NativeRegisterContextRegisterInfo(native_thread,
26 reg_info_interface_p) {}
28 Status NativeRegisterContextNetBSD::ReadGPR() {
29 void *buf = GetGPRBuffer();
31 return Status("GPR buffer is NULL");
33 return DoReadGPR(buf);
36 Status NativeRegisterContextNetBSD::WriteGPR() {
37 void *buf = GetGPRBuffer();
39 return Status("GPR buffer is NULL");
41 return DoWriteGPR(buf);
44 Status NativeRegisterContextNetBSD::ReadFPR() {
45 void *buf = GetFPRBuffer();
47 return Status("FPR buffer is NULL");
49 return DoReadFPR(buf);
52 Status NativeRegisterContextNetBSD::WriteFPR() {
53 void *buf = GetFPRBuffer();
55 return Status("FPR buffer is NULL");
57 return DoWriteFPR(buf);
60 Status NativeRegisterContextNetBSD::ReadDBR() {
61 void *buf = GetDBRBuffer();
63 return Status("DBR buffer is NULL");
65 return DoReadDBR(buf);
68 Status NativeRegisterContextNetBSD::WriteDBR() {
69 void *buf = GetDBRBuffer();
71 return Status("DBR buffer is NULL");
73 return DoWriteDBR(buf);
76 Status NativeRegisterContextNetBSD::DoReadGPR(void *buf) {
77 return NativeProcessNetBSD::PtraceWrapper(PT_GETREGS, GetProcessPid(), buf,
81 Status NativeRegisterContextNetBSD::DoWriteGPR(void *buf) {
82 return NativeProcessNetBSD::PtraceWrapper(PT_SETREGS, GetProcessPid(), buf,
86 Status NativeRegisterContextNetBSD::DoReadFPR(void *buf) {
87 return NativeProcessNetBSD::PtraceWrapper(PT_GETFPREGS, GetProcessPid(), buf,
91 Status NativeRegisterContextNetBSD::DoWriteFPR(void *buf) {
92 return NativeProcessNetBSD::PtraceWrapper(PT_SETFPREGS, GetProcessPid(), buf,
96 Status NativeRegisterContextNetBSD::DoReadDBR(void *buf) {
97 return NativeProcessNetBSD::PtraceWrapper(PT_GETDBREGS, GetProcessPid(), buf,
101 Status NativeRegisterContextNetBSD::DoWriteDBR(void *buf) {
102 return NativeProcessNetBSD::PtraceWrapper(PT_SETDBREGS, GetProcessPid(), buf,
106 NativeProcessNetBSD &NativeRegisterContextNetBSD::GetProcess() {
107 return static_cast<NativeProcessNetBSD &>(m_thread.GetProcess());
110 ::pid_t NativeRegisterContextNetBSD::GetProcessPid() {
111 return GetProcess().GetID();