git: 4fa8cb965e73 - stable/12 - gdb(4): Do not use run length encoding for 3-symbol repetitions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 05 Feb 2022 01:59:03 UTC
The branch stable/12 has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=4fa8cb965e73421df00ac5c724aa27b8a117fc32
commit 4fa8cb965e73421df00ac5c724aa27b8a117fc32
Author: Michał Górny <mgorny@gentoo.org>
AuthorDate: 2022-01-10 03:03:46 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-02-05 01:15:50 +0000
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
(cherry picked from commit 028a372fe2658ccf72ed481b9e942b28a59cb178)
---
sys/gdb/gdb_packet.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/sys/gdb/gdb_packet.c b/sys/gdb/gdb_packet.c
index c74eaaa855b3..32a80a7643e0 100644
--- a/sys/gdb/gdb_packet.c
+++ b/sys/gdb/gdb_packet.c
@@ -254,24 +254,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);