Friday, September 03, 2021

ports/devel/gdb update with riscv support

So here's the result of the torture I've been doing to my self during
this hackathon. gdb-10.x inferior target support is broken for reasons
I still ignore and I've been told that moving to 9.x was already nice
enough. :)

Regarding the changes below:
- DEBUG_PACKAGES, reminded by sthen@
- disable mpfr, linking against libgmp.a breaks on powerpc with
relocation errors
- xxhash support added, just because it took me less time to just add
the dep. I didn't actually check for all possible new hidden deps
- CFLAGS tweak maybe not needed any more? If this actually requires
C11 or C++11 support, COMPILER should be changed
- upstream moved file named <arch><system> to <arch>-<system> so I moved
our files too, sorry for the churn.
- I also had to adapt our aarch64 and powerpc64 support patches to the
API changes that happened upstream
- i386 needed special love, some changes that happened in there haven't
been compile tested
- the ptid_get_pid->get_ptrace_pid issue has been solved upstream, so
a bunch of patches get removed
- some of the configure.nat dedup changes aren't strictly needed but
they just seem better in the long term. For example some of our
architectures didn't use bsd-kvm.c/libkvm.
- OpenBSD/riscv64 support files shamelessly copied from the FreeBSD
support (thanks!). Besides mechanical renaming, I think it's the only
relevant change I made there. riscv64 support means we can read
coredumps and print backtraces. We can't do inferior process
debugging yet because we just don't support PT_STEP (this may also be
a problem on other architectures). We also need a kernel diff that
I haven't sent yet.
- m88k support has been removed, sorry aoyama@ :-/
- the python patch isn't needed anymore

Thanks to all the folks who helped me test a previous diff on various
architectures! Even if there are still open questions (and I may have
forgotten some so reviews would be welcome), I hope we can commit this
update before tagging OpenBSD 7.0. Therefore I'll need another round of
tests!

Things to test with -current devel/gdb *and* after applying the diff below:
- egdb -ex run <dynamic program> # for example du
- egdb -ex run <static program> # for example ls
- reading a coredump and printing a backtrace
- ?

Thanks for reading this far, reviews/input welcome.


Index: Makefile
===================================================================
RCS file: /d/cvs/ports/devel/gdb/Makefile,v
retrieving revision 1.74
diff -u -p -r1.74 Makefile
--- Makefile 22 Mar 2021 17:33:14 -0000 1.74
+++ Makefile 2 Sep 2021 17:29:08 -0000
@@ -3,8 +3,7 @@
COMMENT= GNU debugger
CATEGORIES= devel

-DISTNAME= gdb-7.12.1
-REVISION= 16
+DISTNAME= gdb-9.2

HOMEPAGE= https://www.gnu.org/software/gdb/

@@ -19,7 +18,9 @@ EXTRACT_SUFX= .tar.xz

MODGNU_CONFIG_GUESS_DIRS= ${WRKSRC} ${WRKSRC}/gdb

-WANTLIB = c expat kvm m curses pthread ${MODPY_WANTLIB} ${COMPILER_LIBCXX} util
+WANTLIB = c curses expat kvm intl m pthread ${MODPY_WANTLIB} ${COMPILER_LIBCXX} util
+
+DEBUG_PACKAGES= ${BUILD_PACKAGES}

COMPILER= base-clang ports-gcc base-gcc

@@ -30,18 +31,24 @@ CONFIGURE_ARGS= --program-prefix=e \
--disable-sim \
--without-guile \
--without-lzma \
+ --without-mpfr \
--with-auto-load-dir=${TRUEPREFIX}/share/gdb/auto-load \
--enable-target=all \
--with-python=${MODPY_BIN}

USE_GMAKE= Yes
+MAKE_FLAGS= V=1 LDFLAGS="${LDFLAGS}"

MODULES += lang/python

+BUILD_DEPENDS = sysutils/xxhash
LIB_DEPENDS += ${MODPY_LIB_DEPENDS}
TEST_DEPENDS += devel/dejagnu

post-install:
${MODPY_BIN} -m compileall ${PREFIX}/share/gdb/python
+
+# for max_align_t configure test
+CFLAGS += -std=gnu11

