[NativeProcessLinux] Remove double thread state accounting
Summary:
Now that all thread events are processed synchronously, there is no need to have separate records
of whether a thread is running. This changes the (ever-dwindling) remains of the TSC to use
NativeThreadLinux as the authoritative source of the state of threads. The rest of the
ThreadContext we need has been moved to a member of NTL.
Test Plan: ninja check-lldb continues to pass
Reviewers: chaoren, ovyalov
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D9562
llvm-svn: 236983
diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
index 134e6a0..c7c13a5 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -37,6 +37,11 @@
#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
#include "Plugins/Process/Utility/RegisterInfoInterface.h"
+#include <sys/syscall.h>
+// Try to define a macro to encapsulate the tgkill syscall
+#define tgkill(pid, tid, sig) \
+ syscall(SYS_tgkill, static_cast<::pid_t>(pid), static_cast<::pid_t>(tid), sig)
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_linux;
@@ -479,6 +484,35 @@
m_stop_info.reason = StopReason::eStopReasonThreadExiting;
}
+Error
+NativeThreadLinux::RequestStop ()
+{
+ Log* log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
+
+ const auto process_sp = GetProcess();
+ if (! process_sp)
+ return Error("Process is null.");
+
+ lldb::pid_t pid = process_sp->GetID();
+ lldb::tid_t tid = GetID();
+
+ if (log)
+ log->Printf ("NativeThreadLinux::%s requesting thread stop(pid: %" PRIu64 ", tid: %" PRIu64 ")", __FUNCTION__, pid, tid);
+
+ Error err;
+ errno = 0;
+ if (::tgkill (pid, tid, SIGSTOP) != 0)
+ {
+ err.SetErrorToErrno ();
+ if (log)
+ log->Printf ("NativeThreadLinux::%s tgkill(%" PRIu64 ", %" PRIu64 ", SIGSTOP) failed: %s", __FUNCTION__, pid, tid, err.AsCString ());
+ }
+ else
+ m_thread_context.stop_requested = true;
+
+ return err;
+}
+
void
NativeThreadLinux::MaybeLogStateChange (lldb::StateType new_state)
{