Sun Jul 26 10:49:05 2015 UTC ()
properly copy regs for kgdb, and define the number of registers properly.
from openbsd via Vicente Chaves and PR port-amd64/50091.


(mrg)
diff -r1.8 -r1.9 src/sys/arch/amd64/amd64/kgdb_machdep.c
diff -r1.14 -r1.15 src/sys/arch/amd64/include/db_machdep.h

cvs diff -r1.8 -r1.9 src/sys/arch/amd64/amd64/Attic/kgdb_machdep.c (expand / switch to context diff)
--- src/sys/arch/amd64/amd64/Attic/kgdb_machdep.c 2011/04/03 22:29:25 1.8
+++ src/sys/arch/amd64/amd64/Attic/kgdb_machdep.c 2015/07/26 10:49:05 1.9
@@ -1,4 +1,4 @@
-/*	$NetBSD: kgdb_machdep.c,v 1.8 2011/04/03 22:29:25 dyoung Exp $	*/
+/*	$NetBSD: kgdb_machdep.c,v 1.9 2015/07/26 10:49:05 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.8 2011/04/03 22:29:25 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.9 2015/07/26 10:49:05 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -159,7 +159,26 @@
 kgdb_getregs(db_regs_t *regs, kgdb_reg_t *gdb_regs)
 {
 
-	memcpy(gdb_regs, regs, sizeof *regs);
+	gdb_regs[ 0] = regs->tf_rax;
+	gdb_regs[ 1] = regs->tf_rbx;
+	gdb_regs[ 2] = regs->tf_rcx;
+	gdb_regs[ 3] = regs->tf_rdx;
+	gdb_regs[ 4] = regs->tf_rsi;
+	gdb_regs[ 5] = regs->tf_rdi;
+	gdb_regs[ 6] = regs->tf_rbp;
+	gdb_regs[ 7] = regs->tf_rsp;
+	gdb_regs[ 8] = regs->tf_r8;
+	gdb_regs[ 9] = regs->tf_r9;
+	gdb_regs[10] = regs->tf_r10;
+	gdb_regs[11] = regs->tf_r11;
+	gdb_regs[12] = regs->tf_r12;
+	gdb_regs[13] = regs->tf_r13;
+	gdb_regs[14] = regs->tf_r14;
+	gdb_regs[15] = regs->tf_r15;
+	gdb_regs[16] = regs->tf_rip;
+	gdb_regs[17] = regs->tf_rflags;
+	gdb_regs[18] = regs->tf_cs;
+	gdb_regs[19] = regs->tf_ss;
 }
 
 /*
@@ -169,7 +188,26 @@
 kgdb_setregs(db_regs_t *regs, kgdb_reg_t *gdb_regs)
 {
 
-	memcpy(regs, gdb_regs, sizeof *regs);
+	regs->tf_rax = gdb_regs[ 0];
+	regs->tf_rbx = gdb_regs[ 1];
+	regs->tf_rcx = gdb_regs[ 2];
+	regs->tf_rdx = gdb_regs[ 3];
+	regs->tf_rsi = gdb_regs[ 4];
+	regs->tf_rdi = gdb_regs[ 5];
+	regs->tf_rbp = gdb_regs[ 6];
+	regs->tf_rsp = gdb_regs[ 7];
+	regs->tf_r8  = gdb_regs[ 8];
+	regs->tf_r9  = gdb_regs[ 9];
+	regs->tf_r10 = gdb_regs[10];
+	regs->tf_r11 = gdb_regs[11];
+	regs->tf_r12 = gdb_regs[12];
+	regs->tf_r13 = gdb_regs[13];
+	regs->tf_r14 = gdb_regs[14];
+	regs->tf_r15 = gdb_regs[15];
+	regs->tf_rip = gdb_regs[16];
+	regs->tf_rflags = gdb_regs[17];
+	regs->tf_cs  = gdb_regs[18];
+	regs->tf_ss  = gdb_regs[19];
 }	
 
 /*

cvs diff -r1.14 -r1.15 src/sys/arch/amd64/include/db_machdep.h (expand / switch to context diff)
--- src/sys/arch/amd64/include/db_machdep.h 2013/10/17 23:05:08 1.14
+++ src/sys/arch/amd64/include/db_machdep.h 2015/07/26 10:49:05 1.15
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.h,v 1.14 2013/10/17 23:05:08 christos Exp $	*/
+/*	$NetBSD: db_machdep.h,v 1.15 2015/07/26 10:49:05 mrg Exp $	*/
 
 /* 
  * Mach Operating System
@@ -120,7 +120,7 @@
  * Constants for KGDB.
  */
 typedef	long		kgdb_reg_t;
-#define	KGDB_NUMREGS	16
+#define	KGDB_NUMREGS	20
 #define	KGDB_BUFLEN	512
 
 #if 0