From: Greg Clayton Date: Fri, 20 Jun 2014 20:41:07 +0000 (+0000) Subject: Fixed the "log enable gdb-remote packets" to support dumping the binary memory read... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06f09b58f7d712a047fc1a52f86b3d4177b13844;p=platform%2Fupstream%2Fllvm.git Fixed the "log enable gdb-remote packets" to support dumping the binary memory read packet ('x') by printing out the binary data correctly using only printable characters and removing the 0x7d escapes so the memory is readable in the packet output. llvm-svn: 211400 --- diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 9630b06..d3ab3b8 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -458,7 +458,8 @@ GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, Stri assert (content_length <= m_bytes.size()); assert (total_length <= m_bytes.size()); assert (content_length <= total_length); - + const size_t content_end = content_start + content_length; + bool success = true; std::string &packet_str = packet.GetStringRef(); @@ -472,7 +473,45 @@ GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, Stri if (!m_history.DidDumpToLog ()) m_history.Dump (log); - log->Printf("<%4" PRIu64 "> read packet: %.*s", (uint64_t)total_length, (int)(total_length), m_bytes.c_str()); + bool binary = false; + // Only detect binary for packets that start with a '$' and have a '#CC' checksum + if (m_bytes[0] == '$' && total_length > 4) + { + for (size_t i=0; !binary && i read packet: %c", (uint64_t)total_length, m_bytes[0]); + for (size_t i=content_start; iPutCString(strm.GetString().c_str()); + } + else + { + log->Printf("<%4" PRIu64 "> read packet: %.*s", (uint64_t)total_length, (int)(total_length), m_bytes.c_str()); + } } m_history.AddPacket (m_bytes.c_str(), total_length, History::ePacketTypeRecv, total_length); @@ -483,7 +522,7 @@ GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, Stri // 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) + for (std::string::const_iterator c = m_bytes.begin() + content_start; c != m_bytes.begin() + content_end; ++c) { if (*c == '*') {