aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-12-14 14:54:20 +0000
committerMark Johnston <markj@FreeBSD.org>2020-12-14 14:54:20 +0000
commitafa53e3372114192a6c7e5fd8dc2682e97a61e34 (patch)
tree60bb1461ec84d8708864e4a23f03079cfd4787a9
parent15a74ac247e7ef3d77088a202ca1c479abd50703 (diff)
downloadsrc-afa53e3372114192a6c7e5fd8dc2682e97a61e34.tar.gz
src-afa53e3372114192a6c7e5fd8dc2682e97a61e34.zip
MFC r368414:
arm: Let the GDB stub write to SP, LR and GP registers PR: 251463
Notes
Notes: svn path=/stable/12/; revision=368636
-rw-r--r--sys/arm/arm/gdb_machdep.c18
-rw-r--r--sys/arm/include/gdb_machdep.h2
2 files changed, 18 insertions, 2 deletions
diff --git a/sys/arm/arm/gdb_machdep.c b/sys/arm/arm/gdb_machdep.c
index 21c04341c3f6..fb957418c234 100644
--- a/sys/arm/arm/gdb_machdep.c
+++ b/sys/arm/arm/gdb_machdep.c
@@ -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;
}
}
diff --git a/sys/arm/include/gdb_machdep.h b/sys/arm/include/gdb_machdep.h
index 79c74cdd0e1f..017025253bd5 100644
--- a/sys/arm/include/gdb_machdep.h
+++ b/sys/arm/include/gdb_machdep.h
@@ -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