FreeCalypso > hg > freecalypso-sw
comparison target-utils/libload/cmd_memdump_human.c @ 19:c0e063494194
loadagent built with memory dump commands
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 04 May 2013 00:25:30 +0000 |
parents | |
children | 9ee91bc6057c |
comparison
equal
deleted
inserted
replaced
18:fa3e9a5665bd | 19:c0e063494194 |
---|---|
1 /* | |
2 * This is a human-oriented memory dump command. The dump is given in | |
3 * both hex and ASCII, with readable spacing. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include "types.h" | |
8 | |
9 void | |
10 cmd_memdump_human(argbulk) | |
11 char *argbulk; | |
12 { | |
13 char *argv[3]; | |
14 u_long start, length; | |
15 u_long offset; | |
16 u_char intbuf[16]; | |
17 int i, c; | |
18 | |
19 if (parse_args(argbulk, 2, 2, argv, 0) < 0) | |
20 return; | |
21 if (parse_hexarg(argv[0], 8, &start) < 0) { | |
22 printf("ERROR: arg1 must be a valid 32-bit hex address\n"); | |
23 return; | |
24 } | |
25 if (parse_hexarg(argv[1], 2, &length) < 0) { | |
26 printf("ERROR: arg2 must be a valid 32-bit hex value (length)\n"); | |
27 return; | |
28 } | |
29 if (start & 0xF || length & 0xF) { | |
30 printf("ERROR: implementation limit: 16-byte alignment required\n"); | |
31 return; | |
32 } | |
33 for (offset = 0; offset < length; offset += 0x10) { | |
34 bcopy(start + offset, intbuf, 0x10); | |
35 printf("%08X: ", start + offset); | |
36 for (i = 0; i < 16; i++) { | |
37 printf("%02X ", intbuf[i]); | |
38 if ((i & 3) == 3) | |
39 putchar(' '); | |
40 } | |
41 for (i = 0; i < 16; i++) { | |
42 c = intbuf[i]; | |
43 if (c >= ' ' && c <= '~') | |
44 putchar(c); | |
45 else | |
46 putchar('.'); | |
47 } | |
48 putchar('\n'); | |
49 } | |
50 } |