diff options
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 9 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 36 | 
2 files changed, 37 insertions, 8 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index dc5e8d1afea..90fb47eb7a3 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -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)); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 6b5bb9aae4d..caf3461048d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -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;  | 

