summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/powerpc/include/db_machdep.h46
-rw-r--r--sys/arch/powerpc/powerpc/db_trace.c113
-rw-r--r--sys/arch/powerpc/powerpc/trap.c55
3 files changed, 114 insertions, 100 deletions
diff --git a/sys/arch/powerpc/include/db_machdep.h b/sys/arch/powerpc/include/db_machdep.h
index a653426ce6f..ffb22e9e9c0 100644
--- a/sys/arch/powerpc/include/db_machdep.h
+++ b/sys/arch/powerpc/include/db_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_machdep.h,v 1.5 1998/04/06 20:22:23 pefo Exp $ */
+/* $OpenBSD: db_machdep.h,v 1.6 1998/08/22 17:54:29 rahnds Exp $ */
/* $NetBSD: db_machdep.h,v 1.13 1996/04/29 20:50:08 leo Exp $ */
/*
@@ -41,58 +41,24 @@
typedef vm_offset_t db_addr_t; /* address - unsigned */
typedef int db_expr_t; /* expression - signed */
struct powerpc_saved_state {
- u_int32_t r0; /* data registers */
- u_int32_t r1;
- u_int32_t r2;
- u_int32_t r3;
- u_int32_t r4;
- u_int32_t r5;
- u_int32_t r6;
- u_int32_t r7;
- u_int32_t r8;
- u_int32_t r9;
- u_int32_t r10;
- u_int32_t r11;
- u_int32_t r12;
- u_int32_t r13;
- u_int32_t r14;
- u_int32_t r15;
- u_int32_t r16;
- u_int32_t r17;
- u_int32_t r18;
- u_int32_t r19;
- u_int32_t r20;
- u_int32_t r21;
- u_int32_t r22;
- u_int32_t r23;
- u_int32_t r24;
- u_int32_t r25;
- u_int32_t r26;
- u_int32_t r27;
- u_int32_t r28;
- u_int32_t r29;
- u_int32_t r30;
- u_int32_t r31;
- u_int32_t r32;
- u_int32_t iar;
- u_int32_t msr;
+ struct trapframe tf;
};
typedef struct powerpc_saved_state db_regs_t;
db_regs_t ddb_regs; /* register state */
#define DDB_REGS (&ddb_regs)
-#define PC_REGS(regs) ((db_addr_t)(regs)->iar)
+#define PC_REGS(regs) ((regs)->tf.srr0)
#define BKPT_INST 0x7C810808 /* breakpoint instruction */
#define BKPT_SIZE (4) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)
-#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->iar -= 4)
+#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf.srr0 -= 4)
#define SR_SINGLESTEP 0x8000
-#define db_clear_single_step(regs) ((regs)->msr &= ~SR_SINGLESTEP)
-#define db_set_single_step(regs) ((regs)->msr |= SR_SINGLESTEP)
+#define db_clear_single_step(regs) ((regs)->tf.srr1 &= ~SR_SINGLESTEP)
+#define db_set_single_step(regs) ((regs)->tf.srr1 |= SR_SINGLESTEP)
#define T_BREAKPOINT 0xffff
#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT)
diff --git a/sys/arch/powerpc/powerpc/db_trace.c b/sys/arch/powerpc/powerpc/db_trace.c
index 624af3db705..612e31244fb 100644
--- a/sys/arch/powerpc/powerpc/db_trace.c
+++ b/sys/arch/powerpc/powerpc/db_trace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_trace.c,v 1.3 1997/03/21 02:10:48 niklas Exp $ */
+/* $OpenBSD: db_trace.c,v 1.4 1998/08/22 17:54:27 rahnds Exp $ */
/* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */
/*
@@ -31,51 +31,86 @@
#include <sys/proc.h>
#include <machine/db_machdep.h>
+#include <machine/signal.h>
#include <ddb/db_access.h>
#include <ddb/db_sym.h>
#include <ddb/db_variables.h>
struct db_variable db_regs[] = {
- { "r1", (long *)&ddb_regs.r1, FCN_NULL },
- { "r2", (long *)&ddb_regs.r2, FCN_NULL },
- { "r3", (long *)&ddb_regs.r3, FCN_NULL },
- { "r4", (long *)&ddb_regs.r4, FCN_NULL },
- { "r5", (long *)&ddb_regs.r5, FCN_NULL },
- { "r6", (long *)&ddb_regs.r6, FCN_NULL },
- { "r7", (long *)&ddb_regs.r7, FCN_NULL },
- { "r8", (long *)&ddb_regs.r8, FCN_NULL },
- { "r9", (long *)&ddb_regs.r9, FCN_NULL },
- { "r10", (long *)&ddb_regs.r10, FCN_NULL },
- { "r11", (long *)&ddb_regs.r11, FCN_NULL },
- { "r12", (long *)&ddb_regs.r12, FCN_NULL },
- { "r13", (long *)&ddb_regs.r13, FCN_NULL },
- { "r14", (long *)&ddb_regs.r13, FCN_NULL },
- { "r15", (long *)&ddb_regs.r13, FCN_NULL },
- { "r16", (long *)&ddb_regs.r13, FCN_NULL },
- { "r17", (long *)&ddb_regs.r17, FCN_NULL },
- { "r18", (long *)&ddb_regs.r18, FCN_NULL },
- { "r19", (long *)&ddb_regs.r19, FCN_NULL },
- { "r20", (long *)&ddb_regs.r20, FCN_NULL },
- { "r21", (long *)&ddb_regs.r21, FCN_NULL },
- { "r22", (long *)&ddb_regs.r22, FCN_NULL },
- { "r23", (long *)&ddb_regs.r23, FCN_NULL },
- { "r24", (long *)&ddb_regs.r24, FCN_NULL },
- { "r25", (long *)&ddb_regs.r25, FCN_NULL },
- { "r26", (long *)&ddb_regs.r26, FCN_NULL },
- { "r27", (long *)&ddb_regs.r27, FCN_NULL },
- { "r28", (long *)&ddb_regs.r28, FCN_NULL },
- { "r29", (long *)&ddb_regs.r29, FCN_NULL },
- { "r30", (long *)&ddb_regs.r30, FCN_NULL },
- { "r31", (long *)&ddb_regs.r31, FCN_NULL },
- { "r32", (long *)&ddb_regs.r32, FCN_NULL },
- { "iar", (long *)&ddb_regs.iar, FCN_NULL },
+ { "r0", (long *)&(DDB_REGS->tf.fixreg[0]), FCN_NULL },
+ { "r1", (long *)&(DDB_REGS->tf.fixreg[1]), FCN_NULL },
+ { "r2", (long *)&(DDB_REGS->tf.fixreg[2]), FCN_NULL },
+ { "r3", (long *)&(DDB_REGS->tf.fixreg[3]), FCN_NULL },
+ { "r4", (long *)&(DDB_REGS->tf.fixreg[4]), FCN_NULL },
+ { "r5", (long *)&(DDB_REGS->tf.fixreg[5]), FCN_NULL },
+ { "r6", (long *)&(DDB_REGS->tf.fixreg[6]), FCN_NULL },
+ { "r7", (long *)&(DDB_REGS->tf.fixreg[7]), FCN_NULL },
+ { "r8", (long *)&(DDB_REGS->tf.fixreg[8]), FCN_NULL },
+ { "r9", (long *)&(DDB_REGS->tf.fixreg[9]), FCN_NULL },
+ { "r10", (long *)&(DDB_REGS->tf.fixreg[10]), FCN_NULL },
+ { "r11", (long *)&(DDB_REGS->tf.fixreg[11]), FCN_NULL },
+ { "r12", (long *)&(DDB_REGS->tf.fixreg[12]), FCN_NULL },
+ { "r13", (long *)&(DDB_REGS->tf.fixreg[13]), FCN_NULL },
+ { "r14", (long *)&(DDB_REGS->tf.fixreg[13]), FCN_NULL },
+ { "r15", (long *)&(DDB_REGS->tf.fixreg[13]), FCN_NULL },
+ { "r16", (long *)&(DDB_REGS->tf.fixreg[13]), FCN_NULL },
+ { "r17", (long *)&(DDB_REGS->tf.fixreg[17]), FCN_NULL },
+ { "r18", (long *)&(DDB_REGS->tf.fixreg[18]), FCN_NULL },
+ { "r19", (long *)&(DDB_REGS->tf.fixreg[19]), FCN_NULL },
+ { "r20", (long *)&(DDB_REGS->tf.fixreg[20]), FCN_NULL },
+ { "r21", (long *)&(DDB_REGS->tf.fixreg[21]), FCN_NULL },
+ { "r22", (long *)&(DDB_REGS->tf.fixreg[22]), FCN_NULL },
+ { "r23", (long *)&(DDB_REGS->tf.fixreg[23]), FCN_NULL },
+ { "r24", (long *)&(DDB_REGS->tf.fixreg[24]), FCN_NULL },
+ { "r25", (long *)&(DDB_REGS->tf.fixreg[25]), FCN_NULL },
+ { "r26", (long *)&(DDB_REGS->tf.fixreg[26]), FCN_NULL },
+ { "r27", (long *)&(DDB_REGS->tf.fixreg[27]), FCN_NULL },
+ { "r28", (long *)&(DDB_REGS->tf.fixreg[28]), FCN_NULL },
+ { "r29", (long *)&(DDB_REGS->tf.fixreg[29]), FCN_NULL },
+ { "r30", (long *)&(DDB_REGS->tf.fixreg[30]), FCN_NULL },
+ { "r31", (long *)&(DDB_REGS->tf.fixreg[31]), FCN_NULL },
+ { "lr", (long *)&(DDB_REGS->tf.lr), FCN_NULL },
+ { "cr", (long *)&(DDB_REGS->tf.cr), FCN_NULL },
+ { "xer", (long *)&(DDB_REGS->tf.xer), FCN_NULL },
+ { "ctr", (long *)&(DDB_REGS->tf.ctr), FCN_NULL },
+ { "iar", (long *)&(DDB_REGS->tf.srr0), FCN_NULL },
+ { "msr", (long *)&(DDB_REGS->tf.srr1), FCN_NULL },
};
struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
extern label_t *db_recover;
/*
+ * this is probably hackery.
+ */
+void
+db_save_regs(struct trapframe *frame)
+{
+ printf ("%x %x %d\n", frame, &(ddb_regs.tf), sizeof (struct trapframe));
+ bcopy(frame, &(ddb_regs.tf), sizeof (struct trapframe));
+}
+
+
+db_expr_t
+db_dumpframe (u_int32_t pframe)
+{
+ u_int32_t nextframe;
+ u_int32_t lr;
+ u_int32_t *access;
+ int error;
+
+ access = (u_int32_t *)(pframe);
+ nextframe = *access;
+
+ access = (u_int32_t *)(pframe+4);
+ lr = *access;
+
+ db_printf("lr %x fp %x nfp %x\n", lr, pframe, nextframe);
+
+ return nextframe;
+}
+/*
* Frame tracing.
*/
void
@@ -91,6 +126,12 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
boolean_t kernel_only = TRUE;
boolean_t trace_thread = FALSE;
- db_printf("not supported");
+ while (1) {
+ addr = db_dumpframe(addr);
+ if (addr == 0) {
+ break;
+ }
+ }
+ for (i = count; i > 0 ; i--) {
+ }
}
-
diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c
index c88c18ac34b..6e7a54ab881 100644
--- a/sys/arch/powerpc/powerpc/trap.c
+++ b/sys/arch/powerpc/powerpc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.9 1998/08/07 02:22:09 rahnds Exp $ */
+/* $OpenBSD: trap.c,v 1.10 1998/08/22 17:54:26 rahnds Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
@@ -48,6 +48,7 @@
#include <machine/pmap.h>
#include <machine/psl.h>
#include <machine/trap.h>
+#include <machine/db_machdep.h>
/* These definitions should probably be somewhere else XXX */
#define FIRSTARG 3 /* first argument is in reg 3 */
@@ -57,30 +58,15 @@
volatile int want_resched;
#ifdef PPC_WANT_BACKTRACE
-void dumpframe (u_int32_t pframe)
-{
- u_int32_t nextframe;
- u_int32_t lr;
- int error;
- if (error = copyin ((void *)pframe, &nextframe , 4) ){
- printf("unable to read next frame @%x\n", pframe);
- return;
- }
- if (error = copyin ((void *)(pframe+4), &lr , 4) ){
- printf("unable to read lr @%x\n", pframe+4);
- return;
- }
- printf("lr %x fp %x nfp %x\n", lr, pframe, nextframe);
-
- if (nextframe != 0) {
- dumpframe(nextframe);
- }
- return;
-}
+u_int32_t dumpframe(u_int32_t);
void
ppc_dumpbt(struct trapframe *frame)
{
- dumpframe(frame->fixreg[1]);
+ /* dumpframe is defined in db_trace.c */
+ addr=frame->fixreg[1];
+ while (addr != 0) {
+ addr = dumpframe(addr);
+ }
return;
}
#endif
@@ -99,8 +85,11 @@ trap(frame)
}
switch (type) {
- case EXC_TRC|EXC_USER: /* Temporarily! XXX */
- printf("TRC: %x\n", frame->srr0);
+ case EXC_TRC|EXC_USER:
+ {
+ sv.sival_int = frame->srr0;
+ trapsignal(p, SIGTRAP, type, TRAP_TRACE, sv);
+ }
break;
case EXC_DSI:
{
@@ -295,10 +284,28 @@ brain_damage:
/*
mpc_print_pci_stat();
*/
+
+#ifdef DDB
+ /* set up registers */
+ db_save_regs(frame);
+#endif
panic("trap");
+
case EXC_PGM|EXC_USER:
printf("pgm iar %x\n", frame->srr0);
+ if (frame->srr1 && (1<<11)) {
+ /* floating point enabled program exception */
+ }
+ if (frame->srr1 && (1<<12)) {
+ /* illegal instruction program exception */
+ }
+ if (frame->srr1 && (1<<13)) {
+ /* privileged instruction exception */
+ }
+ if (frame->srr1 && (1<<14)) {
+ /* trap instruction exception */
+ }
sv.sival_int = frame->srr0;
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
break;