예제 #1
0
void
db_print_loc(
    db_addr_t       loc,
    task_t          task)
{
    db_task_printsym(loc, DB_STGY_PROC, task);
}
예제 #2
0
void
db_print_loc_and_inst(
    db_addr_t	loc,
    task_t		task)
{
    db_task_printsym(loc, DB_STGY_PROC, task);
    db_printf(":\t");
    (void) db_disasm(loc, TRUE, task);
}
예제 #3
0
/*
 * Write to file.
 */
void
db_write_cmd(
	db_expr_t	address,
	boolean_t	have_addr,
	db_expr_t	count,
	char *		modif)
{
	register db_addr_t	addr;
	register db_expr_t	old_value;
	db_expr_t	new_value;
	register int	size;
	boolean_t	wrote_one = FALSE;
	boolean_t	t_opt, u_opt;
	thread_act_t	thr_act;
	task_t		task;

	addr = (db_addr_t) address;

	size = db_size_option(modif, &u_opt, &t_opt);

	if (t_opt) 
	  {
	    if (!db_get_next_act(&thr_act, 0))
	      return;
	    task = thr_act->task;
	  }
	else
	  task = db_current_space();

	/* if user space is not explicitly specified, 
	   look in the kernel */
	if (!u_opt)
	  task = TASK_NULL;

	if (!DB_VALID_ADDRESS(addr, u_opt)) {
	  db_printf("Bad address 0x%x\n", addr);
	  return;
	}

	while (db_expression(&new_value)) {
	    old_value = db_get_task_value(addr, size, FALSE, task);
	    db_task_printsym(addr, DB_STGY_ANY, task);
	    db_printf("\t\t%#8n\t=\t%#8n\n", old_value, new_value);
	    db_put_task_value(addr, size, new_value, task);
	    addr += size;

	    wrote_one = TRUE;
	}

	if (!wrote_one)
	    db_error("Nothing written.\n");

	db_next = addr;
	db_prev = addr - size;
}
예제 #4
0
파일: db_break.c 프로젝트: rohsaini/mkunity
static void
db_force_delete_breakpoint(
	db_breakpoint_t	bkpt,
	vm_offset_t	task_thd,
	boolean_t	is_task)
{
	db_printf("deleted a stale breakpoint at ");
	if (bkpt->task == TASK_NULL || db_lookup_task(bkpt->task) >= 0)
	   db_task_printsym(bkpt->address, DB_STGY_PROC, bkpt->task);
	else
	   db_printf("%#X", bkpt->address);
	if (bkpt->task)
	   db_printf(" in task %X", bkpt->task);
	if (task_thd)
	   db_printf(" for %s %X", (is_task)? "task": "thr_act", task_thd);
	db_printf("\n");
	db_delete_thread_breakpoint(bkpt, task_thd);
}
예제 #5
0
/*
 * Disassemble instruction at 'loc'.  'altfmt' specifies an
 * (optional) alternate format.  Return address of start of
 * next instruction.
 */
db_addr_t
db_disasm(
	db_addr_t	loc,
	boolean_t	altfmt,
	task_t		task)
{
	int inst;
	char *p;

	inst = db_get_task_value(loc, 4, FALSE, task);
	db_disasm_pc = loc;
	db_disasm_print_symaddr = FALSE;
	p = in(inst);
	db_printf("%s", p);
	if (db_disasm_print_symaddr) {
		db_printf(" <");
		db_task_printsym(db_disasm_symaddr, DB_STGY_ANY, task);
		db_printf(">");
	}
	dis_done();
	return (loc+4);
}
예제 #6
0
/*
 * Disassemble instruction at 'loc'.  'altfmt' specifies an
 * (optional) alternate format.  Return address of start of
 * next instruction.
 */
db_addr_t
db_disasm(
	db_addr_t	loc,
	boolean_t	altfmt,
	task_t		task)
{
	int inst;
	char *p;

	inst = db_get_task_value(loc, 4, FALSE, task);
	db_disasm_pc = loc;
	db_disasm_print_symaddr = FALSE;
	p = in(inst);
	db_printf("%s", p);
	if (db_disasm_print_symaddr) {
		db_printf(" <");
		db_task_printsym(db_disasm_symaddr, DB_STGY_ANY, task);
		db_printf(">");
	}
	db_printf("\n");		/* Make sure we have a new line for multiline displays */
	dis_done();
	return (loc+4);
}
예제 #7
0
파일: db_break.c 프로젝트: rohsaini/mkunity
/*
 * List breakpoints.
 */
