debug_dump: improved printout

- use 'h' suffix when len printed in hexa
- for missing bytes at the end (not aligned to 16 B) print 2 spaces
instead of 1, because it stands for 2 nibbles. Otherwise the ASCII
representation would be moved left (the muber of chars didn't match).
This commit is contained in:
Martin Pulec
2024-09-03 09:26:38 +02:00
parent 33675df8f6
commit 5aa5261dda

View File

@@ -183,7 +183,7 @@ void debug_dump(const void *lp, int len)
char Buff[81];
char tmpBuf[10];
_dprintf("Dump of %d=%x bytes\n", len, len);
_dprintf("Dump of %d=%xh bytes\n", len, len);
start = 0L;
while (start < len) {
/* start line with pointer position key */
@@ -196,7 +196,7 @@ void debug_dump(const void *lp, int len)
snprintf(tmpBuf, sizeof tmpBuf, "%02X", ((int)(*p) & 0xFF));
strcat(Buff, tmpBuf);
} else
strcat(Buff, " ");
strcat(Buff, " ");
if (j % 2 == 1) /* space between groups of 2 */
strcat(Buff, " ");
if (j == 7) /* space between groups of 8 */