pkgsrc-WIP-changes archive

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

lldb-netbsd: Initial support for LWPs in ::Resume()



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Wed Apr 26 02:05:58 2017 +0200
Changeset:	cf22065aaf016bf4c461ad337c4fb4fdf2d9e0ca

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

Log Message:
lldb-netbsd: Initial support for LWPs in ::Resume()

This is work in progress.

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

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 | 130 +++++++++++++++++++--
 2 files changed, 122 insertions(+), 10 deletions(-)

diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index 467e43a841..76a1acaa15 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -13,7 +13,7 @@ SHA1 (llvm-3.6.2.src.tar.xz) = 7a00257eb2bc9431e4c77c3a36b033072c54bc7e
 RMD160 (llvm-3.6.2.src.tar.xz) = 521cbc5fe2925ea3c6e90c7a31f752a04045c972
 Size (llvm-3.6.2.src.tar.xz) = 12802380 bytes
 SHA1 (patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp) = 76d47d654951d36dc493611dfa636c1dcff0c3af
-SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 288f34fab5a692710941046358b84e5e98ca59da
+SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 366114a3b5edf766668ae2d309bf77757329ae50
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.h) = 0dbad0c386c14eec866f469deb9b49e689391891
 SHA1 (patch-source_Plugins_Process_elf-core_ProcessElfCore.cpp) = 16d6404b9565bee3a8dd67e9743eeb36bf20d613
 SHA1 (patch-source_Plugins_Process_elf-core_ProcessElfCore.h) = 902ce5e0187aa2649986db08c79af7291b852727
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 128a2553dc..4f8d7d79b9 100644
--- a/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
+++ b/lldb-netbsd/patches/patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp
@@ -90,7 +90,7 @@ $NetBSD$
 +      default:
 +        llvm_unreachable("Unexpected state");
 +      }
-+      } break;
++    } break;
 +    case PTRACE_LWP_EXIT:
 +      error = RemoveThread(state.pe_lwp);
 +      if (error.Fail()) {
@@ -214,7 +214,119 @@ $NetBSD$
    SetState(StateType::eStateStopped, true);
  }
  
