summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRic Claus <claus@SLAC.Stanford.edu>2012-02-17 21:29:58 (GMT)
committer Joel Sherrill <joel.sherrill@oarcorp.com>2012-03-30 15:19:18 (GMT)
commit4648adea97face2b819dc0d6ed8706d04974631e (patch)
tree625dc6dec5e413dafb05bb404441867a73f5baed
parent16a86162a231a3d511341bbfa0c8cc663f6f080b (diff)
downloadrtems-4648adea97face2b819dc0d6ed8706d04974631e.tar.bz2
PR 2021 - mdump address problem with volatile
-rw-r--r--cpukit/libmisc/shell/main_mdump.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/cpukit/libmisc/shell/main_mdump.c b/cpukit/libmisc/shell/main_mdump.c
index 156a6f2..df0d955 100644
--- a/cpukit/libmisc/shell/main_mdump.c
+++ b/cpukit/libmisc/shell/main_mdump.c
@@ -31,6 +31,7 @@ static int args_parse(int argc, char* argv[], void** addr, int* max, int* sz);
static void mdumpB(void* addr, int m);
static void mdumpW(void* addr, int m);
static void mdumpL(void* addr, int m);
+static void mdumpC(void* addr, int m);
int rtems_mdump(void* addr, int max, int sz);
@@ -43,7 +44,7 @@ int rtems_shell_main_mdump(
int max;
int sz;
- if (args_parse(argc, argv, &addr, &max, &sz))
+ if (args_parse(argc, argv, &addr, &max, &sz))
return -1;
return rtems_mdump(addr, max, sz);
}
@@ -114,11 +115,10 @@ int args_parse(int argc,
int rtems_mdump(void* addr, int max, int sz)
{
- unsigned char n;
- unsigned char m;
- volatile unsigned char *pb;
- int res;
- int cnt;
+ unsigned char m;
+ unsigned char *pb;
+ int res;
+ int cnt;
if (!((sz == 1) || (sz == 2) || (sz == 4))) {
printf( "Size argument (%d) is not one of 1 (bytes), "
@@ -147,9 +147,7 @@ int rtems_mdump(void* addr, int max, int sz)
if (sz == 1) mdumpB(pb, cnt);
else if (sz == 2) mdumpW(pb, cnt);
else if (sz == 4) mdumpL(pb, cnt);
- for (n=0;n<=cnt;n++) {
- printf("%c", isprint(pb[n]) ? pb[n] : '.');
- }
+ mdumpC(pb, cnt);
printf("\n");
pb += 16;
}
@@ -191,6 +189,15 @@ void mdumpL(void* addr, int m)
}
+void mdumpC(void* addr, int m)
+{
+ volatile unsigned char* pb = addr;
+ int n;
+ for (n=0;n<=m;n++)
+ printf("%c", isprint(pb[n]) ? pb[n] : '.');
+}
+
+
rtems_shell_cmd_t rtems_shell_MDUMP_Command = {
"mdump", /* name */
"mdump [address [length [size]]]", /* usage */