Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Mar 2004 19:55:16 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 49427 for review
Message-ID:  <200403210355.i2L3tG4h045488@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=49427

Change 49427 by marcel@marcel_nfs on 2004/03/20 19:55:07

	o  Port the GDB backend to amd64.
	o  Introduce gdb_cpu_trap() to give MD code a chance to
	   do some necessary preparations (like flushing).
	o  Fill in the real register values on sparc64.

Affected files ...

.. //depot/projects/gdb/sys/alpha/alpha/gdb_machdep.c#2 edit
.. //depot/projects/gdb/sys/amd64/amd64/gdb_machdep.c#1 add
.. //depot/projects/gdb/sys/amd64/include/gdb_machdep.h#1 add
.. //depot/projects/gdb/sys/gdb/gdb.h#6 edit
.. //depot/projects/gdb/sys/gdb/gdb_main.c#7 edit
.. //depot/projects/gdb/sys/i386/i386/gdb_machdep.c#3 edit
.. //depot/projects/gdb/sys/ia64/ia64/gdb_machdep.c#3 edit
.. //depot/projects/gdb/sys/sparc64/include/gdb_machdep.h#2 edit
.. //depot/projects/gdb/sys/sparc64/sparc64/gdb_machdep.c#2 edit

Differences ...

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

@@ -80,30 +80,46 @@
 }
 
 int
-gdb_cpu_signal(int vector, int dummy)
+gdb_cpu_signal(int entry, int code)
 {
-
-	switch (vector) {
-	case 0: return (SIGFPE);	/* Divide by zero. */
-	case 1: return (SIGTRAP);	/* Debug exception. */
-	case 3: return (SIGTRAP);	/* Breakpoint. */
-	case 4: return (SIGURG);	/* into instr. (overflow). */
-	case 5: return (SIGURG);	/* bound instruction. */
-	case 6: return (SIGILL);	/* Invalid opcode. */
-	case 7: return (SIGFPE);	/* Coprocessor not present. */
-	case 8: return (SIGEMT);	/* Double fault. */
-	case 9: return (SIGSEGV);	/* Coprocessor segment overrun. */
-	case 10: return (SIGTRAP);	/* Invalid TSS (also single-step). */
-	case 11: return (SIGSEGV);	/* Segment not present. */
-	case 12: return (SIGSEGV);	/* Stack exception. */
-	case 13: return (SIGSEGV);	/* General protection. */
-	case 14: return (SIGSEGV);	/* Page fault. */
-	case 16: return (SIGEMT);	/* Coprocessor error. */
+	switch (entry) {
+	case ALPHA_KENTRY_INT:
+	case ALPHA_KENTRY_ARITH:
+		return (SIGILL);	/* Can this happen? */
+	case ALPHA_KENTRY_MM:
+		switch (code) {
+		case ALPHA_MMCSR_INVALTRANS:
+			return (SIGSEGV);
+		case ALPHA_MMCSR_ACCESS:
+		case ALPHA_MMCSR_FOR:
+		case ALPHA_MMCSR_FOE:
+		case ALPHA_MMCSR_FOW:
+			return (SIGBUS);
+		}
+	case ALPHA_KENTRY_IF:
+		switch (code) {
+		case ALPHA_IF_CODE_BUGCHK:
+		case ALPHA_IF_CODE_BPT:
+			return (SIGTRAP);
+		case ALPHA_IF_CODE_GENTRAP:
+		case ALPHA_IF_CODE_FEN:
+		case ALPHA_IF_CODE_OPDEC:
+			return (SIGILL);
+		}
+	case ALPHA_KENTRY_UNA:
+		return (SIGSEGV);
+	case ALPHA_KENTRY_SYS:
+		return (SIGILL);
 	}
-	return (SIGEMT);
+	return (SIGILL);
 }
 
 void
 gdb_cpu_singlestep(int on, struct trapframe *tf)
 {
 }
+
+void
+gdb_cpu_trap(int entry, int code, struct trapframe *tf)
+{
+}

==== //depot/projects/gdb/sys/gdb/gdb.h#6 (text+ko) ====

@@ -67,5 +67,6 @@
 void gdb_cpu_setreg(int, struct trapframe *, uintmax_t);
 int gdb_cpu_signal(int, int);
 void gdb_cpu_singlestep(int, struct trapframe *);
+void gdb_cpu_trap(int, int, struct trapframe *);
 
 #endif /* !_GDB_GDB_H_ */

==== //depot/projects/gdb/sys/gdb/gdb_main.c#7 (text+ko) ====

@@ -99,6 +99,9 @@
 	tid_cont = -1;
 	tid_gen = (p != NULL) ? p->p_pid : 0;
 
+	/* Give MD code a change to set things up. */
+	gdb_cpu_trap(type, code, tf);
+
 	/*
 	 * Send a T packet. We currently do not support watchpoints (the
 	 * awatch, rwatch or watch elements).

==== //depot/projects/gdb/sys/i386/i386/gdb_machdep.c#3 (text+ko) ====

@@ -120,7 +120,11 @@
 void
 gdb_cpu_singlestep(int on, struct trapframe *tf)
 {
-
 	tf->tf_eflags &= ~PSL_T;
 	tf->tf_eflags |= (on) ? PSL_T : 0;
 }
+
+void
+gdb_cpu_trap(int type, int code, struct trapframe *tf)
+{
+}

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

@@ -45,7 +45,7 @@
 	case GDB_REG_FP:
 		return (tf->tf_special.bspstore + tf->tf_special.ndirty);
 	case GDB_REG_PC:
-		return (tf->tf_special.iip);
+		return (tf->tf_special.iip + ((tf->tf_special.psr >> 41) & 3));
 	case GDB_REG_SP:
 		return (tf->tf_special.sp);
 	}
@@ -84,28 +84,18 @@
 int
 gdb_cpu_signal(int vector, int dummy)
 {
+	return (vector);
+}
 
-	switch (vector) {
-	case 0: return (SIGFPE);	/* Divide by zero. */
-	case 1: return (SIGTRAP);	/* Debug exception. */
-	case 3: return (SIGTRAP);	/* Breakpoint. */
-	case 4: return (SIGURG);	/* into instr. (overflow). */
-	case 5: return (SIGURG);	/* bound instruction. */
-	case 6: return (SIGILL);	/* Invalid opcode. */
-	case 7: return (SIGFPE);	/* Coprocessor not present. */
-	case 8: return (SIGEMT);	/* Double fault. */
-	case 9: return (SIGSEGV);	/* Coprocessor segment overrun. */
-	case 10: return (SIGTRAP);	/* Invalid TSS (also single-step). */
-	case 11: return (SIGSEGV);	/* Segment not present. */
-	case 12: return (SIGSEGV);	/* Stack exception. */
-	case 13: return (SIGSEGV);	/* General protection. */
-	case 14: return (SIGSEGV);	/* Page fault. */
-	case 16: return (SIGEMT);	/* Coprocessor error. */
-	}
-	return (SIGEMT);
+void
+gdb_cpu_singlestep(int on, struct trapframe *tf)
+{
 }
 
 void
