git: 82beca9e630e - main - devel/gdb: Upgrade to 15.1

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 24 Sep 2024 16:09:37 UTC
The branch main has been updated by jhb:

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

commit 82beca9e630ec9226c58a9cd3ee9adb355e21314
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-09-24 16:08:56 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-09-24 16:08:56 +0000

    devel/gdb: Upgrade to 15.1
    
    This includes an update to the bundled libc++ pretty printers with
    fixes for recent changes in libc++ to std::string and std::unordered_map.
    
    PR:             272922
    Sponsored by:   AFRL, DARPA
    Differential Revision:  https://reviews.freebsd.org/D46232
---
 devel/gdb/Makefile                       |   7 +-
 devel/gdb/distinfo                       |  10 +--
 devel/gdb/files/extrapatch-kgdb          | 102 +++++++++++++--------------
 devel/gdb/files/kgdb/aarch64-fbsd-kern.c |   9 +--
 devel/gdb/files/kgdb/amd64fbsd-kern.c    |   8 +--
 devel/gdb/files/kgdb/arm-fbsd-kern.c     |  10 +--
 devel/gdb/files/kgdb/fbsd-kld.c          | 116 +++++++++++++------------------
 devel/gdb/files/kgdb/fbsd-kthr.c         |  17 ++---
 devel/gdb/files/kgdb/fbsd-kvm.c          |  10 +--
 devel/gdb/files/kgdb/i386fbsd-kern.c     |  16 ++---
 devel/gdb/files/kgdb/kgdb-main.c         |   2 +
 devel/gdb/files/kgdb/kgdb.h              |   2 +-
 devel/gdb/files/kgdb/mipsfbsd-kern.c     |  10 +--
 devel/gdb/files/kgdb/ppcfbsd-kern.c      |   8 +--
 devel/gdb/files/kgdb/riscv-fbsd-kern.c   |   8 +--
 devel/gdb/files/kgdb/sparc64fbsd-kern.c  |   8 +--
 devel/gdb/pkg-plist                      |   5 ++
 17 files changed, 167 insertions(+), 181 deletions(-)

diff --git a/devel/gdb/Makefile b/devel/gdb/Makefile
index 029f36d86653..df5668984623 100644
--- a/devel/gdb/Makefile
+++ b/devel/gdb/Makefile
@@ -1,6 +1,5 @@
 PORTNAME=	gdb
-DISTVERSION=	14.1
-PORTREVISION=	2
+DISTVERSION=	15.1
 CATEGORIES=	devel
 MASTER_SITES=	GNU
 
@@ -17,7 +16,7 @@ LIB_DEPENDS=	libexpat.so:textproc/expat2 \
 		libzstd.so:archivers/zstd
 TEST_DEPENDS=	runtest:misc/dejagnu
 
-USES=		compiler:c++11-lang cpe gmake libtool makeinfo pkgconfig tar:xz
+USES=		compiler:c++17-lang cpe gmake libtool makeinfo pkgconfig tar:xz
 USE_PYTHON=	flavors py3kplist
 
 TEST_TARGET=	check
@@ -103,7 +102,7 @@ USE_GITHUB=	nodefault
 
 GH_ACCOUNT=	bsdjhb:libcxx
 GH_PROJECT=	libcxx-gdbpy:libcxx
-GH_TAGNAME=	03d0d9b:libcxx
+GH_TAGNAME=	4bb8585:libcxx
 
 # Workaround USE_GITHUB preventing the default DISTFILES
 DISTFILES=	${DISTNAME}${EXTRACT_SUFX}
diff --git a/devel/gdb/distinfo b/devel/gdb/distinfo
index 95fd730add1c..68103e44a681 100644
--- a/devel/gdb/distinfo
+++ b/devel/gdb/distinfo
@@ -1,5 +1,5 @@
-TIMESTAMP = 1702493574
-SHA256 (gdb-14.1.tar.xz) = d66df51276143451fcbff464cc8723d68f1e9df45a6a2d5635a54e71643edb80
-SIZE (gdb-14.1.tar.xz) = 24108624
-SHA256 (bsdjhb-libcxx-gdbpy-03d0d9b_GH0.tar.gz) = 2c1563f361d4fb59b54b1b39bff5cdf609d73962758eb05a8cdfe2c22551b259
-SIZE (bsdjhb-libcxx-gdbpy-03d0d9b_GH0.tar.gz) = 6052
+TIMESTAMP = 1722632408
+SHA256 (gdb-15.1.tar.xz) = 38254eacd4572134bca9c5a5aa4d4ca564cbbd30c369d881f733fb6b903354f2
+SIZE (gdb-15.1.tar.xz) = 24295712
+SHA256 (bsdjhb-libcxx-gdbpy-4bb8585_GH0.tar.gz) = f182d52b7a88260846ce65a451e9631a04dceaeb738889156e1168fa351306ea
+SIZE (bsdjhb-libcxx-gdbpy-4bb8585_GH0.tar.gz) = 6234
diff --git a/devel/gdb/files/extrapatch-kgdb b/devel/gdb/files/extrapatch-kgdb
index f9098cc19de8..340f63662257 100644
--- a/devel/gdb/files/extrapatch-kgdb
+++ b/devel/gdb/files/extrapatch-kgdb
@@ -1,8 +1,8 @@
 diff --git gdb/Makefile.in gdb/Makefile.in
-index 9c0a0bff2cd..0e62786dd31 100644
+index 84bc54b303e..e2df898d907 100644
 --- gdb/Makefile.in
 +++ gdb/Makefile.in
