31 m_info(info), m_state(
State::WaitTimeout) {
44 std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
45 std::chrono::milliseconds duration_ms =
46 std::chrono::duration_cast<std::chrono::milliseconds>(now -
48 return timeout_in_ms - duration_ms.count();
53 s->
Printf(
"Single thread timeout, state(%s), remaining %" PRIu64
" ms",
62 return "AsyncInterrupt";
66 llvm_unreachable(
"Uncovered state value!");
72 if (timeout_in_ms == 0)
86 "ThreadPlanSingleThreadTimeout pushing a brand new one with %" PRIu64
94 if (timeout_in_ms == 0)
112 "ThreadPlanSingleThreadTimeout reset from previous state with %" PRIu64
119 LLDB_LOGF(log,
"ThreadPlanSingleThreadTimeout::WillStop().");
129 std::lock_guard<std::mutex> lock(
m_mutex);
130 LLDB_LOGF(log,
"ThreadPlanSingleThreadTimeout::DidPop().");
132 m_info->m_isAlive =
false;
143 "ThreadPlanSingleThreadTimeout::DoPlanExplainsStop() returns %d. "
144 "%" PRIu64
" ms remaining.",
146 return is_timeout_interrupt;
155 std::unique_lock<std::mutex> lock(self->
m_mutex);
163 "ThreadPlanSingleThreadTimeout::TimeoutThreadFunc(), wait for %" PRIu64
166 self->
m_wakeup_cv.wait_for(lock, std::chrono::milliseconds(timeout_in_ms),
167 [self] {
return !self->
m_info->m_isAlive; });
169 "ThreadPlanSingleThreadTimeout::TimeoutThreadFunc() wake up with "
172 if (!self->
m_info->m_isAlive)
180 LLDB_LOGF(log,
"ThreadPlanSingleThreadTimeout::MischiefManaged() called.");
207 "ThreadPlanSingleThreadTimeout::IsTimeoutAsyncInterrupt(): got "
224 "ThreadPlanSingleThreadTimeout::HandleEvent(): Got a stop and "
225 "restart, so we'll continue waiting.");
230 "ThreadPlanSingleThreadTimeout::HandleEvent(): Got async interrupt "
231 ", so we will resume all threads.");
245 "ThreadPlanSingleThreadTimeout::HandleTimeout() send async interrupt.");
#define LLDB_LOGF(log,...)
static bool GetRestartedFromEvent(const Event *event_ptr)
static lldb::StateType GetStateFromEvent(const Event *event_ptr)
void SendAsyncInterrupt(Thread *thread=nullptr)
Send an async interrupt request.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
bool ShouldStop(Event *event_ptr) override
bool MischiefManaged() override
std::shared_ptr< ThreadPlanSingleThreadTimeout::TimeoutInfo > TimeoutInfoSP
static void ResumeFromPrevState(Thread &thread, TimeoutInfoSP &info)
std::chrono::steady_clock::time_point m_timeout_start
static void TimeoutThreadFunc(ThreadPlanSingleThreadTimeout *self)
bool HandleEvent(Event *event_ptr)
std::condition_variable m_wakeup_cv
static void PushNewWithTimeout(Thread &thread, TimeoutInfoSP &info)
static std::string StateToString(State state)
bool DoPlanExplainsStop(Event *event_ptr) override
bool StopOthers() override
uint64_t GetRemainingTimeoutMilliSeconds()
~ThreadPlanSingleThreadTimeout() override
std::thread m_timer_thread
ThreadPlanSingleThreadTimeout(Thread &thread, TimeoutInfoSP &info)
void GetDescription(Stream *s, lldb::DescriptionLevel level) override
Print a description of this thread to the stream s.
lldb::StateType GetPlanRunState() override
bool IsTimeoutAsyncInterrupt(Event *event_ptr)
void SetStopOthers(bool new_value) override
virtual lldb::StateType GetPlanRunState()=0
Thread & GetThread()
Returns the Thread that is using this thread plan.
virtual bool StopOthers()
ThreadPlan * GetPreviousPlan()
virtual void SetStopOthers(bool new_value)
uint64_t GetSingleThreadPlanTimeout() const
Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans)
Queues a generic thread plan.
ThreadPlan * GetCurrentPlan() const
Gets the plan which will execute next on the plan stack.
lldb::StopInfoSP GetStopInfo()
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
StateType
Process and Thread States.
@ eStateStopped
Process or thread is stopped and can be examined.
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
@ eStopReasonInterrupt
Thread requested interrupt.