Add a generic hexdump tool for debugging purposes.
This commit is contained in:
parent
66411419a6
commit
acd1d918fe
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=39472
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bootstrap.h,v 1.4 1998/09/04 02:43:26 msmith Exp $
|
||||
* $Id: bootstrap.h,v 1.5 1998/09/14 18:27:04 msmith Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -65,6 +65,7 @@ extern int autoboot(int delay, char *prompt);
|
||||
|
||||
/* misc.c */
|
||||
extern char *unargv(int argc, char *argv[]);
|
||||
extern void hexdump(caddr_t region, size_t len);
|
||||
extern size_t strlenout(vm_offset_t str);
|
||||
extern char *strdupout(vm_offset_t str);
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: misc.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $
|
||||
* $Id: misc.c,v 1.2 1998/09/03 02:10:07 msmith Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
@ -87,3 +87,43 @@ strdupout(vm_offset_t str)
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Display a region in traditional hexdump format.
|
||||
*/
|
||||
void
|
||||
hexdump(caddr_t region, size_t len)
|
||||
{
|
||||
caddr_t line;
|
||||
int x, c;
|
||||
char lbuf[80];
|
||||
#define emit(fmt, args...) {sprintf(lbuf, fmt , ## args); pager_output(lbuf);}
|
||||
|
||||
pager_open();
|
||||
for (line = region; line < (region + len); line += 16) {
|
||||
emit("%08x ", line);
|
||||
|
||||
for (x = 0; x < 16; x++) {
|
||||
if ((line + x) < (region + len)) {
|
||||
emit("%02x ", *(u_int8_t *)(line + x));
|
||||
} else {
|
||||
emit("-- ");
|
||||
}
|
||||
if (x == 7)
|
||||
emit(" ");
|
||||
}
|
||||
emit(" |");
|
||||
for (x = 0; x < 16; x++) {
|
||||
if ((line + x) < (region + len)) {
|
||||
c = *(u_int8_t *)(line + x);
|
||||
if ((c < ' ') || (c > '~')) /* !isprint(c) */
|
||||
c = '.';
|
||||
emit("%c", c);
|
||||
} else {
|
||||
emit(" ");
|
||||
}
|
||||
}
|
||||
emit("|\n");
|
||||
}
|
||||
pager_close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user