summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorRoland Hieber <r.hieber@pengutronix.de>2018-11-20 23:57:13 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-11-21 09:54:42 +0100
commit7dab73c677e0e50aed4813f0301241ffead666ce (patch)
treea4aa9cf023d3a96b7c939b45a7dbcdecf27a38f3 /common
parent8ef6940ce9ffff4ccbd87a684b387fa47fc82ab7 (diff)
downloadbarebox-7dab73c677e0e50aed4813f0301241ffead666ce.tar.gz
memory_display: add padding to simplify counting
Trying to count single bytes (e.g. when adding an offset) in 'word' or 'byte' output mode is not easy in the current formatting, and (at least for me) has a high chance of miscounting or losing track of groups: barebox@boardname:/ md -b 0x149983f0+32 149983f0: 18 00 00 00 00 00 0d 86 00 00 00 00 00 00 00 00 ................ 14998400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ barebox@boardname:/ md -w 0x149983f0+32 149983f0: 0018 0000 0000 860d 0000 0000 0000 0000 ................ 14998400: 0000 0000 0000 0000 0000 0000 0000 0000 ................ With an additional space after 8 bytes, counting becomes easier: barebox@boardname:/ md -b 0x149983f0+32 149983f0: 18 00 00 00 00 00 0d 86 00 00 00 00 00 00 00 00 ................ 14998400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ barebox@boardname:/ md -w 0x149983f0+32 149983f0: 0018 0000 0000 860d 0000 0000 0000 0000 ................ 14998400: 0000 0000 0000 0000 0000 0000 0000 0000 ................ The 'quad' and 'long' output modes stay the same and are already much more easier to count because they build bigger and therefore less groups of bytes per line. Signed-off-by: Roland Hieber <r.hieber@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/memory_display.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/memory_display.c b/common/memory_display.c
index ea91985..30821cc 100644
--- a/common/memory_display.c
+++ b/common/memory_display.c
@@ -58,6 +58,8 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int
res = *((uint16_t *)addr);
if (swab)
res = __swab16(res);
+ if (i > 1 && i % 8 == 0)
+ count -= printf(" ");
if (data_abort_unmask()) {
res = 0xffff;
count -= printf(" xxxx");
@@ -69,6 +71,8 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int
uint8_t res;
data_abort_mask();
res = *((uint8_t *)addr);
+ if (i > 1 && i % 8 == 0)
+ count -= printf(" ");
if (data_abort_unmask()) {
res = 0xff;
count -= printf(" xx");