PERFORCE change 48643 for review

Marcel Moolenaar marcel at FreeBSD.org
Wed Mar 10 15:44:00 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=48643

Change 48643 by marcel at marcel_nfs on 2004/03/10 15:43:41

	Cleanup kdb_trap(). Each platform had its own implementation
	of this function, with differing prototypes. Since it's
	basicly a wrapper for db_trap() most of the logic can be
	moved there with appropriate calls to MD specific functions.
	For now, just compile-out the existing kdb_trap() functions
	and fixup the existing call-sites. When DDB and GDB get
	hooked into the KDB frontend, this will be merged into a
	single db_trap() (or gdb_trap() for that matter).

Affected files ...

.. //depot/projects/gdb/sys/alpha/alpha/db_interface.c#3 edit
.. //depot/projects/gdb/sys/alpha/alpha/interrupt.c#2 edit
.. //depot/projects/gdb/sys/alpha/alpha/trap.c#2 edit
.. //depot/projects/gdb/sys/alpha/include/db_machdep.h#2 edit
.. //depot/projects/gdb/sys/amd64/amd64/db_interface.c#4 edit
.. //depot/projects/gdb/sys/amd64/amd64/trap.c#4 edit
.. //depot/projects/gdb/sys/amd64/include/frame.h#2 edit
.. //depot/projects/gdb/sys/ia64/ia64/db_interface.c#3 edit
.. //depot/projects/gdb/sys/ia64/ia64/machdep.c#5 edit
.. //depot/projects/gdb/sys/ia64/ia64/trap.c#3 edit
.. //depot/projects/gdb/sys/ia64/include/db_machdep.h#2 edit
.. //depot/projects/gdb/sys/kern/subr_kdb.c#2 edit
.. //depot/projects/gdb/sys/powerpc/include/db_machdep.h#2 edit
.. //depot/projects/gdb/sys/powerpc/powerpc/db_interface.c#3 edit
.. //depot/projects/gdb/sys/powerpc/powerpc/trap.c#2 edit
.. //depot/projects/gdb/sys/sparc64/include/frame.h#2 edit
.. //depot/projects/gdb/sys/sparc64/sparc64/db_interface.c#2 edit
.. //depot/projects/gdb/sys/sparc64/sparc64/trap.c#3 edit

Differences ...

==== //depot/projects/gdb/sys/alpha/alpha/db_interface.c#3 (text+ko) ====

@@ -143,11 +143,12 @@
 	    entry);
 }
 
+#if 0
 /*
  *  ddb_trap - field a kernel trap
  */
 int
-kdb_trap(a0, a1, a2, entry, regs)
+ddb_trap(a0, a1, a2, entry, regs)
 	unsigned long a0, a1, a2, entry;
 	db_regs_t *regs;
 {
@@ -225,6 +226,7 @@
 	 */
 	return (1);
 }
+#endif
 
 /*
  * Read bytes from kernel address space for debugger.

==== //depot/projects/gdb/sys/alpha/alpha/interrupt.c#2 (text+ko) ====

@@ -230,8 +230,8 @@
 		printf("        pid = %d, comm = %s\n", curproc->p_pid,
 		    curproc->p_comm);
 	printf("\n");
-#ifdef DDB
-	kdb_trap(mces, vector, param, ALPHA_KENTRY_MM, framep);
+#ifdef KDB
+	kdb_trap(ALPHA_KENTRY_MM, mces, framep);
 #endif
 	panic("machine check");
 }

==== //depot/projects/gdb/sys/alpha/alpha/trap.c#2 (text+ko) ====

@@ -375,7 +375,7 @@
 			 */
 			if (a0 == ALPHA_IF_CODE_BUGCHK ||
 			    a0 == ALPHA_IF_CODE_BPT) {
-				if (kdb_trap(a0, a1, a2, entry, framep))
+				if (kdb_trap(entry, a0, framep))
 					goto out;
 			}
 
@@ -595,8 +595,8 @@
 dopanic:
 	printtrap(a0, a1, a2, entry, framep, 1, user);
 	/* XXX dump registers */
-#ifdef DDB
-	kdb_trap(a0, a1, a2, entry, framep);
+#ifdef KDB
+	kdb_trap(entry, a0, framep);
 #endif
 	panic("trap");
 }

==== //depot/projects/gdb/sys/alpha/include/db_machdep.h#2 (text+ko) ====

@@ -95,8 +95,6 @@
 #define	next_instr_address(v, b) ((db_addr_t) ((b) ? (v) : ((v) + 4)))
 
 u_long	db_register_value(db_regs_t *, int);
