pkgsrc-WIP-changes archive

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

lldb-netbsd: Kill PT_STEP walkardound and __WALL->WALLSIG, kill __WNOTHREAD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sat Dec 17 23:50:22 2016 +0100
Changeset:	0d0128c4e58c1e00e187a10f9c9af50f7b42133e

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

Log Message:
lldb-netbsd: Kill PT_STEP walkardound and __WALL->WALLSIG, kill __WNOTHREAD

PT_STEP walkaround is for arm64 on Linux.

NetBSD symbol WALLSIG is equivalent to __WALL on Linux.
Kill __WNOTHREAD as it has no alternative and apparently is not needed.

/* Don't wait on children of other threads in this group */

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=0d0128c4e58c1e00e187a10f9c9af50f7b42133e

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

diffstat:
 lldb-netbsd/distinfo                               |   4 +-
 ..._Plugins_Process_NetBSD_NativeProcessNetBSD.cpp |  16 +--
 ...urce_Plugins_Process_NetBSD_SingleStepCheck.cpp | 141 +--------------------
 3 files changed, 11 insertions(+), 150 deletions(-)

diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index 9465c0a..27913f3 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) = 44f4eafd7a2d7a6c96343e36b1f4733147c237b9
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = d0cc6c3a5761e983cc3747dd05222fb473a75445
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h) = 11641e9c3a5fdf4d9feb098c9c0bb2d9e05aa274
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeRegisterContextNetBSD.cpp) = cf569f95362538af5a2709aab9ff61770744a78d
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeRegisterContextNetBSD.h) = 558e8514b2a8f0595c0e375f308c53d8a9a6e9f1
@@ -29,7 +29,7 @@ SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = 9ed9cd17600e66
 SHA1 (patch-source_Plugins_Process_NetBSD_ProcFileReader.cpp) = dff1193e16aa79d8a577a3db4a9056521911d6f1
 SHA1 (patch-source_Plugins_Process_NetBSD_ProcFileReader.h) = c8393049c7303b466d3ce98ec5581a3155b71aff
 SHA1 (patch-source_Plugins_Process_NetBSD_Procfs.h) = 5994fa837260136b78cd0b4988dafc6f96ca1e3d
-SHA1 (patch-source_Plugins_Process_NetBSD_SingleStepCheck.cpp) = a3b64eca776c32e84dd8f4ee131b28551acab7a8
+SHA1 (patch-source_Plugins_Process_NetBSD_SingleStepCheck.cpp) = 3144f1ad3c33c43c6aa429f2490fdc0cebec1958
 SHA1 (patch-source_Plugins_Process_NetBSD_SingleStepCheck.h) = bc4196768184baca74068a48bb47413c7254d1ce
 SHA1 (patch-tools_lldb-mi_MICmnBase.cpp) = 851c82ac61e1241018755fbd7236af00379ac986
 SHA1 (patch-tools_lldb-mi_MICmnBase.h) = f550d5e10bcf02fb46472733acdbb820791f22e5
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 cdd0894..c926ec4 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
@@ -422,9 +422,9 @@ $NetBSD$
 +        }
 +
 +        int status;
-+        // Need to use __WALL otherwise we receive an error with errno=ECHLD
++        // Need to use WALLSIG otherwise we receive an error with errno=ECHLD
 +        // At this point we should have a thread stopped if waitpid succeeds.
