Example #1
0
static void
db_cmd_list(struct command *table, struct command **aux_tablep,
	    struct command **aux_tablep_end)
{
	struct command *cmd;
	struct command **aux_cmdp;

	for (cmd = table; cmd->name != 0; cmd++) {
	    db_printf("%-12s", cmd->name);
	    db_end_line(12);
	}
	if (aux_tablep == NULL)
	    return;
	for (aux_cmdp = aux_tablep; aux_cmdp < aux_tablep_end; aux_cmdp++) {
	    db_printf("%-12s", (*aux_cmdp)->name);
	    db_end_line(12);
	}
}
Example #2
0
void
db_cmd_list(struct db_command *table)
{
	struct db_command *cmd;

	for (cmd = table; cmd->name != 0; cmd++) {
	    db_printf("%-12s", cmd->name);
	    db_end_line(12);
	}
}
Example #3
0
void
db_help_cmd(void)
{
	struct command *cmd = db_command_table;

	while (cmd->name != 0) {
	    db_printf("%-12s", cmd->name);
	    db_end_line(12);
	    cmd++;
	}
}
Example #4
0
void
db_examine(db_addr_t addr, char *fmt, int count)
{
	int		c;
	db_expr_t	value;
	int		size;
	int		width;
	char *		fp;
	char		tmpfmt[28];

	while (--count >= 0) {
		fp = fmt;
		size = 4;
		width = 12;
		while ((c = *fp++) != 0) {
			if (db_print_position() == 0) {
				/* Always print the address. */
				db_printsym(addr, DB_STGY_ANY, db_printf);
				db_printf(":\t");
				db_prev = addr;
			}
			switch (c) {
			case 'b':	/* byte */
				size = 1;
				width = 4;
				break;
			case 'h':	/* half-word */
				size = 2;
				width = 8;
				break;
			case 'l':	/* long-word */
				size = 4;
				width = 12;
				break;
#ifdef __LP64__
			case 'q':	/* quad-word */
				size = 8;
				width = 20;
				break;
#endif
			case 'a':	/* address */
				db_printf("= 0x%lx\n", (long)addr);
				break;
			case 'r':	/* signed, current radix */
				value = db_get_value(addr, size, TRUE);
				addr += size;
				db_format(tmpfmt, sizeof tmpfmt,
				    (long)value, DB_FORMAT_R, 0, width);
				db_printf("%-*s", width, tmpfmt);
				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(tmpfmt, sizeof tmpfmt,
				    (long)value, DB_FORMAT_Z, 0, width);
				db_printf("%-*s", width, tmpfmt);
				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, value);
				break;
			case 'c':	/* character */
				value = db_get_value(addr, 1, FALSE);
				addr += 1;
				if (value >= ' ' && value <= '~')
					db_printf("%c", value);
				else
					db_printf("\\%03o", 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", value);
					else
						db_printf("\\%03o", value);
				}
				break;
			case 'i':	/* instruction */
				addr = db_disasm(addr, FALSE);
				break;
			case 'I':	/* instruction, alternate form */
				addr = db_disasm(addr, TRUE);
				break;
			default:
				break;
			}
			if (db_print_position() != 0)
				db_end_line(width);
		}
	}
	db_next = addr;
}
Example #5
0
static void
db_examine(db_addr_t addr, char *fmt, int count)
{
	int		i, c;
	db_expr_t	value;
	int		size;
	int		width;
	int		bytes;
	char *		fp;
	char		tbuf[24];

	while (--count >= 0) {
		fp = fmt;
		size = 4;
		width = 12;
		while ((c = *fp++) != 0) {
			if (db_print_position() == 0) {
				/* Always print the address. */
				db_printsym(addr, DB_STGY_ANY, db_printf);
				db_printf(":\t");
				db_prev = addr;
			}
			switch (c) {
			case 'b':	/* byte */
				size = 1;
				width = 4;
				break;
			case 'h':	/* half-word */
				size = 2;
				width = 8;
				break;
			case 'l':	/* long-word */
				size = 4;
				width = 12;
				break;
			case 'q':
				if (sizeof(db_expr_t) != sizeof(uint64_t)) {
					size = -1;
					db_error("q not supported\n");
					/*NOTREACHED*/
				}
			case 'L':	/* implementation maximum */
				size = sizeof value;
				width = 12 * (sizeof value / 4);
				break;
			case 'a':	/* address */
				db_printf("= 0x%lx\n", (long)addr);
				break;
			case 'r':	/* signed, current radix */
				value = db_get_value(addr, size, true);
				addr += size;
				db_format_radix(tbuf, 24, value, false);
				db_printf("%-*s", width, tbuf);
				break;
			case 'x':	/* unsigned hex */
				value = db_get_value(addr, size, false);
				addr += size;
				db_printf("%-*" DDB_EXPR_FMT "x", width, value);
				break;
			case 'm':	/* hex dump */
				/*
				 * Print off in chunks of size. Try to print 16
				 * bytes at a time into 4 columns. This
				 * loops modify's count extra times in order
				 * to get the nicely formatted lines.
				 */

				bytes = 0;
				do {
					for (i = 0; i < size; i++) {
						value =
 						    db_get_value(addr+bytes, 1,
							false);
						db_printf(
						    "%02" DDB_EXPR_FMT "x",
						    value);
						bytes++;
						if (!(bytes % 4))
							db_printf(" ");
					}
				} while ((bytes != 16) && count--);
				/* True up the columns before continuing */
				for (i = 4; i >= (bytes / 4); i--)
					db_printf ("\t");
				/* Print chars,  use . for non-printable's. */
				while (bytes--) {
					value = db_get_value(addr, 1, false);
					addr += 1;
					if (value >= ' ' && value <= '~')
						db_printf("%c", (char)value);
					else
						db_printf(".");
				}
				db_printf("\n");
				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("%-*" DDB_EXPR_FMT "d", width, value);
				break;
			case 'u':	/* unsigned decimal */
				value = db_get_value(addr, size, false);
				addr += size;
				db_printf("%-*" DDB_EXPR_FMT "u", width, value);
				break;
			case 'o':	/* unsigned octal */
				value = db_get_value(addr, size, false);
				addr += size;
				db_printf("%-*" DDB_EXPR_FMT "o", width, value);
				break;
			case 'c':	/* character */
				value = db_get_value(addr, 1, false);
				addr += 1;
				if (value >= ' ' && value <= '~')
					db_printf("%c", (char)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", (char)value);
					else
						db_printf("\\%03o", (int)value);
				}
				break;
			case 'i':	/* instruction */
				addr = db_disasm(addr, false);
				break;
			case 'I':	/* instruction, alternate form */
				addr = db_disasm(addr, true);
				break;
			default:
				break;
			}
			if (db_print_position() != 0)
				db_end_line();
		}
	}
	db_next = addr;
}
Example #6
0
void
db_examine(
    db_addr_t	addr,
    char *		fmt,	/* format string */
    int		count,	/* repeat count */
    task_t		task)
{
    int		c;
    db_expr_t	value;
    int		size;
    int		width;
    int		leader;
    int		items;
    int		nitems;
    char *		fp;
    db_addr_t	next_addr;
    int		sz;

    db_examine_prev_addr = addr;
    while (--count >= 0) {
        fp = fmt;
        size = sizeof(int);
        width = db_examine_width(size, &items, &leader);
        while ((c = *fp++) != 0) {
            switch (c) {
            case 'b':
                size = sizeof(char);
                width = db_examine_width(size, &items, &leader);
                break;
            case 'h':
                size = sizeof(short);
                width = db_examine_width(size, &items, &leader);
                break;
            case 'l':
                size = sizeof(int);
                width = db_examine_width(size, &items, &leader);
                break;
            case 'q':
                size = sizeof(long);
                width = db_examine_width(size, &items, &leader);
                break;
            case 'a':	/* address */
            case 'A':   /* function address */
                /* always forces a new line */
                if (db_print_position() != 0)
                    db_printf("\n");
                db_prev = addr;
                next_addr = addr + 4;
                db_task_printsym(addr,
                                 (c == 'a')?DB_STGY_ANY:DB_STGY_PROC,
                                 task);
                db_printf(":\t");
                break;
            case 'm':
                db_next = db_xcdump(addr, size, count+1, task);
                return;
            case 't':
            case 'u':
                break;
            default:
restart:
                /* Reset next_addr in case we are printing in
                   multiple formats.  */
                next_addr = addr;
                if (db_print_position() == 0) {
                    /* If we hit a new symbol, print it */
                    char *	name;
                    db_addr_t	off;

                    db_find_task_sym_and_offset(addr,&name,&off,task);
                    if (off == 0)
                        db_printf("\r%s:\n", name);
                    db_printf("%#n: ", addr);
                    for (sz = 0; sz < leader; sz++)
                        db_putchar(' ');
                    db_prev = addr;
                    nitems = items;
                }

                switch (c) {
                case 'p':	/* Addrs rendered symbolically. */
                    if( size == sizeof(void *) )  {
                        char       *symName;
                        db_addr_t	offset;

                        items = 1;
                        value = db_get_task_value( next_addr,
                                                   sizeof(db_expr_t), FALSE, task );
                        db_find_task_sym_and_offset( value,
                                                     &symName, &offset, task);
                        db_printf("\n\t*%8x(%8X) = %s",
                                  next_addr, value, symName );
                        if( offset )  {
                            db_printf("+%X", offset );
                        }
                        next_addr += size;
                    }
                    break;
                case 'r':	/* signed, current radix */
                    for (sz = size, next_addr = addr;
                            sz >= sizeof (db_expr_t);
                            sz -= sizeof (db_expr_t)) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr,
                                                  sizeof (db_expr_t),
                                                  TRUE,task);
                        db_printf("%-*r", width, value);
                        next_addr += sizeof (db_expr_t);
                    }
                    if (sz > 0) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr, sz,
                                                  TRUE, task);
                        db_printf("%-*R", width, value);
                        next_addr += sz;
                    }
                    break;
                case 'x':	/* unsigned hex */
                    for (sz = size, next_addr = addr;
                            sz >= sizeof (db_expr_t);
                            sz -= sizeof (db_expr_t)) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr,
                                                  sizeof (db_expr_t),
                                                  FALSE,task);
                        db_printf("%-*x", width, value);
                        next_addr += sizeof (db_expr_t);
                    }
                    if (sz > 0) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr, sz,
                                                  FALSE, task);
                        db_printf("%-*X", width, value);
                        next_addr += sz;
                    }
                    break;
                case 'z':	/* signed hex */
                    for (sz = size, next_addr = addr;
                            sz >= sizeof (db_expr_t);
                            sz -= sizeof (db_expr_t)) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr,
                                                  sizeof (db_expr_t),
                                                  TRUE, task);
                        db_printf("%-*z", width, value);
                        next_addr += sizeof (db_expr_t);
                    }
                    if (sz > 0) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr,sz,
                                                  TRUE,task);
                        db_printf("%-*Z", width, value);
                        next_addr += sz;
                    }
                    break;
                case 'd':	/* signed decimal */
                    for (sz = size, next_addr = addr;
                            sz >= sizeof (db_expr_t);
                            sz -= sizeof (db_expr_t)) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr,
                                                  sizeof (db_expr_t),
                                                  TRUE,task);
                        db_printf("%-*d", width, value);
                        next_addr += sizeof (db_expr_t);
                    }
                    if (sz > 0) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr, sz,
                                                  TRUE, task);
                        db_printf("%-*D", width, value);
                        next_addr += sz;
                    }
                    break;
                case 'U':	/* unsigned decimal */
                case 'u':
                    for (sz = size, next_addr = addr;
                            sz >= sizeof (db_expr_t);
                            sz -= sizeof (db_expr_t)) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr,
                                                  sizeof (db_expr_t),
                                                  FALSE,task);
                        db_printf("%-*u", width, value);
                        next_addr += sizeof (db_expr_t);
                    }
                    if (sz > 0) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr, sz,
                                                  FALSE, task);
                        db_printf("%-*U", width, value);
                        next_addr += sz;
                    }
                    break;
                case 'o':	/* unsigned octal */
                    for (sz = size, next_addr = addr;
                            sz >= sizeof (db_expr_t);
                            sz -= sizeof (db_expr_t)) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr,
                                                  sizeof (db_expr_t),
                                                  FALSE,task);
                        db_printf("%-*o", width, value);
                        next_addr += sizeof (db_expr_t);
                    }
                    if (sz > 0) {
                        if (nitems-- == 0) {
                            db_putchar('\n');
                            goto restart;
                        }
                        value = db_get_task_value(next_addr, sz,
                                                  FALSE, task);
                        db_printf("%-*o", width, value);
                        next_addr += sz;
                    }
                    break;
                case 'c':	/* character */
                    for (sz = 0, next_addr = addr;
                            sz < size;
                            sz++, next_addr++) {
                        value = db_get_task_value(next_addr,1,
                                                  FALSE,task);
                        if ((value >= ' ' && value <= '~') ||
                                value == '\n' ||
                                value == '\t')
                            db_printf("%c", value);
                        else
                            db_printf("\\%03o", value);
                    }
                    break;
                case 's':	/* null-terminated string */
                    size = 0;
                    for (;;) {
                        value = db_get_task_value(next_addr,1,
                                                  FALSE,task);
                        next_addr += 1;
                        size++;
                        if (value == 0)
                            break;
                        if (value >= ' ' && value <= '~')
                            db_printf("%c", value);
                        else
                            db_printf("\\%03o", value);
                    }
                    break;
                case 'i':	/* instruction */
                    next_addr = db_disasm(addr, FALSE, task);
                    size = next_addr - addr;
                    break;
                case 'I':	/* instruction, alternate form */
                    next_addr = db_disasm(addr, TRUE, task);
                    size = next_addr - addr;
                    break;
                default:
                    break;
                }
                if (db_print_position() != 0)
                    db_end_line();
                break;
            }
        }
        addr = next_addr;
    }
    db_next = addr;
}