.include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /d/cvs/ports/devel/gdb/distinfo,v
retrieving revision 1.22
diff -u -p -r1.22 distinfo
--- distinfo 28 Jan 2017 21:38:15 -0000 1.22
+++ distinfo 2 Sep 2021 17:30:26 -0000
@@ -1,2 +1,2 @@
-SHA256 (gdb/gdb-7.12.1.tar.xz) = RgdoC5c9PsksMK0Cnxt9veOHaGnms6EX2KfpAIERMYY=
-SIZE (gdb/gdb-7.12.1.tar.xz) = 19225392
+SHA256 (gdb/gdb-9.2.tar.xz) = NgzXrnm3dpiOidj5oByYXQsfohx2ekKV5fiMtJF1xVU=
+SIZE (gdb/gdb-9.2.tar.xz) = 20979436
Index: patches/patch-bfd_config_bfd
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-bfd_config_bfd,v
retrieving revision 1.3
diff -u -p -r1.3 patch-bfd_config_bfd
--- patches/patch-bfd_config_bfd 10 Jul 2018 11:03:46 -0000 1.3
+++ patches/patch-bfd_config_bfd 2 Sep 2021 17:31:23 -0000
@@ -1,7 +1,8 @@
$OpenBSD: patch-bfd_config_bfd,v 1.3 2018/07/10 11:03:46 kettenis Exp $
---- bfd/config.bfd.orig Sat Jan 21 05:48:42 2017
-+++ bfd/config.bfd Tue Mar 7 22:55:11 2017
-@@ -202,6 +202,11 @@ case "${targ}" in
+Index: bfd/config.bfd
+--- bfd/config.bfd.orig
++++ bfd/config.bfd
+@@ -257,6 +257,11 @@ case "${targ}" in
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
want64=true
;;
Index: patches/patch-bfd_elf_c
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-bfd_elf_c,v
retrieving revision 1.9
diff -u -p -r1.9 patch-bfd_elf_c
--- patches/patch-bfd_elf_c 9 Oct 2016 11:39:20 -0000 1.9
+++ patches/patch-bfd_elf_c 2 Sep 2021 17:31:23 -0000
@@ -1,7 +1,8 @@
$OpenBSD: patch-bfd_elf_c,v 1.9 2016/10/09 11:39:20 pascal Exp $
---- bfd/elf.c.orig Fri Oct 7 19:09:21 2016
-+++ bfd/elf.c Fri Oct 7 20:53:14 2016
-@@ -9866,6 +9866,11 @@ elfcore_grok_openbsd_procinfo (bfd *abfd, Elf_Internal
+Index: bfd/elf.c
+--- bfd/elf.c.orig
++++ bfd/elf.c
+@@ -10758,6 +10758,11 @@ elfcore_grok_openbsd_procinfo (bfd *abfd, Elf_Internal
static bfd_boolean
elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note)
{
Index: patches/patch-bfd_peXXigen_c
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-bfd_peXXigen_c,v
retrieving revision 1.6
diff -u -p -r1.6 patch-bfd_peXXigen_c
--- patches/patch-bfd_peXXigen_c 9 Oct 2016 11:39:20 -0000 1.6
+++ patches/patch-bfd_peXXigen_c 2 Sep 2021 17:31:23 -0000
@@ -1,8 +1,9 @@
$OpenBSD: patch-bfd_peXXigen_c,v 1.6 2016/10/09 11:39:20 pascal Exp $
Fix out-of-bounds memcpys (FILNMLEN is 18, sizeof x_fname is 14).
---- bfd/peXXigen.c.orig Fri Oct 7 19:09:21 2016
-+++ bfd/peXXigen.c Fri Oct 7 20:53:14 2016
-@@ -311,7 +311,7 @@ _bfd_XXi_swap_aux_in (bfd * abfd,
+Index: bfd/peXXigen.c
+--- bfd/peXXigen.c.orig
++++ bfd/peXXigen.c
+@@ -318,7 +318,7 @@ _bfd_XXi_swap_aux_in (bfd * abfd,
in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
}
else
@@ -11,7 +12,7 @@ Fix out-of-bounds memcpys (FILNMLEN is 1
return;

case C_STAT:
-@@ -385,7 +385,7 @@ _bfd_XXi_swap_aux_out (bfd * abfd,
+@@ -392,7 +392,7 @@ _bfd_XXi_swap_aux_out (bfd * abfd,
H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
}
else
Index: patches/patch-gdb_Makefile_in
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-gdb_Makefile_in,v
retrieving revision 1.3
diff -u -p -r1.3 patch-gdb_Makefile_in
--- patches/patch-gdb_Makefile_in 10 Jul 2018 11:03:46 -0000 1.3
+++ patches/patch-gdb_Makefile_in 3 Sep 2021 11:22:50 -0000
@@ -2,23 +2,45 @@ $OpenBSD: patch-gdb_Makefile_in,v 1.3 20
Index: gdb/Makefile.in
--- gdb/Makefile.in.orig
+++ gdb/Makefile.in
-@@ -644,7 +644,8 @@ TARGET_OBS = @TARGET_OBS@
- # All target-dependent objects files that require 64-bit CORE_ADDR
- # (used with --enable-targets=all --enable-64-bit-bfd).
- ALL_64_TARGET_OBS = \
-- aarch64-tdep.o aarch64-linux-tdep.o aarch64-newlib-tdep.o aarch64-insn.o \
-+ aarch64-tdep.o aarch64-linux-tdep.o \
-+ aarch64-newlib-tdep.o aarch64obsd-tdep.o aarch64-insn.o \
- alphabsd-tdep.o alphafbsd-tdep.o alpha-linux-tdep.o alpha-mdebug-tdep.o \
- alphanbsd-tdep.o alphaobsd-tdep.o alpha-tdep.o \
- amd64fbsd-tdep.o amd64-darwin-tdep.o amd64-dicos-tdep.o \
-@@ -1663,7 +1664,8 @@ MAKEOVERRIDES=
-
- ALLDEPFILES = \
- aarch64-tdep.c aarch64-linux-tdep.c aarch64-newlib-tdep.c \
-- aarch64-linux-nat.c \
-+ aarch64obsd-tdep.c \
-+ aarch64-linux-nat.c aarch64obsd-nat.c \
+@@ -651,6 +651,7 @@ ALL_64_TARGET_OBS = \
+ aarch64-fbsd-tdep.o \
+ aarch64-linux-tdep.o \
+ aarch64-newlib-tdep.o \
++ aarch64-obsd-tdep.o \
+ aarch64-ravenscar-thread.o \
+ aarch64-tdep.o \
+ alpha-bsd-tdep.o \
+@@ -675,6 +676,7 @@ ALL_64_TARGET_OBS = \
+ ia64-tdep.o \
+ ia64-vms-tdep.o \
+ mips64-obsd-tdep.o \
++ riscv-obsd-tdep.o \
+ sparc64-fbsd-tdep.o \
+ sparc64-linux-tdep.o \
+ sparc64-nbsd-tdep.o \
+@@ -1381,6 +1383,7 @@ HFILES_NO_SRCDIR = \
+ remote-notif.h \
+ riscv-fbsd-tdep.h \
+ riscv-tdep.h \
++ riscv-obsd-tdep.h \
+ rs6000-aix-tdep.h \
+ rs6000-tdep.h \
+ run-on-main-thread.h \
+@@ -2157,6 +2160,8 @@ ALLDEPFILES = \
+ aarch64-linux-nat.c \
+ aarch64-linux-tdep.c \
+ aarch64-newlib-tdep.c \
++ aarch64-obsd-nat.c \
++ aarch64-obsd-tdep.c \
+ aarch64-ravenscar-thread.c \
+ aarch64-tdep.c \
aix-thread.c \
- alphabsd-nat.c alpha-linux-nat.c \
- alpha-tdep.c alpha-mdebug-tdep.c \
+@@ -2300,6 +2305,8 @@ ALLDEPFILES = \
+ riscv-linux-nat.c \
+ riscv-linux-tdep.c \
+ riscv-tdep.c \
++ riscv-obsd-nat.c \
++ riscv-obsd-tdep.c \
+ rl78-tdep.c \
+ rs6000-lynx178-tdep.c \
+ rs6000-nat.c \
Index: patches/patch-gdb_aarch64-obsd-nat_c
===================================================================
RCS file: patches/patch-gdb_aarch64-obsd-nat_c
diff -N patches/patch-gdb_aarch64-obsd-nat_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_aarch64-obsd-nat_c 2 Sep 2021 15:34:14 -0000
@@ -0,0 +1,212 @@
+$OpenBSD$
+
+Index: gdb/aarch64-obsd-nat.c
+--- gdb/aarch64-obsd-nat.c.orig
++++ gdb/aarch64-obsd-nat.c
+@@ -0,0 +1,206 @@
++/* Native-dependent code for OpenBSD/arm64 (AArch64)
++
++ Copyright (C) 2011-2017 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include "defs.h"
++#include "gdbcore.h"
++#include "inferior.h"
++#include "regcache.h"
++#include <sys/types.h>
++#include <sys/ptrace.h>
++#include <machine/reg.h>
++
++#include "aarch64-tdep.h"
++#include "inf-ptrace.h"
++#include "obsd-nat.h"
++
++/* Fill GDB's register array with the general-purpose register values
++ from the current thread. */
++
++static void
++fetch_gregs_from_thread (struct regcache *regcache)
++{
++ struct reg regs;
++ pid_t pid;
++ int regno;
++ int ret;
++
++ pid = get_ptrace_pid (inferior_ptid);
++
++ ret = ptrace(PT_GETREGS, pid, (caddr_t)&regs, 0);
++ if (ret < 0)
++ perror_with_name (_("Unable to fetch general registers."));
++
++ for (regno = AARCH64_X0_REGNUM; regno <= AARCH64_FP_REGNUM; regno++)
++ regcache->raw_supply (regno, &regs.r_reg[regno]);
++ regcache->raw_supply (AARCH64_LR_REGNUM, &regs.r_lr);
++ regcache->raw_supply (AARCH64_SP_REGNUM, &regs.r_sp);
++ regcache->raw_supply (AARCH64_PC_REGNUM, &regs.r_pc);
++ regcache->raw_supply (AARCH64_CPSR_REGNUM, &regs.r_spsr);
++}
++
++/* Store to the current thread the valid general-purpose register
++ values in the GDB's register array. */
++
++static void
++store_gregs_to_thread (const struct regcache *regcache)
++{
++ struct reg regs;
++ pid_t pid;
++ int regno;
++ int ret;
++
++ pid = get_ptrace_pid (inferior_ptid);
++
++ // fetch old values as only 'valid' entries will be replaced.
++ ret = ptrace(PT_GETREGS, pid, (caddr_t)&regs, 0);
++ if (ret < 0) {
++ perror_with_name (_("Unable to store general registers."));
++ return;
++ }
++
++ for (regno = AARCH64_X0_REGNUM; regno <= AARCH64_FP_REGNUM; regno++)
++ if (REG_VALID == regcache->get_register_status (regno))
++ regcache->raw_collect (regno, &regs.r_reg[regno]);
++ if (REG_VALID == regcache->get_register_status (AARCH64_LR_REGNUM))
++ regcache->raw_collect (AARCH64_LR_REGNUM, &regs.r_lr);
++ if (REG_VALID == regcache->get_register_status (AARCH64_SP_REGNUM))
++ regcache->raw_collect (AARCH64_SP_REGNUM, &regs.r_sp);
++ if (REG_VALID == regcache->get_register_status (AARCH64_PC_REGNUM))
++ regcache->raw_collect (AARCH64_PC_REGNUM, &regs.r_pc);
++ if (REG_VALID == regcache->get_register_status (AARCH64_CPSR_REGNUM))
++ regcache->raw_collect (AARCH64_CPSR_REGNUM, &regs.r_spsr);
++
++ ret = ptrace(PT_SETREGS, pid, (caddr_t)&regs, 0);
++ if (ret < 0)
++ perror_with_name (_("Unable to store general registers."));
++}
++
++/* Fill GDB's register array with the fp/simd register values
++ from the current thread. */
++
++static void
++fetch_fpregs_from_thread (struct regcache *regcache)
++{
++ int ret;
++ pid_t pid;
++ int regno;
++ struct fpreg fpregs;
++
++ pid = get_ptrace_pid (inferior_ptid);
++
++ ret = ptrace(PT_GETFPREGS, pid, (caddr_t)&fpregs, 0);
++ if (ret < 0) {
++ perror_with_name (_("Unable to fetch general registers."));
++ return;
++ }
++
++ for (regno = AARCH64_V0_REGNUM; regno <= AARCH64_V31_REGNUM; regno++)
++ regcache->raw_supply (regno, &fpregs.fp_reg[regno]);
++
++ regcache->raw_supply (AARCH64_FPSR_REGNUM, &fpregs.fp_sr);
++ regcache->raw_supply (AARCH64_FPCR_REGNUM, &fpregs.fp_cr);
++}
++
++/* Store to the current thread the valid fp/simd register
++ values in the GDB's register array. */
++
++static void
++store_fpregs_to_thread (const struct regcache *regcache)
++{
++ int ret;
++ pid_t pid;
++ int regno;
++ struct fpreg fpregs;
++
++ pid = get_ptrace_pid (inferior_ptid);
++
++ ret = ptrace(PT_GETFPREGS, pid, (caddr_t)&fpregs, 0);
++ if (ret < 0) {
++ perror_with_name (_("Unable to store general registers."));
++ return;
++ }
++
++ for (regno = AARCH64_V0_REGNUM; regno <= AARCH64_V31_REGNUM; regno++)
++ if (REG_VALID == regcache->get_register_status (regno))
++ regcache->raw_collect (regno, &fpregs.fp_reg[regno]);
++
++ if (REG_VALID == regcache->get_register_status (AARCH64_FPSR_REGNUM))
++ regcache->raw_collect (AARCH64_FPSR_REGNUM, &fpregs.fp_sr);
++ if (REG_VALID == regcache->get_register_status (AARCH64_FPCR_REGNUM))
++ regcache->raw_collect (AARCH64_FPCR_REGNUM, &fpregs.fp_cr);
++
++ ret = ptrace(PT_SETFPREGS, pid, (caddr_t)&fpregs, 0);
++ if (ret < 0)
++ perror_with_name (_("Unable to store general registers."));
++}
++
++/* Implement the "to_fetch_register" target_ops method. */
++
++static void
++aarch64_obsd_fetch_inferior_registers (struct target_ops *ops,
++ struct regcache *regcache,
++ int regno)
++{
++ if (regno == -1)
++ {
++ fetch_gregs_from_thread (regcache);
++ fetch_fpregs_from_thread (regcache);
++ }
++ else if (regno < AARCH64_V0_REGNUM)
++ fetch_gregs_from_thread (regcache);
++ else
++ fetch_fpregs_from_thread (regcache);
++}
++
++/* Implement the "to_store_register" target_ops method. */
++
++static void
++aarch64_obsd_store_inferior_registers (struct target_ops *ops,
++ struct regcache *regcache,
++ int regno)
++{
++ if (regno == -1)
++ {
++ store_gregs_to_thread (regcache);
++ store_fpregs_to_thread (regcache);
++ }
++ else if (regno < AARCH64_V0_REGNUM)
++ store_gregs_to_thread (regcache);
++ else
++ store_fpregs_to_thread (regcache);
++}
++
++
++/* -Wmissing-prototypes. */
++void _initialize_aarch64_obsd_nat (void);
++
++void
++_initialize_aarch64_obsd_nat (void)
++{
++ struct target_ops *t;
++
++ t = inf_ptrace_target ();
++
++ /* Add our register access methods. */
++ t->to_fetch_registers = aarch64_obsd_fetch_inferior_registers;
++ t->to_store_registers = aarch64_obsd_store_inferior_registers;
++
++ /* Register the target. */
++ obsd_add_target (t);
++}
Index: patches/patch-gdb_aarch64-obsd-tdep_c
===================================================================
RCS file: patches/patch-gdb_aarch64-obsd-tdep_c
diff -N patches/patch-gdb_aarch64-obsd-tdep_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_aarch64-obsd-tdep_c 2 Sep 2021 15:34:14 -0000
@@ -0,0 +1,306 @@
+$OpenBSD$
+
+Index: gdb/aarch64-obsd-tdep.c
+--- gdb/aarch64-obsd-tdep.c.orig
++++ gdb/aarch64-obsd-tdep.c
+@@ -0,0 +1,300 @@
++/* Target-dependent code for OpenBSD/aarch64.
++
++ Copyright (C) 2006-2017 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include "defs.h"
++#include "gdbarch.h"
++#include "frame-unwind.h"
++#include "osabi.h"
++#include "regset.h"
++#include "trad-frame.h"
++#include "tramp-frame.h"
++
++#include "aarch64-tdep.h"
++#include "obsd-tdep.h"
++#include "solib-svr4.h"
++
++/* Signal trampolines. */
++
++/* Since OpenBSD 3.2, the sigtramp routine is mapped at a random page
++ in virtual memory. The randomness makes it somewhat tricky to
++ detect it, but fortunately we can rely on the fact that the start
++ of the sigtramp routine is page-aligned. We recognize the
++ trampoline by looking for the code that invokes the sigreturn
++ system call. The offset where we can find that code varies from
++ release to release.
++
++ By the way, the mapping mentioned above is read-only, so you cannot
++ place a breakpoint in the signal trampoline. */
++
++/* Default page size. */
++static const CORE_ADDR aarch64obsd_page_size = 4096;
++
++/* Offset for sigreturn(2). */
++static const int aarch64obsd_sigreturn_offset[] = {
++ 0xb4, /* OpenBSD 6.2 */
++ 0x08, /* OpenBSD 6.1 */
++ -1
++};
++
++static int
++aarch64obsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
++ struct frame_info *this_frame,
++ void **this_cache)
++{
++ struct gdbarch *gdbarch = get_frame_arch (this_frame);
++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
++ CORE_ADDR pc = get_frame_pc (this_frame);
++ CORE_ADDR start_pc = (pc & ~(aarch64obsd_page_size - 1));
++ const int *offset;
++ const char *name;
++
++ find_pc_partial_function (pc, &name, NULL, NULL);
++ if (name)
++ return 0;
++
++ for (offset = aarch64obsd_sigreturn_offset; *offset != -1; offset++)
++ {
++ gdb_byte buf[8];
++ unsigned long insn;
++
++ if (!safe_frame_unwind_memory (this_frame, start_pc + *offset,
++ buf, sizeof buf))
++ continue;
++
++ /* Check for "mov x8, #SYS_sigreturn". */
++ insn = extract_unsigned_integer (buf, 4, byte_order);
++ if (insn != 0xd2800ce8)
++ continue;
++
++ /* Check for "svc 0". */
++ insn = extract_unsigned_integer (buf + 4, 4, byte_order);
++ if (insn != 0xd4000001)
++ continue;
++
++ return 1;
++ }
++
++ return 0;
++}
++
++/*
++ In 6.1 the sp points to the struct sigframe. Since 6.2 the
++ sigtramp routine saves floating point registers on the stack
++ before the struct sigframe so that needs to be skipped to look
++ at sigframe. A sigframe looks like this:
++
++ struct sigframe {
++ int sf_signum;
++ struct sigcontext sf_sc;
++ siginfo_t sf_si;
++ };
++
++ struct sigcontext {
++ int __sc_unused;
++ int sc_mask;
++
++ unsigned long sc_sp;
++ unsigned long sc_lr;
++ unsigned long sc_elr;
++ unsigned long sc_spsr;
++ unsigned long sc_x[30];
++
++ long sc_cookie;
++ };
++
++*/
++
++#define AARCH64_SIGCONTEXT_REG_SIZE 8
++#define AARCH64_SIGFRAME_SIGCONTEXT_OFFSET 8
++#define AARCH64_SIGCONTEXT_SP_OFFSET 8
++#define AARCH64_SIGCONTEXT_LR_OFFSET 16
++#define AARCH64_SIGCONTEXT_PC_OFFSET 24
++#define AARCH64_SIGCONTEXT_SPSR_OFFSET 32
++#define AARCH64_SIGCONTEXT_X0_OFFSET 40
++
++static struct trad_frame_cache *
++aarch64obsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
++{
++ struct gdbarch *gdbarch = get_frame_arch (this_frame);
++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
++ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
++ struct trad_frame_cache *cache;
++ CORE_ADDR sp, sigcontext_addr, x0_addr, func;
++ gdb_byte buf[4];
++ unsigned long insn, sigframe_offset = 0;
++ int i;
++
++ if (*this_cache)
++ return (struct trad_frame_cache *) *this_cache;
++
++ cache = trad_frame_cache_zalloc (this_frame);
++ *this_cache = cache;
++
++ func = get_frame_pc (this_frame);
++ func &= ~(aarch64obsd_page_size - 1);
++ if (!safe_frame_unwind_memory (this_frame, func, buf, sizeof buf))
++ return cache;
++
++ /* Calculate the offset where we can find `struct sigframe'. In 6.1
++ no adjustment is needed so we look at the first instruction to see
++ if it matches 6.2+. If it is a 'sub sp, sp, #0xNNN' instruction,
++ use the amount of stack space to skip from it. */
++ insn = extract_unsigned_integer (buf, 4, byte_order);
++ if ((insn & 0xffc003ff) == 0xd10003ff)
++ sigframe_offset += ((insn & 0x003ffc00) >> 10);
++
++ sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
++ sigcontext_addr = sp + sigframe_offset + AARCH64_SIGFRAME_SIGCONTEXT_OFFSET;
++ x0_addr = sigcontext_addr + AARCH64_SIGCONTEXT_X0_OFFSET;
++
++ trad_frame_set_reg_addr (cache, AARCH64_SP_REGNUM,
++ sigcontext_addr + AARCH64_SIGCONTEXT_SP_OFFSET);
++ trad_frame_set_reg_addr (cache, AARCH64_LR_REGNUM,
++ sigcontext_addr + AARCH64_SIGCONTEXT_LR_OFFSET);
++ trad_frame_set_reg_addr (cache, AARCH64_PC_REGNUM,
++ sigcontext_addr + AARCH64_SIGCONTEXT_PC_OFFSET);
++ trad_frame_set_reg_addr (cache, AARCH64_CPSR_REGNUM,
++ sigcontext_addr + AARCH64_SIGCONTEXT_SPSR_OFFSET);
++ for (i = 0; i < 30; i++)
++ {
++ trad_frame_set_reg_addr (cache, AARCH64_X0_REGNUM + i,
++ x0_addr + i * AARCH64_SIGCONTEXT_REG_SIZE);
++ }
++
++ trad_frame_set_id (cache, frame_id_build (sp, func));
++
++ return cache;
++}
++
++static void
++aarch64obsd_sigtramp_frame_this_id (struct frame_info *this_frame,
++ void **this_cache,
++ struct frame_id *this_id)
++{
++ struct trad_frame_cache *cache =
++ aarch64obsd_sigtramp_frame_cache (this_frame, this_cache);
++
++ trad_frame_get_id (cache, this_id);
++}
++
++static struct value *
++aarch64obsd_sigtramp_frame_prev_register (struct frame_info *this_frame,
++ void **this_cache, int regnum)
++{
++ struct trad_frame_cache *cache =
++ aarch64obsd_sigtramp_frame_cache (this_frame, this_cache);
++
++ return trad_frame_get_register (cache, this_frame, regnum);
++}
++
++static const struct frame_unwind aarch64obsd_sigtramp_frame_unwind = {
++ SIGTRAMP_FRAME,
++ default_frame_unwind_stop_reason,
++ aarch64obsd_sigtramp_frame_this_id,
++ aarch64obsd_sigtramp_frame_prev_register,
++ NULL,
++ aarch64obsd_sigtramp_frame_sniffer
++};
++
++/* The general-purpose regset consists of 31 X registers, plus SP, PC,
++ and SPSR and TPIDR registers. */
++#define AARCH64_OBSD_SIZEOF_GREGSET (35 * X_REGISTER_SIZE)
++
++/* The fp regset consists of 32 V registers, plus FPSR and FPCR which
++ are 4 bytes wide each, and the whole structure is padded to 128 bit
++ alignment. */
++#define AARCH64_OBSD_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
++
++/* Register maps. */
++
++static const struct regcache_map_entry aarch64_obsd_gregmap[] =
++ {
++ { 31, AARCH64_X0_REGNUM, 8 }, /* x0 ... x30 */
++ { 1, AARCH64_SP_REGNUM, 8 },
++ { 1, AARCH64_PC_REGNUM, 8 },
++ { 1, AARCH64_CPSR_REGNUM, 8 },
++ { 0 }
++ };
++
++static const struct regcache_map_entry aarch64_obsd_fpregmap[] =
++ {
++ { 32, AARCH64_V0_REGNUM, 16 }, /* v0 ... v31 */
++ { 1, AARCH64_FPSR_REGNUM, 4 },
++ { 1, AARCH64_FPCR_REGNUM, 4 },
++ { 0 }
++ };
++
++/* Register set definitions. */
++
++const struct regset aarch64_obsd_gregset =
++ {
++ aarch64_obsd_gregmap,
++ regcache_supply_regset, regcache_collect_regset
++ };
++
++const struct regset aarch64_obsd_fpregset =
++ {
++ aarch64_obsd_fpregmap,
++ regcache_supply_regset, regcache_collect_regset
++ };
++
++static void
++aarch64_obsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
++ iterate_over_regset_sections_cb *cb,
++ void *cb_data,
++ const struct regcache *regcache)
++{
++ cb (".reg", AARCH64_OBSD_SIZEOF_GREGSET, AARCH64_OBSD_SIZEOF_GREGSET,
++ &aarch64_obsd_gregset, NULL, cb_data);
++ cb (".reg2", AARCH64_OBSD_SIZEOF_FPREGSET, AARCH64_OBSD_SIZEOF_FPREGSET,
++ &aarch64_obsd_fpregset, NULL, cb_data);
++}
++
++
++static void
++aarch64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
++{
++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
++
++ obsd_init_abi (info, gdbarch);
++
++ /* OpenBSD/aarch64 uses SVR4-style shared libraries. */
++ set_solib_svr4_fetch_link_map_offsets
++ (gdbarch, svr4_lp64_fetch_link_map_offsets);
++ set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver);
++
++ frame_unwind_append_unwinder (gdbarch, &aarch64obsd_sigtramp_frame_unwind);
++
++ /* Enable longjmp. */
++ tdep->jb_pc = 13;
++
++ set_gdbarch_iterate_over_regset_sections
++ (gdbarch, aarch64_obsd_iterate_over_regset_sections);
++}
++
++
++/* Provide a prototype to silence -Wmissing-prototypes. */
++extern initialize_file_ftype _initialize_aarch64obsd_tdep;
++
++void
++_initialize_aarch64obsd_tdep (void)
++{
++ gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_OPENBSD,
++ aarch64obsd_init_abi);
++}
Index: patches/patch-gdb_aarch64obsd-nat_c
===================================================================
RCS file: patches/patch-gdb_aarch64obsd-nat_c
diff -N patches/patch-gdb_aarch64obsd-nat_c
--- patches/patch-gdb_aarch64obsd-nat_c 17 Oct 2019 17:10:26 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,211 +0,0 @@
-$OpenBSD: patch-gdb_aarch64obsd-nat_c,v 1.2 2019/10/17 17:10:26 kurt Exp $
-Index: gdb/aarch64obsd-nat.c
---- gdb/aarch64obsd-nat.c.orig
-+++ gdb/aarch64obsd-nat.c
-@@ -0,0 +1,206 @@
-+/* Native-dependent code for OpenBSD/arm64 (AArch64)
-+
-+ Copyright (C) 2011-2017 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "defs.h"
-+#include "gdbcore.h"
-+#include "inferior.h"
-+#include "regcache.h"
-+#include <sys/types.h>
-+#include <sys/ptrace.h>
-+#include <machine/reg.h>
-+
-+#include "aarch64-tdep.h"
-+#include "inf-ptrace.h"
-+#include "obsd-nat.h"
-+
-+/* Fill GDB's register array with the general-purpose register values
-+ from the current thread. */
-+
-+static void
-+fetch_gregs_from_thread (struct regcache *regcache)
-+{
-+ struct reg regs;
-+ pid_t pid;
-+ int regno;
-+ int ret;
-+
-+ pid = get_ptrace_pid (inferior_ptid);
-+
-+ ret = ptrace(PT_GETREGS, pid, (caddr_t)&regs, 0);
-+ if (ret < 0)
-+ perror_with_name (_("Unable to fetch general registers."));
-+
-+ for (regno = AARCH64_X0_REGNUM; regno <= AARCH64_FP_REGNUM; regno++)
-+ regcache_raw_supply (regcache, regno, &regs.r_reg[regno]);
-+ regcache_raw_supply (regcache, AARCH64_LR_REGNUM, &regs.r_lr);
-+ regcache_raw_supply (regcache, AARCH64_SP_REGNUM, &regs.r_sp);
-+ regcache_raw_supply (regcache, AARCH64_PC_REGNUM, &regs.r_pc);
-+ regcache_raw_supply (regcache, AARCH64_CPSR_REGNUM, &regs.r_spsr);
-+}
-+
-+/* Store to the current thread the valid general-purpose register
-+ values in the GDB's register array. */
-+
-+static void
-+store_gregs_to_thread (const struct regcache *regcache)
-+{
-+ struct reg regs;
-+ pid_t pid;
-+ int regno;
-+ int ret;
-+
-+ pid = get_ptrace_pid (inferior_ptid);
-+
-+ // fetch old values as only 'valid' entries will be replaced.
-+ ret = ptrace(PT_GETREGS, pid, (caddr_t)&regs, 0);
-+ if (ret < 0) {
-+ perror_with_name (_("Unable to store general registers."));
-+ return;
-+ }
-+
-+ for (regno = AARCH64_X0_REGNUM; regno <= AARCH64_FP_REGNUM; regno++)
-+ if (REG_VALID == regcache_register_status (regcache, regno))
-+ regcache_raw_collect (regcache, regno, &regs.r_reg[regno]);
-+ if (REG_VALID == regcache_register_status (regcache, AARCH64_LR_REGNUM))
-+ regcache_raw_collect (regcache, AARCH64_LR_REGNUM, &regs.r_lr);
-+ if (REG_VALID == regcache_register_status (regcache, AARCH64_SP_REGNUM))
-+ regcache_raw_collect (regcache, AARCH64_SP_REGNUM, &regs.r_sp);
-+ if (REG_VALID == regcache_register_status (regcache, AARCH64_PC_REGNUM))
-+ regcache_raw_collect (regcache, AARCH64_PC_REGNUM, &regs.r_pc);
-+ if (REG_VALID == regcache_register_status (regcache, AARCH64_CPSR_REGNUM))
-+ regcache_raw_collect (regcache, AARCH64_CPSR_REGNUM, &regs.r_spsr);
-+
-+ ret = ptrace(PT_SETREGS, pid, (caddr_t)&regs, 0);
-+ if (ret < 0)
-+ perror_with_name (_("Unable to store general registers."));
-+}
-+
-+/* Fill GDB's register array with the fp/simd register values
-+ from the current thread. */
-+
-+static void
-+fetch_fpregs_from_thread (struct regcache *regcache)
-+{
-+ int ret;
-+ pid_t pid;
-+ int regno;
-+ struct fpreg fpregs;
-+
-+ pid = get_ptrace_pid (inferior_ptid);
-+
-+ ret = ptrace(PT_GETFPREGS, pid, (caddr_t)&fpregs, 0);
-+ if (ret < 0) {
-+ perror_with_name (_("Unable to fetch general registers."));
-+ return;
-+ }
-+
-+ for (regno = AARCH64_V0_REGNUM; regno <= AARCH64_V31_REGNUM; regno++)
-+ regcache_raw_supply (regcache, regno, &fpregs.fp_reg[regno]);
-+
-+ regcache_raw_supply (regcache, AARCH64_FPSR_REGNUM, &fpregs.fp_sr);
-+ regcache_raw_supply (regcache, AARCH64_FPCR_REGNUM, &fpregs.fp_cr);
-+}
-+
-+/* Store to the current thread the valid fp/simd register
-+ values in the GDB's register array. */
-+
-+static void
-+store_fpregs_to_thread (const struct regcache *regcache)
-+{
-+ int ret;
-+ pid_t pid;
-+ int regno;
-+ struct fpreg fpregs;
-+
-+ pid = get_ptrace_pid (inferior_ptid);
-+
-+ ret = ptrace(PT_GETFPREGS, pid, (caddr_t)&fpregs, 0);
-+ if (ret < 0) {
-+ perror_with_name (_("Unable to store general registers."));
-+ return;
-+ }
-+
-+ for (regno = AARCH64_V0_REGNUM; regno <= AARCH64_V31_REGNUM; regno++)
-+ if (REG_VALID == regcache_register_status (regcache, regno))
-+ regcache_raw_collect (regcache, regno, &fpregs.fp_reg[regno]);
-+
-+ if (REG_VALID == regcache_register_status (regcache, AARCH64_FPSR_REGNUM))
-+ regcache_raw_collect (regcache, AARCH64_FPSR_REGNUM, &fpregs.fp_sr);
-+ if (REG_VALID == regcache_register_status (regcache, AARCH64_FPCR_REGNUM))
-+ regcache_raw_collect (regcache, AARCH64_FPCR_REGNUM, &fpregs.fp_cr);
-+
-+ ret = ptrace(PT_SETFPREGS, pid, (caddr_t)&fpregs, 0);
-+ if (ret < 0)
-+ perror_with_name (_("Unable to store general registers."));
-+}
-+
-+/* Implement the "to_fetch_register" target_ops method. */
-+
-+static void
-+aarch64_obsd_fetch_inferior_registers (struct target_ops *ops,
-+ struct regcache *regcache,
-+ int regno)
-+{
-+ if (regno == -1)
-+ {
-+ fetch_gregs_from_thread (regcache);
-+ fetch_fpregs_from_thread (regcache);
-+ }
-+ else if (regno < AARCH64_V0_REGNUM)
-+ fetch_gregs_from_thread (regcache);
-+ else
-+ fetch_fpregs_from_thread (regcache);
-+}
-+
-+/* Implement the "to_store_register" target_ops method. */
-+
-+static void
-+aarch64_obsd_store_inferior_registers (struct target_ops *ops,
-+ struct regcache *regcache,
-+ int regno)
-+{
-+ if (regno == -1)
-+ {
-+ store_gregs_to_thread (regcache);
-+ store_fpregs_to_thread (regcache);
-+ }
-+ else if (regno < AARCH64_V0_REGNUM)
-+ store_gregs_to_thread (regcache);
-+ else
-+ store_fpregs_to_thread (regcache);
-+}
-+
-+
-+/* -Wmissing-prototypes. */
-+void _initialize_aarch64_obsd_nat (void);
-+
-+void
-+_initialize_aarch64_obsd_nat (void)
-+{
-+ struct target_ops *t;
-+
-+ t = inf_ptrace_target ();
-+
-+ /* Add our register access methods. */
-+ t->to_fetch_registers = aarch64_obsd_fetch_inferior_registers;
-+ t->to_store_registers = aarch64_obsd_store_inferior_registers;
-+
-+ /* Register the target. */
-+ obsd_add_target (t);
-+}
Index: patches/patch-gdb_aarch64obsd-tdep_c
===================================================================
RCS file: patches/patch-gdb_aarch64obsd-tdep_c
diff -N patches/patch-gdb_aarch64obsd-tdep_c
--- patches/patch-gdb_aarch64obsd-tdep_c 17 Oct 2019 17:10:26 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,304 +0,0 @@
-$OpenBSD: patch-gdb_aarch64obsd-tdep_c,v 1.2 2019/10/17 17:10:26 kurt Exp $
-Index: gdb/aarch64obsd-tdep.c
---- gdb/aarch64obsd-tdep.c.orig
-+++ gdb/aarch64obsd-tdep.c
-@@ -0,0 +1,299 @@
-+/* Target-dependent code for OpenBSD/aarch64.
-+
-+ Copyright (C) 2006-2017 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+#include "defs.h"
-+#include "frame-unwind.h"
-+#include "osabi.h"
-+#include "regset.h"
-+#include "trad-frame.h"
-+#include "tramp-frame.h"
-+
-+#include "aarch64-tdep.h"
-+#include "obsd-tdep.h"
-+#include "solib-svr4.h"
-+
-+/* Signal trampolines. */
-+
-+/* Since OpenBSD 3.2, the sigtramp routine is mapped at a random page
-+ in virtual memory. The randomness makes it somewhat tricky to
-+ detect it, but fortunately we can rely on the fact that the start
-+ of the sigtramp routine is page-aligned. We recognize the
-+ trampoline by looking for the code that invokes the sigreturn
-+ system call. The offset where we can find that code varies from
-+ release to release.
-+
-+ By the way, the mapping mentioned above is read-only, so you cannot
-+ place a breakpoint in the signal trampoline. */
-+
-+/* Default page size. */
-+static const CORE_ADDR aarch64obsd_page_size = 4096;
-+
-+/* Offset for sigreturn(2). */
-+static const int aarch64obsd_sigreturn_offset[] = {
-+ 0xb4, /* OpenBSD 6.2 */
-+ 0x08, /* OpenBSD 6.1 */
-+ -1
-+};
-+
-+static int
-+aarch64obsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
-+ struct frame_info *this_frame,
-+ void **this_cache)
-+{
-+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
-+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-+ CORE_ADDR pc = get_frame_pc (this_frame);
-+ CORE_ADDR start_pc = (pc & ~(aarch64obsd_page_size - 1));
-+ const int *offset;
-+ const char *name;
-+
-+ find_pc_partial_function (pc, &name, NULL, NULL);
-+ if (name)
-+ return 0;
-+
-+ for (offset = aarch64obsd_sigreturn_offset; *offset != -1; offset++)
-+ {
-+ gdb_byte buf[8];
-+ unsigned long insn;
-+
-+ if (!safe_frame_unwind_memory (this_frame, start_pc + *offset,
-+ buf, sizeof buf))
-+ continue;
-+
-+ /* Check for "mov x8, #SYS_sigreturn". */
-+ insn = extract_unsigned_integer (buf, 4, byte_order);
-+ if (insn != 0xd2800ce8)
-+ continue;
-+
-+ /* Check for "svc 0". */
-+ insn = extract_unsigned_integer (buf + 4, 4, byte_order);
-+ if (insn != 0xd4000001)
-+ continue;
-+
-+ return 1;
-+ }
-+
-+ return 0;
-+}
-+
-+/*
-+ In 6.1 the sp points to the struct sigframe. Since 6.2 the
-+ sigtramp routine saves floating point registers on the stack
-+ before the struct sigframe so that needs to be skipped to look
-+ at sigframe. A sigframe looks like this:
-+
-+ struct sigframe {
-+ int sf_signum;
-+ struct sigcontext sf_sc;
-+ siginfo_t sf_si;
-+ };
-+
-+ struct sigcontext {
-+ int __sc_unused;
-+ int sc_mask;
-+
-+ unsigned long sc_sp;
-+ unsigned long sc_lr;
-+ unsigned long sc_elr;
-+ unsigned long sc_spsr;
-+ unsigned long sc_x[30];
-+
-+ long sc_cookie;
-+ };
-+
-+*/
-+
-+#define AARCH64_SIGCONTEXT_REG_SIZE 8
-+#define AARCH64_SIGFRAME_SIGCONTEXT_OFFSET 8
-+#define AARCH64_SIGCONTEXT_SP_OFFSET 8
-+#define AARCH64_SIGCONTEXT_LR_OFFSET 16
-+#define AARCH64_SIGCONTEXT_PC_OFFSET 24
-+#define AARCH64_SIGCONTEXT_SPSR_OFFSET 32
-+#define AARCH64_SIGCONTEXT_X0_OFFSET 40
-+
-+static struct trad_frame_cache *
-+aarch64obsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
-+{
-+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
-+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-+ struct trad_frame_cache *cache;
-+ CORE_ADDR sp, sigcontext_addr, x0_addr, func;
-+ gdb_byte buf[4];
-+ unsigned long insn, sigframe_offset = 0;
-+ int i;
-+
-+ if (*this_cache)
-+ return (struct trad_frame_cache *) *this_cache;
-+
-+ cache = trad_frame_cache_zalloc (this_frame);
-+ *this_cache = cache;
-+
-+ func = get_frame_pc (this_frame);
-+ func &= ~(aarch64obsd_page_size - 1);
-+ if (!safe_frame_unwind_memory (this_frame, func, buf, sizeof buf))
-+ return cache;
-+
-+ /* Calculate the offset where we can find `struct sigframe'. In 6.1
-+ no adjustment is needed so we look at the first instruction to see
-+ if it matches 6.2+. If it is a 'sub sp, sp, #0xNNN' instruction,
-+ use the amount of stack space to skip from it. */
-+ insn = extract_unsigned_integer (buf, 4, byte_order);
-+ if ((insn & 0xffc003ff) == 0xd10003ff)
-+ sigframe_offset += ((insn & 0x003ffc00) >> 10);
-+
-+ sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
-+ sigcontext_addr = sp + sigframe_offset + AARCH64_SIGFRAME_SIGCONTEXT_OFFSET;
-+ x0_addr = sigcontext_addr + AARCH64_SIGCONTEXT_X0_OFFSET;
-+
-+ trad_frame_set_reg_addr (cache, AARCH64_SP_REGNUM,
-+ sigcontext_addr + AARCH64_SIGCONTEXT_SP_OFFSET);
-+ trad_frame_set_reg_addr (cache, AARCH64_LR_REGNUM,
-+ sigcontext_addr + AARCH64_SIGCONTEXT_LR_OFFSET);
-+ trad_frame_set_reg_addr (cache, AARCH64_PC_REGNUM,
-+ sigcontext_addr + AARCH64_SIGCONTEXT_PC_OFFSET);
-+ trad_frame_set_reg_addr (cache, AARCH64_CPSR_REGNUM,
-+ sigcontext_addr + AARCH64_SIGCONTEXT_SPSR_OFFSET);
-+ for (i = 0; i < 30; i++)
-+ {
-+ trad_frame_set_reg_addr (cache, AARCH64_X0_REGNUM + i,
-+ x0_addr + i * AARCH64_SIGCONTEXT_REG_SIZE);
-+ }
-+
-+ trad_frame_set_id (cache, frame_id_build (sp, func));
-+
-+ return cache;
-+}
-+
-+static void
-+aarch64obsd_sigtramp_frame_this_id (struct frame_info *this_frame,
-+ void **this_cache,
-+ struct frame_id *this_id)
-+{
-+ struct trad_frame_cache *cache =
-+ aarch64obsd_sigtramp_frame_cache (this_frame, this_cache);
-+
-+ trad_frame_get_id (cache, this_id);
-+}
-+
-+static struct value *
-+aarch64obsd_sigtramp_frame_prev_register (struct frame_info *this_frame,
-+ void **this_cache, int regnum)
-+{
-+ struct trad_frame_cache *cache =
-+ aarch64obsd_sigtramp_frame_cache (this_frame, this_cache);
-+
-+ return trad_frame_get_register (cache, this_frame, regnum);
-+}
-+
-+static const struct frame_unwind aarch64obsd_sigtramp_frame_unwind = {
-+ SIGTRAMP_FRAME,
-+ default_frame_unwind_stop_reason,
-+ aarch64obsd_sigtramp_frame_this_id,
-+ aarch64obsd_sigtramp_frame_prev_register,
-+ NULL,
-+ aarch64obsd_sigtramp_frame_sniffer
-+};
-+
-+/* The general-purpose regset consists of 31 X registers, plus SP, PC,
-+ and SPSR and TPIDR registers. */
-+#define AARCH64_OBSD_SIZEOF_GREGSET (35 * X_REGISTER_SIZE)
-+
-+/* The fp regset consists of 32 V registers, plus FPSR and FPCR which
-+ are 4 bytes wide each, and the whole structure is padded to 128 bit
-+ alignment. */
-+#define AARCH64_OBSD_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
-+
-+/* Register maps. */
-+
-+static const struct regcache_map_entry aarch64_obsd_gregmap[] =
-+ {
-+ { 31, AARCH64_X0_REGNUM, 8 }, /* x0 ... x30 */
-+ { 1, AARCH64_SP_REGNUM, 8 },
-+ { 1, AARCH64_PC_REGNUM, 8 },
-+ { 1, AARCH64_CPSR_REGNUM, 8 },
-+ { 0 }
-+ };
-+
-+static const struct regcache_map_entry aarch64_obsd_fpregmap[] =
-+ {
-+ { 32, AARCH64_V0_REGNUM, 16 }, /* v0 ... v31 */
-+ { 1, AARCH64_FPSR_REGNUM, 4 },
-+ { 1, AARCH64_FPCR_REGNUM, 4 },
-+ { 0 }
-+ };
-+
-+/* Register set definitions. */
-+
-+const struct regset aarch64_obsd_gregset =
-+ {
-+ aarch64_obsd_gregmap,
-+ regcache_supply_regset, regcache_collect_regset
-+ };
-+
-+const struct regset aarch64_obsd_fpregset =
-+ {
-+ aarch64_obsd_fpregmap,
-+ regcache_supply_regset, regcache_collect_regset
-+ };
-+
-+static void
-+aarch64_obsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
-+ iterate_over_regset_sections_cb *cb,
-+ void *cb_data,
-+ const struct regcache *regcache)
-+{
-+ cb (".reg", AARCH64_OBSD_SIZEOF_GREGSET, &aarch64_obsd_gregset,
-+ NULL, cb_data);
-+ cb (".reg2", AARCH64_OBSD_SIZEOF_FPREGSET, &aarch64_obsd_fpregset,
-+ NULL, cb_data);
-+}
-+
-+
-+static void
-+aarch64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
-+{
-+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-+
-+ obsd_init_abi (info, gdbarch);
-+
-+ /* OpenBSD/aarch64 uses SVR4-style shared libraries. */
-+ set_solib_svr4_fetch_link_map_offsets
-+ (gdbarch, svr4_lp64_fetch_link_map_offsets);
-+ set_gdbarch_skip_solib_resolver (gdbarch, obsd_skip_solib_resolver);
-+
-+ frame_unwind_append_unwinder (gdbarch, &aarch64obsd_sigtramp_frame_unwind);
-+
-+ /* Enable longjmp. */
-+ tdep->jb_pc = 13;
-+
-+ set_gdbarch_iterate_over_regset_sections
-+ (gdbarch, aarch64_obsd_iterate_over_regset_sections);
-+}
-+
-+
-+/* Provide a prototype to silence -Wmissing-prototypes. */
-+extern initialize_file_ftype _initialize_aarch64obsd_tdep;
-+
-+void
-+_initialize_aarch64obsd_tdep (void)
-+{
-+ gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_OPENBSD_ELF,
-+ aarch64obsd_init_abi);
-+}
Index: patches/patch-gdb_alphabsd-nat_c
===================================================================
RCS file: patches/patch-gdb_alphabsd-nat_c
diff -N patches/patch-gdb_alphabsd-nat_c
--- patches/patch-gdb_alphabsd-nat_c 3 Sep 2016 13:48:39 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-$OpenBSD: patch-gdb_alphabsd-nat_c,v 1.1 2016/09/03 13:48:39 jca Exp $
---- gdb/alphabsd-nat.c.orig Wed Feb 10 04:19:39 2016
-+++ gdb/alphabsd-nat.c Sat May 14 22:54:35 2016
-@@ -91,7 +91,7 @@ alphabsd_fetch_inferior_registers (struct target_ops *
- {
- struct reg gregs;
-
-- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
-
-@@ -105,7 +105,7 @@ alphabsd_fetch_inferior_registers (struct target_ops *
- {
- struct fpreg fpregs;
-
-- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
- perror_with_name (_("Couldn't get floating point status"));
-
-@@ -123,13 +123,13 @@ alphabsd_store_inferior_registers (struct target_ops *
- if (regno == -1 || getregs_supplies (regno))
- {
- struct reg gregs;
-- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
-
- alphabsd_fill_reg (regcache, (char *) &gregs, regno);
-
-- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
- perror_with_name (_("Couldn't write registers"));
-
-@@ -142,13 +142,13 @@ alphabsd_store_inferior_registers (struct target_ops *
- {
- struct fpreg fpregs;
-
-- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
- perror_with_name (_("Couldn't get floating point status"));
-
- alphabsd_fill_fpreg (regcache, (char *) &fpregs, regno);
-
-- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
- perror_with_name (_("Couldn't write floating point status"));
- }
Index: patches/patch-gdb_amd64-obsd-nat_c
===================================================================
RCS file: patches/patch-gdb_amd64-obsd-nat_c
diff -N patches/patch-gdb_amd64-obsd-nat_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_amd64-obsd-nat_c 2 Sep 2021 17:31:23 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: gdb/amd64-obsd-nat.c
+--- gdb/amd64-obsd-nat.c.orig
++++ gdb/amd64-obsd-nat.c
+@@ -135,6 +135,8 @@ _initialize_amd64obsd_nat (void)
+ amd64_native_gregset32_num_regs = ARRAY_SIZE (amd64obsd32_r_reg_offset);
+ amd64_native_gregset64_reg_offset = amd64obsd_r_reg_offset;
+
++ if (getenv("JCA_DEBUGGING") != NULL)
++ abort();
+ add_inf_child_target (&the_amd64_obsd_nat_target);
+
+ /* Support debugging kernel virtual memory images. */
Index: patches/patch-gdb_amd64-obsd-tdep_c
===================================================================
RCS file: patches/patch-gdb_amd64-obsd-tdep_c
diff -N patches/patch-gdb_amd64-obsd-tdep_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_amd64-obsd-tdep_c 2 Sep 2021 15:34:14 -0000
@@ -0,0 +1,107 @@
+$OpenBSD$
+
+Index: gdb/amd64-obsd-tdep.c
+--- gdb/amd64-obsd-tdep.c.orig
++++ gdb/amd64-obsd-tdep.c
+@@ -39,8 +39,40 @@
+ /* Support for signal handlers. */
+
+ /* Default page size. */
+-static const int amd64obsd_page_size = 4096;
++static const CORE_ADDR amd64obsd_page_size = 4096;
+
++/* Offset & instructions for sigreturn(2). */
++
++#define SIGRETURN_INSN_LEN 9
++
++struct amd64obsd_sigreturn_info_t {
++ int offset;
++ gdb_byte sigreturn[SIGRETURN_INSN_LEN];
++};
++
++static const amd64obsd_sigreturn_info_t
++ amd64obsd_sigreturn_info[] = {
++ /* OpenBSD 6.4 */
++ { 9, { 0x48, 0xc7, 0xc0,
++ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
++ 0x0f, 0x05 } }, /* syscall */
++ /* OpenBSD 5.1 */
++ { 6, { 0x48, 0xc7, 0xc0,
++ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
++ 0x0f, 0x05 } }, /* syscall */
++ { 7, { 0x48, 0xc7, 0xc0,
++ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
++ 0x0f, 0x05 } }, /* syscall */
++ /* OpenBSD 5.0 */
++ { 6, { 0x48, 0xc7, 0xc0,
++ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
++ 0xcd, 0x80 } }, /* int $0x80 */
++ { 7, { 0x48, 0xc7, 0xc0,
++ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
++ 0xcd, 0x80 } }, /* int $0x80 */
++ { -1, {} }
++};
++
+ /* Return whether THIS_FRAME corresponds to an OpenBSD sigtramp
+ routine. */
+
+@@ -49,20 +81,8 @@ amd64obsd_sigtramp_p (struct frame_info *this_frame)
+ {
+ CORE_ADDR pc = get_frame_pc (this_frame);
+ CORE_ADDR start_pc = (pc & ~(amd64obsd_page_size - 1));
+- const gdb_byte osigreturn[] =
+- {
+- 0x48, 0xc7, 0xc0,
+- 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
+- 0xcd, 0x80 /* int $0x80 */
+- };
+- const gdb_byte sigreturn[] =
+- {
+- 0x48, 0xc7, 0xc0,
+- 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
+- 0x0f, 0x05 /* syscall */
+- };
+- size_t buflen = (sizeof sigreturn) + 1;
+- gdb_byte *buf;
++ const amd64obsd_sigreturn_info_t *info;
++ gdb_byte buf[SIGRETURN_INSN_LEN];
+ const char *name;
+
+ /* If the function has a valid symbol name, it isn't a
+@@ -76,22 +96,22 @@ amd64obsd_sigtramp_p (struct frame_info *this_frame)
+ if (find_pc_section (pc) != NULL)
+ return 0;
+
+- /* If we can't read the instructions at START_PC, return zero. */
+- buf = (gdb_byte *) alloca ((sizeof sigreturn) + 1);
+- if (!safe_frame_unwind_memory (this_frame, start_pc + 6, buf, buflen))
+- return 0;
++ for (info = amd64obsd_sigreturn_info; info->offset != -1; info++)
++ {
+
+- /* Check for sigreturn(2). Depending on how the assembler encoded
+- the `movq %rsp, %rdi' instruction, the code starts at offset 6 or
+- 7. OpenBSD 5.0 and later use the `syscall' instruction. Older
+- versions use `int $0x80'. Check for both. */
+- if (memcmp (buf, sigreturn, sizeof sigreturn)
+- && memcmp (buf + 1, sigreturn, sizeof sigreturn)
+- && memcmp (buf, osigreturn, sizeof osigreturn)
+- && memcmp (buf + 1, osigreturn, sizeof osigreturn))
+- return 0;
++ /* If we can't read the instructions at return zero. */
++ if (!safe_frame_unwind_memory (this_frame,
++ start_pc + info->offset, buf, sizeof buf))
++ continue;
+
+- return 1;
++ /* Check for sigreturn(2). */
++ if (memcmp (buf, info->sigreturn, sizeof buf))
++ continue;
++
++ return 1;
++ }
++
++ return 0;
+ }
+
+ /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
Index: patches/patch-gdb_amd64obsd-tdep_c
===================================================================
RCS file: patches/patch-gdb_amd64obsd-tdep_c
diff -N patches/patch-gdb_amd64obsd-tdep_c
--- patches/patch-gdb_amd64obsd-tdep_c 1 Jun 2020 21:44:49 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-$OpenBSD: patch-gdb_amd64obsd-tdep_c,v 1.3 2020/06/01 21:44:49 kurt Exp $
-
-Index: gdb/amd64obsd-tdep.c
---- gdb/amd64obsd-tdep.c.orig
-+++ gdb/amd64obsd-tdep.c
-@@ -76,8 +76,40 @@ amd64obsd_iterate_over_regset_sections (struct gdbarch
- /* Support for signal handlers. */
-
- /* Default page size. */
--static const int amd64obsd_page_size = 4096;
-+static const CORE_ADDR amd64obsd_page_size = 4096;
-
-+/* Offset & instructions for sigreturn(2). */
-+
-+#define SIGRETURN_INSN_LEN 9
-+
-+struct amd64obsd_sigreturn_info_t {
-+ int offset;
-+ gdb_byte sigreturn[SIGRETURN_INSN_LEN];
-+};
-+
-+static const amd64obsd_sigreturn_info_t
-+ amd64obsd_sigreturn_info[] = {
-+ /* OpenBSD 6.4 */
-+ { 9, { 0x48, 0xc7, 0xc0,
-+ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
-+ 0x0f, 0x05 } }, /* syscall */
-+ /* OpenBSD 5.1 */
-+ { 6, { 0x48, 0xc7, 0xc0,
-+ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
-+ 0x0f, 0x05 } }, /* syscall */
-+ { 7, { 0x48, 0xc7, 0xc0,
-+ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
-+ 0x0f, 0x05 } }, /* syscall */
-+ /* OpenBSD 5.0 */
-+ { 6, { 0x48, 0xc7, 0xc0,
-+ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
-+ 0xcd, 0x80 } }, /* int $0x80 */
-+ { 7, { 0x48, 0xc7, 0xc0,
-+ 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
-+ 0xcd, 0x80 } }, /* int $0x80 */
-+ { -1, {} }
-+};
-+
- /* Return whether THIS_FRAME corresponds to an OpenBSD sigtramp
- routine. */
-
-@@ -86,20 +118,8 @@ amd64obsd_sigtramp_p (struct frame_info *this_frame)
- {
- CORE_ADDR pc = get_frame_pc (this_frame);
- CORE_ADDR start_pc = (pc & ~(amd64obsd_page_size - 1));
-- const gdb_byte osigreturn[] =
-- {
-- 0x48, 0xc7, 0xc0,
-- 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
-- 0xcd, 0x80 /* int $0x80 */
-- };
-- const gdb_byte sigreturn[] =
-- {
-- 0x48, 0xc7, 0xc0,
-- 0x67, 0x00, 0x00, 0x00, /* movq $SYS_sigreturn, %rax */
-- 0x0f, 0x05 /* syscall */
-- };
-- size_t buflen = (sizeof sigreturn) + 1;
-- gdb_byte *buf;
-+ const amd64obsd_sigreturn_info_t *info;
-+ gdb_byte buf[SIGRETURN_INSN_LEN];
- const char *name;
-
- /* If the function has a valid symbol name, it isn't a
-@@ -113,22 +133,22 @@ amd64obsd_sigtramp_p (struct frame_info *this_frame)
- if (find_pc_section (pc) != NULL)
- return 0;
-
-- /* If we can't read the instructions at START_PC, return zero. */
-- buf = (gdb_byte *) alloca ((sizeof sigreturn) + 1);
-- if (!safe_frame_unwind_memory (this_frame, start_pc + 6, buf, buflen))
-- return 0;
-+ for (info = amd64obsd_sigreturn_info; info->offset != -1; info++)
-+ {
-
-- /* Check for sigreturn(2). Depending on how the assembler encoded
-- the `movq %rsp, %rdi' instruction, the code starts at offset 6 or
-- 7. OpenBSD 5.0 and later use the `syscall' instruction. Older
-- versions use `int $0x80'. Check for both. */
-- if (memcmp (buf, sigreturn, sizeof sigreturn)
-- && memcmp (buf + 1, sigreturn, sizeof sigreturn)
-- && memcmp (buf, osigreturn, sizeof osigreturn)
-- && memcmp (buf + 1, osigreturn, sizeof osigreturn))
-- return 0;
-+ /* If we can't read the instructions at return zero. */
-+ if (!safe_frame_unwind_memory (this_frame,
-+ start_pc + info->offset, buf, sizeof buf))
-+ continue;
-
-- return 1;
-+ /* Check for sigreturn(2). */
-+ if (memcmp (buf, info->sigreturn, sizeof buf))
-+ continue;
-+
-+ return 1;
-+ }
-+
-+ return 0;
- }
-
- /* Assuming THIS_FRAME is for a BSD sigtramp routine, return the
Index: patches/patch-gdb_arm-bsd-tdep_c
===================================================================
RCS file: patches/patch-gdb_arm-bsd-tdep_c
diff -N patches/patch-gdb_arm-bsd-tdep_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_arm-bsd-tdep_c 2 Sep 2021 15:34:14 -0000
@@ -0,0 +1,41 @@
+$OpenBSD$
+
+Index: gdb/arm-bsd-tdep.c
+--- gdb/arm-bsd-tdep.c.orig
++++ gdb/arm-bsd-tdep.c
+@@ -30,15 +30,12 @@
+ #define ARMBSD_SIZEOF_GREGS (17 * 4)
+
+ /* Sizeof `struct fpreg' in <machine/reg.h. */
+-#define ARMBSD_SIZEOF_FPREGS ((1 + (8 * 3)) * 4)
++#define ARMBSD_SIZEOF_FPREGS (32 * 8 + 4 + 4)
+
+ static int
+ armbsd_fpreg_offset (int regnum)
+ {
+- if (regnum == ARM_FPS_REGNUM)
+- return 0;
+-
+- return 4 + (regnum - ARM_F0_REGNUM) * 12;
++ return (regnum - ARM_D0_REGNUM) * 8;
+ }
+
+ /* Supply register REGNUM from the buffer specified by FPREGS and LEN
+@@ -55,7 +52,7 @@ armbsd_supply_fpregset (const struct regset *regset,
+
+ gdb_assert (len >= ARMBSD_SIZEOF_FPREGS);
+
+- for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++)
++ for (i = ARM_D0_REGNUM; i <= ARM_FPSCR_REGNUM; i++)
+ {
+ if (regnum == i || regnum == -1)
+ regcache->raw_supply (i, regs + armbsd_fpreg_offset (i));
+@@ -83,7 +80,7 @@ armbsd_supply_gregset (const struct regset *regset,
+ }
+
+ if (regnum == ARM_PS_REGNUM || regnum == -1)
+- regcache->raw_supply (i, regs + 16 * 4);
++ regcache->raw_supply (ARM_PS_REGNUM, regs + 16 * 4);
+
+ if (len >= ARMBSD_SIZEOF_GREGS + ARMBSD_SIZEOF_FPREGS)
+ {
Index: patches/patch-gdb_armbsd-tdep_c
===================================================================
RCS file: patches/patch-gdb_armbsd-tdep_c
diff -N patches/patch-gdb_armbsd-tdep_c
--- patches/patch-gdb_armbsd-tdep_c 18 Jun 2018 14:53:12 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,41 +0,0 @@
-$OpenBSD: patch-gdb_armbsd-tdep_c,v 1.1 2018/06/18 14:53:12 kettenis Exp $
-
-Index: gdb/armbsd-tdep.c
---- gdb/armbsd-tdep.c.orig
-+++ gdb/armbsd-tdep.c
-@@ -30,15 +30,12 @@
- #define ARMBSD_SIZEOF_GREGS (17 * 4)
-
- /* Sizeof `struct fpreg' in <machine/reg.h. */
--#define ARMBSD_SIZEOF_FPREGS ((1 + (8 * 3)) * 4)
-+#define ARMBSD_SIZEOF_FPREGS (32 * 8 + 4 + 4)
-
- static int
- armbsd_fpreg_offset (int regnum)
- {
-- if (regnum == ARM_FPS_REGNUM)
-- return 0;
--
-- return 4 + (regnum - ARM_F0_REGNUM) * 12;
-+ return (regnum - ARM_D0_REGNUM) * 8;
- }
-
- /* Supply register REGNUM from the buffer specified by FPREGS and LEN
-@@ -55,7 +52,7 @@ armbsd_supply_fpregset (const struct regset *regset,
-
- gdb_assert (len >= ARMBSD_SIZEOF_FPREGS);
-
-- for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++)
-+ for (i = ARM_D0_REGNUM; i <= ARM_FPSCR_REGNUM; i++)
- {
- if (regnum == i || regnum == -1)
- regcache_raw_supply (regcache, i, regs + armbsd_fpreg_offset (i));
-@@ -83,7 +80,7 @@ armbsd_supply_gregset (const struct regset *regset,
- }
-
- if (regnum == ARM_PS_REGNUM || regnum == -1)
-- regcache_raw_supply (regcache, i, regs + 16 * 4);
-+ regcache_raw_supply (regcache, ARM_PS_REGNUM, regs + 16 * 4);
-
- if (len >= ARMBSD_SIZEOF_GREGS + ARMBSD_SIZEOF_FPREGS)
- {
Index: patches/patch-gdb_armnbsd-nat_c
===================================================================
RCS file: patches/patch-gdb_armnbsd-nat_c
diff -N patches/patch-gdb_armnbsd-nat_c
--- patches/patch-gdb_armnbsd-nat_c 24 Jan 2018 00:19:56 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,140 +0,0 @@
-$OpenBSD: patch-gdb_armnbsd-nat_c,v 1.2 2018/01/24 00:19:56 jca Exp $
-Index: gdb/armnbsd-nat.c
---- gdb/armnbsd-nat.c.orig
-+++ gdb/armnbsd-nat.c
-@@ -65,10 +65,10 @@ arm_supply_fparegset (struct regcache *regcache, struc
-
- for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++)
- regcache_raw_supply (regcache, regno,
-- (char *) &fparegset->fpr[regno - ARM_F0_REGNUM]);
-+ (char *) &fparegset->fp_reg[regno - ARM_F0_REGNUM]);
-
- regcache_raw_supply (regcache, ARM_FPS_REGNUM,
-- (char *) &fparegset->fpr_fpsr);
-+ (char *) &fparegset->fp_scr);
- }
-
- static void
-@@ -77,7 +77,7 @@ fetch_register (struct regcache *regcache, int regno)
- struct reg inferior_registers;
- int ret;
-
-- ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
-
- if (ret < 0)
-@@ -130,7 +130,7 @@ fetch_regs (struct regcache *regcache)
- int ret;
- int regno;
-
-- ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
-
- if (ret < 0)
-@@ -148,7 +148,7 @@ fetch_fp_register (struct regcache *regcache, int regn
- struct fpreg inferior_fp_registers;
- int ret;
-
-- ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
-
- if (ret < 0)
-@@ -161,12 +161,12 @@ fetch_fp_register (struct regcache *regcache, int regn
- {
- case ARM_FPS_REGNUM:
- regcache_raw_supply (regcache, ARM_FPS_REGNUM,
-- (char *) &inferior_fp_registers.fpr_fpsr);
-+ (char *) &inferior_fp_registers.fp_scr);
- break;
-
- default:
- regcache_raw_supply (regcache, regno,
-- (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
-+ (char *) &inferior_fp_registers.fp_reg[regno - ARM_F0_REGNUM]);
- break;
- }
- }
-@@ -178,7 +178,7 @@ fetch_fp_regs (struct regcache *regcache)
- int ret;
- int regno;
-
-- ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
-
- if (ret < 0)
-@@ -216,7 +216,7 @@ store_register (const struct regcache *regcache, int r
- struct reg inferior_registers;
- int ret;
-
-- ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
-
- if (ret < 0)
-@@ -279,7 +279,7 @@ store_register (const struct regcache *regcache, int r
- break;
- }
-
-- ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
-
- if (ret < 0)
-@@ -327,7 +327,7 @@ store_regs (const struct regcache *regcache)
- inferior_registers.r_pc = pc_val | psr_val;
- }
-
-- ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_registers, 0);
-
- if (ret < 0)
-@@ -340,7 +340,7 @@ store_fp_register (const struct regcache *regcache, in
- struct fpreg inferior_fp_registers;
- int ret;
-
-- ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
-
- if (ret < 0)
-@@ -353,16 +353,16 @@ store_fp_register (const struct regcache *regcache, in
- {
- case ARM_FPS_REGNUM:
- regcache_raw_collect (regcache, ARM_FPS_REGNUM,
-- (char *) &inferior_fp_registers.fpr_fpsr);
-+ (char *) &inferior_fp_registers.fp_scr);
- break;
-
- default:
- regcache_raw_collect (regcache, regno,
-- (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
-+ (char *) &inferior_fp_registers.fp_reg[regno - ARM_F0_REGNUM]);
- break;
- }
-
-- ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
-
- if (ret < 0)
-@@ -379,12 +379,12 @@ store_fp_regs (const struct regcache *regcache)
-
- for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++)
- regcache_raw_collect (regcache, regno,
-- (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]);
-+ (char *) &inferior_fp_registers.fp_reg[regno - ARM_F0_REGNUM]);
-
- regcache_raw_collect (regcache, ARM_FPS_REGNUM,
-- (char *) &inferior_fp_registers.fpr_fpsr);
-+ (char *) &inferior_fp_registers.fp_scr);
-
-- ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
-+ ret = ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
-
- if (ret < 0)
Index: patches/patch-gdb_config_aarch64_obsd_mh
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-gdb_config_aarch64_obsd_mh,v
retrieving revision 1.1
diff -u -p -r1.1 patch-gdb_config_aarch64_obsd_mh
--- patches/patch-gdb_config_aarch64_obsd_mh 10 Jul 2018 11:03:46 -0000 1.1
+++ patches/patch-gdb_config_aarch64_obsd_mh 2 Sep 2021 15:34:14 -0000
@@ -5,6 +5,6 @@ Index: gdb/config/aarch64/obsd.mh
@@ -0,0 +1,5 @@
+# Host: OpenBSD/arm64
+NATDEPFILES= fork-child.o inf-ptrace.o obsd-nat.o \
-+ aarch64obsd-nat.o bsd-kvm.o
++ aarch64-obsd-nat.o bsd-kvm.o
+
+LOADLIBES= -lkvm
Index: patches/patch-gdb_config_powerpc_obsd64_mh
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-gdb_config_powerpc_obsd64_mh,v
retrieving revision 1.1
diff -u -p -r1.1 patch-gdb_config_powerpc_obsd64_mh
--- patches/patch-gdb_config_powerpc_obsd64_mh 9 Oct 2020 19:22:42 -0000 1.1
+++ patches/patch-gdb_config_powerpc_obsd64_mh 2 Sep 2021 15:34:14 -0000
@@ -5,6 +5,6 @@ Index: gdb/config/powerpc/obsd64.mh
+++ gdb/config/powerpc/obsd64.mh
@@ -0,0 +1,4 @@
+# Host: OpenBSD/powerpc
-+NATDEPFILES= fork-child.o inf-ptrace.o obsd-nat.o ppc64obsd-nat.o bsd-kvm.o
++NATDEPFILES= fork-child.o inf-ptrace.o obsd-nat.o ppc64-obsd-nat.o bsd-kvm.o
+
+LOADLIBES= -lkvm
Index: patches/patch-gdb_configure_host
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-gdb_configure_host,v
retrieving revision 1.2
diff -u -p -r1.2 patch-gdb_configure_host
--- patches/patch-gdb_configure_host 9 Oct 2020 19:22:42 -0000 1.2
+++ patches/patch-gdb_configure_host 2 Sep 2021 21:50:43 -0000
@@ -1,20 +1,28 @@
$OpenBSD: patch-gdb_configure_host,v 1.2 2020/10/09 19:22:42 kettenis Exp $
+
Index: gdb/configure.host
--- gdb/configure.host.orig
+++ gdb/configure.host
-@@ -82,6 +82,7 @@ case "${host}" in
- *-*-darwin*) gdb_host=darwin ;;
+@@ -85,6 +85,7 @@ case "${host}" in

aarch64*-*-linux*) gdb_host=linux ;;
+ aarch64*-*-freebsd*) gdb_host=fbsd ;;
+aarch64*-*-openbsd*) gdb_host=obsd ;;

alpha*-*-linux*) gdb_host=alpha-linux ;;
- alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
-@@ -137,6 +138,7 @@ powerpc*-*-freebsd*) gdb_host=fbsd ;;
+ alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
+@@ -139,12 +140,14 @@ powerpc*-*-freebsd*) gdb_host=fbsd ;;
powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
gdb_host=nbsd ;;
powerpc-*-openbsd*) gdb_host=obsd ;;
+powerpc64-*-openbsd*) gdb_host=obsd64 ;;

- powerpc64*-*-linux*) gdb_host=ppc64-linux
- # Support 'pseudo-native' debugging on the Cell BE
+ powerpc64*-*-linux*) gdb_host=ppc64-linux ;;
+ powerpc*-*-linux*) gdb_host=linux ;;
+
+ riscv*-*-freebsd*) gdb_host=fbsd ;;
+ riscv*-*-linux*) gdb_host=linux ;;
++riscv64-*-openbsd*) gdb_host=obsd64 ;;
+
+ s390*-*-linux*) gdb_host=linux ;;
+
Index: patches/patch-gdb_configure_nat
===================================================================
RCS file: patches/patch-gdb_configure_nat
diff -N patches/patch-gdb_configure_nat
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_configure_nat 2 Sep 2021 21:50:43 -0000
@@ -0,0 +1,95 @@
+$OpenBSD$
+
+All our targets need obsd-nat.o and kvm etc -> dedup.
+Add aarch64 and riscv64 support.
+
+Index: gdb/configure.nat
+--- gdb/configure.nat.orig
++++ gdb/configure.nat
+@@ -48,7 +48,6 @@
+ #
+ # - nat_makefile_frag must contain the full path of the file.
+
+-
+ # This first case is useful for filling default values for each
+ # gdb_host.
+ case ${gdb_host} in
+@@ -72,7 +71,8 @@ case ${gdb_host} in
+ HAVE_NATIVE_GCORE_HOST=1
+ ;;
+ obsd*)
+- NATDEPFILES='fork-child.o nat/fork-inferior.o inf-ptrace.o'
++ NATDEPFILES='fork-child.o nat/fork-inferior.o inf-ptrace.o bsd-kvm.o obsd-nat.o'
++ LOADLIBES='-lkvm'
+ ;;
+ cygwin*)
+ NATDEPFILES='x86-nat.o nat/x86-dregs.o windows-nat.o'
+@@ -416,49 +416,50 @@ case ${gdb_host} in
+ case ${gdb_host_cpu} in
+ i386)
+ # Host: OpenBSD/i386 ELF
+- NATDEPFILES="${NATDEPFILES} obsd-nat.o x86-bsd-nat.o \
+- i386-bsd-nat.o i386-obsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} x86-bsd-nat.o \
++ i386-bsd-nat.o i386-obsd-nat.o"
+ ;;
+ m68k)
+ # Host: OpenBSD/m68k
+- NATDEPFILES="${NATDEPFILES} m68k-bsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} m68k-bsd-nat.o"
+ ;;
+ pa)
+ # Host: OpenBSD/hppa
+- NATDEPFILES="${NATDEPFILES} obsd-nat.o hppa-obsd-nat.o"
++ NATDEPFILES="${NATDEPFILES} hppa-obsd-nat.o"
+ ;;
+ powerpc)
+ # Host: OpenBSD/powerpc
+- NATDEPFILES="${NATDEPFILES} obsd-nat.o ppc-obsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} ppc-obsd-nat.o"
+ ;;
+ vax)
+ # Host: OpenBSD/vax
+- NATDEPFILES="${NATDEPFILES} vax-bsd-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} vax-bsd-nat.o"
+ ;;
+ esac
+ ;;
+ obsd64)
+ case ${gdb_host_cpu} in
++ aarch64)
++ # Host: OpenBSD/arm64
++ NATDEPFILES="${NATDEPFILES} aarch64-obsd-nat.o"
++ ;;
+ i386)
+ # Host: OpenBSD/amd64
+- NATDEPFILES="${NATDEPFILES} obsd-nat.o amd64-nat.o x86-nat.o \
+- x86-bsd-nat.o amd64-bsd-nat.o amd64-obsd-nat.o bsd-kvm.o \
+- nat/x86-dregs.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} amd64-nat.o \
++ x86-bsd-nat.o amd64-bsd-nat.o amd64-obsd-nat.o"
+ ;;
+ mips)
+ # Host: OpenBSD/mips64
+- NATDEPFILES="${NATDEPFILES} obsd-nat.o mips64-obsd-nat.o"
++ NATDEPFILES="${NATDEPFILES} mips64-obsd-nat.o"
+ ;;
++ riscv64)
++ # Host: OpenBSD/riscv64
++ NATDEPFILES="${NATDEPFILES} riscv-obsd-nat.o"
++ ;;
+ sparc)
+ # Host: OpenBSD/sparc64
+- NATDEPFILES="${NATDEPFILES} obsd-nat.o sparc64-obsd-nat.o \
+- sparc-nat.o bsd-kvm.o"
+- LOADLIBES='-lkvm'
++ NATDEPFILES="${NATDEPFILES} sparc64-obsd-nat.o \
++ sparc-nat.o"
+ ;;
+ esac
+ ;;
Index: patches/patch-gdb_configure_tgt
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-gdb_configure_tgt,v
retrieving revision 1.2
diff -u -p -r1.2 patch-gdb_configure_tgt
--- patches/patch-gdb_configure_tgt 9 Oct 2020 19:22:42 -0000 1.2
+++ patches/patch-gdb_configure_tgt 2 Sep 2021 17:31:23 -0000
@@ -2,30 +2,43 @@ $OpenBSD: patch-gdb_configure_tgt,v 1.2
Index: gdb/configure.tgt
--- gdb/configure.tgt.orig
+++ gdb/configure.tgt
-@@ -51,6 +51,13 @@ aarch64*-*-linux*)
+@@ -131,6 +131,13 @@ aarch64*-*-linux*)
build_gdbserver=yes
;;

+aarch64*-*-openbsd*)
+ # Target: OpenBSD/arm64
-+ gdb_target_obs="aarch64-tdep.o aarch64obsd-tdep.o aarch64-insn.o \
++ gdb_target_obs="aarch64-tdep.o aarch64-obsd-tdep.o arch/aarch64-insn.o \
+ obsd-tdep.o solib-svr4.o \
-+ symfile-mem.o aarch64-insn.o"
++ symfile-mem.o"
+ ;;
+
alpha*-*-linux*)
# Target: Little-endian Alpha running Linux
- gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-linux-tdep.o \
-@@ -428,6 +435,12 @@ powerpc-*-openbsd*)
- # Target: OpenBSD/powerpc
- gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppcobsd-tdep.o \
- solib-svr4.o \
-+ ravenscar-thread.o ppc-ravenscar-thread.o"
-+ ;;
+ gdb_target_obs="alpha-mdebug-tdep.o alpha-linux-tdep.o \
+@@ -506,6 +513,12 @@ powerpc-*-openbsd*)
+ gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc-obsd-tdep.o \
+ ravenscar-thread.o ppc-ravenscar-thread.o"
+ ;;
+powerpc64-*-openbsd*)
+ # Target: OpenBSD/powerpc64
+ gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
-+ ppc64obsd-tdep.o obsd-tdep.o solib-svr4.o \
- ravenscar-thread.o ppc-ravenscar-thread.o"
- ;;
++ ppc64-obsd-tdep.o obsd-tdep.o solib-svr4.o \
++ ravenscar-thread.o ppc-ravenscar-thread.o"
++ ;;
powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
+ # Target: PowerPC running AIX
+ gdb_target_obs="rs6000-tdep.o rs6000-aix-tdep.o xcoffread.o \
+@@ -552,6 +565,12 @@ riscv*-*-linux*)
+ # Target: Linux/RISC-V
+ gdb_target_obs="riscv-linux-tdep.o glibc-tdep.o \
+ linux-tdep.o solib-svr4.o symfile-mem.o linux-record.o"
++ ;;
++
++riscv*-*-openbsd*)
++ # Target: OpenBSD/riscv
++ # XXX is that list enough?
++ gdb_target_obs="riscv-obsd-tdep.o"
+ ;;
+
+ riscv*-*-*)
Index: patches/patch-gdb_data-directory_Makefile_in
===================================================================
RCS file: /d/cvs/ports/devel/gdb/patches/patch-gdb_data-directory_Makefile_in,v
retrieving revision 1.9
diff -u -p -r1.9 patch-gdb_data-directory_Makefile_in
--- patches/patch-gdb_data-directory_Makefile_in 9 Oct 2016 11:39:20 -0000 1.9
+++ patches/patch-gdb_data-directory_Makefile_in 2 Sep 2021 15:34:14 -0000
@@ -1,7 +1,8 @@
$OpenBSD: patch-gdb_data-directory_Makefile_in,v 1.9 2016/10/09 11:39:20 pascal Exp $
---- gdb/data-directory/Makefile.in.orig Mon Aug 1 17:50:20 2016
-+++ gdb/data-directory/Makefile.in Fri Oct 7 20:53:14 2016
-@@ -187,7 +187,7 @@ stamp-syscalls: Makefile $(SYSCALLS_FILES)
+Index: gdb/data-directory/Makefile.in
+--- gdb/data-directory/Makefile.in.orig
++++ gdb/data-directory/Makefile.in
+@@ -198,7 +198,7 @@ stamp-syscalls: Makefile $(SYSCALLS_FILES)
for file in $$files ; do \
f=$(SYSCALLS_SRCDIR)/$$file ; \
if test -f $$f ; then \
@@ -10,7 +11,7 @@ $OpenBSD: patch-gdb_data-directory_Makef
fi ; \
done
touch $@
-@@ -229,8 +229,8 @@ stamp-python: Makefile $(PYTHON_FILES)
+@@ -240,8 +240,8 @@ stamp-python: Makefile $(PYTHON_FILES)
if test "x$$files" != x ; then \
for file in $$files ; do \
dir=`echo "$$file" | sed 's,/[^/]*$$,,'` ; \
@@ -21,7 +22,7 @@ $OpenBSD: patch-gdb_data-directory_Makef
done ; \
fi
touch $@
-@@ -323,7 +323,7 @@ stamp-system-gdbinit: Makefile $(SYSTEM_GDBINIT_FILES)
+@@ -334,7 +334,7 @@ stamp-system-gdbinit: Makefile $(SYSTEM_GDBINIT_FILES)
for file in $$files ; do \
f=$(SYSTEM_GDBINIT_SRCDIR)/$$file ; \
if test -f $$f ; then \
Index: patches/patch-gdb_hppaobsd-nat_c
===================================================================
RCS file: patches/patch-gdb_hppaobsd-nat_c
diff -N patches/patch-gdb_hppaobsd-nat_c
--- patches/patch-gdb_hppaobsd-nat_c 3 Sep 2016 13:48:39 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-$OpenBSD: patch-gdb_hppaobsd-nat_c,v 1.1 2016/09/03 13:48:39 jca Exp $
---- gdb/hppaobsd-nat.c.orig Wed Feb 10 04:19:39 2016
-+++ gdb/hppaobsd-nat.c Sat May 14 22:54:35 2016
-@@ -193,7 +193,7 @@ hppaobsd_fetch_registers (struct target_ops *ops,
- {
- struct reg regs;
-
-- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
-
-@@ -204,7 +204,7 @@ hppaobsd_fetch_registers (struct target_ops *ops,
- {
- struct fpreg fpregs;
-
-- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
- perror_with_name (_("Couldn't get floating point status"));
-
-@@ -223,13 +223,13 @@ hppaobsd_store_registers (struct target_ops *ops,
- {
- struct reg regs;
-
-- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
-
- hppaobsd_collect_gregset (regcache, &regs, regnum);
-
-- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't write registers"));
- }
-@@ -238,13 +238,13 @@ hppaobsd_store_registers (struct target_ops *ops,
- {
- struct fpreg fpregs;
-
-- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
- perror_with_name (_("Couldn't get floating point status"));
-
- hppaobsd_collect_fpregset (regcache, &fpregs, regnum);
-
-- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
- perror_with_name (_("Couldn't write floating point status"));
- }
Index: patches/patch-gdb_i386-bsd-nat_h
===================================================================
RCS file: patches/patch-gdb_i386-bsd-nat_h
diff -N patches/patch-gdb_i386-bsd-nat_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_i386-bsd-nat_h 2 Sep 2021 15:34:14 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Missing include.
+
+Index: gdb/i386-bsd-nat.h
+--- gdb/i386-bsd-nat.h.orig
++++ gdb/i386-bsd-nat.h
+@@ -20,6 +20,8 @@
+ #ifndef I386_BSD_NAT_H
+ #define I386_BSD_NAT_H
+
++#include "x86-bsd-nat.h"
++
+ /* Helper functions. See definitions. */
+ extern void i386bsd_fetch_inferior_registers (struct regcache *regcache,
+ int regnum);
Index: patches/patch-gdb_i386-obsd-nat_c
===================================================================
RCS file: patches/patch-gdb_i386-obsd-nat_c
diff -N patches/patch-gdb_i386-obsd-nat_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_i386-obsd-nat_c 2 Sep 2021 17:31:23 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Bogus variable name.
+
+Index: gdb/i386-obsd-nat.c
+--- gdb/i386-obsd-nat.c.orig
++++ gdb/i386-obsd-nat.c
+@@ -93,7 +93,7 @@ static i386_bsd_nat_target<obsd_nat_target> the_i386_o
+ void
+ _initialize_i386obsd_nat (void)
+ {
+- add_inf_child_target (&i386_obsd_nat_target);
++ add_inf_child_target (&the_i386_obsd_nat_target);
+
+ /* Support debugging kernel virtual memory images. */
+ bsd_kvm_add_target (i386obsd_supply_pcb);
Index: patches/patch-gdb_m88kbsd-nat_c
===================================================================
RCS file: patches/patch-gdb_m88kbsd-nat_c
diff -N patches/patch-gdb_m88kbsd-nat_c
--- patches/patch-gdb_m88kbsd-nat_c 3 Sep 2016 13:48:39 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,28 +0,0 @@
-$OpenBSD: patch-gdb_m88kbsd-nat_c,v 1.1 2016/09/03 13:48:39 jca Exp $
---- gdb/m88kbsd-nat.c.orig Wed Feb 10 04:19:39 2016
-+++ gdb/m88kbsd-nat.c Sat May 14 22:54:35 2016
-@@ -68,7 +68,7 @@ m88kbsd_fetch_inferior_registers (struct target_ops *o
- {
- struct reg regs;
-
-- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
-
-@@ -84,13 +84,13 @@ m88kbsd_store_inferior_registers (struct target_ops *o
- {
- struct reg regs;
-
-- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
-
- m88kbsd_collect_gregset (regcache, &regs, regnum);
-
-- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't write registers"));
- }
Index: patches/patch-gdb_mips64obsd-nat_c
===================================================================
RCS file: patches/patch-gdb_mips64obsd-nat_c
diff -N patches/patch-gdb_mips64obsd-nat_c
--- patches/patch-gdb_mips64obsd-nat_c 21 Oct 2016 13:13:31 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-$OpenBSD: patch-gdb_mips64obsd-nat_c,v 1.2 2016/10/21 13:13:31 visa Exp $
---- gdb/mips64obsd-nat.c.orig Mon Aug 1 09:50:20 2016
-+++ gdb/mips64obsd-nat.c Tue Oct 18 07:24:31 2016
-@@ -40,7 +40,7 @@
- static void
- mips64obsd_supply_gregset (struct regcache *regcache, const void *gregs)
- {
-- const char *regs = gregs;
-+ const char *regs = (const char *) gregs;
- int regnum;
-
- for (regnum = MIPS_ZERO_REGNUM; regnum <= MIPS_PC_REGNUM; regnum++)
-@@ -57,7 +57,7 @@ static void
- mips64obsd_collect_gregset (const struct regcache *regcache,
- void *gregs, int regnum)
- {
-- char *regs = gregs;
-+ char *regs = (char *) gregs;
- int i;
-
- for (i = MIPS_ZERO_REGNUM; i <= MIPS_PC_REGNUM; i++)
-@@ -83,7 +83,7 @@ mips64obsd_fetch_inferior_registers (struct target_ops
- {
- struct reg regs;
-
-- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
-
-@@ -99,13 +99,13 @@ mips64obsd_store_inferior_registers (struct target_ops
- {
- struct reg regs;
-
-- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
-
- mips64obsd_collect_gregset (regcache, &regs, regnum);
-
-- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-+ if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &regs, 0) == -1)
- perror_with_name (_("Couldn't write registers"));
- }
Index: patches/patch-gdb_ppc64-obsd-nat_c
===================================================================
RCS file: patches/patch-gdb_ppc64-obsd-nat_c
diff -N patches/patch-gdb_ppc64-obsd-nat_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-gdb_ppc64-obsd-nat_c 2 Sep 2021 15:34:14 -0000
@@ -0,0 +1,230 @@
+$OpenBSD$
+
+Index: gdb/ppc64-obsd-nat.c
+--- gdb/ppc64-obsd-nat.c.orig
++++ gdb/ppc64-obsd-nat.c
+@@ -0,0 +1,224 @@
++/* Native-dependent code for OpenBSD/powerpc64.
++
++ Copyright (C) 2004-2020 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include "defs.h"
++#include "gdbcore.h"
++#include "inferior.h"
++#include "regcache.h"
++
++#include <sys/types.h>
++#include <sys/ptrace.h>
++#include <sys/signal.h>
++#include <machine/frame.h>
++#include <machine/pcb.h>
++#include <machine/reg.h>
++
++#include "ppc-tdep.h"
++#include "ppc64-tdep.h"
++#include "ppc64-obsd-tdep.h"
++#include "inf-ptrace.h"
++#include "obsd-nat.h"
++#include "bsd-kvm.h"
++
++#if 0
++
++/* Returns true if PT_GETFPREGS fetches this register. */
++
++static int
++getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
++{
++ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
++
++ /* FIXME: jimb/2004-05-05: Some PPC variants don't have floating
++ point registers. Traditionally, GDB's register set has still
++ listed the floating point registers for such machines, so this
++ code is harmless. However, the new E500 port actually omits the
++ floating point registers entirely from the register set --- they
++ don't even have register numbers assigned to them.
++
++ It's not clear to me how best to update this code, so this assert
++ will alert the first person to encounter the NetBSD/E500
++ combination to the problem. */
++ gdb_assert (ppc_floating_point_unit_p (gdbarch));
++
++ return ((regnum >= tdep->ppc_fp0_regnum
++ && regnum < tdep->ppc_fp0_regnum + ppc_num_fprs)
++ || regnum == tdep->ppc_fpscr_regnum);
++}
++
++

No comments:

Post a Comment