summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp40
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h9
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp47
3 files changed, 50 insertions, 46 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 92e33b25771..38b823f77aa 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -87,15 +87,24 @@ GDBRemoteCommunication::CalculcateChecksum (const char *payload, size_t payload_
}
size_t
-GDBRemoteCommunication::SendAck (char ack_char)
+GDBRemoteCommunication::SendAck ()
{
- Mutex::Locker locker(m_sequence_mutex);
- ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: %c", ack_char);
+ ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: +");
ConnectionStatus status = eConnectionStatusSuccess;
+ char ack_char = '+';
return Write (&ack_char, 1, status, NULL) == 1;
}
size_t
+GDBRemoteCommunication::SendNack ()
+{
+ ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: -");
+ ConnectionStatus status = eConnectionStatusSuccess;
+ char nack_char = '-';
+ return Write (&nack_char, 1, status, NULL) == 1;
+}
+
+size_t
GDBRemoteCommunication::SendPacketAndWaitForResponse
(
const char *payload,
@@ -141,7 +150,8 @@ GDBRemoteCommunication::SendPacketAndWaitForResponse
m_async_packet_predicate.SetValue (true, eBroadcastNever);
bool timed_out = false;
- if (SendInterrupt(locker, 1, &timed_out))
+ bool sent_interrupt = false;
+ if (SendInterrupt(locker, 1, sent_interrupt, timed_out))
{
if (m_async_packet_predicate.WaitForValueEqualTo (false, &timeout_time, &timed_out))
{
@@ -443,8 +453,9 @@ GDBRemoteCommunication::SendAsyncSignal (int signo)
{
m_async_signal = signo;
bool timed_out = false;
+ bool sent_interrupt = false;
Mutex::Locker locker;
- if (SendInterrupt (locker, 1, &timed_out))
+ if (SendInterrupt (locker, 1, sent_interrupt, timed_out))
return true;
m_async_signal = -1;
return false;
@@ -461,10 +472,16 @@ GDBRemoteCommunication::SendAsyncSignal (int signo)
// (gdb remote protocol requires this), and do what we need to do, then resume.
bool
-GDBRemoteCommunication::SendInterrupt (Mutex::Locker& locker, uint32_t seconds_to_wait_for_stop, bool *timed_out)
+GDBRemoteCommunication::SendInterrupt
+(
+ Mutex::Locker& locker,
+ uint32_t seconds_to_wait_for_stop,
+ bool &sent_interrupt,
+ bool &timed_out
+)
{
- if (timed_out)
- *timed_out = false;
+ sent_interrupt = false;
+ timed_out = false;
if (IsConnected() && IsRunning())
{
@@ -484,8 +501,9 @@ GDBRemoteCommunication::SendInterrupt (Mutex::Locker& locker, uint32_t seconds_t
ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: \\x03");
if (Write (&ctrl_c, 1, status, NULL) > 0)
{
+ sent_interrupt = true;
if (seconds_to_wait_for_stop)
- m_private_is_running.WaitForValueEqualTo (false, &timeout, timed_out);
+ m_private_is_running.WaitForValueEqualTo (false, &timeout, &timed_out);
return true;
}
}
@@ -553,9 +571,9 @@ GDBRemoteCommunication::WaitForPacketNoLock (StringExtractorGDBRemote &response,
checksum_error = packet_checksum != actual_checksum;
// Send the ack or nack if needed
if (checksum_error || !success)
- SendAck('-');
+ SendNack();
else
- SendAck('+');
+ SendAck();
}
}
else
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index ab9384f291e..bcbaeb5ebd9 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -87,7 +87,11 @@ public:
GetAck (uint32_t timeout_seconds);
size_t
- SendAck (char ack_char);
+ SendAck ();
+
+ size_t
+ SendNack ();
+
char
CalculcateChecksum (const char *payload,
@@ -117,7 +121,8 @@ public:
bool
SendInterrupt (lldb_private::Mutex::Locker &locker,
uint32_t seconds_to_wait_for_stop,
- bool *timed_out = NULL);
+ bool &sent_interrupt,
+ bool &timed_out);
bool
GetSequenceMutex(lldb_private::Mutex::Locker& locker);
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index f0087ec4200..5abe070f962 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -541,7 +541,7 @@ ProcessGDBRemote::ConnectToDebugserver (const char *host_port)
if (m_gdb_comm.StartReadThread(&error))
{
// Send an initial ack
- m_gdb_comm.SendAck('+');
+ m_gdb_comm.SendAck();
if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID)
m_debugserver_thread = Host::StartMonitoringChildProcess (MonitorDebugserverProcess,
@@ -1141,24 +1141,16 @@ Error
ProcessGDBRemote::DoHalt (bool &caused_stop)
{
Error error;
-
- if (m_gdb_comm.IsRunning())
- {
- caused_stop = true;
- bool timed_out = false;
- Mutex::Locker locker;
- if (!m_gdb_comm.SendInterrupt (locker, 2, &timed_out))
- {
- if (timed_out)
- error.SetErrorString("timed out sending interrupt packet");
- else
- error.SetErrorString("unknown error sending interrupt packet");
- }
- }
- else
+ bool timed_out = false;
+ Mutex::Locker locker;
+
+ if (!m_gdb_comm.SendInterrupt (locker, 2, caused_stop, timed_out))
{
- caused_stop = false;
+ if (timed_out)
+ error.SetErrorString("timed out sending interrupt packet");
+ else
+ error.SetErrorString("unknown error sending interrupt packet");
}
return error;
@@ -1172,11 +1164,12 @@ ProcessGDBRemote::WillDetach ()
if (m_gdb_comm.IsRunning())
{
bool timed_out = false;
+ bool sent_interrupt = false;
Mutex::Locker locker;
PausePrivateStateThread();
m_thread_list.DiscardThreadPlans();
m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
- if (!m_gdb_comm.SendInterrupt (locker, 2, &timed_out))
+ if (!m_gdb_comm.SendInterrupt (locker, 2, sent_interrupt, timed_out))
{
if (timed_out)
error.SetErrorString("timed out sending interrupt packet");
@@ -1238,22 +1231,10 @@ ProcessGDBRemote::DoDestroy ()
log->Printf ("ProcessGDBRemote::DoDestroy()");
// Interrupt if our inferior is running...
- Mutex::Locker locker;
- m_gdb_comm.SendInterrupt (locker, 1);
- DisableAllBreakpointSites ();
- SetExitStatus(-1, "process killed");
-
- StringExtractorGDBRemote response;
- if (m_gdb_comm.SendPacketAndWaitForResponse("k", response, 1, false))
+ if (m_gdb_comm.IsConnected())
{
- log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS);
- if (log)
- {
- if (response.IsOKPacket())
- log->Printf ("ProcessGDBRemote::DoDestroy() kill was successful");
- else
- log->Printf ("ProcessGDBRemote::DoDestroy() kill failed: %s", response.GetStringRef().c_str());
- }
+ // Don't get a response when killing our
+ m_gdb_comm.SendPacket ("k", 1);
}
StopAsyncThread ();
OpenPOWER on IntegriCloud