// false
// will avoid this behavior.
lldb::StateType
- WaitForProcessToStop(const std::chrono::microseconds &timeout,
+ WaitForProcessToStop(const Timeout<std::micro> &timeout,
lldb::EventSP *event_sp_ptr = nullptr,
bool wait_always = true,
lldb::ListenerSP hijack_listener = lldb::ListenerSP(),
//--------------------------------------------------------------------------------------
void SyncIOHandler(uint32_t iohandler_id, uint64_t timeout_msec);
- lldb::StateType WaitForStateChangedEvents(
- const std::chrono::microseconds &timeout, lldb::EventSP &event_sp,
+ lldb::StateType GetStateChangedEvents(
+ lldb::EventSP &event_sp, const Timeout<std::micro> &timeout,
lldb::ListenerSP
hijack_listener); // Pass an empty ListenerSP to use builtin listener
Error HaltPrivate();
- lldb::StateType
- WaitForProcessStopPrivate(const std::chrono::microseconds &timeout,
- lldb::EventSP &event_sp);
+ lldb::StateType WaitForProcessStopPrivate(lldb::EventSP &event_sp,
+ const Timeout<std::micro> &timeout);
// This waits for both the state change broadcaster, and the control
// broadcaster.
// If control_only, it only waits for the control broadcaster.
- bool WaitForEventsPrivate(const std::chrono::microseconds &timeout,
- lldb::EventSP &event_sp, bool control_only);
+ bool GetEventsPrivate(lldb::EventSP &event_sp,
+ const Timeout<std::micro> &timeout, bool control_only);
lldb::StateType
- WaitForStateChangedEventsPrivate(const std::chrono::microseconds &timeout,
- lldb::EventSP &event_sp);
-
- lldb::StateType WaitForState(const std::chrono::microseconds &timeout,
- const lldb::StateType *match_states,
- const uint32_t num_match_states);
+ GetStateChangedEventsPrivate(lldb::EventSP &event_sp,
+ const Timeout<std::micro> &timeout);
size_t WriteMemoryPrivate(lldb::addr_t addr, const void *buf, size_t size,
Error &error);
using namespace lldb;
using namespace lldb_private;
+using namespace std::chrono;
// A temporary function to convert between old representations of timeouts (0
// means infinite wait) and new Timeout class (0 means "poll").
__FUNCTION__, iohandler_id, new_iohandler_id);
}
-StateType
-Process::WaitForProcessToStop(const std::chrono::microseconds &timeout,
- EventSP *event_sp_ptr, bool wait_always,
- ListenerSP hijack_listener_sp, Stream *stream,
- bool use_run_lock) {
+StateType Process::WaitForProcessToStop(const Timeout<std::micro> &timeout,
+ EventSP *event_sp_ptr, bool wait_always,
+ ListenerSP hijack_listener_sp,
+ Stream *stream, bool use_run_lock) {
// 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
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log)
- log->Printf("Process::%s (timeout = %llu)", __FUNCTION__,
- static_cast<unsigned long long>(timeout.count()));
+ log->Printf(
+ "Process::%s (timeout = %llu)", __FUNCTION__,
+ static_cast<unsigned long long>(timeout ? timeout->count() : -1));
if (!wait_always && StateIsStoppedState(state, true) &&
StateIsStoppedState(GetPrivateState(), true)) {
while (state != eStateInvalid) {
EventSP event_sp;
- state = WaitForStateChangedEvents(timeout, event_sp, hijack_listener_sp);
+ state = GetStateChangedEvents(event_sp, timeout, hijack_listener_sp);
if (event_sp_ptr && event_sp)
*event_sp_ptr = event_sp;
return true;
}
-StateType Process::WaitForState(const std::chrono::microseconds &timeout,
- const StateType *match_states,
- const uint32_t num_match_states) {
- EventSP event_sp;
- StateType state = GetState();
- while (state != eStateInvalid) {
- // If we are exited or detached, we won't ever get back to any
- // other valid state...
- if (state == eStateDetached || state == eStateExited)
- return state;
-
- state = WaitForStateChangedEvents(timeout, event_sp, nullptr);
-
- for (uint32_t i = 0; i < num_match_states; ++i) {
- if (match_states[i] == state)
- return state;
- }
- }
- return state;
-}
-
bool Process::HijackProcessEvents(ListenerSP listener_sp) {
if (listener_sp) {
return HijackBroadcaster(listener_sp, eBroadcastBitStateChanged |
void Process::RestoreProcessEvents() { RestoreBroadcaster(); }
-StateType
-Process::WaitForStateChangedEvents(const std::chrono::microseconds &timeout,
- EventSP &event_sp,
- ListenerSP hijack_listener_sp) {
+StateType Process::GetStateChangedEvents(EventSP &event_sp,
+ const Timeout<std::micro> &timeout,
+ ListenerSP hijack_listener_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log)
- log->Printf("Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
- static_cast<unsigned long long>(timeout.count()));
+ log->Printf(
+ "Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
+ static_cast<unsigned long long>(timeout ? timeout->count() : -1));
ListenerSP listener_sp = hijack_listener_sp;
if (!listener_sp)
StateType state = eStateInvalid;
if (listener_sp->GetEventForBroadcasterWithType(
this, eBroadcastBitStateChanged | eBroadcastBitInterrupt, event_sp,
- ConvertTimeout(timeout))) {
+ timeout)) {
if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged)
state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
else if (log)
}
if (log)
- log->Printf("Process::%s (timeout = %llu, event_sp) => %s", __FUNCTION__,
- static_cast<unsigned long long>(timeout.count()),
- StateAsCString(state));
+ log->Printf(
+ "Process::%s (timeout = %llu, event_sp) => %s", __FUNCTION__,
+ static_cast<unsigned long long>(timeout ? timeout->count() : -1),
+ StateAsCString(state));
return state;
}
return event_ptr;
}
-StateType Process::WaitForStateChangedEventsPrivate(
- const std::chrono::microseconds &timeout, EventSP &event_sp) {
+StateType
+Process::GetStateChangedEventsPrivate(EventSP &event_sp,
+ const Timeout<std::micro> &timeout) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log)
- log->Printf("Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
- static_cast<unsigned long long>(timeout.count()));
+ log->Printf(
+ "Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
+ static_cast<unsigned long long>(timeout ? timeout->count() : -1));
StateType state = eStateInvalid;
if (m_private_state_listener_sp->GetEventForBroadcasterWithType(
&m_private_state_broadcaster,
eBroadcastBitStateChanged | eBroadcastBitInterrupt, event_sp,
- ConvertTimeout(timeout)))
+ timeout))
if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged)
state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
// to the command-line, and that could disable the log, which would render the
// log we got above invalid.
if (log)
- log->Printf("Process::%s (timeout = %llu, event_sp) => %s", __FUNCTION__,
- static_cast<unsigned long long>(timeout.count()),
- state == eStateInvalid ? "TIMEOUT" : StateAsCString(state));
+ log->Printf(
+ "Process::%s (timeout = %llu, event_sp) => %s", __FUNCTION__,
+ static_cast<unsigned long long>(timeout ? timeout->count() : -1),
+ state == eStateInvalid ? "TIMEOUT" : StateAsCString(state));
return state;
}
-bool Process::WaitForEventsPrivate(const std::chrono::microseconds &timeout,
- EventSP &event_sp, bool control_only) {
+bool Process::GetEventsPrivate(EventSP &event_sp,
+ const Timeout<std::micro> &timeout,
+ bool control_only) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log)
- log->Printf("Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
- static_cast<unsigned long long>(timeout.count()));
+ log->Printf(
+ "Process::%s (timeout = %llu, event_sp)...", __FUNCTION__,
+ static_cast<unsigned long long>(timeout ? timeout->count() : -1));
if (control_only)
return m_private_state_listener_sp->GetEventForBroadcaster(
- &m_private_state_control_broadcaster, event_sp,
- ConvertTimeout(timeout));
+ &m_private_state_control_broadcaster, event_sp, timeout);
else
- return m_private_state_listener_sp->GetEvent(event_sp,
- ConvertTimeout(timeout));
+ return m_private_state_listener_sp->GetEvent(event_sp, timeout);
}
bool Process::IsRunning() const {
Error error = PrivateResume();
if (error.Success()) {
- StateType state = WaitForProcessToStop(std::chrono::microseconds(0), NULL,
- true, listener_sp, stream);
+ StateType state =
+ WaitForProcessToStop(llvm::None, NULL, true, listener_sp, stream);
const bool must_be_alive =
false; // eStateExited is ok, so this must be false
if (!StateIsStoppedState(state, must_be_alive))
}
StateType
-Process::WaitForProcessStopPrivate(const std::chrono::microseconds &timeout,
- EventSP &event_sp) {
+Process::WaitForProcessStopPrivate(EventSP &event_sp,
+ const Timeout<std::micro> &timeout) {
StateType state;
// Now wait for the process to launch and return control to us, and then
// call DidLaunch:
while (true) {
event_sp.reset();
- state = WaitForStateChangedEventsPrivate(timeout, event_sp);
+ state = GetStateChangedEventsPrivate(event_sp, timeout);
if (StateIsStoppedState(state, false))
break;
}
} else {
EventSP event_sp;
- StateType state =
- WaitForProcessStopPrivate(std::chrono::seconds(10), event_sp);
+ StateType state = WaitForProcessStopPrivate(event_sp, seconds(10));
if (state == eStateInvalid || !event_sp) {
// We were able to launch the process, but we failed to
if (error.Success()) {
if (GetID() != LLDB_INVALID_PROCESS_ID) {
EventSP event_sp;
- StateType state =
- WaitForProcessStopPrivate(std::chrono::microseconds(0), event_sp);
+ StateType state = WaitForProcessStopPrivate(event_sp, llvm::None);
if (state == eStateStopped || state == eStateCrashed) {
// If we attached and actually have a process on the other end, then
}
// Wait for 10 second for the process to stop.
- StateType state =
- WaitForProcessToStop(std::chrono::seconds(10), &event_sp, true,
- halt_listener_sp, nullptr, use_run_lock);
+ StateType state = WaitForProcessToStop(
+ seconds(10), &event_sp, true, halt_listener_sp, nullptr, use_run_lock);
RestoreProcessEvents();
if (state == eStateInvalid || !event_sp) {
SendAsyncInterrupt();
// Consume the interrupt event.
- StateType state = WaitForProcessToStop(std::chrono::seconds(10),
- &exit_event_sp, true, listener_sp);
+ StateType state =
+ WaitForProcessToStop(seconds(10), &exit_event_sp, true, listener_sp);
RestoreProcessEvents();
bool interrupt_requested = false;
while (!exit_now) {
EventSP event_sp;
- WaitForEventsPrivate(std::chrono::microseconds(0), event_sp, control_only);
+ GetEventsPrivate(event_sp, llvm::None, control_only);
if (event_sp->BroadcasterIs(&m_private_state_control_broadcaster)) {
if (log)
log->Printf("Process::%s (arg = %p, pid = %" PRIu64