[Pdbg] [PATCH] pdbg: Make getmem always hexdump

Alistair Popple alistair at popple.id.au
Thu Oct 17 16:10:47 AEDT 2019


The getmem command would not hexdump if printable characters were
found. This was useful for dumping text buffers such as the OPAL
console buffer. However when dumping other regions it is still common
for there to be printable characters which results in the output not
getting hexdumped.

Instead always hexdump, raw output can always be obtained using the
`--raw` option.

Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
 src/mem.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/src/mem.c b/src/mem.c
index 53d33b8..2fe5918 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -114,29 +114,11 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci, bo
 	}
 
 	if (count > 0) {
-		uint64_t i;
-		bool printable = true;
-
 		if (raw) {
 			if (write(STDOUT_FILENO, buf, size) < 0)
 				PR_ERROR("Unable to write stdout.\n");
 		} else {
-			for (i=0; i<size; i++) {
-				if (buf[i] == 0x0a || buf[i] == 0x0d || buf[i] == 0)
-					continue;
-
-				if (!isprint(buf[i])) {
-					printable = false;
-					break;
-				}
-			}
-
-			if (!printable) {
-				hexdump(addr, buf, size, 1);
-			} else {
-				if (write(STDOUT_FILENO, buf, size) < 0)
-					PR_ERROR("Unable to write stdout.\n");
-			}
+			hexdump(addr, buf, size, 1);
 		}
 	}
 
-- 
2.20.1



More information about the Pdbg mailing list