Index: aarch64-nbsd-nat.c =================================================================== RCS file: /cvsroot/src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c,v retrieving revision 1.1 diff -p -u -r1.1 aarch64-nbsd-nat.c --- aarch64-nbsd-nat.c 21 May 2018 02:10:47 -0000 1.1 +++ aarch64-nbsd-nat.c 21 Dec 2018 07:48:15 -0000 @@ -22,7 +22,9 @@ #include #include -#include + +#include +#include #include "nbsd-nat.h" #include "aarch64-tdep.h" @@ -124,6 +126,47 @@ aarch64_nbsd_store_inferior_registers (s } } +static int +aarch64_nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) +{ + struct trapframe tf; + int i; + + /* The following is true for NetBSD/arm64: + + The pcb contains the stack pointer at the point of the context + switch in cpu_switchto(). At that point we have a stack frame as + described by `struct trapframe', which has the following layout: + + x0..x30 + sp + pc + spsr + tpidr + + This accounts for all callee-saved registers specified by the psABI. + From this information we reconstruct the register state as it would + look when we just returned from cpu_switchto(). + + For kernel core dumps, dumpsys() builds a fake trapframe for us. */ + + /* The stack pointer shouldn't be zero. */ + if (pcb->pcb_sp == 0) + return 0; + + /* Read the stack frame, and check its validity. */ + read_memory (pcb->pcb_sp, (gdb_byte *) &tf, sizeof tf); + + for (i = 0; i <= 30; i++) + { + regcache_raw_supply (regcache, AARCH64_X0_REGNUM + i, &tf.tf_reg[i]); + } + regcache_raw_supply (regcache, AARCH64_SP_REGNUM, &tf.tf_sp); + regcache_raw_supply (regcache, AARCH64_PC_REGNUM, &tf.tf_pc); + + return 1; +} + void _initialize_aarch64_nbsd_nat (void) { @@ -133,4 +176,7 @@ _initialize_aarch64_nbsd_nat (void) t->to_fetch_registers = aarch64_nbsd_fetch_inferior_registers; t->to_store_registers = aarch64_nbsd_store_inferior_registers; nbsd_nat_add_target (t); + + /* Support debugging kernel virtual memory images. */ + bsd_kvm_add_target (aarch64_nbsd_supply_pcb); } Index: aarch64-nbsd-tdep.c =================================================================== RCS file: /cvsroot/src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.c,v retrieving revision 1.3 diff -p -u -r1.3 aarch64-nbsd-tdep.c --- aarch64-nbsd-tdep.c 11 Jul 2018 13:52:35 -0000 1.3 +++ aarch64-nbsd-tdep.c 21 Dec 2018 07:48:15 -0000 @@ -1,4 +1,4 @@ -/* Target-dependent code for FreeBSD/aarch64. +/* Target-dependent code for NetBSD/aarch64. Copyright (C) 2017-2018 Free Software Foundation, Inc. Index: aarch64-nbsd-tdep.h =================================================================== RCS file: /cvsroot/src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.h,v retrieving revision 1.2 diff -p -u -r1.2 aarch64-nbsd-tdep.h --- aarch64-nbsd-tdep.h 22 Jun 2018 19:41:40 -0000 1.2 +++ aarch64-nbsd-tdep.h 21 Dec 2018 07:48:15 -0000 @@ -1,4 +1,4 @@ -/* FreeBSD/aarch64 target support, prototypes. +/* NetBSD/aarch64 target support, prototypes. Copyright (C) 2017-2018 Free Software Foundation, Inc. Index: config/aarch64/nbsd.mh =================================================================== RCS file: /cvsroot/src/external/gpl3/gdb/dist/gdb/config/aarch64/nbsd.mh,v retrieving revision 1.1 diff -p -u -r1.1 nbsd.mh --- config/aarch64/nbsd.mh 21 May 2018 02:10:47 -0000 1.1 +++ config/aarch64/nbsd.mh 21 Dec 2018 07:48:15 -0000 @@ -1,4 +1,4 @@ -# Host: NetBSD/amd64 +# Host: NetBSD/arm64 NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o aarch64-nbsd-nat.o \ bsd-kvm.o