-@@ -704,6 +704,7 @@ ALL_AMD_DBGAPI_TARGET_OBS = \
+@@ -723,6 +723,7 @@ ALL_AMD_DBGAPI_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 = \
@@ -10,7 +10,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	aarch64-fbsd-tdep.o \
  	aarch64-linux-tdep.o \
  	aarch64-newlib-tdep.o \
-@@ -718,6 +719,7 @@ ALL_64_TARGET_OBS = \
+@@ -737,6 +738,7 @@ ALL_64_TARGET_OBS = \
  	amd64-darwin-tdep.o \
  	amd64-dicos-tdep.o \
  	amd64-fbsd-tdep.o \
@@ -18,7 +18,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	amd64-linux-tdep.o \
  	amd64-netbsd-tdep.o \
  	amd64-obsd-tdep.o \
-@@ -737,18 +739,21 @@ ALL_64_TARGET_OBS = \
+@@ -756,18 +758,21 @@ ALL_64_TARGET_OBS = \
  	ia64-vms-tdep.o \
  	loongarch-linux-tdep.o \
  	loongarch-tdep.o \
@@ -40,7 +40,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	sparc64-linux-tdep.o \
  	sparc64-netbsd-tdep.o \
  	sparc64-obsd-tdep.o \
-@@ -773,6 +778,7 @@ ALL_TARGET_OBS = \
+@@ -792,6 +797,7 @@ ALL_TARGET_OBS = \
  	arch/loongarch.o \
  	arch/ppc-linux-common.o \
  	arm-bsd-tdep.o \
@@ -48,7 +48,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	arm-fbsd-tdep.o \
  	arm-linux-tdep.o \
  	arm-netbsd-tdep.o \
-@@ -790,6 +796,8 @@ ALL_TARGET_OBS = \
+@@ -809,6 +815,8 @@ ALL_TARGET_OBS = \
  	csky-linux-tdep.o \
  	csky-tdep.o \
  	dicos-tdep.o \
@@ -57,7 +57,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	fbsd-tdep.o \
  	frv-linux-tdep.o \
  	frv-tdep.o \
-@@ -804,6 +812,7 @@ ALL_TARGET_OBS = \
+@@ -823,6 +831,7 @@ ALL_TARGET_OBS = \
  	i386-bsd-tdep.o \
  	i386-darwin-tdep.o \
  	i386-dicos-tdep.o \
@@ -65,7 +65,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	i386-fbsd-tdep.o \
  	i386-gnu-tdep.o \
  	i386-go32-tdep.o \
-@@ -841,6 +850,7 @@ ALL_TARGET_OBS = \
+@@ -860,6 +869,7 @@ ALL_TARGET_OBS = \
  	obsd-tdep.o \
  	or1k-linux-tdep.o \
  	or1k-tdep.o \
@@ -73,7 +73,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	ppc-fbsd-tdep.o \
  	ppc-linux-tdep.o \
  	ppc-netbsd-tdep.o \
-@@ -1642,6 +1652,7 @@ ALLDEPFILES = \
+@@ -1666,6 +1676,7 @@ ALLDEPFILES = \
  	arch/riscv.c \
  	arch/tic6x.c \
  	aarch32-tdep.c \
@@ -81,7 +81,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	aarch64-fbsd-nat.c \
  	aarch64-fbsd-tdep.c \
  	aarch64-linux-nat.c \
-@@ -1662,6 +1673,7 @@ ALLDEPFILES = \
+@@ -1686,6 +1697,7 @@ ALLDEPFILES = \
  	amd64-bsd-nat.c \
  	amd64-darwin-tdep.c \
  	amd64-dicos-tdep.c \
@@ -89,7 +89,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	amd64-fbsd-nat.c \
  	amd64-fbsd-tdep.c \
  	amd64-linux-nat.c \
-@@ -1678,6 +1690,7 @@ ALLDEPFILES = \
+@@ -1702,6 +1714,7 @@ ALLDEPFILES = \
  	arc-linux-nat.c \
  	arc-tdep.c \
  	arm-bsd-tdep.c \
@@ -97,7 +97,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	arm-fbsd-nat.c \
  	arm-fbsd-tdep.c \
  	arm-linux-nat.c \
-@@ -1697,6 +1710,9 @@ ALLDEPFILES = \
+@@ -1721,6 +1734,9 @@ ALLDEPFILES = \
  	csky-tdep.c \
  	darwin-nat.c \
  	dicos-tdep.c \
@@ -107,7 +107,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	fbsd-nat.c \
  	fbsd-tdep.c \
  	fork-child.c \
-@@ -1717,6 +1733,7 @@ ALLDEPFILES = \
+@@ -1741,6 +1757,7 @@ ALLDEPFILES = \
  	i386-darwin-nat.c \
  	i386-darwin-tdep.c \
  	i386-dicos-tdep.c \
@@ -115,7 +115,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	i386-fbsd-nat.c \
  	i386-fbsd-tdep.c \
  	i386-gnu-nat.c \
-@@ -1757,6 +1774,7 @@ ALLDEPFILES = \
+@@ -1781,6 +1798,7 @@ ALLDEPFILES = \
  	microblaze-linux-tdep.c \
  	microblaze-tdep.c \
  	mingw-hdep.c \
@@ -123,7 +123,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	mips-fbsd-nat.c \
  	mips-fbsd-tdep.c \
  	mips-linux-nat.c \
-@@ -1777,6 +1795,7 @@ ALLDEPFILES = \
+@@ -1801,6 +1819,7 @@ ALLDEPFILES = \
  	obsd-tdep.c \
  	or1k-linux-nat.c \
  	posix-hdep.c \
@@ -131,7 +131,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	ppc-fbsd-nat.c \
  	ppc-fbsd-tdep.c \
  	ppc-linux-nat.c \
