Hi,
I recent make a patch which give the rd command to dump the raw data. With this,
we could then do the dump the specified range of memory to the file with console's
redirection feature like: rd -r 0x7000000 -e 0x8000000 > dump.img.
What about this idea? Could it be accepted?
Thanks,
Lei
I think it's a pretty good idea.
However, one problem with the patch is that if you forget to append
the "> dump.img" part, it would end up spewing non-ASCII data to
the terminal. I would suggest using a construct like "-r dump.img",
which would force the user to supply a filename argument with
the -r.
Also, maybe you could write a more efficient output function that
ignores the "typesz", and fwrite()'s larger fixed-size blocks of
data until it reaches the end of the desired memory chunk.
Thanks,
Dave
>From f60eee5520993d823cf705ecea62b8d60166f3ae Mon Sep 17
00:00:00
>2001
From: Lei Wen <leiwen(a)marvell.com>
Date: Thu, 29 Sep 2011 20:03:29 -0700
Subject: [PATCH] rd: add option to dump the raw format
Signed-off-by: Lei Wen <leiwen(a)marvell.com>
---
help.c | 3 ++-
memory.c | 13 ++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/help.c b/help.c
index b8db00a..987bd95 100755
--- a/help.c
+++ b/help.c
@@ -1396,7 +1396,7 @@ NULL
char *help_rd[] = {
"rd",
"read memory",
-"[-adDsSupxmfN][-8|-16|-32|-64][-o offs][-e addr] [address|symbol]
[count]",
+"[-adDsSupxrmfN][-8|-16|-32|-64][-o offs][-e addr] [address|symbol]
[count]",
" This command displays the contents of memory, with the output
formatted",
" in several different manners. The starting address may be
entered either",
" symbolically or by address. The default output size is the size
of a long",
@@ -1426,6 +1426,7 @@ char *help_rd[] = {
" non-printable character.",
" -N display output in network byte order (only valid for 16-
and 32-bit",
" values)",
+" -r dump the address as raw format",
" -o offs offset the starting address by offs.",
" -e addr display memory until reaching specified ending
hexadecimal address.",
" address starting hexadecimal address:",
diff --git a/memory.c b/memory.c
index 9575d8e..985e2ec 100755
--- a/memory.c
+++ b/memory.c
@@ -264,6 +264,7 @@ static void dump_page_flags(ulonglong);
#define SLAB_CACHE (0x1000)
#define DISPLAY_ASCII (0x2000)
#define NET_ENDIAN (0x4000)
+#define DISPLAY_RAW (0x8000)
#define DISPLAY_TYPES
(DISPLAY_ASCII|DISPLAY_8|DISPLAY_16|DISPLAY_32|DISPLAY_64)
#define ASCII_UNLIMITED ((ulong)(-1) >> 1)
@@ -973,9 +974,12 @@ cmd_rd(void)
memtype = KVADDR;
count = -1;
- while ((c = getopt(argcnt, args, "axme:pfudDusSNo:81:3:6:"))
!= EOF) {
+ while ((c = getopt(argcnt, args,
"raxme:pfudDusSNo:81:3:6:")) != EOF) {
switch(c)
{
+ case 'r':
+ flag |= DISPLAY_RAW;
+ break;
case 'a':
flag &= ~DISPLAY_TYPES;
flag |= DISPLAY_ASCII;
@@ -1291,6 +1295,13 @@ display_memory(ulonglong addr, long count,
ulong flag, int memtype)
for (i = a = 0; i < count; i++) {
readmem(addr, memtype, location, typesz,
readtype, FAULT_ON_ERROR);
+ if (flag & DISPLAY_RAW) {
+ for (j = 0; j < typesz; j++)
+ fputc(*(char *)(location + j), fp);
+
+ addr += typesz;
+ continue;
+ }
if (!(flag & DISPLAY_ASCII) && ((i % per_line) ==
0)) {
if (i) {
--
1.7.0.4
--
Crash-utility mailing list
Crash-utility(a)redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility