This is an archive of the discontinued LLVM Phabricator instance.

[lldb/gdb-remote] remove junk bytes, then decode the packet
AbandonedPublic

Authored by borneoa on Dec 19 2021, 10:29 AM.

Details

Reviewers
clayborg
Summary

In case of receiving, in a single packet, some junk byte followed
by a complete gdb-remote reply, e.g. "junk+$OK#9a", the current
implementation of CheckForPacket() drops the junk bytes and
returns.
The caller will call again CheckForPacket() only if it receives
another packet. But the reply is already complete and the remote
will not send anything else, so the caller will timeout.

Check for junk bytes and drop them, then decode the packet.

Diff Detail

Event Timeline

borneoa requested review of this revision.Dec 19 2021, 10:29 AM
borneoa created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2021, 10:29 AM
borneoa updated this revision to Diff 395347.Dec 19 2021, 10:40 AM

resend it on top of its dependency
[lldb/gdb-remote] drop all junk bytes in incoming packet

borneoa abandoned this revision.Dec 19 2021, 1:56 PM

Sorry, very first time user of arcanist and phabricator.
This revision was actually made by two independent patches that get squashed!
Abandoned, I will try to send the patches separately

clayborg added inline comments.Dec 19 2021, 6:10 PM
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
650–676

Might be easier to use std::string methods to do this:

const size_t idx = m_bytes.find_first_of("+-\x03%$");
if (idx != 0) {
      LLDB_LOGF(log, "GDBRemoteCommunication::%s tossing %u junk bytes: '%.*s'",
                __FUNCTION__, idx, idx, m_bytes.c_str());
      m_bytes.erase(0, idx);
}