pkgsrc-WIP-changes archive

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

lldb-netbsd: Preliminary adaption of attach function for NetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Dec 18 01:12:07 2016 +0100
Changeset:	bfc6da3cb81ea68dc04bda67997643a31186cbe0

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

Log Message:
lldb-netbsd: Preliminary adaption of attach function for NetBSD

Linux code has logic to attach to every thread, this is not needed on NetBSD.

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=bfc6da3cb81ea68dc04bda67997643a31186cbe0

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 | 78 ++++------------------
 2 files changed, 15 insertions(+), 65 deletions(-)

diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index a946e44..6aa1acc 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) = 6daf733dbf5715c9909daac3dfe499e8e4e13ce3
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 1ef6b008f9db4dbc8791d17390fe470661acd1fc
 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
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 866c7fa..58335e6 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,2013 @@
+@@ -0,0 +1,1963 @@
 +//===-- NativeProcessNetBSD.cpp -------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -397,71 +397,21 @@ $NetBSD$
 +    return -1;
 +  }
 +
-+  while (Host::FindProcessThreads(pid, tids_to_attach)) {
-+    for (Host::TidMap::iterator it = tids_to_attach.begin();
-+         it != tids_to_attach.end();) {
-+      if (it->second == false) {
-+        lldb::tid_t tid = it->first;
-+
-+        // Attach to the requested process.
-+        // An attach will cause the thread to stop with a SIGSTOP.
-+        error = PtraceWrapper(PTRACE_ATTACH, tid);
-+        if (error.Fail()) {
-+          // No such thread. The thread may have exited.
-+          // More error handling may be needed.
-+          if (error.GetError() == ESRCH) {
-+            it = tids_to_attach.erase(it);
-+            continue;
-+          } else
-+            return -1;
-+        }
-+
-+        int status;
-+        // 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, WALLSIG)) < 0) {
-+          // No such thread. The thread may have exited.
-+          // More error handling may be needed.
-+          if (errno == ESRCH) {
-+            it = tids_to_attach.erase(it);
-+            continue;
-+          } else {
-+            error.SetErrorToErrno();
-+            return -1;
-+          }
-+        }
-+
-+        if (log)
-+          log->Printf("NativeProcessNetBSD::%s() adding tid = %" PRIu64,
-+                      __FUNCTION__, tid);
-+
-+        it->second = true;
-+
-+        // Create the thread, mark it as stopped.
-+        NativeThreadNetBSDSP thread_sp(AddThread(static_cast<lldb::tid_t>(tid)));
-+        assert(thread_sp && "AddThread() returned a nullptr");
-+
-+        // This will notify this is a new thread and tell the system it is
-+        // stopped.
-+        thread_sp->SetStoppedBySignal(SIGSTOP);
-+        ThreadWasCreated(*thread_sp);
-+        SetCurrentThreadID(thread_sp->GetID());
-+      }
-+
-+      // move the loop forward
-+      ++it;
-+    }
-+  }
++  // Attach to the requested process.
++  // An attach will cause the thread to stop with a SIGSTOP.
++  error = PtraceWrapper(PT_ATTACH, pid);
++  if (error.Fail())
++    return -1;
 +
-+  if (tids_to_attach.size() > 0) {
-+    m_pid = pid;
-+    // Let our process instance know the thread has stopped.
-+    SetState(StateType::eStateStopped);
-+  } else {
-+    error.SetErrorToGenericError();
-+    error.SetErrorString("No such process.");
++  int status;
++  // 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, WALLSIG)) < 0)
 +    return -1;
-+  }
++
++  m_pid = pid;
++  // Let our process instance know the thread has stopped.
++  SetState(StateType::eStateStopped);
 +
 +  return pid;
 +}


Home | Main Index | Thread Index | Old Index