summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-12-06 21:45:27 +0000
committerGreg Clayton <gclayton@apple.com>2013-12-06 21:45:27 +0000
commit3dedae12b5453757055857e83a1f2624bf08d914 (patch)
tree9394760a1d2f54ddf4438a3eca18b493480c608c /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
parent0db73111a97137b10897ab8e544d4d9d25f39ce5 (diff)
downloadbcm5719-llvm-3dedae12b5453757055857e83a1f2624bf08d914.tar.gz
bcm5719-llvm-3dedae12b5453757055857e83a1f2624bf08d914.zip
Fixed the GDBRemoteCommuncation to return a new GDBRemoteCommuncation::PacketResult enum for all packet sends/receives.
<rdar://problem/15600045> Due to other recent changes, all connections to GDB servers that didn't support the "QStartNoAckMode" packet would cause us to fail to attach to the remote GDB server. The problem was that SendPacket* and WaitForResponse* packets would return a size_t indicating the number of bytes sent/received. The other issue was WaitForResponse* packets would strip the leading '$' and the trailing "#CC" (checksum) bytes, so the unimplemented response packet of "$#00" would get stripped and the WaitForResponse* packets would return 0. These new error codes give us flexibility to to more intelligent things in response to what is returned. llvm-svn: 196610
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 5966ccadffc..77eb6058d6b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -199,14 +199,14 @@ GDBRemoteCommunication::SendNack ()
return bytes_written;
}
-size_t
+GDBRemoteCommunication::PacketResult
GDBRemoteCommunication::SendPacket (const char *payload, size_t payload_length)
{
Mutex::Locker locker(m_sequence_mutex);
return SendPacketNoLock (payload, payload_length);
}
-size_t
+GDBRemoteCommunication::PacketResult
GDBRemoteCommunication::SendPacketNoLock (const char *payload, size_t payload_length)
{
if (IsConnected())
@@ -239,32 +239,32 @@ GDBRemoteCommunication::SendPacketNoLock (const char *payload, size_t payload_le
if (bytes_written == packet.GetSize())
{
if (GetSendAcks ())
- {
- if (GetAck () != '+')
- {
- if (log)
- log->Printf("get ack failed...");
- return 0;
- }
- }
+ return GetAck ();
+ else
+ return PacketResult::Success;
}
else
{
if (log)
log->Printf ("error: failed to send packet: %.*s", (int)packet.GetSize(), packet.GetData());
}
- return bytes_written;
}
- return 0;
+ return PacketResult::ErrorSendFailed;
}
-char
+GDBRemoteCommunication::PacketResult
GDBRemoteCommunication::GetAck ()
{
StringExtractorGDBRemote packet;
- if (WaitForPacketWithTimeoutMicroSecondsNoLock (packet, GetPacketTimeoutInMicroSeconds ()) == 1)
- return packet.GetChar();
- return 0;
+ PacketResult result = WaitForPacketWithTimeoutMicroSecondsNoLock (packet, GetPacketTimeoutInMicroSeconds ());
+ if (result == PacketResult::Success)
+ {
+ if (packet.GetResponseType() == StringExtractorGDBRemote::ResponseType::eAck)
+ return PacketResult::Success;
+ else
+ return PacketResult::ErrorSendAck;
+ }
+ return result;
}
bool
@@ -284,7 +284,7 @@ GDBRemoteCommunication::WaitForNotRunningPrivate (const TimeValue *timeout_ptr)
return m_private_is_running.WaitForValueEqualTo (false, timeout_ptr, NULL);
}
-size_t
+GDBRemoteCommunication::PacketResult
GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &packet, uint32_t timeout_usec)
{
uint8_t buffer[8192];
@@ -294,9 +294,10 @@ GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtrac
// Check for a packet from our cache first without trying any reading...
if (CheckForPacket (NULL, 0, packet))
- return packet.GetStringRef().size();
+ return PacketResult::Success;
bool timed_out = false;
+ bool disconnected = false;
while (IsConnected() && !timed_out)
{
lldb::ConnectionStatus status = eConnectionStatusNoConnection;
@@ -313,7 +314,7 @@ GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtrac
if (bytes_read > 0)
{
if (CheckForPacket (buffer, bytes_read, packet))
- return packet.GetStringRef().size();
+ return PacketResult::Success;
}
else
{
@@ -330,13 +331,19 @@ GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtrac
case eConnectionStatusNoConnection:
case eConnectionStatusLostConnection:
case eConnectionStatusError:
+ disconnected = true;
Disconnect();
break;
}
}
}
- packet.Clear ();
- return 0;
+ packet.Clear ();
+ if (disconnected)
+ return PacketResult::ErrorDisconnected;
+ if (timed_out)
+ return PacketResult::ErrorReplyTimeout;
+ else
+ return PacketResult::ErrorReplyFailed;
}
bool
OpenPOWER on IntegriCloud