Re: [PATCH 2/2] hexdump: Allow skipping identical lines

From: Andy Shevchenko
Date: Mon Aug 26 2024 - 13:35:54 EST


On Mon, Aug 26, 2024 at 06:24:16PM +0200, Miquel Raynal wrote:
> When dumping long buffers (especially for debug purposes) it may be very
> convenient to sometimes avoid spitting all the lines of the buffer if
> the lines are identical. Typically on embedded devices, the console
> would be wired to a UART running at 115200 bauds, which makes the dumps
> very (very) slow. In this case, having a flag to avoid printing
> duplicated lines is handy.
>
> Example of a made up repetitive output:
> 0f 53 63 47 56 55 78 7a aa b7 8c ff ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff 01 2a 39 eb
>
> Same but with the flag enabled:
> 0f 53 63 47 56 55 78 7a aa b7 8c ff ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> *
> ff ff ff ff ff ff ff ff ff ff ff ff 01 2a 39 eb

The problem here is that without offset we can't see how many lines were
skipped.

Two ways to solve (that come to my mind immediately, maybe more and better):
1) make sure that new flag implies or expects (otherwise BUILD_BUG_ON() or so)
the OFFSET to be set;
2) [OR] add number of lines skipped in that * line.

Personally I prefer the 1) as I think that you tried to follow the existing
format of user space tools and there is a chance that there are other tools or
scripts that parse the dump to restore the binary contents.

--
With Best Regards,
Andy Shevchenko