sys/ddb/db_examine.c
static void
db_examine(db_addr_t addr, char *fmt, int count)
{
	int		c;
	db_expr_t	value;
	int		size;
	int		width;
	char *		fp;
	char		tbuf[24];

	while (--count >= 0) {
	    fp = fmt;
	    size = 4;
	    width = 16;
	    while ((c = *fp++) != 0) {
		switch (c) {
		    case 'b':
			size = 1;
			width = 4;
			break;
		    case 'h':
			size = 2;
			width = 8;
			break;
		    case 'l':
			size = 4;
			width = 16;
			break;
		    case 'g':
			size = 8;
			width = 32;
			break;
		    case 'a':	/* address */
			/* always forces a new line */
			if (db_print_position() != 0)
			    db_printf("\n");
			db_prev = addr;
			db_printsym(addr, DB_STGY_ANY);
			db_printf(":\t");
			break;
		    default:
			if (db_print_position() == 0) {
			    /* Print the address. */
			    db_printsym(addr, DB_STGY_ANY);
			    db_printf(":\t");
			    db_prev = addr;
			}

			switch (c) {
			    case 'r':	/* signed, current radix */
				value = db_get_value(addr, size, TRUE);
				addr += size;
				db_printf("%+-*lr", width, (long)value);
				break;
			    case 'x':	/* unsigned hex */
				value = db_get_value(addr, size, FALSE);
				addr += size;
				db_printf("%-*lx", width, (long)value);
				break;
			    case 'z':	/* signed hex */
				value = db_get_value(addr, size, TRUE);
				addr += size;
				db_format_hex(tbuf, 24, value, FALSE);
				db_printf("%-*s", width, tbuf);
				break;
			    case 'd':	/* signed decimal */
				value = db_get_value(addr, size, TRUE);
				addr += size;
				db_printf("%-*ld", width, (long)value);
				break;
			    case 'u':	/* unsigned decimal */
				value = db_get_value(addr, size, FALSE);
				addr += size;
				db_printf("%-*lu", width, (long)value);
				break;
			    case 'o':	/* unsigned octal */
				value = db_get_value(addr, size, FALSE);
				addr += size;
				db_printf("%-*lo", width, (long)value);
				break;
			    case 'c':	/* character */
				value = db_get_value(addr, 1, FALSE);
				addr += 1;
				if (value >= ' ' && value <= '~')
				    db_printf("%c", (int)value);
				else
				    db_printf("\\%03o", (int)value);
				break;
			    case 's':	/* null-terminated string */
				for (;;) {
				    value = db_get_value(addr, 1, FALSE);
				    addr += 1;
				    if (value == 0)
					break;
				    if (value >= ' ' && value <= '~')
					db_printf("%c", (int)value);
				    else
					db_printf("\\%03o", (int)value);
				}
				break;
			    case 'i':	/* instruction */
				addr = db_disasm(addr, FALSE, NULL);
				break;
			    case 'I':	/* instruction, alternate form */
				addr = db_disasm(addr, TRUE, NULL);
				break;
			    default:
				break;
			}
			if (db_print_position() != 0)
			    db_end_line();
			break;
		}
	    }
	}
	db_next = addr;
}
/*
 * Parameters:
 *     fmt:	format string
 *     count:	repeat count
 */