-+        if ((status = waitpid(tid, NULL, __WALL)) < 0) {
++        if ((status = waitpid(tid, NULL, WALLSIG)) < 0) {
 +          // No such thread. The thread may have exited.
 +          // More error handling may be needed.
 +          if (errno == ESRCH) {
@@ -698,7 +698,7 @@ $NetBSD$
 +                  "tid %" PRIu32
 +                  ". tid not tracked yet, waiting for thread to appear...",
 +                  __FUNCTION__, tid);
-+    wait_pid = waitpid(tid, &status, __WALL);
++    wait_pid = waitpid(tid, &status, WALLSIG);
 +  } while (wait_pid == -1 && errno == EINTR);
 +  // Since we are waiting on a specific tid, this must be the creation event.
 +  // But let's do
@@ -2535,7 +2535,7 @@ $NetBSD$
 +  // Process all pending waitpid notifications.
 +  while (true) {
 +    int status = -1;
-+    ::pid_t wait_pid = waitpid(-1, &status, __WALL | __WNOTHREAD | WNOHANG);
++    ::pid_t wait_pid = waitpid(-1, &status, WALLSIG | WNOHANG);
 +
 +    if (wait_pid == 0)
 +      break; // We are done.
@@ -2546,8 +2546,8 @@ $NetBSD$
 +
 +      Error error(errno, eErrorTypePOSIX);
 +      if (log)
-+        log->Printf("NativeProcessNetBSD::%s waitpid (-1, &status, __WALL | "
-+                    "__WNOTHREAD | WNOHANG) failed: %s",
++        log->Printf("NativeProcessNetBSD::%s waitpid (-1, &status, WALLSIG | "
++                    "WNOHANG) failed: %s",
 +                    __FUNCTION__, error.AsCString());
 +      break;
 +    }
@@ -2574,8 +2574,8 @@ $NetBSD$
 +      status_cstr = "(\?\?\?)";
 +
 +    if (log)
-+      log->Printf("NativeProcessNetBSD::%s: waitpid (-1, &status, __WALL | "
-+                  "__WNOTHREAD | WNOHANG)"
++      log->Printf("NativeProcessNetBSD::%s: waitpid (-1, &status, WALLSIG | "
++                  "WNOHANG)"
 +                  "=> pid = %" PRIi32
 +                  ", status = 0x%8.8x (%s), signal = %i, exit_state = %i",
 +                  __FUNCTION__, wait_pid, status, status_cstr, signal,
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_SingleStepCheck.cpp b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_SingleStepCheck.cpp
index 5b21ff8..bea9134 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_SingleStepCheck.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_SingleStepCheck.cpp
@@ -2,7 +2,7 @@ $NetBSD$
 
 --- source/Plugins/Process/NetBSD/SingleStepCheck.cpp.orig	2016-12-17 13:23:23.785537353 +0000
 +++ source/Plugins/Process/NetBSD/SingleStepCheck.cpp
-@@ -0,0 +1,166 @@
+@@ -0,0 +1,27 @@
 +//===-- SingleStepCheck.cpp ----------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -29,143 +29,4 @@ $NetBSD$
 +
 +using namespace lldb_private::process_netbsd;
 +
-+#if defined(__arm64__) || defined(__aarch64__)
-+namespace {
-+
-+void LLVM_ATTRIBUTE_NORETURN Child() {
-+  if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
-+    _exit(1);
-+
-+  // We just do an endless loop SIGSTOPPING ourselves until killed. The tracer
-+  // will fiddle with our cpu
-+  // affinities and monitor the behaviour.
-+  for (;;) {
-+    raise(SIGSTOP);
-+
-+    // Generate a bunch of instructions here, so that a single-step does not
-+    // land in the
-+    // raise() accidentally. If single-stepping works, we will be spinning in
-+    // this loop. If
-+    // it doesn't, we'll land in the raise() call above.
-+    for (volatile unsigned i = 0; i < CPU_SETSIZE; ++i)
-+      ;
-+  }
-+}
-+
-+struct ChildDeleter {
-+  ::pid_t pid;
-+
-+  ~ChildDeleter() {
-+    int status;
-+    kill(pid, SIGKILL);            // Kill the child.
-+    waitpid(pid, &status, __WALL); // Pick up the remains.
-+  }
-+};
-+
-+} // end anonymous namespace
-+
-+bool impl::SingleStepWorkaroundNeeded() {
-+  // We shall spawn a child, and use it to verify the debug capabilities of the
-+  // cpu. We shall
-+  // iterate through the cpus, bind the child to each one in turn, and verify
-+  // that
-+  // single-stepping works on that cpu. A workaround is needed if we find at
-+  // least one broken
-+  // cpu.
-+
-+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-+  Error error;
-+  ::pid_t child_pid = fork();
-+  if (child_pid == -1) {
-+    if (log) {
-+      error.SetErrorToErrno();
-+      log->Printf("%s failed to fork(): %s", __FUNCTION__, error.AsCString());
-+    }
-+    return false;
-+  }
-+  if (child_pid == 0)
-+    Child();
-+
-+  ChildDeleter child_deleter{child_pid};
-+  cpu_set_t available_cpus;
-+  if (sched_getaffinity(child_pid, sizeof available_cpus, &available_cpus) ==
-+      -1) {
-+    if (log) {
-+      error.SetErrorToErrno();
-+      log->Printf("%s failed to get available cpus: %s", __FUNCTION__,
-+                  error.AsCString());
-+    }
-+    return false;
-+  }
-+
-+  int status;
-+  ::pid_t wpid = waitpid(child_pid, &status, __WALL);
-+  if (wpid != child_pid || !WIFSTOPPED(status)) {
-+    if (log) {
-+      error.SetErrorToErrno();
-+      log->Printf("%s waitpid() failed (status = %x): %s", __FUNCTION__, status,
-+                  error.AsCString());
-+    }
-+    return false;
-+  }
-+
-+  unsigned cpu;
-+  for (cpu = 0; cpu < CPU_SETSIZE; ++cpu) {
-+    if (!CPU_ISSET(cpu, &available_cpus))
-+      continue;
-+
-+    cpu_set_t cpus;
-+    CPU_ZERO(&cpus);
-+    CPU_SET(cpu, &cpus);
-+    if (sched_setaffinity(child_pid, sizeof cpus, &cpus) == -1) {
-+      if (log) {
-+        error.SetErrorToErrno();
-+        log->Printf("%s failed to switch to cpu %u: %s", __FUNCTION__, cpu,
-+                    error.AsCString());
-+      }
-+      continue;
-+    }
-+
-+    int status;
-+    error = NativeProcessNetBSD::PtraceWrapper(PTRACE_SINGLESTEP, child_pid);
-+    if (error.Fail()) {
-+      if (log)
-+        log->Printf("%s single step failed: %s", __FUNCTION__,
-+                    error.AsCString());
-+      break;
-+    }
-+
-+    wpid = waitpid(child_pid, &status, __WALL);
-+    if (wpid != child_pid || !WIFSTOPPED(status)) {
-+      if (log) {
-+        error.SetErrorToErrno();
-+        log->Printf("%s waitpid() failed (status = %x): %s", __FUNCTION__,
-+                    status, error.AsCString());
-+      }
-+      break;
-+    }
-+    if (WSTOPSIG(status) != SIGTRAP) {
-+      if (log)
-+        log->Printf("%s single stepping on cpu %d failed with status %x",
-+                    __FUNCTION__, cpu, status);
-+      break;
-+    }
-+  }
-+
-+  // cpu is either the index of the first broken cpu, or CPU_SETSIZE.
-+  if (cpu == 0) {
-+    if (log)
-+      log->Printf("%s SINGLE STEPPING ON FIRST CPU IS NOT WORKING. DEBUGGING "
-+                  "LIKELY TO BE UNRELIABLE.",
-+                  __FUNCTION__);
-+    // No point in trying to fiddle with the affinities, just give it our best
-+    // shot and see how it goes.
-+    return false;
-+  }
-+
-+  return cpu != CPU_SETSIZE;
-+}
-+
-+#else // !arm64
 +bool impl::SingleStepWorkaroundNeeded() { return false; }
-+#endif


Home | Main Index | Thread Index | Old Index