Fix a place in GDBRemoteCommunicationClient::SendContinuePacketAndWaitForReply where we weren't taking

m_interrupt_sent into account.  Also don't reset m_interrupt_sent in SendInterrupt but do so in SendPacketAndWaitForResponse
when we know we've handled the interrupt.
Fix a code path through ProcessGDBRemote::DoDestroy where we were tearing down the debug session but
not setting the exit status.

llvm-svn: 158043
This commit is contained in:
Jim Ingham 2012-06-06 00:32:39 +00:00
parent aacc31813e
commit babfc38abc
2 changed files with 37 additions and 8 deletions

View File

@ -289,6 +289,7 @@ GDBRemoteCommunicationClient::SendPacketAndWaitForResponse
{
if (m_interrupt_sent)
{
m_interrupt_sent = false;
TimeValue timeout_time;
timeout_time = TimeValue::Now();
timeout_time.OffsetWithSeconds (m_packet_timeout);
@ -390,7 +391,7 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
m_public_is_running.SetValue (true, eBroadcastNever);
// Set the starting continue packet into "continue_packet". This packet
// make change if we are interrupted and we continue after an async packet...
// may change if we are interrupted and we continue after an async packet...
std::string continue_packet(payload, packet_length);
bool got_stdout = false;
@ -445,10 +446,9 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
const uint8_t signo = response.GetHexU8 (UINT8_MAX);
bool continue_after_async = false;
if (m_async_signal != -1 || m_async_packet_predicate.GetValue())
bool continue_after_async = m_async_signal != -1 || m_async_packet_predicate.GetValue();
if (continue_after_async || m_interrupt_sent)
{
continue_after_async = true;
// We sent an interrupt packet to stop the inferior process
// for an async signal or to send an async packet while running
// but we might have been single stepping and received the
@ -660,7 +660,6 @@ GDBRemoteCommunicationClient::SendInterrupt
bool &timed_out
)
{
m_interrupt_sent = false;
timed_out = false;
LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_PROCESS | GDBR_LOG_PACKETS));

View File

@ -1646,6 +1646,10 @@ ProcessGDBRemote::WillDetach ()
bool discard_thread_plans = true;
bool catch_stop_event = true;
EventSP event_sp;
// FIXME: InterruptIfRunning should be done in the Process base class, or better still make Halt do what is
// needed. This shouldn't be a feature of a particular plugin.
return InterruptIfRunning (discard_thread_plans, catch_stop_event, event_sp);
}
@ -1688,6 +1692,9 @@ ProcessGDBRemote::DoDestroy ()
log->Printf ("ProcessGDBRemote::DoDestroy()");
// Interrupt if our inferior is running...
int exit_status = SIGABRT;
std::string exit_string;
if (m_gdb_comm.IsConnected())
{
if (m_public_state.GetValue() != eStateAttaching)
@ -1703,16 +1710,39 @@ ProcessGDBRemote::DoDestroy ()
{
SetLastStopPacket (response);
ClearThreadIDList ();
SetExitStatus(response.GetHexU8(), NULL);
exit_status = response.GetHexU8();
}
else
{
if (log)
log->Printf ("ProcessGDBRemote::DoDestroy - got unexpected response to k packet: %s", response.GetStringRef().c_str());
exit_string.assign("got unexpected response to k packet: ");
exit_string.append(response.GetStringRef());
}
}
else
{
SetExitStatus(SIGABRT, NULL);
//error.SetErrorString("kill packet failed");
if (log)
log->Printf ("ProcessGDBRemote::DoDestroy - failed to send k packet");
exit_string.assign("failed to send the k packet");
}
}
else
{
if (log)
log->Printf ("ProcessGDBRemote::DoDestroy - failed to send k packet");
exit_string.assign ("killing while attaching.");
}
}
else
{
// If we missed setting the exit status on the way out, do it here.
// NB set exit status can be called multiple times, the first one sets the status.
exit_string.assign("destroying when not connected to debugserver");
}
SetExitStatus(exit_status, exit_string.c_str());
StopAsyncThread ();
KillDebugserverProcess ();
return error;