borneoa created this revision. borneoa added a reviewer: clayborg. borneoa requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
The loop that detects the junk bytes exits: a) when it reaches the last byte in m_bytes, or b) when it finds a valid 'first byte'. The current code drops the first 'idx-1' bytes. This is consistent with case b), but it left one junk byte in case a). Let the code dropping all the junk bytes in both the cases above. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D116009 Files: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -689,7 +689,7 @@ const size_t bytes_len = m_bytes.size(); bool done = false; uint32_t idx; - for (idx = 1; !done && idx < bytes_len; ++idx) { + for (idx = 1; !done && idx < bytes_len;) { switch (m_bytes[idx]) { case '+': case '-': @@ -700,12 +700,13 @@ break; default: + ++idx; break; } } LLDB_LOGF(log, "GDBRemoteCommunication::%s tossing %u junk bytes: '%.*s'", - __FUNCTION__, idx - 1, idx - 1, m_bytes.c_str()); - m_bytes.erase(0, idx - 1); + __FUNCTION__, idx, idx, m_bytes.c_str()); + m_bytes.erase(0, idx); } break; }
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -689,7 +689,7 @@ const size_t bytes_len = m_bytes.size(); bool done = false; uint32_t idx; - for (idx = 1; !done && idx < bytes_len; ++idx) { + for (idx = 1; !done && idx < bytes_len;) { switch (m_bytes[idx]) { case '+': case '-': @@ -700,12 +700,13 @@ break; default: + ++idx; break; } } LLDB_LOGF(log, "GDBRemoteCommunication::%s tossing %u junk bytes: '%.*s'", - __FUNCTION__, idx - 1, idx - 1, m_bytes.c_str()); - m_bytes.erase(0, idx - 1); + __FUNCTION__, idx, idx, m_bytes.c_str()); + m_bytes.erase(0, idx); } break; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits