Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Dec 2020 14:54:20 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r368636 - in stable/12/sys/arm: arm include
Message-ID:  <202012141454.0BEEsKSO082015@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Mon Dec 14 14:54:20 2020
New Revision: 368636
URL: https://svnweb.freebsd.org/changeset/base/368636

Log:
  MFC r368414:
  arm: Let the GDB stub write to SP, LR and GP registers
  
  PR:	251463

Modified:
  stable/12/sys/arm/arm/gdb_machdep.c
  stable/12/sys/arm/include/gdb_machdep.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/arm/arm/gdb_machdep.c
==============================================================================
--- stable/12/sys/arm/arm/gdb_machdep.c	Mon Dec 14 14:00:54 2020	(r368635)
+++ stable/12/sys/arm/arm/gdb_machdep.c	Mon Dec 14 14:54:20 2020	(r368636)
@@ -98,11 +98,25 @@ gdb_cpu_getreg(int regnum, size_t *regsz)
 void
 gdb_cpu_setreg(int regnum, void *val)
 {
+	if (kdb_thread != curthread)
+		return;
 
 	switch (regnum) {
 	case GDB_REG_PC:
-		if (kdb_thread  == curthread)
-			kdb_frame->tf_pc = *(register_t *)val;
+		kdb_frame->tf_pc = *(register_t *)val;
+		break;
+	case GDB_REG_SP:
+		kdb_frame->tf_svc_sp = *(register_t *)val;
+		break;
+	case GDB_REG_LR:
+		kdb_frame->tf_svc_lr = *(register_t *)val;
+		break;
+	default:
+		/* Write to the general purpose registers r0-r12. */
+		if (regnum >= 0 && regnum <= 12) {
+			*(&kdb_frame->tf_r0 + regnum) = *(register_t *)val;
+		}
+		break;
 	}
 }
 

Modified: stable/12/sys/arm/include/gdb_machdep.h
==============================================================================
--- stable/12/sys/arm/include/gdb_machdep.h	Mon Dec 14 14:00:54 2020	(r368635)
+++ stable/12/sys/arm/include/gdb_machdep.h	Mon Dec 14 14:54:20 2020	(r368636)
@@ -33,6 +33,8 @@
 
 #define	GDB_BUFSZ	400
 #define	GDB_NREGS	26
+#define	GDB_REG_SP	13
+#define	GDB_REG_LR	14
 #define	GDB_REG_PC	15
 
 static __inline size_t



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