pkgsrc-WIP-changes archive

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

lldb-netbsd: Fix process resume action for NetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Fri Jan 20 22:06:17 2017 +0100
Changeset:	cef5e7e2c3ac153dacf068a27288662ec3e69432

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

Log Message:
lldb-netbsd: Fix process resume action for NetBSD

Old report:

The current status is that in Linux process=thread and each
thread needs to be spawned or suspended separately. The code for remote
debugging is designed after Linux model and for NetBSD, we need to mimic
that there is single thread for certain interfaces (I've discussed it
with LLDB developers) - matching our concept of Process. Linux has code
to step or resume a process in the NativeThreadLinux part, we need to
call it per-process basis.

The action of Signal Monitor was ignored, as a tracee was marked as
Stopped after attaching (Launching -> Stopped). In the code to resume
it, I was just calling PT_CONTINUE without altering the status of tracee
(to Running or Stepping) and using ResumeAction list (it contains signal
to be passed). I discussed the proper design for NetBSD and our code for
it should live in NativeProcessNetBSD (not in NativeThreadNetBSD).

New report:

$ lldb
(lldb) process connect connect://localhost:1234
Process 29742 stopped
* thread #1, stop reason = The signal Stopped (signal) was caught
    frame #0:
(lldb) c
Process 29742 resuming
Hello world!
Process 29742 stopped
* thread #1, stop reason = The signal was generated via _lwp_kill(2) from pid=29742, uid=1000
    frame #0:
(lldb) c
Process 29742 resuming
Process 29742 exited with status = 0 (0x00000000)
(lldb)

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

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

diffstat:
 lldb-netbsd/distinfo                               |  6 +--
 ..._Plugins_Process_NetBSD_NativeProcessNetBSD.cpp | 53 +++++++++++++++++++---
 ...e_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp | 22 ++++++++-
 ...rce_Plugins_Process_NetBSD_NativeThreadNetBSD.h |  8 +++-
 4 files changed, 76 insertions(+), 13 deletions(-)

diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index 0d7b254..9e4dcdc 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -28,10 +28,10 @@ SHA1 (patch-source_Plugins_Platform_NetBSD_PlatformNetBSD.cpp) = 129e853c1f93f06
 SHA1 (patch-source_Plugins_Platform_NetBSD_PlatformNetBSD.h) = 4327a21e79378b8f35adb07614adb41c37bbaf61
 SHA1 (patch-source_Plugins_Process_CMakeLists.txt) = c0168f81da56d9896eb414e6b8bb7262de04ac33
 SHA1 (patch-source_Plugins_Process_NetBSD_CMakeLists.txt) = df17afdf71c29d945c887e318718904793cd48ad
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 47cc1c157482c23f1ad985ee3df2ebd43193f412
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = b5160a1d531cf5aeadccb88f73a9365bdddefc2c
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h) = 3470c54fa069c9df8a70f08d49df319dece9e0c8
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = 672226249f8b6bea7a033bed062c637579dc1b7a
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = 4d00521042968217fe2c59b525d56477ea80e2ec
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp) = a9352bd87a799fdeab544f66533911425765b337
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h) = 2aab40efe7cb29133d08be927de1b58d7f3d3d48
 SHA1 (patch-tools_lldb-mi_MICmnBase.cpp) = 851c82ac61e1241018755fbd7236af00379ac986
 SHA1 (patch-tools_lldb-mi_MICmnBase.h) = f550d5e10bcf02fb46472733acdbb820791f22e5
 SHA1 (patch-tools_lldb-mi_MIDriver.cpp) = bf1b5399e82bcfe54d6d852f64ed155328f2064d
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 5079112..085596f 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp.orig	2017-01-19 22:12:22.349530366 +0000
+--- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp.orig	2017-01-20 20:30:48.330267591 +0000
 +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
-@@ -0,0 +1,1733 @@
+@@ -0,0 +1,1774 @@
 +//===-- NativeProcessNetBSD.cpp -------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -791,11 +791,52 @@ $NetBSD$
 +    log->Printf("NativeProcessNetBSD::%s called: pid %d", __FUNCTION__,
 +                GetID());
 +
