From 9e9919f0431cc2ddc297813bdb772c776d14281c Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 9 Oct 2013 16:56:28 +0000 Subject: Allow Process::WaitForProcessToStop to return immediately if process is already in the stopped state - By default, the above function will wait for at least one event - Set wait_always=false to make the function return immediately if the process is already stopped llvm-svn: 192301 --- lldb/source/Target/Process.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lldb/source/Target/Process.cpp') diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 3c9fea377e9..93159fcae99 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1230,7 +1230,7 @@ Process::GetNextEvent (EventSP &event_sp) StateType -Process::WaitForProcessToStop (const TimeValue *timeout, lldb::EventSP *event_sp_ptr) +Process::WaitForProcessToStop (const TimeValue *timeout, lldb::EventSP *event_sp_ptr, bool wait_always) { // We can't just wait for a "stopped" event, because the stopped event may have restarted the target. // We have to actually check each event, and in the case of a stopped event check the restarted flag @@ -1243,6 +1243,19 @@ Process::WaitForProcessToStop (const TimeValue *timeout, lldb::EventSP *event_sp if (state == eStateDetached || state == eStateExited) return state; + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf ("Process::%s (timeout = %p)", __FUNCTION__, timeout); + + if (!wait_always && + StateIsStoppedState(state, true) && + StateIsStoppedState(GetPrivateState(), true)) { + if (log) + log->Printf("Process::%s returning without waiting for events; process private and public states are already 'stopped'.", + __FUNCTION__); + return state; + } + while (state != eStateInvalid) { EventSP event_sp; -- cgit v1.2.3