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.
Might be easier to use std::string methods to do this: