More DDB cleanup.

This commit is contained in:
mycroft 1999-01-20 13:56:35 +00:00
parent 64b6a85f9c
commit cefdcd4840
4 changed files with 75 additions and 73 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.25 1998/11/25 13:09:14 mycroft Exp $ */
/* $NetBSD: db_interface.c,v 1.26 1999/01/20 13:56:35 mycroft Exp $ */
/*
* Copyright (c) 1996 Scott K. Stevens
@ -62,25 +62,25 @@ int db_access_irq_sp __P((struct db_variable *, db_expr_t *, int));
u_int db_fetch_reg __P((int, db_regs_t *));
struct db_variable db_regs[] = {
{ "spsr", (long *)&DDB_TF->tf_spsr, FCN_NULL, },
{ "r0", (long *)&DDB_TF->tf_r0, FCN_NULL, },
{ "r1", (long *)&DDB_TF->tf_r1, FCN_NULL, },
{ "r2", (long *)&DDB_TF->tf_r2, FCN_NULL, },
{ "r3", (long *)&DDB_TF->tf_r3, FCN_NULL, },
{ "r4", (long *)&DDB_TF->tf_r4, FCN_NULL, },
{ "r5", (long *)&DDB_TF->tf_r5, FCN_NULL, },
{ "r6", (long *)&DDB_TF->tf_r6, FCN_NULL, },
{ "r7", (long *)&DDB_TF->tf_r7, FCN_NULL, },
{ "r8", (long *)&DDB_TF->tf_r8, FCN_NULL, },
{ "r9", (long *)&DDB_TF->tf_r9, FCN_NULL, },
{ "r10", (long *)&DDB_TF->tf_r10, FCN_NULL, },
{ "r11", (long *)&DDB_TF->tf_r11, FCN_NULL, },
{ "r12", (long *)&DDB_TF->tf_r12, FCN_NULL, },
{ "usr_sp", (long *)&DDB_TF->tf_usr_sp, FCN_NULL, },
{ "usr_lr", (long *)&DDB_TF->tf_usr_lr, FCN_NULL, },
{ "svc_sp", (long *)&DDB_TF->tf_svc_sp, FCN_NULL, },
{ "svc_lr", (long *)&DDB_TF->tf_svc_lr, FCN_NULL, },
{ "pc", (long *)&DDB_TF->tf_pc, FCN_NULL, },
{ "spsr", (long *)&DDB_REGS->tf_spsr, FCN_NULL, },
{ "r0", (long *)&DDB_REGS->tf_r0, FCN_NULL, },
{ "r1", (long *)&DDB_REGS->tf_r1, FCN_NULL, },
{ "r2", (long *)&DDB_REGS->tf_r2, FCN_NULL, },
{ "r3", (long *)&DDB_REGS->tf_r3, FCN_NULL, },
{ "r4", (long *)&DDB_REGS->tf_r4, FCN_NULL, },
{ "r5", (long *)&DDB_REGS->tf_r5, FCN_NULL, },
{ "r6", (long *)&DDB_REGS->tf_r6, FCN_NULL, },
{ "r7", (long *)&DDB_REGS->tf_r7, FCN_NULL, },
{ "r8", (long *)&DDB_REGS->tf_r8, FCN_NULL, },
{ "r9", (long *)&DDB_REGS->tf_r9, FCN_NULL, },
{ "r10", (long *)&DDB_REGS->tf_r10, FCN_NULL, },
{ "r11", (long *)&DDB_REGS->tf_r11, FCN_NULL, },
{ "r12", (long *)&DDB_REGS->tf_r12, FCN_NULL, },
{ "usr_sp", (long *)&DDB_REGS->tf_usr_sp, FCN_NULL, },
{ "usr_lr", (long *)&DDB_REGS->tf_usr_lr, FCN_NULL, },
{ "svc_sp", (long *)&DDB_REGS->tf_svc_sp, FCN_NULL, },
{ "svc_lr", (long *)&DDB_REGS->tf_svc_lr, FCN_NULL, },
{ "pc", (long *)&DDB_REGS->tf_pc, FCN_NULL, },
{ "und_sp", (long *)&nil, db_access_und_sp, },
{ "abt_sp", (long *)&nil, db_access_abt_sp, },
{ "irq_sp", (long *)&nil, db_access_irq_sp, },
@ -126,9 +126,9 @@ int db_access_irq_sp(vp, valp, rw)
* kdb_trap - field a TRACE or BPT trap
*/
int
kdb_trap(type, tf)
int type;
register struct trapframe *tf;
kdb_trap(type, regs)
int type;
db_regs_t *regs;
{
int s;
@ -146,8 +146,7 @@ kdb_trap(type, tf)
/* Should switch to kdb`s own stack here. */
ddb_regs.ddb_tf = *tf;
ddb_regs.ddb_tf.tf_pc -= INSN_SIZE;
ddb_regs = *regs;
s = splhigh();
db_active++;
@ -157,9 +156,9 @@ kdb_trap(type, tf)
db_active--;
splx(s);
*tf = ddb_regs.ddb_tf;
*regs = ddb_regs;
return(1);
return (1);
}
@ -167,12 +166,12 @@ kdb_trap(type, tf)
* Received keyboard interrupt sequence.
*/
void
kdb_kbd_trap(tf)
struct trapframe *tf;
kdb_kbd_trap(regs)
db_regs_t *regs;
{
if (db_active == 0 && (boothowto & RB_KDB)) {
printf("\n\nkernel: keyboard interrupt\n");
kdb_trap(-1, tf);
kdb_trap(-1, regs);
}
}
@ -334,14 +333,14 @@ db_trapper(addr, inst, frame, fault_code)
int fault_code;
{
if (fault_code == 0) {
frame->tf_pc -= INSN_SIZE;
if ((inst & ~INSN_COND_MASK) == (BKPT_INST & ~INSN_COND_MASK))
kdb_trap(T_BREAKPOINT, frame);
else
panic("Undefined instruction 0x%08x @ 0x%08x in kernel\n",
inst, addr);
kdb_trap(-1, frame);
} else
return(1);
return(0);
return (1);
return (0);
}
extern u_int esym;
@ -387,37 +386,37 @@ db_fetch_reg(reg, db_regs)
switch (reg) {
case 0:
return (db_regs->ddb_tf.tf_r0);
return (db_regs->tf_r0);
case 1:
return (db_regs->ddb_tf.tf_r1);
return (db_regs->tf_r1);
case 2:
return (db_regs->ddb_tf.tf_r2);
return (db_regs->tf_r2);
case 3:
return (db_regs->ddb_tf.tf_r3);
return (db_regs->tf_r3);
case 4:
return (db_regs->ddb_tf.tf_r4);
return (db_regs->tf_r4);
case 5:
return (db_regs->ddb_tf.tf_r5);
return (db_regs->tf_r5);
case 6:
return (db_regs->ddb_tf.tf_r6);
return (db_regs->tf_r6);
case 7:
return (db_regs->ddb_tf.tf_r7);
return (db_regs->tf_r7);
case 8:
return (db_regs->ddb_tf.tf_r8);
return (db_regs->tf_r8);
case 9:
return (db_regs->ddb_tf.tf_r9);
return (db_regs->tf_r9);
case 10:
return (db_regs->ddb_tf.tf_r10);
return (db_regs->tf_r10);
case 11:
return (db_regs->ddb_tf.tf_r11);
return (db_regs->tf_r11);
case 12:
return (db_regs->ddb_tf.tf_r12);
return (db_regs->tf_r12);
case 13:
return (db_regs->ddb_tf.tf_svc_sp);
return (db_regs->tf_svc_sp);
case 14:
return (db_regs->ddb_tf.tf_svc_lr);
return (db_regs->tf_svc_lr);
case 15:
return (db_regs->ddb_tf.tf_pc);
return (db_regs->tf_pc);
default:
panic("db_fetch_reg: botch");
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_trace.c,v 1.7 1997/10/14 10:12:04 mark Exp $ */
/* $NetBSD: db_trace.c,v 1.8 1999/01/20 13:56:35 mycroft Exp $ */
/*
* Copyright (c) 1996 Scott K. Stevens
@ -65,7 +65,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
*/
if (!have_addr)
frame = (struct frame *)(DDB_TF->tf_r11
frame = (struct frame *)(DDB_REGS->tf_r11
- (sizeof(struct frame) - sizeof(u_int)));
else
frame = (struct frame *)(addr - (sizeof(struct frame)

View File

@ -1,4 +1,4 @@
/* $NetBSD: fault.c,v 1.33 1998/09/22 01:40:28 mark Exp $ */
/* $NetBSD: fault.c,v 1.34 1999/01/20 13:56:35 mycroft Exp $ */
/*
* Copyright (c) 1994-1997 Mark Brinicombe.
@ -66,6 +66,9 @@
#include <machine/cpu.h>
#include <machine/pte.h>
#include <machine/irqhandler.h>
#ifdef DDB
#include <machine/db_machdep.h>
#endif
#include <arm32/arm32/disassem.h>
@ -174,11 +177,10 @@ data_abort_handler(frame)
#ifdef DDB
printf("Fault with intr_depth > 0\n");
report_abort(NULL, fault_status, fault_address, fault_pc);
printf("Instruction @V%08x = %08x\n",
fault_pc, fault_instruction);
Debugger();
kdb_trap(-1, frame);
return;
#else
panic("Fault with intr_depth > 0\n");
panic("Fault with intr_depth > 0");
#endif /* DDB */
}
#endif /* DIAGNOSTIC */
@ -329,8 +331,14 @@ copyfault:
* Were are dead, try and provide some debug
* infomation before dying
*/
panic("Halting (frame = %p)\n", frame);
break;
#ifdef DDB
printf("Unhandled trap (frame = %p)\n", frame);
report_abort(NULL, fault_status, fault_address, fault_pc);
kdb_trap(-1, frame);
return;
#else
panic("Unhandled trap (frame = %p)", frame);
#endif /* DDB */
case FAULT_PERM_S: /* Section Permission Fault */
/*
@ -338,10 +346,9 @@ copyfault:
* Only from user processes mis-behaving.
* If this happens from SVC mode then we are in trouble.
*/
if (user == 0) {
report_abort(NULL, fault_status, fault_address, fault_pc);
panic("Halting (frame = %p)\n", frame);
}
if (user == 0)
goto we_re_toast;
report_abort("", fault_status, fault_address, fault_pc);
trapsignal(p, SIGSEGV, TRAP_CODE);
break;
@ -403,9 +410,7 @@ copyfault:
return;
}
report_abort(NULL, fault_status, fault_address,
fault_pc);
panic("permission fault in kernel by kernel\n");
goto we_re_toast;
} else
map = &vm->vm_map;

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.11 1998/11/25 13:58:49 mycroft Exp $ */
/* $NetBSD: db_machdep.h,v 1.12 1999/01/20 13:56:35 mycroft Exp $ */
/*
* Copyright (c) 1996 Scott K Stevens
@ -45,21 +45,18 @@
typedef vm_offset_t db_addr_t; /* address - unsigned */
typedef long db_expr_t; /* expression - signed */
typedef struct {
trapframe_t ddb_tf;
} db_regs_t;
typedef trapframe_t db_regs_t;
db_regs_t ddb_regs; /* register state */
#define DDB_REGS (&ddb_regs)
#define DDB_TF (&ddb_regs.ddb_tf)
#define PC_REGS(regs) ((db_addr_t)(regs)->ddb_tf.tf_pc)
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_pc)
#define BKPT_INST (KERNEL_BREAKPOINT) /* breakpoint instruction */
#define BKPT_SIZE (INSN_SIZE) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)
/*#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->ddb_tf.tf_pc -= BKPT_SIZE)*/
/*#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_pc -= BKPT_SIZE)*/
#define T_BREAKPOINT (1)
@ -98,6 +95,7 @@ db_regs_t ddb_regs; /* register state */
#define SOFTWARE_SSTEP
u_int branch_taken __P((u_int insn, u_int pc, db_regs_t *db_regs));
int kdb_trap __P((int, db_regs_t *));
/*
* We use a.out symbols in DDB.