svn commit: r368414 - in head/sys/arm: arm include

Mark Johnston markj at FreeBSD.org
Mon Dec 7 15:09:29 UTC 2020


Author: markj
Date: Mon Dec  7 15:09:28 2020
New Revision: 368414
URL: https://svnweb.freebsd.org/changeset/base/368414

Log:
  arm: Let the GDB stub write to SP, LR and GP registers
  
  This can be handy if gdb's stack unwinder fails, for example because of
  a bug in kgdb's trap frame unwinder.
  
  PR:		251463
  Submitted by:	Dmitry Salychev <dsl at mcusim.org>
  MFC after:	1 week

Modified:
  head/sys/arm/arm/gdb_machdep.c
  head/sys/arm/include/gdb_machdep.h

Modified: head/sys/arm/arm/gdb_machdep.c
==============================================================================
--- head/sys/arm/arm/gdb_machdep.c	Mon Dec  7 14:53:34 2020	(r368413)
+++ head/sys/arm/arm/gdb_machdep.c	Mon Dec  7 15:09:28 2020	(r368414)
@@ -97,11 +97,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: head/sys/arm/include/gdb_machdep.h
==============================================================================
--- head/sys/arm/include/gdb_machdep.h	Mon Dec  7 14:53:34 2020	(r368413)
+++ head/sys/arm/include/gdb_machdep.h	Mon Dec  7 15:09:28 2020	(r368414)
@@ -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


More information about the svn-src-head mailing list