void
db_list_breakpoints(void)
{
	register db_breakpoint_t	bkpt;

	if (db_breakpoint_list == 0) {
	    db_printf("No breakpoints set\n");
	    return;
	}

	db_printf(" No  Space    Task.Act    Cnt  Address(Cond)\n");
	for (bkpt = db_breakpoint_list;
	     bkpt != 0;
	     bkpt = bkpt->link)
	{
	    register 	db_thread_breakpoint_t tp;
	    int		task_id;
	    int		act_id;

	    if (bkpt->threads) {
		for (tp = bkpt->threads; tp; tp = tp->tb_next) {
		    db_printf("%3d  ", tp->tb_number);
		    if (bkpt->flags & BKPT_USR_GLOBAL)
			db_printf("user     ");
		    else if (bkpt->task == TASK_NULL)
			db_printf("kernel   ");
		    else if ((task_id = db_lookup_task(bkpt->task)) < 0)
			db_printf("%0*X ", 2*sizeof(vm_offset_t), bkpt->task);
		    else
			db_printf("task%-3d  ", task_id);
		    if (tp->tb_task_thd == 0) {
			db_printf("all         ");
		    } else {
			if (tp->tb_is_task) {
			    task_id = db_lookup_task((task_t)(tp->tb_task_thd));
			    if (task_id < 0)
				db_printf("%0*X    ", 2*sizeof(vm_offset_t),
					   tp->tb_task_thd);
			    else
				db_printf("task%03d     ", task_id);
			} else {
			    thread_act_t thd = (thread_act_t)(tp->tb_task_thd);
			    task_id = db_lookup_task(thd->task);
			    act_id = db_lookup_task_act(thd->task, thd);
			    if (task_id < 0 || act_id < 0)
				db_printf("%0*X    ", 2*sizeof(vm_offset_t),
						tp->tb_task_thd);
			    else	
				db_printf("task%03d.%-3d ", task_id, act_id);
			}
		    }
	    	    db_printf("%3d  ", tp->tb_init_count);
		    db_task_printsym(bkpt->address, DB_STGY_PROC, bkpt->task);
		    if (tp->tb_cond > 0) {
			db_printf("(");
			db_cond_print(tp);
			db_printf(")");
		    }
		    db_printf("\n");
		}
	    } else {
		if (bkpt->task == TASK_NULL)
		    db_printf("  ?  kernel   ");
		else
		    db_printf("%*X ", 2*sizeof(vm_offset_t), bkpt->task);
		db_printf("(?)              ");
		db_task_printsym(bkpt->address, DB_STGY_PROC, bkpt->task);
		db_printf("\n");
	    }
	}
}
예제 #8
0
void
db_print_cmd(void)
{
    db_expr_t	value;
    int		t;
    task_t		task = TASK_NULL;

    if ((t = db_read_token()) == tSLASH) {
        if (db_read_token() != tIDENT) {
            db_printf("Bad modifier \"/%s\"\n", db_tok_string);
            db_error(0);
            /* NOTREACHED */
        }
        if (db_tok_string[0])
            db_print_format = db_tok_string[0];
        if (db_option(db_tok_string, 't')) {
            if (db_default_act)
                task = db_default_act->task;
            if (db_print_format == 't')
                db_print_format = db_tok_string[1];
        }
    } else
        db_unread_token(t);

    for ( ; ; ) {
        t = db_read_token();
        if (t == tSTRING) {
            db_printf("%s", db_tok_string);
            continue;
        }
        db_unread_token(t);
        if (!db_expression(&value))
            break;
        switch (db_print_format) {
        case 'a':
        case 'A':
            db_task_printsym((db_addr_t)value,
                             (db_print_format == 'a') ? DB_STGY_ANY:
                             DB_STGY_PROC,
                             task);
            break;
        case 'r':
            db_printf("%11r", value);
            break;
        case 'x':
            db_printf("%08x", value);
            break;
        case 'z':
            db_printf("%8z", value);
            break;
        case 'd':
            db_printf("%11d", value);
            break;
        case 'u':
            db_printf("%11u", value);
            break;
        case 'o':
            db_printf("%16o", value);
            break;
        case 'c':
            value = value & 0xFF;
            if (value >= ' ' && value <= '~')
                db_printf("%c", value);
            else
                db_printf("\\%03o", value);
            break;
        default:
            db_printf("Unknown format %c\n", db_print_format);
            db_print_format = 'x';
            db_error(0);
        }
    }
}
예제 #9
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;
}