Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64 properly copy regs for kgdb, and define the n...



details:   https://anonhg.NetBSD.org/src/rev/faef11b8e7b2
branches:  trunk
changeset: 809656:faef11b8e7b2
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Jul 26 10:49:05 2015 +0000

description:
properly copy regs for kgdb, and define the number of registers properly.
from openbsd via Vicente Chaves and PR port-amd64/50091.

diffstat:

 sys/arch/amd64/amd64/kgdb_machdep.c |  46 +++++++++++++++++++++++++++++++++---
 sys/arch/amd64/include/db_machdep.h |   4 +-
 2 files changed, 44 insertions(+), 6 deletions(-)

diffs (92 lines):

diff -r 74f601b59513 -r faef11b8e7b2 sys/arch/amd64/amd64/kgdb_machdep.c
--- a/sys/arch/amd64/amd64/kgdb_machdep.c       Sun Jul 26 10:09:53 2015 +0000
+++ b/sys/arch/amd64/amd64/kgdb_machdep.c       Sun Jul 26 10:49:05 2015 +0000
@@ -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];
 }      
 
 /*
diff -r 74f601b59513 -r faef11b8e7b2 sys/arch/amd64/include/db_machdep.h
--- a/sys/arch/amd64/include/db_machdep.h       Sun Jul 26 10:09:53 2015 +0000
+++ b/sys/arch/amd64/include/db_machdep.h       Sun Jul 26 10:49:05 2015 +0000
@@ -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



Home | Main Index | Thread Index | Old Index