From: Douglas Miller <dougmill@linux•vnet.ibm.com>
To: linuxppc-dev@lists•ozlabs.org
Subject: [PATCH 1/1] powerpc/xmon: Dump memory in native endian format.
Date: Tue, 7 Feb 2017 07:40:44 -0600 [thread overview]
Message-ID: <1486474844-9872-1-git-send-email-dougmill@linux.vnet.ibm.com> (raw)
Extend dump command to allow display of 2, 4, and 8 byte words in native
endian format. Also adds dump command for "1 byte words" for the sake
of symmetry. New commands are:
d1 dump 8 bit values
d2 dump 16 bit values
d4 dump 32 bit values
d8 dump 64 bit values
Signed-off-by: Douglas Miller <dougmill@linux•vnet.ibm.com>
---
arch/powerpc/xmon/xmon.c | 65 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 9c0e17c..6249975 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -212,6 +212,10 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
"\
C checksum\n\
d dump bytes\n\
+ d1 dump 8 bit values\n\
+ d2 dump 16 bit values\n\
+ d4 dump 32 bit values\n\
+ d8 dump 64 bit values\n\
di dump instructions\n\
df dump float values\n\
dd dump double values\n\
@@ -2334,9 +2338,49 @@ static void dump_pacas(void)
}
#endif
+static void dump_by_size(unsigned long addr, long count, int size)
+{
+ unsigned char temp[16];
+ int i, j;
+ u64 val;
+
+ /*
+ * 'count' was aligned 16. If that changes, the following
+ * must also change to accommodate other values for 'count'.
+ */
+ for (i = 0; i < count; i += 16, addr += 16) {
+ printf(REG, addr);
+
+ if (mread(addr, temp, 16) != 16) {
+ printf("Faulted reading %d bytes from 0x"REG"\n", 16, addr);
+ return;
+ }
+
+ for (j = 0; j < 16; j += size) {
+ putchar(' ');
+ switch (size) {
+ case 1: val = temp[j]; break;
+ case 2: val = *(u16 *)&temp[j]; break;
+ case 4: val = *(u32 *)&temp[j]; break;
+ case 8: val = *(u64 *)&temp[j]; break;
+ default: val = 0;
+ }
+
+ printf("%0*lx", size * 2, val);
+ }
+ printf(" |");
+ for (j = 0; j < 16; ++j) {
+ val = temp[j];
+ putchar(' ' <= val && val <= '~' ? val : '.');
+ }
+ printf("|\n");
+ }
+}
+
static void
dump(void)
{
+ static char last[] = { "d?\n" };
int c;
c = inchar();
@@ -2350,8 +2394,9 @@ static void dump_pacas(void)
}
#endif
- if ((isxdigit(c) && c != 'f' && c != 'd') || c == '\n')
+ if (c == '\n')
termch = c;
+
scanhex((void *)&adrs);
if (termch != '\n')
termch = 0;
@@ -2383,9 +2428,23 @@ static void dump_pacas(void)
ndump = 64;
else if (ndump > MAX_DUMP)
ndump = MAX_DUMP;
- prdump(adrs, ndump);
+
+ switch (c) {
+ case '8':
+ case '4':
+ case '2':
+ case '1':
+ ndump = ALIGN(ndump, 16);
+ dump_by_size(adrs, ndump, c - '0');
+ last[1] = c;
+ last_cmd = last;
+ break;
+ default:
+ prdump(adrs, ndump);
+ last_cmd = "d\n";
+ }
+
adrs += ndump;
- last_cmd = "d\n";
}
}
--
1.7.1
next reply other threads:[~2017-02-07 13:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 13:40 Douglas Miller [this message]
2017-02-08 8:22 ` [PATCH 1/1] powerpc/xmon: Dump memory in native endian format Balbir Singh
2017-02-08 9:18 ` Michael Ellerman
2017-02-10 9:03 ` Balbir Singh
2017-02-21 5:01 ` Michael Ellerman
2017-02-21 13:45 ` Douglas Miller
2017-02-27 10:11 ` [1/1] " Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486474844-9872-1-git-send-email-dougmill@linux.vnet.ibm.com \
--to=dougmill@linux$(echo .)vnet.ibm.com \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox