Fix disassembly of 8-bit branch displacements (sign extend).

Fix invalid array references disassembling float instructions.
Make the system stack pointer visible in show regs.
Make "sr" a proper short, remove some junk...
This commit is contained in:
gwr 1994-11-14 20:53:52 +00:00
parent 21a1e8e747
commit 2e0e96ea27
3 changed files with 42 additions and 38 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_disasm.c,v 1.11 1994/10/26 07:51:03 cgd Exp $ */
/* $NetBSD: db_disasm.c,v 1.12 1994/11/14 20:53:52 gwr Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -183,27 +183,6 @@ db_disasm(loc, moto_syntax)
dbuf.dasm[0] = 0;
dbuf.info[0] = 0;
#if 0
/* This is now done in db_examine. */
diff = INT_MAX;
sym = db_search_symbol(loc, DB_STGY_PROC, &diff);
db_symbol_values(sym, &symname, 0);
/* addstr(&dbuf, "["); */
if (symname == NULL)
printu (&dbuf, loc, SIZE_LONG);
else if (diff == 0) {
addstr(&dbuf, symname);
iprintu(&dbuf, loc, SIZE_LONG);
iaddstr(&dbuf, ":: ");
} else {
addstr(&dbuf, symname);
addstr(&dbuf, "+");
printu(&dbuf, diff, SIZE_LONG);
}
addstr(&dbuf, ": ");
#endif
opc = *dbuf.val;
dbuf.used++;
@ -873,23 +852,22 @@ opcode_branch(dbuf, opc)
disp = BITFIELD(opc,7,0);
if (disp == 0) {
/* 16-bit signed displacement */
disp = *(dbuf->val + 1);
dbuf->used++;
sz = SIZE_WORD;
#if 0 /* XXX Note GNU as doesn't like this */
addchar('w');
#endif
} else if (disp == 0xff) {
/* 32-bit signed displacement */
disp = *(long *)(dbuf->val + 1);
dbuf->used += 2;
sz = SIZE_LONG;
addchar('l');
} else {
disp = *((char *)dbuf->val + 1);
/*
* XXX gas chokes on this, I am not sure if
* XXX it can even be made to emit it (short of .word)
*/
/* 8-bit signed displacement in opcode. */
/* Needs to be sign-extended... */
if (ISBITSET(disp,7))
disp -= 256;
sz = SIZE_BYTE;
addchar('b');
}
@ -1594,6 +1572,9 @@ opcode_fpu(dbuf, opc)
}
}
/*
* XXX - This screws up on: fmovem a0@(312),fpcr/fpsr/fpi
*/
void
opcode_fmove_ext(dbuf, opc, ext)
dis_buffer_t *dbuf;
@ -2771,7 +2752,7 @@ make_cond(dbuf, bit, base)
const char *ccs;
cc = BITFIELD(*dbuf->val,bit,bit-3);
ccs = cc_table[cc];
ccs = cc_table[cc&15];
addstr(dbuf, base);
addstr(dbuf, ccs);
@ -2782,7 +2763,7 @@ print_fcond(dbuf, cp)
dis_buffer_t *dbuf;
char cp;
{
addstr(dbuf,fpcc_table[cp]);
addstr(dbuf,fpcc_table[cp&31]); /* XXX - not 63 ?*/
}
void
@ -2790,7 +2771,7 @@ print_mcond(dbuf, cp)
dis_buffer_t *dbuf;
char cp;
{
addstr(dbuf,mmcc_table[cp]);
addstr(dbuf,mmcc_table[cp&15]);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.9 1994/10/26 07:51:08 cgd Exp $ */
/* $NetBSD: db_interface.c,v 1.10 1994/11/14 20:53:54 gwr Exp $ */
/*
* Mach Operating System
@ -43,6 +43,7 @@
extern jmp_buf *db_recover;
int db_active = 0;
int ddb_regs_ssp; /* system stack pointer */
/*
* Received keyboard interrupt sequence.
@ -78,17 +79,25 @@ kdb_trap(type, regs)
}
}
/* Should switch to kdb's own stack here. */
/* XXX - Should switch to kdb's own stack here. */
ddb_regs = *regs;
/* Get System Stack Pointer (SSP) */
ddb_regs_ssp = (int)(&regs[1]);
db_active++;
cnpollc(TRUE);
/* (void) setvideoenable(1);*/
#if 0
/* XXX - Should do this in cnpollc() if needed. */
(void) setvideoenable(1);
#endif
db_trap(type, 0);
cnpollc(FALSE);
db_active--;
/* Can't easily honor change in ssp. Oh well. */
*regs = ddb_regs;
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_trace.c,v 1.10 1994/10/26 07:51:09 cgd Exp $ */
/* $NetBSD: db_trace.c,v 1.11 1994/11/14 20:53:55 gwr Exp $ */
/*
* Mach Operating System
@ -41,6 +41,8 @@ jmp_buf *db_recover;
/*
* Register list
*/
static int db_var_short(struct db_variable *, db_expr_t *, int);
extern int ddb_regs_ssp;
struct db_variable db_regs[] = {
{ "d0", (int *)&ddb_regs.d0, FCN_NULL },
{ "d1", (int *)&ddb_regs.d1, FCN_NULL },
@ -57,12 +59,24 @@ struct db_variable db_regs[] = {
{ "a4", (int *)&ddb_regs.a4, FCN_NULL },
{ "a5", (int *)&ddb_regs.a5, FCN_NULL },
{ "a6", (int *)&ddb_regs.a6, FCN_NULL },
{ "sp", (int *)&ddb_regs.sp, FCN_NULL },
{ "ssp",&ddb_regs_ssp, FCN_NULL },
{ "usp",(int *)&ddb_regs.sp, FCN_NULL },
{ "pc", (int *)&ddb_regs.pc, FCN_NULL },
{ "sr", (int *)&ddb_regs.sr, FCN_NULL }
{ "sr", (int *)&ddb_regs.sr, db_var_short }
};
struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
static int db_var_short(varp, valp, op)
struct db_variable *varp;
db_expr_t *valp;
int op;
{
if (op == DB_VAR_GET)
*valp = (db_expr_t) *((short*)varp->valuep);
else
*((short*)varp->valuep) = (short) *valp;
}
#define MAXINT 0x7fffffff
#define INKERNEL(va) (((vm_offset_t)(va)) >= VM_MIN_KERNEL_ADDRESS && \