pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lldb-netbsd: Adapt PtraceDisplayBytes() and PtraceWrapper() for NetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sat Dec 17 16:54:10 2016 +0100
Changeset:	a09654ee29f0cfe5d743fcddc6020e819b7c5e4e

Modified Files:
	lldb-netbsd/distinfo
	lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp

Log Message:
lldb-netbsd: Adapt PtraceDisplayBytes() and PtraceWrapper() for NetBSD

ptrace(2) prototype differs on Linux and NetBSD.
Linux:
    long ptrace(enum __ptrace_request request, pid_t pid, void *addr, void *data);
NetBSD:
    int ptrace(int request, pid_t pid, void *addr, int data)

All the other fields differ as well. Adapt code accordingly to the differences.

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=a09654ee29f0cfe5d743fcddc6020e819b7c5e4e

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 lldb-netbsd/distinfo                               |  2 +-
 ..._Plugins_Process_NetBSD_NativeProcessNetBSD.cpp | 74 ++++++++++------------
 2 files changed, 35 insertions(+), 41 deletions(-)

diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index 0672997..5b22684 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -18,7 +18,7 @@ SHA1 (patch-include_lldb_Host_netbsd_Ptrace.h) = 3ef61ded004c2acb81e132dc0e46d0a
 SHA1 (patch-source_CMakeLists.txt) = 5dacabc3f39c23bdfd432b5a4895866157b97aa0
 SHA1 (patch-source_Plugins_Process_CMakeLists.txt) = c0168f81da56d9896eb414e6b8bb7262de04ac33
 SHA1 (patch-source_Plugins_Process_NetBSD_CMakeLists.txt) = 8c1d8274523f6ef4bce90caa6c981160ef930cb9
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 60538c27004c97dfb76a3952df7ee95712ec8e22
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 071f81ea0d1b1a07f7aba75867c4a27f43d2a357
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h) = 3177f7a17f3ab1fa8c155f2bcab6cbf2033644e9
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeRegisterContextNetBSD.cpp) = cf569f95362538af5a2709aab9ff61770744a78d
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeRegisterContextNetBSD.h) = 558e8514b2a8f0595c0e375f308c53d8a9a6e9f1
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
index e15fe2b..a0dd50c 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
@@ -2,7 +2,7 @@ $NetBSD$
 
 --- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp.orig	2016-12-17 13:23:23.782610208 +0000
 +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
-@@ -0,0 +1,2753 @@
+@@ -0,0 +1,2747 @@
 +//===-- NativeProcessNetBSD.cpp -------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -149,49 +149,51 @@ $NetBSD$
 +  }
 +}
 +