-int	kdb_trap(unsigned long, unsigned long, unsigned long,
-	    unsigned long, struct trapframe *);
 
 /*
  * Pretty arbitrary

==== //depot/projects/gdb/sys/amd64/amd64/db_interface.c#4 (text+ko) ====

@@ -69,11 +69,12 @@
 	return ss;
 }
 
+#if 0
 /*
- *  kdb_trap - field a TRACE or BPT trap
+ *  ddb_trap - field a TRACE or BPT trap
  */
 int
-kdb_trap(int type, int code, struct amd64_saved_state *regs)
+ddb_trap(int type, int code, struct amd64_saved_state *regs)
 {
 	u_long ef;
 	volatile int ddb_mode = !(boothowto & RB_GDB);
@@ -233,6 +234,7 @@
 
 	return (1);
 }
+#endif
 
 /*
  * Read bytes from kernel address space for debugger.

==== //depot/projects/gdb/sys/amd64/amd64/trap.c#4 (text+ko) ====

@@ -283,7 +283,7 @@
 			/* machine/parity/power fail/"kitchen sink" faults */
 			/* XXX Giant */
 			if (isa_nmi(code) == 0) {
-#ifdef DDB
+#ifdef KDB
 				/*
 				 * NMI can be hooked up to a pushbutton
 				 * for debugging.
@@ -292,7 +292,7 @@
 					printf ("NMI ... going to debugger\n");
 					kdb_trap (type, 0, &frame);
 				}
-#endif /* DDB */
+#endif /* KDB */
 				goto userout;
 			} else if (panic_on_nmi)
 				panic("NMI indicates hardware failure");
@@ -422,7 +422,7 @@
 			 * If DDB is enabled, let it handle the debugger trap.
 			 * Otherwise, debugger traps "can't happen".
 			 */
-#ifdef DDB
+#ifdef KDB
 			/* XXX Giant */
 			if (kdb_trap (type, 0, &frame))
 				goto out;
@@ -434,7 +434,7 @@
 			/* XXX Giant */
 			/* machine/parity/power fail/"kitchen sink" faults */
 			if (isa_nmi(code) == 0) {
-#ifdef DDB
+#ifdef KDB
 				/*
 				 * NMI can be hooked up to a pushbutton
 				 * for debugging.
@@ -443,7 +443,7 @@
 					printf ("NMI ... going to debugger\n");
 					kdb_trap (type, 0, &frame);
 				}
-#endif /* DDB */
+#endif /* KDB */
 				goto out;
 			} else if (panic_on_nmi == 0)
 				goto out;
@@ -630,10 +630,6 @@
 	}
 
 #ifdef KDB
-	if (kdb_trap(&psl))
-		return;
-#endif
-#ifdef DDB
 	if ((debugger_on_panic || db_active) && kdb_trap(type, 0, frame))
 		return;
 #endif

==== //depot/projects/gdb/sys/amd64/include/frame.h#2 (text+ko) ====

@@ -140,6 +140,4 @@
 	register_t	cf_ss;
 };
 
-int	kdb_trap(int, int, struct trapframe *);
-
 #endif /* _MACHINE_FRAME_H_ */

==== //depot/projects/gdb/sys/ia64/ia64/db_interface.c#3 (text+ko) ====

@@ -278,11 +278,12 @@
 #define CPUSTOP_ON_DDBBREAK
 #define VERBOSE_CPUSTOP_ON_DDBBREAK
 
+#if 0
 /*
  *  ddb_trap - field a kernel trap
  */
 int
-kdb_trap(int vector, struct trapframe *regs)
+ddb_trap(int vector, struct trapframe *regs)
 {
 	int ddb_mode = !(boothowto & RB_GDB);
 	register_t s;
@@ -393,6 +394,7 @@
 	 */
 	return (1);
 }
