/*
 * Disassemble instruction at 'loc'.
 * Return address of start of next instruction.
 * Since this function is used by 'examine' and by 'step'
 * "next instruction" does NOT mean the next instruction to
 * be executed but the 'linear' next instruction.
 */
db_addr_t
mips_disassem(db_addr_t loc, char *di_buffer, int alt_dis_format)
{
    u_int32_t instr;

    if (alt_dis_format) {   // use ARM register names for disassembly
        reg_name = &alt_arm_reg_name[0];
    }

    sprintf_buffer = di_buffer;     // quick 'n' dirty printf() vs sprintf()
    sprintf_buf_len = 39;           // should be passed in

    instr =  *(u_int32_t *)loc;
    return (db_disasm_insn(instr, loc, false));
}
Exemple #2
0
/*
 * Disassemble instruction at 'loc'.  'altfmt' specifies an
 * (optional) alternate format (altfmt for vax: don't assume
 * that each external label is a procedure entry mask).
 * Return address of start of next instruction.
 * Since this function is used by 'examine' and by 'step'
 * "next instruction" does NOT mean the next instruction to
 * be executed but the 'linear' next instruction.
 */
db_addr_t
db_disasm(db_addr_t loc, bool altfmt)
{
	u_int32_t instr;

	/*
	 * Take some care with addresses to not UTLB here as it
	 * loses the current debugging context.  KSEG2 not checked.
	 */
	if (loc < MIPS_KSEG0_START) {
		instr = fuword((void *)loc);
		if (instr == 0xffffffff) {
			/* "sd ra, -1(ra)" is unlikely */
			db_printf("invalid address.\n");
			return loc;
		}
	}
	else {
		instr =  *(u_int32_t *)loc;
	}

	return (db_disasm_insn(instr, loc, altfmt));
}