1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-03 09:00:21 +00:00

gdb(4): Do not use run length encoding for 3-symbol repetitions

Disable the gdb packet run length encoding for 3-symbol repetitions.
While it is technically possible to encode them, they have no advantage
over sending the characters verbatim (the resulting length is the same)
and they result in sending non-printable \x1f character.  The protocol
has been designed with the intent of avoiding non-printable characters
and therefore the run length encoding is biased to emit \x20 (a space)
with the minimal intended run length of 4.

While at it, simplify the logic by merging the different 'if' blocks
into a single while loop, and moving 'runlen == 0' check lower.

Reviewed by:	cem, emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33686
This commit is contained in:
Michał Górny 2022-01-09 22:03:46 -05:00 committed by Ed Maste
parent 6f6fbfa3a8
commit 028a372fe2

View File

@ -315,24 +315,16 @@ gdb_tx_end(void)
runlen--;
}
}
if (runlen == 1) {
/* Don't emit '$', '#', '+', '-' or a run length below 3. */
while (runlen == 1 || runlen == 2 ||
runlen + 29 == '$' || runlen + 29 == '#' ||
runlen + 29 == '+' || runlen + 29 == '-') {
gdb_cur->gdb_putc(c);
cksum += c;
runlen--;
}
if (runlen == 0)
continue;
/* Don't emit '$', '#', '+' or '-'. */
if (runlen == 7) {
gdb_cur->gdb_putc(c);
cksum += c;
runlen--;
}
if (runlen == 6 || runlen == 14 || runlen == 16) {
gdb_cur->gdb_putc(c);
cksum += c;
runlen--;
}
gdb_cur->gdb_putc('*');
cksum += '*';
gdb_cur->gdb_putc(runlen+29);