-@@ -1791,6 +1810,7 @@ ALLDEPFILES = \
+@@ -1815,6 +1834,7 @@ ALLDEPFILES = \
  	procfs.c \
  	ravenscar-thread.c \
  	remote-sim.c \
@@ -139,7 +139,7 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	riscv-fbsd-nat.c \
  	riscv-fbsd-tdep.c \
  	riscv-linux-nat.c \
-@@ -1828,6 +1848,7 @@ ALLDEPFILES = \
+@@ -1852,6 +1872,7 @@ ALLDEPFILES = \
  	sparc-sol2-nat.c \
  	sparc-sol2-tdep.c \
  	sparc-tdep.c \
@@ -147,16 +147,16 @@ index 9c0a0bff2cd..0e62786dd31 100644
  	sparc64-fbsd-nat.c \
  	sparc64-fbsd-tdep.c \
  	sparc64-linux-nat.c \
-@@ -1915,7 +1936,7 @@ generated_files = \
+@@ -1939,7 +1960,7 @@ generated_files = \
  # Flags needed to compile Python code
  PYTHON_CFLAGS = @PYTHON_CFLAGS@
  
--all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb
-+all: gdb$(EXEEXT) kgdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb
+-all: gdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb gcore
++all: gdb$(EXEEXT) kgdb$(EXEEXT) $(CONFIG_ALL) gdb-gdb.py gdb-gdb.gdb gcore
  	@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=$(SUBDIRS)" subdir_do
  
  # Rule for compiling .c files in the top-level gdb directory.
-@@ -2178,6 +2199,12 @@ ifneq ($(CODESIGN_CERT),)
+@@ -2205,6 +2226,12 @@ ifneq ($(CODESIGN_CERT),)
  	$(ECHO_SIGN) $(CODESIGN) -s $(CODESIGN_CERT) gdb$(EXEEXT)
  endif
  
@@ -169,28 +169,28 @@ index 9c0a0bff2cd..0e62786dd31 100644
  # This is useful when debugging GDB, because some Unix's don't let you run GDB
  # on itself without copying the executable.  So "make gdb1" will make
  # gdb and put a copy in gdb1, and you can run it with "gdb gdb1".
-@@ -2213,6 +2240,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
+@@ -2240,6 +2267,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
  	rm -f init.c stamp-init version.c stamp-version
  	rm -f gdb$(EXEEXT) core make.log
  	rm -f gdb[0-9]$(EXEEXT)
 +	rm -f kgdb$(EXEEXT)
- 	rm -f test-cp-name-parser$(EXEEXT)
  	rm -f xml-builtin.c stamp-xml
  	rm -f $(DEPDIR)/*
-@@ -2636,7 +2664,7 @@ endif
+ 	for i in $(CONFIG_SRC_SUBDIR); do \
+@@ -2672,7 +2700,7 @@ endif
  
  # A list of all the objects we might care about in this build, for
  # dependency tracking.
--all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \
-+all_object_files = kgdb-main.o gdb.o $(LIBGDB_OBS) gdbtk-main.o \
- 	test-cp-name-parser.o
+-all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o
++all_object_files = kgdb-main.o gdb.o $(LIBGDB_OBS) gdbtk-main.o
  
  # All the .deps files to include.
+ all_deps_files = $(foreach dep,$(patsubst %.o,%.Po,$(all_object_files)),\
 diff --git gdb/config.in gdb/config.in
-index e17245156d8..e1be9fdbc40 100644
+index 0c144c8918b..b18687e766f 100644
 --- gdb/config.in
 +++ gdb/config.in
-@@ -229,6 +229,12 @@
+@@ -244,6 +244,12 @@
  /* Define to 1 if you have the `kinfo_getfile' function. */
  #undef HAVE_KINFO_GETFILE
  
@@ -204,10 +204,10 @@ index e17245156d8..e1be9fdbc40 100644
  #undef HAVE_LANGINFO_CODESET
  
 diff --git gdb/configure gdb/configure
-index 5361bf42952..9f4c500fd22 100755
+index 66a7ad8d256..198c3a4b43d 100755
 --- gdb/configure
 +++ gdb/configure
-@@ -19724,6 +19724,126 @@ fi
+@@ -26398,6 +26398,126 @@ fi
  
  
  
@@ -335,10 +335,10 @@ index 5361bf42952..9f4c500fd22 100755
  # Check whether --with-zstd was given.
  if test "${with_zstd+set}" = set; then :
 diff --git gdb/configure.ac gdb/configure.ac
-index 3912b77b27f..bc960202b22 100644
+index 62ff09cea20..3baeb32d3bc 100644
 --- gdb/configure.ac
 +++ gdb/configure.ac
-@@ -516,6 +516,16 @@ AC_SEARCH_LIBS(gethostbyname, nsl)
+@@ -518,6 +518,16 @@ AC_SEARCH_LIBS(gethostbyname, nsl)
  AM_ZLIB
  AC_ZSTD
  
@@ -356,7 +356,7 @@ index 3912b77b27f..bc960202b22 100644
  
  # GDB may fork/exec the iconv program to get the list of supported character
 diff --git gdb/configure.nat gdb/configure.nat
-index 1dc4206b69c..cb46e1505c7 100644
+index 8b98511cef7..c222e482ce9 100644
 --- gdb/configure.nat
 +++ gdb/configure.nat
 @@ -63,7 +63,8 @@ case ${gdb_host} in
@@ -460,10 +460,10 @@ index 47a674201f9..4b4b6893edf 100644
  x86_64-*-mingw* | x86_64-*-cygwin*)
          # Target: MingW/amd64
 diff --git gdb/osabi.c gdb/osabi.c
