diff options
| author | Pavel Labath <labath@google.com> | 2015-05-11 10:03:10 +0000 |
|---|---|---|
| committer | Pavel Labath <labath@google.com> | 2015-05-11 10:03:10 +0000 |
| commit | 8c8ff7af288829f357375a952155155c88e8945e (patch) | |
| tree | c8326956da696b518638571f1f2c08eab5401754 /lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp | |
| parent | ec05fc7b16473e5bee82bc8f18bcd97fe68df101 (diff) | |
| download | llvm-8c8ff7af288829f357375a952155155c88e8945e.zip llvm-8c8ff7af288829f357375a952155155c88e8945e.tar.gz llvm-8c8ff7af288829f357375a952155155c88e8945e.tar.bz2 | |
[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
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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 @@ NativeThreadLinux::SetExited () 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) { |
