Page MenuHomeFreeBSD

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

Authored by mgorny_gentoo.org on Dec 28 2021, 10:43 PM.

Details

Summary

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.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mgorny_gentoo.org created this revision.
This revision is now accepted and ready to land.Dec 28 2021, 10:52 PM

I don't have commit access. Could you push it for me, please?

I’m hoping emaste will be able to test and commit it.

sys/gdb/gdb_packet.c
319

It took me a moment to understand the intent here -- do you think this might be even more clear?

while (runlen == 1 || runlen == 2 || runlen == 6 || runlen == 7 || runlen == 14 || runlen == 16) {
	gdb_cur->gdb_putc(c);
	cksum += c;
	runlen--;
}

or even runlen == 1 || runlen = 2 || runlen + 29 == '$' || runlen + 29 == '#' || ...?

sys/gdb/gdb_packet.c
319

Yes, I was thinking of replacing it with while but it would add at least one extra iteration of checks for every symbol, wouldn't it? I mean, if that cost is fine, I can do it.

sys/gdb/gdb_packet.c
319

I don't think so, the only extra work is the addition of a few extraneous tests (e.g. if runlen starts at 7 we'd have a few comparisons that happen twice instead of once).

mgorny_gentoo.org marked 2 inline comments as done.
mgorny_gentoo.org edited the summary of this revision. (Show Details)

Use a while loop.

This revision now requires review to proceed.Jan 2 2022, 11:21 PM
This revision is now accepted and ready to land.Jan 2 2022, 11:44 PM

I have staged in my wip branch and will push to main soon.