-index ad3dad5b849..29e8578d031 100644
+index d494d899623..f04e0cb3699 100644
 --- gdb/osabi.c
 +++ gdb/osabi.c
-@@ -67,6 +67,7 @@ static const struct osabi_names gdb_osabi_names[] =
+@@ -66,6 +66,7 @@ static const struct osabi_names gdb_osabi_names[] =
    { "Solaris", NULL },
    { "GNU/Linux", "linux(-gnu[^-]*)?" },
    { "FreeBSD", NULL },
@@ -472,7 +472,7 @@ index ad3dad5b849..29e8578d031 100644
    { "OpenBSD", NULL },
    { "WindowsCE", NULL },
 diff --git gdb/osabi.h gdb/osabi.h
-index 35f14ec433c..1276d34d5f7 100644
+index c1a85d1b9a3..88feacab384 100644
 --- gdb/osabi.h
 +++ gdb/osabi.h
 @@ -31,6 +31,7 @@ enum gdb_osabi
@@ -484,33 +484,29 @@ index 35f14ec433c..1276d34d5f7 100644
    GDB_OSABI_OPENBSD,
    GDB_OSABI_WINCE,
 diff --git gdb/regcache.c gdb/regcache.c
-index 91b20b7a2a2..0cfa1bae3d9 100644
+index f04354d822f..b239064ac16 100644
 --- gdb/regcache.c
 +++ gdb/regcache.c
-@@ -1123,6 +1123,22 @@ reg_buffer::raw_supply_zeroed (int regnum)
+@@ -1187,6 +1187,18 @@ reg_buffer::raw_supply_zeroed (int regnum)
    m_register_status[regnum] = REG_VALID;
  }
  
 +void
 +reg_buffer::raw_supply_unsigned (int regnum, ULONGEST val)
 +{
-+  enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch);
-+  gdb_byte *regbuf;
-+  size_t regsize;
-+
 +  assert_regnum (regnum);
 +
-+  regbuf = register_buffer (regnum);
-+  regsize = m_descr->sizeof_register[regnum];
++  gdb::array_view<gdb_byte> dst = register_buffer (regnum);
++  enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch);
 +
-+  store_unsigned_integer (regbuf, regsize, byte_order, val);
++  store_unsigned_integer (dst.data (), dst.size (), byte_order, val);
 +  m_register_status[regnum] = REG_VALID;
 +}
 +
  /* See gdbsupport/common-regcache.h.  */
  
  void
-@@ -1289,6 +1305,53 @@ regcache::collect_regset (const struct regset *regset, int regbase,
+@@ -1353,6 +1365,53 @@ regcache::collect_regset (const struct regset *regset, int regbase,
  		   size);
  }
  
@@ -565,10 +561,10 @@ index 91b20b7a2a2..0cfa1bae3d9 100644
  regcache_map_supplies (const struct regcache_map_entry *map, int regnum,
  		       struct gdbarch *gdbarch, size_t size)
 diff --git gdb/regcache.h gdb/regcache.h
-index 57ddac465f0..b9f62994901 100644
+index 2f4b7d94c69..7ae67a309a7 100644
 --- gdb/regcache.h
 +++ gdb/regcache.h
-@@ -133,6 +133,11 @@ regcache_map_entry_size (const struct regcache_map_entry *map)
+@@ -130,6 +130,11 @@ regcache_map_entry_size (const struct regcache_map_entry *map)
    return size;
  }
  
@@ -580,7 +576,7 @@ index 57ddac465f0..b9f62994901 100644
  /* Transfer a set of registers (as described by REGSET) between
     REGCACHE and BUF.  If REGNUM == -1, transfer all registers
     belonging to the regset, otherwise just the register numbered
-@@ -151,6 +156,13 @@ extern void regcache_collect_regset (const struct regset *regset,
+@@ -148,6 +153,13 @@ extern void regcache_collect_regset (const struct regset *regset,
  				     int regnum, void *buf, size_t size);
  
  
@@ -594,9 +590,9 @@ index 57ddac465f0..b9f62994901 100644
  /* Return true if a set of registers contains the value of the
     register numbered REGNUM.  The size of the set of registers is
     given in SIZE, and the layout of the set of registers is described
-@@ -238,6 +250,8 @@ class reg_buffer : public reg_buffer_common
-      only LEN, without editing the rest of the register.  */
-   void raw_supply_part (int regnum, int offset, int len, const gdb_byte *in);
+@@ -249,6 +261,8 @@ class reg_buffer : public reg_buffer_common
+   void raw_supply_part (int regnum, int offset,
+ 			gdb::array_view<const gdb_byte> src);
  
 +  void raw_supply_unsigned (int regnum, ULONGEST val);
 +
diff --git a/devel/gdb/files/kgdb/aarch64-fbsd-kern.c b/devel/gdb/files/kgdb/aarch64-fbsd-kern.c
index 2eb89a7da5e1..3ff80e0d7b76 100644
--- a/devel/gdb/files/kgdb/aarch64-fbsd-kern.c
+++ b/devel/gdb/files/kgdb/aarch64-fbsd-kern.c
@@ -142,7 +142,8 @@ static const struct regcache_map_entry aarch64_fbsd13_trapframe_map[] =
   };
 
 static struct trad_frame_cache *