-+void PtraceDisplayBytes(int &req, void *data, size_t data_size) {
++void PtraceDisplayBytes(int &req, void *addr, int data) {
 +  StreamString buf;
 +  Log *verbose_log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(
 +      POSIX_LOG_PTRACE | POSIX_LOG_VERBOSE));
 +
 +  if (verbose_log) {
 +    switch (req) {
-+    case PTRACE_POKETEXT: {
-+      DisplayBytes(buf, &data, 8);
-+      verbose_log->Printf("PTRACE_POKETEXT %s", buf.GetData());
++    case PT_WRITE_I: {
++      DisplayBytes(buf, &data, sizeof(int));
++      verbose_log->Printf("PT_WRITE_I %s", buf.GetData());
 +      break;
 +    }
-+    case PTRACE_POKEDATA: {
-+      DisplayBytes(buf, &data, 8);
-+      verbose_log->Printf("PTRACE_POKEDATA %s", buf.GetData());
++    case PT_WRITE_D: {
++      DisplayBytes(buf, &data, sizeof(int));
++      verbose_log->Printf("PT_WRITE_I %s", buf.GetData());
 +      break;
 +    }
-+    case PTRACE_POKEUSER: {
-+      DisplayBytes(buf, &data, 8);
-+      verbose_log->Printf("PTRACE_POKEUSER %s", buf.GetData());
++#ifdef PT_SETREGS
++    case PT_SETREGS: {
++      DisplayBytes(buf, addr, sizeof(struct reg));
++      verbose_log->Printf("PT_SETREGS %s", buf.GetData());
 +      break;
 +    }
-+    case PTRACE_SETREGS: {
-+      DisplayBytes(buf, data, data_size);
-+      verbose_log->Printf("PTRACE_SETREGS %s", buf.GetData());
-+      break;
-+    }
-+    case PTRACE_SETFPREGS: {
-+      DisplayBytes(buf, data, data_size);
-+      verbose_log->Printf("PTRACE_SETFPREGS %s", buf.GetData());
++#endif
++#ifdef PT_SETFPREGS
++    case PT_SETFPREGS: {
++      DisplayBytes(buf, addr, sizeof(struct fpreg));
++      verbose_log->Printf("PT_SETFPREGS %s", buf.GetData());
 +      break;
 +    }
-+    case PTRACE_SETSIGINFO: {
-+      DisplayBytes(buf, data, sizeof(siginfo_t));
-+      verbose_log->Printf("PTRACE_SETSIGINFO %s", buf.GetData());
++#endif
++#ifdef PT_SETXMMREGS
++    case PT_SETXMMREGS: {
++      DisplayBytes(buf, addr, sizeof(struct xmmregs));
++      verbose_log->Printf("PT_SETXMMREGS %s", buf.GetData());
 +      break;
 +    }
-+    case PTRACE_SETREGSET: {
-+      // Extract iov_base from data, which is a pointer to the struct IOVEC
-+      DisplayBytes(buf, *(void **)data, data_size);
-+      verbose_log->Printf("PTRACE_SETREGSET %s", buf.GetData());
++#endif
++#ifdef PT_SETVECREGS
++    case PT_SETVECREGS: {
++      DisplayBytes(buf, addr, sizeof(struct vreg));
++      verbose_log->Printf("PT_SETVECREGS %s", buf.GetData());
 +      break;
 +    }
++#endif
 +    default: {}
 +    }
 +  }
@@ -2702,24 +2704,18 @@ $NetBSD$
 +
 +// Wrapper for ptrace to catch errors and log calls.
 +// Note that ptrace sets errno on error because -1 can be a valid result (i.e.
-+// for PTRACE_PEEK*)
++// for PT_READ*)
 +Error NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
-+                                        void *data, size_t data_size,
-+                                        long *result) {
++                                        int data, long *result) {
 +  Error error;
 +  long int ret;
 +
 +  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
 +
-+  PtraceDisplayBytes(req, data, data_size);
++  PtraceDisplayBytes(req, addr, data);
 +
 +  errno = 0;
-+  if (req == PTRACE_GETREGSET || req == PTRACE_SETREGSET)
-+    ret = ptrace(static_cast<__ptrace_request>(req), static_cast<::pid_t>(pid),
-+                 *(unsigned int *)addr, data);
-+  else
-+    ret = ptrace(static_cast<__ptrace_request>(req), static_cast<::pid_t>(pid),
-+                 addr, data);
++  ret = ptrace(req, static_cast<::pid_t>(pid), addr, data);
 +
 +  if (ret == -1)
 +    error.SetErrorToErrno();
@@ -2728,10 +2724,8 @@ $NetBSD$
 +    *result = ret;
 +
 +  if (log)
-+    log->Printf("ptrace(%d, %" PRIu64 ", %p, %p, %zu)=%lX", req, pid, addr,
-+                data, data_size, ret);
-+
-+  PtraceDisplayBytes(req, data, data_size);
++    log->Printf("ptrace(%d, %d, %p, %d, %zu)=%lX", req, pid, addr,
++                data, ret);
 +
 +  if (log && error.GetError() != 0) {
 +    const char *str;


Home | Main Index | Thread Index | Old Index