git: a22f1db084fb - main - devel/gdb: kgdb: fix aarch64 trapframe handling

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Wed, 13 Sep 2023 15:35:09 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a22f1db084fb50880a0df90f9a0f031a7fc34921

commit a22f1db084fb50880a0df90f9a0f031a7fc34921
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2023-09-13 15:34:07 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-09-13 15:34:26 +0000

    devel/gdb: kgdb: fix aarch64 trapframe handling
    
    regcache_map_entry_size() doesn't do the magic to convert size == 0 to
    register_size, so we must supply sizes for all registers if we're going
    to use it.
    
    This fixes handling of the trapframe so that we can actually unwind
    properly, where-as before we would end up with, e.g.,
    
     #6 0xffff0000004b4860 in kdb_trap (type=60, code=0, tf=<optimized out>)
      at /usr/src/sys/kern/subr_kdb.c:790
     #7 <signal handler called>
     #8 <signal handler called>
     #9 <signal handler called>
     #10 <signal handler called>
     #11 <signal handler called>
    
    Reported by:    Mark Millard
    Approved by:    jhb (implicit, kgdb maintainer)
    MFH:            2023Q3
---
 devel/gdb/Makefile                       |  2 +-
 devel/gdb/files/kgdb/aarch64-fbsd-kern.c | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/devel/gdb/Makefile b/devel/gdb/Makefile
index 921a14b566de..f72743a1dfa8 100644
--- a/devel/gdb/Makefile
+++ b/devel/gdb/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	gdb
 DISTVERSION=	13.1
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	devel
 MASTER_SITES=	GNU
 
diff --git a/devel/gdb/files/kgdb/aarch64-fbsd-kern.c b/devel/gdb/files/kgdb/aarch64-fbsd-kern.c
index 4d813c786b52..68b12130fa83 100644
--- a/devel/gdb/files/kgdb/aarch64-fbsd-kern.c
+++ b/devel/gdb/files/kgdb/aarch64-fbsd-kern.c
@@ -126,13 +126,13 @@ aarch64_fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr)
 
 static const struct regcache_map_entry aarch64_fbsd_trapframe_map[] =
   {
-    { 1, AARCH64_SP_REGNUM, 0 },
-    { 1, AARCH64_LR_REGNUM, 0 },
-    { 1, AARCH64_PC_REGNUM, 0 },
-    { 1, AARCH64_CPSR_REGNUM, 0 },
+    { 1, AARCH64_SP_REGNUM, 8 },
+    { 1, AARCH64_LR_REGNUM, 8 },
+    { 1, AARCH64_PC_REGNUM, 8 },
+    { 1, AARCH64_CPSR_REGNUM, 8 },
     { 1, REGCACHE_MAP_SKIP, 8 },	/* esr */
     { 1, REGCACHE_MAP_SKIP, 8 },	/* far */
-    { 30, AARCH64_X0_REGNUM, 0 },	/* x0 ... x29 */
+    { 30, AARCH64_X0_REGNUM, 8 },	/* x0 ... x29 */
     { 0 },
   };
 
@@ -141,12 +141,12 @@ static const struct regcache_map_entry aarch64_fbsd_trapframe_map[] =
 
 static const struct regcache_map_entry aarch64_fbsd13_trapframe_map[] =
   {
-    { 1, AARCH64_SP_REGNUM, 0 },
-    { 1, AARCH64_LR_REGNUM, 0 },
-    { 1, AARCH64_PC_REGNUM, 0 },
+    { 1, AARCH64_SP_REGNUM, 8 },
+    { 1, AARCH64_LR_REGNUM, 8 },
+    { 1, AARCH64_PC_REGNUM, 8 },
     { 1, AARCH64_CPSR_REGNUM, 4 },
     { 1, REGCACHE_MAP_SKIP, 4 },	/* esr */
-    { 30, AARCH64_X0_REGNUM, 0 },	/* x0 ... x29 */
+    { 30, AARCH64_X0_REGNUM, 8 },	/* x0 ... x29 */
     { 0 },
   };