format string
count:   repeat count
format string count : repeat count
static void
db_examine(db_addr_t addr, char *fmt, int count)
{
	int		c;
	db_expr_t	value;
	int		size;
	int		width;
	char *		fp;
	char		tbuf[24];
	while (--count >= 0) {
	    fp = fmt;
	    size = 4;
	    width = 16;
	    while ((c = *fp++) != 0) {
		switch (c) {
		    case 'b':
			size = 1;
			width = 4;
			break;
		    case 'h':
			size = 2;
			width = 8;
			break;
		    case 'l':
			size = 4;
			width = 16;
			break;
		    case 'g':
			size = 8;
			width = 32;
			break;
		    case 'a':	
			if (db_print_position() != 0)
			    db_printf("\n");
			db_prev = addr;
			db_printsym(addr, DB_STGY_ANY);
			db_printf(":\t");
			break;
		    default:
			if (db_print_position() == 0) {
			    db_printsym(addr, DB_STGY_ANY);
			    db_printf(":\t");
			    db_prev = addr;
			}
			switch (c) {
			    case 'r':	
				value = db_get_value(addr, size, TRUE);
				addr += size;
				db_printf("%+-*lr", width, (long)value);
				break;
			    case 'x':	
				value = db_get_value(addr, size, FALSE);
				addr += size;
				db_printf("%-*lx", width, (long)value);
				break;
			    case 'z':	
				value = db_get_value(addr, size, TRUE);
				addr += size;
				db_format_hex(tbuf, 24, value, FALSE);
				db_printf("%-*s", width, tbuf);
				break;
			    case 'd':	
				value = db_get_value(addr, size, TRUE);
				addr += size;
				db_printf("%-*ld", width, (long)value);
				break;
			    case 'u':	
				value = db_get_value(addr, size, FALSE);
				addr += size;
				db_printf("%-*lu", width, (long)value);
				break;
			    case 'o':	
				value = db_get_value(addr, size, FALSE);
				addr += size;
				db_printf("%-*lo", width, (long)value);
				break;
			    case 'c':	
				value = db_get_value(addr, 1, FALSE);
				addr += 1;
				if (value >= ' ' && value <= '~')
				    db_printf("%c", (int)value);
				else
				    db_printf("\\%03o", (int)value);
				break;
			    case 's':	
				for (;;) {
				    value = db_get_value(addr, 1, FALSE);
				    addr += 1;
				    if (value == 0)
					break;
				    if (value >= ' ' && value <= '~')
					db_printf("%c", (int)value);
				    else
					db_printf("\\%03o", (int)value);
				}
				break;
			    case 'i':	
				addr = db_disasm(addr, FALSE, NULL);
				break;
			    case 'I':	
				addr = db_disasm(addr, TRUE, NULL);
				break;
			    default:
				break;
			}
			if (db_print_position() != 0)
			    db_end_line();
			break;
		}
	    }
	}
	db_next = addr;
}
static void db_examine ( db_addr_t addr , char * fmt , int count ) { int c ; db_expr_t value ; int size ; int width ; char * fp ; char tbuf [ 24 ] ; while ( -- count >= 0 ) { fp = fmt ; size = 4 ; width = 16 ; while ( ( c = * fp ++ ) != 0 ) { switch ( c ) { case ' ' : size = 1 ; width = 4 ; break ; case ' ' : size = 2 ; width = 8 ; break ; case ' ' : size = 4 ; width = 16 ; break ; case ' ' : size = 8 ; width = 32 ; break ; case ' ' : if ( db_print_position ( ) != 0 ) db_printf ( " \n " ) ; db_prev = addr ; db_printsym ( addr , DB_STGY_ANY ) ; db_printf ( " \t " ) ; break ; default : if ( db_print_position ( ) == 0 ) { db_printsym ( addr , DB_STGY_ANY ) ; db_printf ( " \t " ) ; db_prev = addr ; } switch ( c ) { case ' ' : value = db_get_value ( addr , size , TRUE ) ; addr += size ; db_printf ( " " , width , ( long ) value ) ; break ; case ' ' : value = db_get_value ( addr , size , FALSE ) ; addr += size ; db_printf ( " " , width , ( long ) value ) ; break ; case ' ' : value = db_get_value ( addr , size , TRUE ) ; addr += size ; db_format_hex ( tbuf , 24 , value , FALSE ) ; db_printf ( " " , width , tbuf ) ; break ; case ' ' : value = db_get_value ( addr , size , TRUE ) ; addr += size ; db_printf ( " " , width , ( long ) value ) ; break ; case ' ' : value = db_get_value ( addr , size , FALSE ) ; addr += size ; db_printf ( " " , width , ( long ) value ) ; break ; case ' ' : value = db_get_value ( addr , size , FALSE ) ; addr += size ; db_printf ( " " , width , ( long ) value ) ; break ; case ' ' : value = db_get_value ( addr , 1 , FALSE ) ; addr += 1 ; if ( value >= ' ' && value <= ' ' ) db_printf ( " " , ( int ) value ) ; else db_printf ( " \\ " , ( int ) value ) ; break ; case ' ' : for ( ; ; ) { value = db_get_value ( addr , 1 , FALSE ) ; addr += 1 ; if ( value == 0 ) break ; if ( value >= ' ' && value <= ' ' ) db_printf ( " " , ( int ) value ) ; else db_printf ( " \\ " , ( int ) value ) ; } break ; case ' ' : addr = db_disasm ( addr , FALSE , NULL ) ; break ; case ' ' : addr = db_disasm ( addr , TRUE , NULL ) ; break ; default : break ; } if ( db_print_position ( ) != 0 ) db_end_line ( ) ; break ; } } } db_next = addr ; }
Parameters:
     fmt:     format string
     count:   repeat count
Parameters : fmt : format string count : repeat count
/* address */ /* always forces a new line */ /* Print the address. */ /* signed, current radix */ /* unsigned hex */ /* signed hex */ /* signed decimal */ /* unsigned decimal */ /* unsigned octal */ /* character */ /* null-terminated string */ /* instruction */ /* instruction, alternate form */