diff options
author | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2013-08-28 10:31:52 +0000 |
---|---|---|
committer | Hafiz Abid Qadeer <hafiz_abid@mentor.com> | 2013-08-28 10:31:52 +0000 |
commit | da96ef20b4a55dc5a5d8772e6bd592aa22470ca9 (patch) | |
tree | 2d9fa9f1d79b0e3261f546a981336e55ddb16312 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | |
parent | 35b9be298a26b7f2815b8fa4480321252ad15a03 (diff) | |
download | bcm5719-llvm-da96ef20b4a55dc5a5d8772e6bd592aa22470ca9.tar.gz bcm5719-llvm-da96ef20b4a55dc5a5d8772e6bd592aa22470ca9.zip |
Handle run-length-encoding.
The change was taken from a patch by Virgile Bello.
llvm-svn: 189470
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 46bd9ca8069..e54fec5817f 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -465,8 +465,31 @@ GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, Stri m_history.AddPacket (m_bytes.c_str(), total_length, History::ePacketTypeRecv, total_length); - packet_str.assign (m_bytes, content_start, content_length); - + // Copy the packet from m_bytes to packet_str expanding the + // run-length encoding in the process. + // Reserve enough byte for the most common case (no RLE used) + packet_str.reserve(m_bytes.length()); + for (std::string::const_iterator c = m_bytes.begin() + content_start; c != m_bytes.begin() + content_start + content_length; ++c) + { + if (*c == '*') + { + // '*' indicates RLE. Next character will give us the + // repeat count and previous character is what is to be + // repeated. + char char_to_repeat = packet_str.back(); + // Number of time the previous character is repeated + int repeat_count = *++c + 3 - ' '; + // We have the char_to_repeat and repeat_count. Now push + // it in the packet. + for (int i = 0; i < repeat_count; ++i) + packet_str.push_back(char_to_repeat); + } + else + { + packet_str.push_back(*c); + } + } + if (m_bytes[0] == '$') { assert (checksum_idx < m_bytes.size()); |