-+  /* XXX: resume_actions unused */
-+  /* XXX: Pass signal to ptrace(2) */
++  const auto &thread_sp = m_threads[0];
++  const ResumeAction *const action = resume_actions.GetActionForThread(thread_sp->GetID(), true);
 +
-+  return NativeProcessNetBSD::PtraceWrapper(PT_CONTINUE, GetID(),(void *)1,
-+                                            0);
++  if (action == nullptr) {
++    if (log)
++      log->Printf("NativeProcessLinux::%s no action specified for pid %" PRIu64 " tid %" PRIu64,
++                  __FUNCTION__, GetID(), thread_sp->GetID());
++     return Error();
++  }
++
++  switch (action->state) {
++  case eStateRunning: {
++    // Run the thread, possibly feeding it the signal.
++    Error error = NativeProcessNetBSD::PtraceWrapper(PT_CONTINUE, GetID(),(void *)1, action->signal);
++    if (!error.Success())
++      return error;
++    for (const auto &thread_sp : m_threads) {
++      static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetRunning();
++    }
++    SetState(eStateRunning, true);
++    break;
++  }
++  case eStateStepping: {
++    // Run the thread, possibly feeding it the signal.
++    Error error = NativeProcessNetBSD::PtraceWrapper(PT_STEP, GetID(),(void *)1, action->signal);
++    if (!error.Success())
++      return error;
++    for (const auto &thread_sp : m_threads) {
++      static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStepping();
++    }
++    SetState(eStateStepping, true);
++    break;
++  }
++
++  case eStateSuspended:
++  case eStateStopped:
++    lldbassert(0 && "Unexpected state");
++ 
++  default:
++    return Error("NativeProcessLinux::%s (): unexpected state %s specified "
++                 "for pid %" PRIu64 ", tid %" PRIu64,
++                 __FUNCTION__, StateAsCString(action->state), GetID(),
++                 thread_sp->GetID());
++  }
++
++  return Error();
 +}
 +
 +Error NativeProcessNetBSD::Halt() {
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
index 06f0ac8..8492c25 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.cpp
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp.orig	2017-01-19 22:12:22.362789785 +0000
+--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp.orig	2017-01-20 20:30:48.343442890 +0000
 +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
-@@ -0,0 +1,355 @@
+@@ -0,0 +1,373 @@
 +//===-- NativeThreadNetBSD.cpp --------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -352,6 +352,24 @@ $NetBSD$
 +  m_stop_info.details.signal.signo = SIGTRAP;
 +}
 +
++void NativeThreadNetBSD::SetRunning() {
++  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
++  if (log)
++    log->Printf("NativeThreadNetBSD::%s()", __FUNCTION__);
++
++  m_state = StateType::eStateRunning;
++  m_stop_info.reason = StopReason::eStopReasonNone;
++}
++
++void NativeThreadNetBSD::SetStepping() {
++  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
++  if (log)
++    log->Printf("NativeThreadNetBSD::%s()", __FUNCTION__);
++
++  m_state = StateType::eStateStepping;
++  m_stop_info.reason = StopReason::eStopReasonNone;
++}
++
 +NativeProcessNetBSD &NativeThreadNetBSD::GetProcess() {
 +  auto process_sp = std::static_pointer_cast<NativeProcessNetBSD>(
 +      NativeThreadProtocol::GetProcess());
diff --git a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
index 2b14676..cddb40f 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeThreadNetBSD.h
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h.orig	2017-01-19 22:12:22.368977024 +0000
+--- source/Plugins/Process/NetBSD/NativeThreadNetBSD.h.orig	2017-01-20 20:30:48.349697339 +0000
 +++ source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
-@@ -0,0 +1,83 @@
+@@ -0,0 +1,87 @@
 +//===-- NativeThreadNetBSD.h ----------------------------------- -*- C++ -*-===//
 +//
 +//                     The LLVM Compiler Infrastructure
@@ -65,6 +65,10 @@ $NetBSD$
 +
 +  void SetStoppedByExec();
 +
++  void SetRunning();
++
++  void SetStepping();
++
 +  // ---------------------------------------------------------------------
 +  // Private interface
 +  // ---------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index