diff options
| author | Greg Clayton <gclayton@apple.com> | 2013-07-10 01:05:05 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2013-07-10 01:05:05 +0000 |
| commit | 7ad05d136a41b117ae55c8eae920bee4d3a83d81 (patch) | |
| tree | 71956366c218bc40c66d5382379bd8cc2da2855b | |
| parent | 488c99e075fa82edbf8e99422dea9b94c1e4f0ce (diff) | |
| download | bcm5719-llvm-7ad05d136a41b117ae55c8eae920bee4d3a83d81.tar.gz bcm5719-llvm-7ad05d136a41b117ae55c8eae920bee4d3a83d81.zip | |
Fixed the CommunicationKDP::SendRequestAndGetReply() to correctly be able to deal with getting a reply from a previous packet without resending the packet again.
llvm-svn: 185988
| -rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 12c17801767..595b8e6b11f 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -124,20 +124,49 @@ CommunicationKDP::SendRequestAndGetReply (const CommandType command, if (SendRequestPacketNoLock(request_packet)) { const uint8_t request_sequence_id = (uint8_t)request_packet.GetData()[1]; - if (WaitForPacketWithTimeoutMicroSecondsNoLock (reply_packet, GetPacketTimeoutInMicroSeconds ())) + while (1) { - offset = 0; - const uint8_t reply_command = reply_packet.GetU8 (&offset); - const uint8_t reply_sequence_id = reply_packet.GetU8 (&offset); - if ((reply_command & eCommandTypeMask) == command) + if (WaitForPacketWithTimeoutMicroSecondsNoLock (reply_packet, GetPacketTimeoutInMicroSeconds ())) { + offset = 0; + const uint8_t reply_sequence_id = reply_packet.GetU8 (&offset); if (request_sequence_id == reply_sequence_id) { - if (command == KDP_RESUMECPUS) - m_is_running.SetValue(true, eBroadcastAlways); - return true; + const uint8_t reply_command = reply_packet.GetU8 (&offset); + // The sequent ID was correct, now verify we got the response we were looking for + if ((reply_command & eCommandTypeMask) == command) + { + // Success + if (command == KDP_RESUMECPUS) + m_is_running.SetValue(true, eBroadcastAlways); + return true; + } + else + { + // Failed to get the correct response, bail + reply_packet.Clear(); + return false; + } + } + else if (reply_sequence_id > request_sequence_id) + { + // Sequence ID was greater than the sequence ID of the packet we sent, something + // is really wrong... + reply_packet.Clear(); + return false; + } + else + { + // The reply sequence ID was less than our current packet's sequence ID + // so we should keep trying to get a response because this was a response + // for a previous packet that we must have retried. } } + else + { + // Break and retry sending the packet as we didn't get a response due to timeout + break; + } } } } |

