From 11560dc0a685affd607eae0d5b005ba4f003423c Mon Sep 17 00:00:00 2001
From: Ric Claus <claus@SLAC.Stanford.edu>
Date: Fri, 17 Feb 2012 13:29:58 -0800
Subject: [PATCH 2/7] Fixed problem with 'volatile'
---
cpukit/libmisc/shell/main_mdump.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/cpukit/libmisc/shell/main_mdump.c b/cpukit/libmisc/shell/main_mdump.c
index 156a6f2..85b690b 100644
a
|
b
|
|
10 | 10 | * The license and distribution terms for this file may be |
11 | 11 | * found in the file LICENSE in this distribution or at |
12 | 12 | * http://www.rtems.com/license/LICENSE. |
| 13 | * |
| 14 | * $Id:$ |
13 | 15 | */ |
14 | 16 | |
15 | 17 | #ifdef HAVE_CONFIG_H |
… |
… |
static int args_parse(int argc, char* argv[], void** addr, int* max, int* sz); |
31 | 33 | static void mdumpB(void* addr, int m); |
32 | 34 | static void mdumpW(void* addr, int m); |
33 | 35 | static void mdumpL(void* addr, int m); |
| 36 | static void mdumpC(void* addr, int m); |
34 | 37 | |
35 | 38 | int rtems_mdump(void* addr, int max, int sz); |
36 | 39 | |
… |
… |
int rtems_shell_main_mdump( |
43 | 46 | int max; |
44 | 47 | int sz; |
45 | 48 | |
46 | | if (args_parse(argc, argv, &addr, &max, &sz)) |
| 49 | if (args_parse(argc, argv, &addr, &max, &sz)) |
47 | 50 | return -1; |
48 | 51 | return rtems_mdump(addr, max, sz); |
49 | 52 | } |
… |
… |
int args_parse(int argc, |
114 | 117 | |
115 | 118 | int rtems_mdump(void* addr, int max, int sz) |
116 | 119 | { |
117 | | unsigned char n; |
118 | | unsigned char m; |
119 | | volatile unsigned char *pb; |
120 | | int res; |
121 | | int cnt; |
| 120 | unsigned char m; |
| 121 | unsigned char *pb; |
| 122 | int res; |
| 123 | int cnt; |
122 | 124 | |
123 | 125 | if (!((sz == 1) || (sz == 2) || (sz == 4))) { |
124 | 126 | printf( "Size argument (%d) is not one of 1 (bytes), " |
… |
… |
int rtems_mdump(void* addr, int max, int sz) |
147 | 149 | if (sz == 1) mdumpB(pb, cnt); |
148 | 150 | else if (sz == 2) mdumpW(pb, cnt); |
149 | 151 | else if (sz == 4) mdumpL(pb, cnt); |
150 | | for (n=0;n<=cnt;n++) { |
151 | | printf("%c", isprint(pb[n]) ? pb[n] : '.'); |
152 | | } |
| 152 | mdumpC(pb, cnt); |
153 | 153 | printf("\n"); |
154 | 154 | pb += 16; |
155 | 155 | } |
… |
… |
void mdumpL(void* addr, int m) |
191 | 191 | } |
192 | 192 | |
193 | 193 | |
| 194 | void mdumpC(void* addr, int m) |
| 195 | { |
| 196 | volatile unsigned char* pb = addr; |
| 197 | int n; |
| 198 | for (n=0;n<=m;n++) |
| 199 | printf("%c", isprint(pb[n]) ? pb[n] : '.'); |
| 200 | } |
| 201 | |
| 202 | |
194 | 203 | rtems_shell_cmd_t rtems_shell_MDUMP_Command = { |
195 | 204 | "mdump", /* name */ |
196 | 205 | "mdump [address [length [size]]]", /* usage */ |