diff options
author | Pavel Labath <labath@google.com> | 2017-01-25 11:19:45 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2017-01-25 11:19:45 +0000 |
commit | 8abd34f0155a162a37c4dd692b65604ccbcb14d1 (patch) | |
tree | 4a0b27a35b000c23a6d020cdcf18612eb6df0221 /lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp | |
parent | 2d0c5b02970da62dd10baab1d197535f0d3c16ac (diff) | |
download | llvm-8abd34f0155a162a37c4dd692b65604ccbcb14d1.zip llvm-8abd34f0155a162a37c4dd692b65604ccbcb14d1.tar.gz llvm-8abd34f0155a162a37c4dd692b65604ccbcb14d1.tar.bz2 |
NPL: Compartmentalize arm64 single step workaround better
The main motivation for me doing this is being able to build an arm
android lldb-server against api level 9 headers, but it seems like a
good cleanup nonetheless.
The entirety of the cpu_set_t dance now resides in SingleStepCheck.cpp,
which is only built on arm64.
llvm-svn: 293046
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp index d18d3c1..c2e1214 100644 --- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp @@ -220,63 +220,12 @@ Error NativeThreadLinux::Resume(uint32_t signo) { reinterpret_cast<void *>(data)); } -void NativeThreadLinux::MaybePrepareSingleStepWorkaround() { - if (!SingleStepWorkaroundNeeded()) - return; - - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); - - if (sched_getaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set, - &m_original_cpu_set) != 0) { - // This should really not fail. But, just in case... - if (log) { - Error error(errno, eErrorTypePOSIX); - log->Printf( - "NativeThreadLinux::%s Unable to get cpu affinity for thread %" PRIx64 - ": %s", - __FUNCTION__, m_tid, error.AsCString()); - } - return; - } - - cpu_set_t set; - CPU_ZERO(&set); - CPU_SET(0, &set); - if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof set, &set) != 0 && - log) { - // This may fail in very locked down systems, if the thread is not allowed - // to run on - // cpu 0. If that happens, only thing we can do is it log it and continue... - Error error(errno, eErrorTypePOSIX); - log->Printf( - "NativeThreadLinux::%s Unable to set cpu affinity for thread %" PRIx64 - ": %s", - __FUNCTION__, m_tid, error.AsCString()); - } -} - -void NativeThreadLinux::MaybeCleanupSingleStepWorkaround() { - if (!SingleStepWorkaroundNeeded()) - return; - - if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set, - &m_original_cpu_set) != 0) { - Error error(errno, eErrorTypePOSIX); - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD)); - log->Printf( - "NativeThreadLinux::%s Unable to reset cpu affinity for thread %" PRIx64 - ": %s", - __FUNCTION__, m_tid, error.AsCString()); - } -} - Error NativeThreadLinux::SingleStep(uint32_t signo) { const StateType new_state = StateType::eStateStepping; MaybeLogStateChange(new_state); m_state = new_state; m_stop_info.reason = StopReason::eStopReasonNone; - - MaybePrepareSingleStepWorkaround(); + m_step_workaround = SingleStepWorkaround::Get(m_tid); intptr_t data = 0; if (signo != LLDB_INVALID_SIGNAL_NUMBER) @@ -338,7 +287,7 @@ bool NativeThreadLinux::IsStopped(int *signo) { void NativeThreadLinux::SetStopped() { if (m_state == StateType::eStateStepping) - MaybeCleanupSingleStepWorkaround(); + m_step_workaround.reset(); const StateType new_state = StateType::eStateStopped; MaybeLogStateChange(new_state); |