+#endif
 
 /*
  * Read bytes from kernel address space for debugger.

==== //depot/projects/gdb/sys/ia64/ia64/machdep.c#5 (text+ko) ====

@@ -35,6 +35,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/eventhandler.h>
+#include <sys/kdb.h>
 #include <sys/sysproto.h>
 #include <sys/signalvar.h>
 #include <sys/imgact.h>

==== //depot/projects/gdb/sys/ia64/ia64/trap.c#3 (text+ko) ====

@@ -316,8 +316,8 @@
 {
 
 	printtrap(vector, tf, 1, TRAPF_USERMODE(tf));
-#ifdef DDB
-	kdb_trap(vector, tf);
+#ifdef KDB
+	kdb_trap(vector, 0, tf);
 #endif
 	panic("trap");
 }
@@ -461,8 +461,8 @@
 				sig = SIGTRAP;
 			}
 		} else {
-#ifdef DDB
-			if (kdb_trap(vector, tf))
+#ifdef KDB
+			if (kdb_trap(vector, 0, tf))
 				return;
 			panic("trap");
 #else
@@ -626,8 +626,8 @@
 	case IA64_VEC_SINGLE_STEP_TRAP:
 		tf->tf_special.psr &= ~IA64_PSR_SS;
 		if (!user) {
-#ifdef DDB
-			if (kdb_trap(vector, tf))
+#ifdef KDB
+			if (kdb_trap(vector, 0, tf))
 				return;
 			panic("trap");
 #else

==== //depot/projects/gdb/sys/ia64/include/db_machdep.h#2 (text+ko) ====

@@ -83,7 +83,6 @@
 #define	next_instr_address(v, b) ((db_addr_t) ((b) ? (v) : ((v) + 4)))
 
 u_long	db_register_value(db_regs_t *, int);
-int	kdb_trap(int vector, struct trapframe *regs);
 
 u_int64_t *db_rse_current_frame(void);
 u_int64_t *db_rse_previous_frame(u_int64_t *bsp, int sof);

==== //depot/projects/gdb/sys/kern/subr_kdb.c#2 (text+ko) ====


==== //depot/projects/gdb/sys/powerpc/include/db_machdep.h#2 (text+ko) ====

@@ -104,7 +104,6 @@
 #ifdef _KERNEL
 
 void	kdb_kintr(void *);
-int	kdb_trap(int, void *);
 
 #endif /* _KERNEL */
 

==== //depot/projects/gdb/sys/powerpc/powerpc/db_interface.c#3 (text+ko) ====

@@ -63,11 +63,12 @@
 		if (type == EXC_PGM && (frame->srr1 & 0x20000)) {
 			type = T_BREAKPOINT;
 		}
-		return kdb_trap(type, frame);
+		return kdb_trap(type, 0, frame);
 	}
 	return 0;
 }
 
+#if 0
 int
 ddb_trap(type, v)
 	int type;
@@ -143,6 +144,7 @@
 
 	return 1;
 }
+#endif
 
 #ifdef PPC_IBM4XX
 const struct db_command db_machine_command_table[] = {

==== //depot/projects/gdb/sys/powerpc/powerpc/trap.c#2 (text+ko) ====

@@ -271,8 +271,8 @@
 {
 
 	printtrap(frame->exc, frame, 1, (frame->srr1 & PSL_PR));
-#ifdef DDB
-	if ((debugger_on_panic || db_active) && kdb_trap(frame->exc, frame))
+#ifdef KDB
+	if ((debugger_on_panic || db_active) && kdb_trap(frame->exc, 0, frame))
 		return;
 #endif
 	panic("%s trap", trapname(frame->exc));

==== //depot/projects/gdb/sys/sparc64/include/frame.h#2 (text+ko) ====

@@ -90,6 +90,4 @@
 int	rwindow_save(struct thread *td);
 int	rwindow_load(struct thread *td, struct trapframe *tf, int n);
 
-int	kdb_trap(struct trapframe *tf);
-
 #endif /* !_MACHINE_FRAME_H_ */

==== //depot/projects/gdb/sys/sparc64/sparc64/db_interface.c#2 (text+ko) ====

@@ -60,6 +60,7 @@
 static jmp_buf db_global_jmpbuf;
 static int db_global_jmpbuf_valid;
 
+#if 0
 int
 kdb_trap(struct trapframe *tf)
 {
@@ -88,6 +89,7 @@
 	TF_DONE(tf);
 	return (1);
 }
+#endif
 
 void
 db_read_bytes(vm_offset_t addr, size_t size, char *data)

==== //depot/projects/gdb/sys/sparc64/sparc64/trap.c#3 (text+ko) ====

@@ -298,10 +298,10 @@
 		    ("trap: kernel trap isn't"));
 
 		switch (tf->tf_type & ~T_KERNEL) {
-#ifdef DDB
+#ifdef KDB
 		case T_BREAKPOINT:
 		case T_KSTACK_FAULT:
-			error = (kdb_trap(tf) == 0);
+			error = (kdb_trap(tf->tf_type, 0, tf) == 0);
 			break;
 #ifdef notyet
 		case T_PA_WATCHPOINT:


More information about the p4-projects mailing list