Page MenuHomeFreeBSD

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

Authored by on Dec 28 2021, 10:43 PM.
Referenced Files
Unknown Object (File)
Sat, Mar 11, 4:15 AM
Unknown Object (File)
Thu, Mar 2, 4:01 PM
Unknown Object (File)
Feb 11 2023, 7:40 PM
Unknown Object (File)
Feb 9 2023, 2:52 PM
Unknown Object (File)
Dec 12 2022, 2:10 AM



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

Lint Skipped
Tests Skipped

Event Timeline 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.


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) {
	cksum += c;

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


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.


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). marked 2 inline comments as done. 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.