-gdb_cpu_singlestep(int on, struct trapframe *tf)
+gdb_cpu_trap(int vector, int dummy, struct trapframe *tf)
 {
+	__asm __volatile("flushrs;;");
+	if (vector == IA64_VEC_BREAK && tf->tf_special.ifa == IA64_FIXED_BREAK)
+		tf->tf_special.psr += IA64_PSR_RI_1;
 }

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

@@ -31,8 +31,8 @@
 
 #define	GDB_BUFSZ	600
 
-#define	GDB_REG_FP	328
-#define	GDB_REG_PC	331
-#define	GDB_REG_SP	12
+#define	GDB_REG_FP	30
+#define	GDB_REG_PC	80
+#define	GDB_REG_SP	14
 
 #endif /* !_MACHINE_GDB_MACHDEP_H_ */

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

@@ -80,30 +80,20 @@
 }
 
 int
-gdb_cpu_signal(int vector, int dummy)
+gdb_cpu_signal(int type, int dummy)
 {
+	return (type);
+}
 
-	switch (vector) {
-	case 0: return (SIGFPE);	/* Divide by zero. */
-	case 1: return (SIGTRAP);	/* Debug exception. */
-	case 3: return (SIGTRAP);	/* Breakpoint. */
-	case 4: return (SIGURG);	/* into instr. (overflow). */
-	case 5: return (SIGURG);	/* bound instruction. */
-	case 6: return (SIGILL);	/* Invalid opcode. */
-	case 7: return (SIGFPE);	/* Coprocessor not present. */
-	case 8: return (SIGEMT);	/* Double fault. */
-	case 9: return (SIGSEGV);	/* Coprocessor segment overrun. */
-	case 10: return (SIGTRAP);	/* Invalid TSS (also single-step). */
-	case 11: return (SIGSEGV);	/* Segment not present. */
-	case 12: return (SIGSEGV);	/* Stack exception. */
-	case 13: return (SIGSEGV);	/* General protection. */
-	case 14: return (SIGSEGV);	/* Page fault. */
-	case 16: return (SIGEMT);	/* Coprocessor error. */
-	}
-	return (SIGEMT);
+void
+gdb_cpu_singlestep(int on, struct trapframe *tf)
+{
+	/* XXX dunno. */
+	TF_DONE(tf);
 }
 
 void
-gdb_cpu_singlestep(int on, struct trapframe *tf)
+gdb_cpu_trap(int type, int dummy, struct trapframe *tf)
 {
+	flushw();
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403210355.i2L3tG4h045488>