forked from Imagelibrary/rtems
2008-10-01 Gene Smith <gene.smith@siemens.com>
PR 1328/cpukit * libmisc/shell/main_mdump.c, libmisc/shell/main_mwdump.c: Fix printing of more than 256 bytes.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2008-10-01 Gene Smith <gene.smith@siemens.com>
|
||||||
|
|
||||||
|
PR 1328/cpukit
|
||||||
|
* libmisc/shell/main_mdump.c, libmisc/shell/main_mwdump.c: Fix printing
|
||||||
|
of more than 256 bytes.
|
||||||
|
|
||||||
2008-09-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
2008-09-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
* libi2c/libi2c.h: Added definitions for asynchronous read and write IO
|
* libi2c/libi2c.h: Added definitions for asynchronous read and write IO
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ int rtems_shell_main_mdump(
|
|||||||
char *argv[]
|
char *argv[]
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned char n, m, max=20;
|
unsigned char n, m;
|
||||||
|
int max;
|
||||||
|
int res;
|
||||||
uintptr_t addr = 0;
|
uintptr_t addr = 0;
|
||||||
unsigned char *pb;
|
unsigned char *pb;
|
||||||
|
|
||||||
@@ -43,19 +45,34 @@ int rtems_shell_main_mdump(
|
|||||||
|
|
||||||
if (argc>2) {
|
if (argc>2) {
|
||||||
max = rtems_shell_str2int(argv[2]);
|
max = rtems_shell_str2int(argv[2]);
|
||||||
max /= 16;
|
if (max <= 0) {
|
||||||
|
max = 1; /* print 1 item if 0 or neg. */
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
max--;
|
||||||
|
res = max & 0xf;/* num bytes in last row */
|
||||||
|
max >>= 4; /* div by 16 */
|
||||||
|
max++; /* num of rows to print */
|
||||||
|
if (max > 20) { /* limit to 20 */
|
||||||
|
max = 20;
|
||||||
|
res = 0xf; /* 16 bytes print in last row */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
max = 20;
|
||||||
|
res = 0xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!max)
|
|
||||||
max = 1;
|
|
||||||
|
|
||||||
for (m=0; m<max; m++) {
|
for (m=0; m<max; m++) {
|
||||||
printf("0x%08" PRIXPTR " ", addr);
|
printf("0x%08" PRIXPTR " ", addr);
|
||||||
pb = (unsigned char*) addr;
|
pb = (unsigned char*) addr;
|
||||||
for (n=0;n<16;n++)
|
for (n=0;n<=(m==(max-1)?res:0xf);n++)
|
||||||
printf("%02X%c", pb[n], (n == 7) ? '-' : ' ');
|
printf("%02X%c",pb[n],n==7?'-':' ');
|
||||||
for (n=0;n<16;n++) {
|
for (;n<=0xf;n++)
|
||||||
|
printf(" %c",n==7?'-':' ');
|
||||||
|
for (n=0;n<=(m==(max-1)?res:0xf);n++) {
|
||||||
printf("%c", isprint(pb[n]) ? pb[n] : '.');
|
printf("%c", isprint(pb[n]) ? pb[n] : '.');
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|||||||
@@ -30,30 +30,46 @@ int rtems_shell_main_mwdump(
|
|||||||
char *argv[]
|
char *argv[]
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned char n, m, max=20;
|
unsigned char n, m;
|
||||||
|
int max;
|
||||||
|
int res;
|
||||||
uintptr_t addr = 0;
|
uintptr_t addr = 0;
|
||||||
unsigned short *pw;
|
unsigned char *pb;
|
||||||
unsigned char *p;
|
|
||||||
|
|
||||||
if (argc>1)
|
if (argc>1)
|
||||||
addr = rtems_shell_str2int(argv[1]);
|
addr = rtems_shell_str2int(argv[1]);
|
||||||
|
|
||||||
if (argc>2) {
|
if (argc>2) {
|
||||||
max = rtems_shell_str2int(argv[2]);
|
max = rtems_shell_str2int(argv[2]);
|
||||||
max /= 16;
|
if (max <= 0) {
|
||||||
|
max = 1; /* print 1 item if 0 or neg. */
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
max--;
|
||||||
|
res = max & 0xf;/* num bytes in last row */
|
||||||
|
max >>= 4; /* div by 16 */
|
||||||
|
max++; /* num of rows to print */
|
||||||
|
if (max > 20) { /* limit to 20 */
|
||||||
|
max = 20;
|
||||||
|
res = 0xf; /* 16 bytes print in last row */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
max = 20;
|
||||||
|
res = 0xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!max)
|
|
||||||
max = 1;
|
|
||||||
|
|
||||||
for (m=0;m<max;m++) {
|
for (m=0;m<max;m++) {
|
||||||
printf("0x%08" PRIXPTR " ",addr);
|
printf("0x%08" PRIXPTR " ",addr);
|
||||||
p = (unsigned char *) addr;
|
pb = (unsigned char *) addr;
|
||||||
pw = (unsigned short*) addr;
|
for (n=0;n<=(m==(max-1)?res:0xf);n+=2)
|
||||||
for (n=0;n<8;n++)
|
printf("%04X%c",*((unsigned short*)(pb+n)),n==6?'-':' ');
|
||||||
printf("%04X%c",pw[n],n==3?'-':' ');
|
for (;n<=0xf;n+=2)
|
||||||
for (n=0;n<16;n++) {
|
printf(" %c", n==6?'-':' ');
|
||||||
printf("%c",isprint(p[n])?p[n]:'.');
|
for (n=0;n<=(m==(max-1)?res:0xf);n++) {
|
||||||
|
printf("%c", isprint(pb[n]) ? pb[n] : '.');
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
addr += 16;
|
addr += 16;
|
||||||
|
|||||||
Reference in New Issue
Block a user