-@@ -812,6 +908,18 @@ Error NativeProcessNetBSD::LaunchInferio
+@@ -444,55 +540,71 @@ Error NativeProcessNetBSD::Resume(const 
+   Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+   LLDB_LOG(log, "pid {0}", GetID());
+ 
+-  const auto &thread_sp = m_threads[0];
+-  const ResumeAction *const action =
+-      resume_actions.GetActionForThread(thread_sp->GetID(), true);
+-
+-  if (action == nullptr) {
+-    LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(),
+-             thread_sp->GetID());
+-    return Error();
+-  }
++  int sig = 0;
++  bool step = false;
+ 
+-  Error error;
++  for (auto thread_sp : m_threads) {
++    assert(thread_sp && "thread list should not contain NULL threads");
+ 
+-  switch (action->state) {
+-  case eStateRunning: {
+-    // Run the thread, possibly feeding it the signal.
+-    error = NativeProcessNetBSD::PtraceWrapper(PT_CONTINUE, GetID(), (void *)1,
+-                                               action->signal);
+-    if (!error.Success())
+-      return error;
+-    for (const auto &thread_sp : m_threads) {
++    const ResumeAction *const action =
++        resume_actions.GetActionForThread(thread_sp->GetID(), true);
++
++    if (action == nullptr) {
++      LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(),
++               thread_sp->GetID());
++      continue;
++    }
++
++    LLDB_LOG(log, "processing resume action state {0} for pid {1} tid {2}",
++             action->state, GetID(), thread_sp->GetID());
++
++    sig = action->signal; // No support for several signals per LWP
++
++    switch (action->state) {
++    case eStateRunning: {
++      // Run the thread, possibly feeding it the signal.
++      Error error = NativeProcessNetBSD::PtraceWrapper(PT_CLEARSTEP, GetID(), 0,
++                                                       action->tid);
++      if (!error.Success())
++        return error;
+       static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetRunning();
++    } break;
++    case eStateStepping: {
++      // Run the thread, possibly feeding it the signal.
++      Error error = NativeProcessNetBSD::PtraceWrapper(PT_SETSTEP, GetID(), 0,
++                                                       action->tid);
++      if (!error.Success())
++        return error;
++      static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStepping();
++      step = true;
++    } break;
++
++    case eStateSuspended:
++    case eStateStopped:
++      llvm_unreachable("Unexpected state");
++
++    default:
++      return Error("NativeProcessNetBSD::%s (): unexpected state %s specified "
++                   "for pid %" PRIu64 ", tid %" PRIu64,
++                   __FUNCTION__, StateAsCString(action->state), GetID(),
++                   thread_sp->GetID());
+     }
+-    SetState(eStateRunning, true);
+-    break;
+-  }
+-  case eStateStepping:
+-    // Run the thread, possibly feeding it the signal.
+-    error = NativeProcessNetBSD::PtraceWrapper(PT_STEP, GetID(), (void *)1,
+-                                               action->signal);
+-    if (!error.Success())
++
++    Error error;
++
++    error = NativeProcessNetBSD::PtraceWrapper(PT_CONTINUE, GetID(), (void *)1,
++                                               sig);
++    if (error.Fail()) {
+       return error;
+-    for (const auto &thread_sp : m_threads) {
+-      static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStepping();
+     }
+-    SetState(eStateStepping, true);
+-    break;
+ 
+-  case eStateSuspended:
+-  case eStateStopped:
+-    llvm_unreachable("Unexpected state");
++    if (step)
++      SetState(eStateStepping, true);
++    else
++      SetState(eStateRunning, true);
+ 
+-  default:
+-    return Error("NativeProcessNetBSD::%s (): unexpected state %s specified "
+-                 "for pid %" PRIu64 ", tid %" PRIu64,
+-                 __FUNCTION__, StateAsCString(action->state), GetID(),
+-                 thread_sp->GetID());
++    return Error();
+   }
+-
+-  return Error();
+ }
+ 
+ Error NativeProcessNetBSD::Halt() {
+@@ -812,6 +924,18 @@ Error NativeProcessNetBSD::LaunchInferio
      return error;
    }
  
@@ -223,8 +335,8 @@ $NetBSD$
 +    LLDB_LOG(log, "failed to set default ptrace options: {0}", error);
 +
 +    // Mark the inferior as invalid.
-+    // FIXME this could really use a new state - eStateLaunchFailure.  For now,
-+    // using eStateInvalid.
++    // FIXME this could really use a new state - eStateLaunchFailure.  For
++    // now, using eStateInvalid.
 +    SetState(StateType::eStateInvalid);
 +
 +    return error;
@@ -233,7 +345,7 @@ $NetBSD$
    for (const auto &thread_sp : m_threads) {
      static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
          SIGSTOP);
-@@ -898,6 +1006,42 @@ void NativeProcessNetBSD::SigchldHandler
+@@ -898,6 +1022,42 @@ void NativeProcessNetBSD::SigchldHandler
      MonitorCallback(wait_pid, signal);
  }
  
@@ -276,7 +388,7 @@ $NetBSD$
  NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) {
  
    Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
-@@ -912,6 +1056,7 @@ NativeThreadNetBSDSP NativeProcessNetBSD
+@@ -912,6 +1072,7 @@ NativeThreadNetBSDSP NativeProcessNetBSD
  
    auto thread_sp = std::make_shared<NativeThreadNetBSD>(this, thread_id);
    m_threads.push_back(thread_sp);
@@ -284,7 +396,7 @@ $NetBSD$
    return thread_sp;
  }
  
-@@ -945,6 +1090,10 @@ NativeThreadNetBSDSP NativeProcessNetBSD
+@@ -945,6 +1106,10 @@ NativeThreadNetBSDSP NativeProcessNetBSD
      return -1;
    }
  
@@ -295,7 +407,7 @@ $NetBSD$
    for (const auto &thread_sp : m_threads) {
      static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
          SIGSTOP);
-@@ -1062,7 +1211,7 @@ Error NativeProcessNetBSD::ReinitializeT
+@@ -1062,7 +1227,7 @@ Error NativeProcessNetBSD::ReinitializeT
    }
    // Reinitialize from scratch threads and register them in process
    while (info.pl_lwpid != 0) {
@@ -304,7 +416,7 @@ $NetBSD$
      error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info));
      if (error.Fail()) {
        return error;
-@@ -1071,3 +1220,13 @@ Error NativeProcessNetBSD::ReinitializeT
+@@ -1071,3 +1236,13 @@ Error NativeProcessNetBSD::ReinitializeT
  
    return error;
  }


Home | Main Index | Thread Index | Old Index