#include <xinu.h>
#include <string.h>
#include <stdio.h>
Go to the source code of this file.
◆ parseval()
static uint32 parseval |
( |
char * |
string | ) |
|
|
static |
Definition at line 126 of file xsh_memdump.c.
References NULLCH.
Referenced by xsh_memdump().
141 if (*
string++ !=
'x') {
144 for (ch = *
string++; ch !=
NULLCH; ch = *
string++) {
145 if ((ch >=
'0') && (ch <=
'9') ) {
146 value = 16*value + (ch -
'0');
147 }
else if ((ch >=
'a') && (ch <=
'f') ) {
148 value = 16*value + 10 + (ch -
'a');
149 }
else if ((ch >=
'A') && (ch <=
'F') ) {
150 value = 16*value + 10 + (ch -
'A');
157 if ( (ch <
'0') || (ch >
'9') ) {
160 value = 10*value + (ch -
'0');
unsigned int uint32
符号なし32ビット整数(unsigned int)
#define NULLCH
NULL文字(NULL終端)
◆ xsh_memdump()
shellcmd xsh_memdump |
( |
int |
nargs, |
|
|
char * |
args[] |
|
) |
| |
Definition at line 15 of file xsh_memdump.c.
References FALSE, fprintf(), maxheap, parseval(), printf(), start, stderr, stop(), strncmp(), and TRUE.
30 if (nargs == 2 &&
strncmp(args[1],
"--help", 7) == 0) {
31 printf(
"Use: %s [-f] Address Length\n\n", args[0]);
33 printf(
"\tDumps Length bytes of memory begining at the\n");
34 printf(
"\tspecified starting address (both the address\n");
35 printf(
"\tand length can be specified in decimal or hex)\n");
37 printf(
"\t-f ignore sanity checks for addresses\n");
38 printf(
"\tAddress memory address at which to start\n");
39 printf(
"\tLength the number of bytes to dump\n");
40 printf(
"\t--help display this help and exit\n");
46 if (nargs < 3 || nargs > 4) {
55 if (
strncmp(args[arg],
"-f", 2) == 0) {
68 if ( (begin=
parseval(args[arg])) == 0 ) {
73 if ( (length =
parseval(args[arg+1])) == 0 ) {
83 length = (length + 3) & ~0x3;
87 stop = begin + length;
91 if ( force || ( (begin >= (
uint32)&
start) && (stop > begin) &&
96 chptr = (
char *)begin;
97 for (l=0; l<length; l+=16) {
100 for (i=0; i<4; i++) {
104 for (i=0; i<16; i++) {
106 if ( (ch >= 0x20) && (ch <= 0x7e) ) {
117 printf(
"Values are out of range; use -f to force\n");
int32 strncmp(const char *, const char *, int32)
int32 printf(const char *,...)
int32 stop(char *s)
処理を停止させる。無限ループによる停止のため、復帰にはリセットが必要である。
#define FALSE
Boolean False(0)
#define TRUE
Boolean True(1)
void * maxheap
最上位かつ正常なヒープアドレス
int int32
符号あり32ビット整数(int)
int32 fprintf(int, char *,...)
unsigned int uint32
符号なし32ビット整数(unsigned int)
static uint32 parseval(char *)
◆ start