-aarch64_fbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
+aarch64_fbsd_trapframe_cache (const frame_info_ptr &this_frame,
+			      void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -190,7 +191,7 @@ aarch64_fbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static void
-aarch64_fbsd_trapframe_this_id (frame_info_ptr this_frame,
+aarch64_fbsd_trapframe_this_id (const frame_info_ptr &this_frame,
 				void **this_cache, struct frame_id *this_id)
 {
   struct trad_frame_cache *cache =
@@ -200,7 +201,7 @@ aarch64_fbsd_trapframe_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-aarch64_fbsd_trapframe_prev_register (frame_info_ptr this_frame,
+aarch64_fbsd_trapframe_prev_register (const frame_info_ptr &this_frame,
 				      void **this_cache, int regnum)
 {
   struct trad_frame_cache *cache =
@@ -211,7 +212,7 @@ aarch64_fbsd_trapframe_prev_register (frame_info_ptr this_frame,
 
 static int
 aarch64_fbsd_trapframe_sniffer (const struct frame_unwind *self,
-				frame_info_ptr this_frame,
+				const frame_info_ptr &this_frame,
 				void **this_prologue_cache)
 {
   const char *name;
diff --git a/devel/gdb/files/kgdb/amd64fbsd-kern.c b/devel/gdb/files/kgdb/amd64fbsd-kern.c
index 7c71bf919cdc..347215009861 100644
--- a/devel/gdb/files/kgdb/amd64fbsd-kern.c
+++ b/devel/gdb/files/kgdb/amd64fbsd-kern.c
@@ -128,7 +128,7 @@ static const int amd64fbsd_trapframe_offset[] = {
 #define TRAPFRAME_SIZE	192
 
 static struct trad_frame_cache *
-amd64fbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
+amd64fbsd_trapframe_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -179,7 +179,7 @@ amd64fbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static void
-amd64fbsd_trapframe_this_id (frame_info_ptr this_frame,
+amd64fbsd_trapframe_this_id (const frame_info_ptr &this_frame,
 			     void **this_cache, struct frame_id *this_id)
 {
   struct trad_frame_cache *cache =
@@ -189,7 +189,7 @@ amd64fbsd_trapframe_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-amd64fbsd_trapframe_prev_register (frame_info_ptr this_frame,
+amd64fbsd_trapframe_prev_register (const frame_info_ptr &this_frame,
 				   void **this_cache, int regnum)
 {
   struct trad_frame_cache *cache =
@@ -200,7 +200,7 @@ amd64fbsd_trapframe_prev_register (frame_info_ptr this_frame,
 
 static int
 amd64fbsd_trapframe_sniffer (const struct frame_unwind *self,
-			     frame_info_ptr this_frame,
+			     const frame_info_ptr &this_frame,
 			     void **this_prologue_cache)
 {
   const char *name;
diff --git a/devel/gdb/files/kgdb/arm-fbsd-kern.c b/devel/gdb/files/kgdb/arm-fbsd-kern.c
index 0caa5af96cb5..eaa0364b268e 100644
--- a/devel/gdb/files/kgdb/arm-fbsd-kern.c
+++ b/devel/gdb/files/kgdb/arm-fbsd-kern.c
@@ -68,14 +68,14 @@ arm_fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr)
    * of xPSR to determine if Thumb mode is active.  FreeBSD's kernels never
    * use Thumb.
    */
-  regcache->raw_supply_unsigned(ARM_PS_REGNUM, 0);
+  regcache->raw_supply_zeroed (ARM_PS_REGNUM);
 }
 
 #define PSR_MODE        0x0000001f      /* mode mask */
 #define PSR_USR32_MODE  0x00000010
 
 static struct trad_frame_cache *
-arm_fbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
+arm_fbsd_trapframe_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -132,7 +132,7 @@ arm_fbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static void
-arm_fbsd_trapframe_this_id (frame_info_ptr this_frame,
+arm_fbsd_trapframe_this_id (const frame_info_ptr &this_frame,
 			    void **this_cache, struct frame_id *this_id)
 {
   struct trad_frame_cache *cache =
@@ -142,7 +142,7 @@ arm_fbsd_trapframe_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-arm_fbsd_trapframe_prev_register (frame_info_ptr this_frame,
+arm_fbsd_trapframe_prev_register (const frame_info_ptr &this_frame,
 				  void **this_cache, int regnum)
 {
   struct trad_frame_cache *cache =
@@ -153,7 +153,7 @@ arm_fbsd_trapframe_prev_register (frame_info_ptr this_frame,
 
 static int
 arm_fbsd_trapframe_sniffer (const struct frame_unwind *self,
-			    frame_info_ptr this_frame,
+			    const frame_info_ptr &this_frame,
 			    void **this_prologue_cache)
 {
   const char *name;
diff --git a/devel/gdb/files/kgdb/fbsd-kld.c b/devel/gdb/files/kgdb/fbsd-kld.c
index 55121d87d974..df5b6a6d7be2 100644
--- a/devel/gdb/files/kgdb/fbsd-kld.c
+++ b/devel/gdb/files/kgdb/fbsd-kld.c
@@ -29,6 +29,7 @@
 #include "completer.h"
 #include "environ.h"
 #include "exec.h"
+#include "extract-store-integer.h"
 #include "frame-unwind.h"
 #include "inferior.h"
 #include "objfiles.h"
@@ -39,7 +40,7 @@
 
 #include "kgdb.h"
 
-struct lm_info_kld : public lm_info_base {
+struct lm_info_kld final : public lm_info {
 	CORE_ADDR base_address;
 };
 
@@ -53,7 +54,7 @@ struct kld_info {
 	CORE_ADDR kernel_file_addr;
 };
 
-struct target_so_ops kld_so_ops;
+solib_ops kld_so_ops;
 
 /* Per-program-space data key.  */
 static const registry<program_space>::key<kld_info> kld_pspace_data;
@@ -62,13 +63,13 @@ static const registry<program_space>::key<kld_info> kld_pspace_data;
    function always returns a valid object.  */
 
 static struct kld_info *
-get_kld_info (void)
+get_kld_info (program_space *pspace)
 {
   struct kld_info *info;
 
-  info = kld_pspace_data.get (current_program_space);
+  info = kld_pspace_data.get (pspace);
   if (info == nullptr)
-    info = kld_pspace_data.emplace (current_program_space);
+    info = kld_pspace_data.emplace (pspace);
 
   return info;
 }
@@ -111,7 +112,7 @@ check_kld_path (std::string &path)
  * Try to find the path for a kld by looking in the kernel's directory and
  * in the various paths in the module path.
  */
-static gdb::optional<std::string>
+static std::optional<std::string>
 find_kld_path (const char *filename)
 {
   bfd *exec_bfd = current_program_space->exec_bfd ();
@@ -127,7 +128,7 @@ find_kld_path (const char *filename)
 	}
     }
 
-  struct kld_info *info = get_kld_info ();
+  struct kld_info *info = get_kld_info (current_program_space);
   if (info->module_path_addr != 0)
     {
       gdb::unique_xmalloc_ptr<char> module_path
@@ -162,7 +163,7 @@ read_pointer (CORE_ADDR address)
 	arch_size = bfd_get_arch_size (current_program_space->exec_bfd ());
 	if (arch_size == -1)
 		return (0);
-	ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+	ptr_type = builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
 	if (target_read_memory(address, ptr_buf, arch_size / 8) != 0)
 		return (0);
 	return (extract_typed_address (ptr_buf, ptr_type));
@@ -174,7 +175,7 @@ read_pointer (CORE_ADDR address)
 static int
 find_kld_address (const char *arg, CORE_ADDR *address)
 {
-	struct kld_info *info = get_kld_info();
+	struct kld_info *info = get_kld_info(current_program_space);
 	if (info->linker_files_addr == 0 || info->off_address == 0 ||
 	    info->off_filename == 0 || info->off_next == 0)
 		return (0);
@@ -241,7 +242,7 @@ load_kld (const char *path, CORE_ADDR base_addr, int from_tty)
 		error("\"%s\": can't find text section", path);
 
 	/* Build a section table from the bfd and relocate the sections. */
-	target_section_table sections = build_section_table (bfd.get());
+	std::vector<target_section> sections = build_section_table (bfd.get());
 	CORE_ADDR curr_addr = base_addr;
 	for (target_section &s : sections)
 		adjust_section_address(&s, &curr_addr);
@@ -253,7 +254,7 @@ load_kld (const char *path, CORE_ADDR base_addr, int from_tty)
 	printf_unfiltered("add symbol table from file \"%s\" at\n", path);
 	for (const other_sections &s : sap)
 		printf_unfiltered("\t%s_addr = %s\n", s.name.c_str(),
-		    paddress(target_gdbarch(), s.addr));
+		    paddress(current_inferior ()->arch (), s.addr));
 
 	if (from_tty && (!query("%s", "")))
 		error("Not confirmed.");
@@ -281,7 +282,7 @@ kgdb_add_kld_cmd (const char *arg, int from_tty)
 		 * If that didn't work, look in the various possible
 		 * paths for the module.
 		 */
-		gdb::optional<std::string> found = find_kld_path (arg);
+		std::optional<std::string> found = find_kld_path (arg);
 		if (!found) {
 			error("Unable to locate kld");
 			return;
@@ -300,42 +301,32 @@ kgdb_add_kld_cmd (const char *arg, int from_tty)
 }
 
 static void
-kld_relocate_section_addresses (struct so_list *so, struct target_section *sec)
+kld_relocate_section_addresses (solib &so, struct target_section *sec)
 {
-  lm_info_kld *li = (lm_info_kld *) so->lm_info;
+  auto *li = gdb::checked_static_cast<lm_info_kld *> (so.lm_info.get ());
   static CORE_ADDR curr_addr;
 
-  if (sec == &so->sections->front())
+  if (sec == &so.sections.front())
     curr_addr = li->base_address;
 
-  adjust_section_address(sec, &curr_addr);
+  adjust_section_address (sec, &curr_addr);
 }
 
 static void
-kld_free_so (struct so_list *so)
+kld_clear_so (const solib &so)
 {
-  lm_info_kld *li = (lm_info_kld *) so->lm_info;
-
-  delete li;
-}
-
-static void
-kld_clear_so (struct so_list *so)
-{
-  lm_info_kld *li = (lm_info_kld *) so->lm_info;
+  auto *li = gdb::checked_static_cast<lm_info_kld *> (so.lm_info.get ());
 
   if (li != NULL)
     li->base_address = 0;
 }
 
 static void
-kld_clear_solib (void)
+kld_clear_solib (program_space *pspace)
 {
-	struct kld_info *info;
+  kld_info *info = get_kld_info (pspace);
 
-	info = get_kld_info();
-
-	memset(info, 0, sizeof(*info));
+  memset(info, 0, sizeof(*info));
 }
 
 static void
@@ -343,7 +334,7 @@ kld_solib_create_inferior_hook (int from_tty)
 {
 	struct kld_info *info;
 
-	info = get_kld_info();
+	info = get_kld_info (current_program_space);
 
 	/*
 	 * Compute offsets of relevant members in struct linker_file
@@ -360,7 +351,7 @@ kld_solib_create_inferior_hook (int from_tty)
 		try {
 			struct symbol *linker_file_sym =
 			    lookup_symbol_in_language ("struct linker_file",
-				NULL, STRUCT_DOMAIN, language_c, NULL).symbol;
+				NULL, SEARCH_TYPE_DOMAIN, language_c, NULL).symbol;
 			if (linker_file_sym == NULL)
 				error (_(
 			    "Unable to find struct linker_file symbol"));
@@ -400,20 +391,19 @@ kld_solib_create_inferior_hook (int from_tty)
 	solib_add(NULL, from_tty, auto_solib_add);
 }
 
-static struct so_list *
+static intrusive_list<solib>
 kld_current_sos (void)
 {
-	struct kld_info *info = get_kld_info();
+	struct kld_info *info = get_kld_info(current_program_space);
 	if (info->linker_files_addr == 0 || info->kernel_file_addr == 0 ||
 	    info->off_address == 0 || info->off_filename == 0 ||
 	    info->off_next == 0)
-		return (NULL);
+		return {};
 
-	struct so_list *head = NULL;
-	struct so_list **prev = &head;
+	intrusive_list<solib> sos;
 
 	/*
-	 * Walk the list of linker files creating so_list entries for
+	 * Walk the list of linker files creating solib entries for
 	 * each non-kernel file.
 	 */
 	CORE_ADDR kernel = read_pointer(info->kernel_file_addr);
@@ -423,63 +413,56 @@ kld_current_sos (void)
 		if (kld == kernel)
 			continue;
 
-		struct so_list *newobj = XCNEW (struct so_list);
+		solib *newobj = new solib;
 
-		lm_info_kld *li = new lm_info_kld;
+		auto li = std::make_unique<lm_info_kld> ();
 		li->base_address = 0;
 
-		newobj->lm_info = li;
-
 		/* Read the base filename and store it in so_original_name. */
-		gdb::unique_xmalloc_ptr<char> path =
+		gdb::unique_xmalloc_ptr<char> filename =
 		    target_read_string (read_pointer (kld + info->off_filename),
-		    sizeof(newobj->so_original_name));
-		if (path == nullptr) {
+		    SO_NAME_MAX_PATH_SIZE - 1);
+		if (filename == nullptr) {
 			warning("kld_current_sos: Can't read filename\n");
-			free_so(newobj);
+			delete newobj;
 			continue;
 		}
-		strlcpy(newobj->so_original_name, path.get(),
-		    sizeof(newobj->so_original_name));
+		newobj->so_original_name = filename.get ();
 
 		/*
 		 * Try to read the pathname (if it exists) and store
 		 * it in so_name.
 		 */
 		if (info->off_pathname != 0) {
-			path = target_read_string (read_pointer (kld +
-			    info->off_pathname),
-			    sizeof(newobj->so_name));
+			gdb::unique_xmalloc_ptr<char> path =
+			  target_read_string (read_pointer (kld +
+			  info->off_pathname), SO_NAME_MAX_PATH_SIZE - 1);
 			if (path == nullptr) {
 				warning(
 		    "kld_current_sos: Can't read pathname for \"%s\"\n",
-				    newobj->so_original_name);
-				strlcpy(newobj->so_name, newobj->so_original_name,
-				    sizeof(newobj->so_name));
+				    newobj->so_original_name.c_str ());
+				newobj->so_name = newobj->so_original_name;
 			} else {
-				strlcpy(newobj->so_name, path.get(),
-				    sizeof(newobj->so_name));
+				newobj->so_name = path.get();
 			}
 		} else
-			strlcpy(newobj->so_name, newobj->so_original_name,
-			    sizeof(newobj->so_name));
+			newobj->so_name = newobj->so_original_name;
 
 		/* Read this kld's base address. */
 		li->base_address = read_pointer(kld + info->off_address);
 		if (li->base_address == 0) {
 			warning(
 			    "kld_current_sos: Invalid address for kld \"%s\"",
-			    newobj->so_original_name);
-			free_so(newobj);
+			    newobj->so_original_name.c_str ());
+			delete newobj;
 			continue;
 		}
 
-		/* Append to the list. */
-		*prev = newobj;
-		prev = &newobj->next;
+		newobj->lm_info = std::move (li);
+		sos.push_back (*newobj);
 	}
 
-	return (head);
+	return sos;
 }
 
 static int
@@ -501,7 +484,7 @@ kld_find_and_open_solib (const char *solib, unsigned o_flags,
     gdb::unique_xmalloc_ptr<char> *temp_pathname)
 {
   temp_pathname->reset (NULL);
-  gdb::optional<std::string> found = find_kld_path (solib);
+  std::optional<std::string> found = find_kld_path (solib);
   if (!found) {
     errno = ENOENT;
     return (-1);
@@ -519,7 +502,6 @@ _initialize_kld_target ()
 	struct cmd_list_element *c;
 
 	kld_so_ops.relocate_section_addresses = kld_relocate_section_addresses;
-	kld_so_ops.free_so = kld_free_so;
 	kld_so_ops.clear_so = kld_clear_so;
 	kld_so_ops.clear_solib = kld_clear_solib;
 	kld_so_ops.solib_create_inferior_hook = kld_solib_create_inferior_hook;
diff --git a/devel/gdb/files/kgdb/fbsd-kthr.c b/devel/gdb/files/kgdb/fbsd-kthr.c
index 603e9bd4178f..19b7f0a621fb 100644
--- a/devel/gdb/files/kgdb/fbsd-kthr.c
+++ b/devel/gdb/files/kgdb/fbsd-kthr.c
@@ -30,6 +30,7 @@
 
 #include "defs.h"
 #include "gdbcore.h"
+#include "inferior.h"
 #include "objfiles.h"
 #include "value.h"
 
@@ -70,7 +71,7 @@ kgdb_lookup(const char *sym)
 static bool
 cpu_stopped(int cpu)
 {
-	struct gdbarch *gdbarch = target_gdbarch ();
+	struct gdbarch *gdbarch = current_inferior ()->arch ();
 	CORE_ADDR addr;
 	ULONGEST mask;
 	int bit, long_bytes, word;
@@ -95,7 +96,7 @@ kgdb_thr_first(void)
 static void
 kgdb_thr_add_proc(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int))
 {
-	struct gdbarch *gdbarch = target_gdbarch ();
+	struct gdbarch *gdbarch = current_inferior ()->arch ();
 	struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
 	enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 	struct kthr *kt;
@@ -149,7 +150,7 @@ kgdb_thr_add_proc(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int))
 static void
 kgdb_thr_add_procs_hash(CORE_ADDR pidhashtbl, CORE_ADDR (*cpu_pcb_addr) (u_int))
 {
-	struct gdbarch *gdbarch = target_gdbarch ();
+	struct gdbarch *gdbarch = current_inferior ()->arch ();
 	struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
 	enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 	CORE_ADDR paddr, pnext;
@@ -179,7 +180,7 @@ kgdb_thr_add_procs_hash(CORE_ADDR pidhashtbl, CORE_ADDR (*cpu_pcb_addr) (u_int))
 static void
 kgdb_thr_add_procs_list(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int))
 {
-	struct gdbarch *gdbarch = target_gdbarch ();
+	struct gdbarch *gdbarch = current_inferior ()->arch ();
 	struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
 	enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 	CORE_ADDR pnext;
@@ -199,7 +200,7 @@ kgdb_thr_add_procs_list(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int))
 struct kthr *
 kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int))
 {
-	struct gdbarch *gdbarch = target_gdbarch ();
+	struct gdbarch *gdbarch = current_inferior ()->arch ();
 	struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
 	struct kthr *kt;
 	CORE_ADDR addr, paddr;
@@ -249,7 +250,7 @@ kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int))
 		try {
 			struct symbol *proc_sym =
 			    lookup_symbol_in_language ("struct proc", NULL,
-				STRUCT_DOMAIN, language_c, NULL).symbol;
+				SEARCH_TYPE_DOMAIN, language_c, NULL).symbol;
 			if (proc_sym == NULL)
 				error (_("Unable to find struct proc symbol"));
 
@@ -268,7 +269,7 @@ kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int))
 
 			struct symbol *thread_sym =
 			    lookup_symbol_in_language ("struct thread", NULL,
-				STRUCT_DOMAIN, language_c, NULL).symbol;
+				SEARCH_TYPE_DOMAIN, language_c, NULL).symbol;
 			if (thread_sym == NULL)
 				error (_("Unable to find struct thread symbol"));
 
@@ -314,7 +315,7 @@ kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int))
 		try {
 			struct symbol *proc_sym =
 			    lookup_symbol_in_language ("struct proc", NULL,
-				STRUCT_DOMAIN, language_c, NULL).symbol;
+				SEARCH_TYPE_DOMAIN, language_c, NULL).symbol;
 			if (proc_sym == NULL)
 				error (_("Unable to find struct proc symbol"));
 
diff --git a/devel/gdb/files/kgdb/fbsd-kvm.c b/devel/gdb/files/kgdb/fbsd-kvm.c
index 8c7406c0b177..29dda6c9c349 100644
--- a/devel/gdb/files/kgdb/fbsd-kvm.c
+++ b/devel/gdb/files/kgdb/fbsd-kvm.c
@@ -271,7 +271,7 @@ kgdb_resolve_symbol(const char *name, kvaddr_t *kva)
 static void
 fbsd_kvm_target_open (const char *args, int from_tty)
 {
-	struct fbsd_vmcore_ops *ops = get_fbsd_vmcore_ops (target_gdbarch ());
+	struct fbsd_vmcore_ops *ops = get_fbsd_vmcore_ops (current_inferior ()->arch ());
 	char kvm_err[_POSIX2_LINE_MAX];
 	struct inferior *inf;
 	struct cleanup *old_chain;
@@ -376,7 +376,7 @@ fbsd_kvm_target_open (const char *args, int from_tty)
 		/* stoppcbs is now a pointer rather than an array. */
 		try {
 			stoppcbs = read_memory_typed_address(stoppcbs,
-			    builtin_type(target_gdbarch())->builtin_data_ptr);
+			    builtin_type(current_inferior ()->arch())->builtin_data_ptr);
 		} catch (const gdb_exception_error &e) {
 			stoppcbs = 0;
 		}
@@ -420,7 +420,7 @@ fbsd_kvm_target_open (const char *args, int from_tty)
 
 	post_create_inferior (from_tty);
 
-	target_fetch_registers (get_current_regcache (), -1);
+	target_fetch_registers (get_thread_regcache (curthr), -1);
 
 	reinit_frame_cache ();
 	print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
@@ -434,7 +434,7 @@ fbsd_kvm_target::close()
 		switch_to_no_thread ();
 		exit_inferior (current_inferior ());
 
-		clear_solib();
+		clear_solib (current_program_space);
 		if (kvm_close(kvm) != 0)
 			warning("cannot close \"%s\": %s", vmcore.c_str (),
 			    kvm_geterr(kvm));
@@ -507,7 +507,7 @@ fbsd_kvm_target::thread_alive(ptid_t ptid)
 void
 fbsd_kvm_target::fetch_registers(struct regcache *regcache, int regnum)
 {
-	struct fbsd_vmcore_ops *ops = get_fbsd_vmcore_ops (target_gdbarch ());
*** 310 LINES SKIPPED ***