Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse( | ||||
// The main ReadPacket loop wakes up at computed_timeout intervals, just to | // The main ReadPacket loop wakes up at computed_timeout intervals, just to | ||||
// check that the connection hasn't dropped. When we wake up we also check | // check that the connection hasn't dropped. When we wake up we also check | ||||
// whether there is an interrupt request that has reached its endpoint. | // whether there is an interrupt request that has reached its endpoint. | ||||
// If we want a shorter interrupt timeout that kWakeupInterval, we need to | // If we want a shorter interrupt timeout that kWakeupInterval, we need to | ||||
// choose the shorter interval for the wake up as well. | // choose the shorter interval for the wake up as well. | ||||
std::chrono::seconds computed_timeout = | std::chrono::seconds computed_timeout = | ||||
std::min(interrupt_timeout, kWakeupInterval); | std::min(interrupt_timeout, kWakeupInterval); | ||||
for (;;) { | for (;;) { | ||||
PacketResult read_result = ReadPacket(response, computed_timeout, false); | PacketResult read_result = | ||||
ReadPacket(response, computed_timeout, false, m_non_stop_protocol); | |||||
// Reset the computed_timeout to the default value in case we are going | // Reset the computed_timeout to the default value in case we are going | ||||
// round again. | // round again. | ||||
computed_timeout = std::min(interrupt_timeout, kWakeupInterval); | computed_timeout = std::min(interrupt_timeout, kWakeupInterval); | ||||
switch (read_result) { | switch (read_result) { | ||||
case PacketResult::ErrorReplyTimeout: { | case PacketResult::ErrorReplyTimeout: { | ||||
std::lock_guard<std::mutex> lock(m_mutex); | std::lock_guard<std::mutex> lock(m_mutex); | ||||
if (m_async_count == 0) { | if (m_async_count == 0) { | ||||
continue; | continue; | ||||
Show All 9 Lines | case PacketResult::ErrorReplyTimeout: { | ||||
auto new_wait = m_interrupt_endpoint - cur_time; | auto new_wait = m_interrupt_endpoint - cur_time; | ||||
computed_timeout = std::min( | computed_timeout = std::min( | ||||
kWakeupInterval, | kWakeupInterval, | ||||
std::chrono::duration_cast<std::chrono::seconds>(new_wait)); | std::chrono::duration_cast<std::chrono::seconds>(new_wait)); | ||||
continue; | continue; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
case PacketResult::Notify: | |||||
case PacketResult::Success: | case PacketResult::Success: | ||||
break; | break; | ||||
default: | default: | ||||
LLDB_LOGF(log, "GDBRemoteClientBase::%s () ReadPacket(...) => false", | LLDB_LOGF(log, "GDBRemoteClientBase::%s () ReadPacket(...) => false", | ||||
__FUNCTION__); | __FUNCTION__); | ||||
return eStateInvalid; | return eStateInvalid; | ||||
} | } | ||||
if (response.Empty()) | if (response.Empty()) | ||||
return eStateInvalid; | return eStateInvalid; | ||||
LLDB_LOGF(log, "GDBRemoteClientBase::%s () got packet: %s", __FUNCTION__, | LLDB_LOGF(log, "GDBRemoteClientBase::%s () got packet: %s", __FUNCTION__, | ||||
response.GetStringRef().data()); | response.GetStringRef().data()); | ||||
// We do not currently support full asynchronous communication. Instead, | // We do not currently support full asynchronous communication. Instead, | ||||
// when in non-stop mode, we: | // when in non-stop mode, we: | ||||
// 1) get the "OK" response to the continue packet | // 1) get the "OK" response to the continue packet | ||||
// 2) wait for the asynchronous %Stop notification | // 2) wait for the asynchronous %Stop notification | ||||
// 3) drain the notification queue | // 3) drain the notification queue | ||||
// 4) issue a "vCtrlC" command to ensure that all threads stop | // 4) issue a "vCtrlC" command to ensure that all threads stop | ||||
// 5) repeat 1-3 for the response to this packet | // 5) repeat 1-3 for the response to this packet | ||||
if (response.IsOKResponse()) | if (read_result == PacketResult::Success && m_non_stop_protocol && | ||||
response.IsOKResponse()) | |||||
continue; | continue; | ||||
// TODO: get a proper mechanism for async notifications | if (read_result == PacketResult::Notify && | ||||
if (response.GetStringRef().startswith("Stop:")) { | response.GetStringRef().startswith("Stop:")) { | ||||
response.Reset(response.GetStringRef().substr(5)); | response.Reset(response.GetStringRef().substr(5)); | ||||
if (!DrainNotificationQueue("vStopped")) | if (!DrainNotificationQueue("vStopped")) | ||||
return eStateInvalid; | return eStateInvalid; | ||||
switch (response.GetStringRef()[0]) { | switch (response.GetStringRef()[0]) { | ||||
case 'W': | case 'W': | ||||
case 'X': | case 'X': | ||||
Show All 17 Lines | if (read_result == PacketResult::Notify && | ||||
} | } | ||||
if (!stop_response.IsOKResponse()) { | if (!stop_response.IsOKResponse()) { | ||||
LLDB_LOGF(log, "GDBRemoteClientBase::%s () vCtrlC failed", | LLDB_LOGF(log, "GDBRemoteClientBase::%s () vCtrlC failed", | ||||
__FUNCTION__); | __FUNCTION__); | ||||
return eStateInvalid; | return eStateInvalid; | ||||
} | } | ||||
// vCtrlC may not do anything, so timeout if we don't get notification | // vCtrlC may not do anything, so timeout if we don't get notification | ||||
if (ReadPacket(stop_response, milliseconds(500), false) == | if (ReadPacket(stop_response, milliseconds(500), false, true) == | ||||
PacketResult::Success) { | PacketResult::Notify) { | ||||
if (!stop_response.GetStringRef().startswith("Stop:")) { | if (!stop_response.GetStringRef().startswith("Stop:")) { | ||||
LLDB_LOGF(log, | LLDB_LOGF(log, | ||||
"GDBRemoteClientBase::%s () unexpected response " | "GDBRemoteClientBase::%s () unexpected response " | ||||
"after vCtrlC", | "after vCtrlC", | ||||
__FUNCTION__); | __FUNCTION__); | ||||
return eStateInvalid; | return eStateInvalid; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 324 Lines • Show Last 20 Lines |