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)
89 "ThreadPlanSingleThreadTimeout pushing a brand new one with %" PRIu64
97 if (timeout_in_ms == 0)
118 "ThreadPlanSingleThreadTimeout reset from previous state with %" PRIu64
125 LLDB_LOGF(log,
"ThreadPlanSingleThreadTimeout::WillStop().");
135 std::lock_guard<std::mutex> lock(
m_mutex);
136 LLDB_LOGF(log,
"ThreadPlanSingleThreadTimeout::DidPop().");
138 m_info->m_isAlive =
false;
149 "ThreadPlanSingleThreadTimeout::DoPlanExplainsStop() returns %d. "
150 "%" PRIu64
" ms remaining.",
152 return is_timeout_interrupt;
161 std::unique_lock<std::mutex> lock(self->
m_mutex);
169 "ThreadPlanSingleThreadTimeout::TimeoutThreadFunc(), wait for %" PRIu64
172 self->
m_wakeup_cv.wait_for(lock, std::chrono::milliseconds(timeout_in_ms),
173 [self] {
return !self->
m_info->m_isAlive; });
175 "ThreadPlanSingleThreadTimeout::TimeoutThreadFunc() wake up with "
178 if (!self->
m_info->m_isAlive)
186 LLDB_LOGF(log,
"ThreadPlanSingleThreadTimeout::MischiefManaged() called.");
213 "ThreadPlanSingleThreadTimeout::IsTimeoutAsyncInterrupt(): got "
230 "ThreadPlanSingleThreadTimeout::HandleEvent(): Got a stop and "
231 "restart, so we'll continue waiting.");
236 "ThreadPlanSingleThreadTimeout::HandleEvent(): Got async interrupt "
237 ", so we will resume all threads.");
251 "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
virtual bool SupportsResumeOthers()
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.