From 580f28da6d340979c78174e4e1cb7cc17002f735 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Wed, 11 May 2022 17:48:53 +0200 Subject: [PATCH] kernel debug: rewrite dump_block to use a single dprintf call In the syslog, each dprintf call is prefixed with a KERN: prefix, rendering the dump unreadable. Bufferize things to print each line with a single call. Change-Id: I27c1b1f74434fbc6e554acb0a716f0700821bc8d Reviewed-on: https://review.haiku-os.org/c/haiku/+/5305 Reviewed-by: Adrien Destugues --- src/system/kernel/debug/debug.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/system/kernel/debug/debug.cpp b/src/system/kernel/debug/debug.cpp index ef0c6ee30a..a8ae4dee20 100644 --- a/src/system/kernel/debug/debug.cpp +++ b/src/system/kernel/debug/debug.cpp @@ -2329,33 +2329,34 @@ dump_block(const char* buffer, int size, const char* prefix) { const int DUMPED_BLOCK_SIZE = 16; int i; + char lineBuffer[3 + DUMPED_BLOCK_SIZE * 4]; for (i = 0; i < size;) { + char* pointer = lineBuffer; int start = i; - dprintf("%s%04x ", prefix, i); for (; i < start + DUMPED_BLOCK_SIZE; i++) { if (!(i % 4)) - dprintf(" "); + pointer += sprintf(pointer, " "); if (i >= size) - dprintf(" "); + pointer += sprintf(pointer, " "); else - dprintf("%02x", *(unsigned char*)(buffer + i)); + pointer += sprintf(pointer, "%02x", *(unsigned char*)(buffer + i)); } - dprintf(" "); + pointer += sprintf(pointer, " "); for (i = start; i < start + DUMPED_BLOCK_SIZE; i++) { if (i < size) { char c = buffer[i]; if (c < 30) - dprintf("."); + pointer += sprintf(pointer, "."); else - dprintf("%c", c); + pointer += sprintf(pointer, "%c", c); } else break; } - dprintf("\n"); + dprintf("%s%04x%s\n", prefix, start, lineBuffer); } }