From c40d0a908eec9fc657eaa72efc960a02dd49ff66 Mon Sep 17 00:00:00 2001 From: Oleg Borodin Date: Mon, 8 Jan 2024 23:40:37 +0200 Subject: [PATCH] update --- devel/gdb/Makefile | 29 +- devel/gdb/distinfo | 8 +- devel/gdb/files/commit-1163a4b7a3 | 419 ---------- devel/gdb/files/commit-36c53a0262 | 60 -- devel/gdb/files/commit-6e056c8178 | 166 ---- devel/gdb/files/commit-8399425f5f | 69 -- devel/gdb/files/commit-945f3901b5 | 224 ------ devel/gdb/files/commit-a980a7d24b9 | 37 + devel/gdb/files/commit-ae61525fcf4 | 128 ++++ devel/gdb/files/commit-b0f87ed032 | 60 -- devel/gdb/files/commit-cd250a1898 | 30 - devel/gdb/files/commit-ce25aa57a3 | 64 -- devel/gdb/files/commit-dd6876c91c | 237 ------ devel/gdb/files/commit-df22c1e5d5 | 36 - devel/gdb/files/commit-ef0bd2046f | 165 ---- devel/gdb/files/commit-f5424cfa7e | 63 -- devel/gdb/files/extrapatch-guile22 | 717 ------------------ devel/gdb/files/extrapatch-kgdb | 342 +++++---- devel/gdb/files/kgdb/aarch64-fbsd-kern.c | 154 +++- devel/gdb/files/kgdb/amd64fbsd-kern.c | 19 +- devel/gdb/files/kgdb/arm-fbsd-kern.c | 48 +- devel/gdb/files/kgdb/fbsd-kld.c | 319 ++++---- devel/gdb/files/kgdb/fbsd-kthr.c | 326 +++++--- devel/gdb/files/kgdb/fbsd-kvm.c | 260 +++---- devel/gdb/files/kgdb/i386fbsd-kern.c | 65 +- devel/gdb/files/kgdb/kgdb-main.c | 4 +- devel/gdb/files/kgdb/kgdb.1 | 2 - devel/gdb/files/kgdb/kgdb.h | 2 - devel/gdb/files/kgdb/mipsfbsd-kern.c | 31 +- devel/gdb/files/kgdb/ppcfbsd-kern.c | 115 +-- devel/gdb/files/kgdb/riscv-fbsd-kern.c | 31 +- devel/gdb/files/kgdb/sparc64fbsd-kern.c | 35 +- devel/gdb/files/patch-fixes | 10 - devel/gdb/files/patch-gdb_amd64-bsd-nat.c | 30 - devel/gdb/files/patch-gdb_configure | 16 - ...s.h => patch-gdb_gdbsupport_common-defs.h} | 10 +- .../files/patch-gdb_gnulib_import_stddef.in.h | 11 - devel/gdb/files/patch-gdb_i386-fbsd-nat.c | 22 +- devel/gdb/files/patch-gdb_inflow.c | 14 + .../files/patch-gdb_python_python-config.py | 16 +- .../gdb/files/patch-gnulib_import_stddef.in.h | 11 + devel/gdb/files/patch-include_libiberty.h | 11 - devel/gdb/files/patch-libiberty_configure | 12 - devel/gdb/pkg-plist | 1 + media/libv4l/Makefile | 4 +- .../files/patch-x-lib-libdvbv5-dvb-v5.h | 36 + system/dpkg/Makefile | 3 +- system/dpkg/distinfo | 5 +- 48 files changed, 1232 insertions(+), 3245 deletions(-) delete mode 100644 devel/gdb/files/commit-1163a4b7a3 delete mode 100644 devel/gdb/files/commit-36c53a0262 delete mode 100644 devel/gdb/files/commit-6e056c8178 delete mode 100644 devel/gdb/files/commit-8399425f5f delete mode 100644 devel/gdb/files/commit-945f3901b5 create mode 100644 devel/gdb/files/commit-a980a7d24b9 create mode 100644 devel/gdb/files/commit-ae61525fcf4 delete mode 100644 devel/gdb/files/commit-b0f87ed032 delete mode 100644 devel/gdb/files/commit-cd250a1898 delete mode 100644 devel/gdb/files/commit-ce25aa57a3 delete mode 100644 devel/gdb/files/commit-dd6876c91c delete mode 100644 devel/gdb/files/commit-df22c1e5d5 delete mode 100644 devel/gdb/files/commit-ef0bd2046f delete mode 100644 devel/gdb/files/commit-f5424cfa7e delete mode 100644 devel/gdb/files/extrapatch-guile22 delete mode 100644 devel/gdb/files/patch-fixes delete mode 100644 devel/gdb/files/patch-gdb_amd64-bsd-nat.c delete mode 100644 devel/gdb/files/patch-gdb_configure rename devel/gdb/files/{patch-gdb_common_common-defs.h => patch-gdb_gdbsupport_common-defs.h} (53%) delete mode 100644 devel/gdb/files/patch-gdb_gnulib_import_stddef.in.h create mode 100644 devel/gdb/files/patch-gdb_inflow.c create mode 100644 devel/gdb/files/patch-gnulib_import_stddef.in.h delete mode 100644 devel/gdb/files/patch-include_libiberty.h delete mode 100644 devel/gdb/files/patch-libiberty_configure create mode 100644 media/libv4l/files/patch-x-lib-libdvbv5-dvb-v5.h diff --git a/devel/gdb/Makefile b/devel/gdb/Makefile index 3e675a96..54e23d59 100644 --- a/devel/gdb/Makefile +++ b/devel/gdb/Makefile @@ -2,7 +2,7 @@ # $FreeBSD: head/devel/gdb/Makefile 513464 2019-10-01 08:51:39Z pizzamig $ PORTNAME= gdb -PORTVERSION= 8.3.1 +PORTVERSION= 13.2 CATEGORIES= devel MASTER_SITES= GNU @@ -23,18 +23,17 @@ USES= compiler:c++11-lang cpe gmake libtool pkgconfig tar:xz EXCLUDE= dejagnu expect sim texinfo intl EXTRACT_AFTER_ARGS= ${EXCLUDE:S/^/--exclude /} -EXTRA_PATCHES= ${FILESDIR}/commit-1163a4b7a3 \ - ${FILESDIR}/commit-dd6876c91c \ - ${FILESDIR}/commit-6e056c8178 \ - ${FILESDIR}/commit-36c53a0262 \ - ${FILESDIR}/commit-ef0bd2046f \ - ${FILESDIR}/commit-945f3901b5 \ - ${FILESDIR}/commit-f5424cfa7e \ - ${FILESDIR}/commit-ce25aa57a3 \ - ${FILESDIR}/commit-8399425f5f - - -USE_CSTD= gnu89 +#EXTRA_PATCHES= ${FILESDIR}/commit-1163a4b7a3 \ +# ${FILESDIR}/commit-dd6876c91c \ +# ${FILESDIR}/commit-6e056c8178 \ +# ${FILESDIR}/commit-36c53a0262 \ +# ${FILESDIR}/commit-ef0bd2046f \ +# ${FILESDIR}/commit-945f3901b5 \ +# ${FILESDIR}/commit-f5424cfa7e \ +# ${FILESDIR}/commit-ce25aa57a3 \ +# ${FILESDIR}/commit-8399425f5f + +#USE_CSTD= gnu89 GNU_CONFIGURE= yes CONFIGURE_ENV= CONFIGURED_M4=gm4 CONFIGURED_BISON=byacc CONFIGURE_ARGS+= --program-suffix=${PORTVERSION:S/.//g} @@ -42,13 +41,13 @@ CONFIGURE_ARGS+= --enable-targets=all --enable-64-bit-bfd CONFIGURE_ARGS+= --with-separate-debug-dir=/usr/lib/debug CONFIGURE_ARGS+= --with-expat=yes --with-libexpat-prefix=${LOCALBASE} CONFIGURE_ARGS+= --without-libunwind-ia64 --with-system-zlib + CFLAGS:= ${CFLAGS:C/ +$//} # blanks at EOL creep in sometimes CFLAGS+= -DRL_NO_COMPAT -Wno-unused-function -Wno-unused-variable CFLAGS+= -Wno-unknown-warning-option - -CONFIGURE_ARGS+= --with-system-readline +#CONFIGURE_ARGS+= --with-system-readline CONFIGURE_ARGS+= --with-system-zlib CONFIGURE_ARGS+= --without-python diff --git a/devel/gdb/distinfo b/devel/gdb/distinfo index 0e15910a..0e8ea3ae 100644 --- a/devel/gdb/distinfo +++ b/devel/gdb/distinfo @@ -1,5 +1,3 @@ -TIMESTAMP = 1569514923 -SHA256 (gdb-8.3.1.tar.xz) = 1e55b4d7cdca7b34be12f4ceae651623aa73b2fd640152313f9f66a7149757c4 -SIZE (gdb-8.3.1.tar.xz) = 20489528 -SHA256 (bsdjhb-libcxx-gdbpy-229610a_GH0.tar.gz) = d4235f98b71c4d5e3f01744de279e64808229dd46c0f00cac6a12fdeb3a998a1 -SIZE (bsdjhb-libcxx-gdbpy-229610a_GH0.tar.gz) = 5299 +TIMESTAMP = 1704654728 +SHA256 (gdb-13.2.tar.xz) = fd5bebb7be1833abdb6e023c2f498a354498281df9d05523d8915babeb893f0a +SIZE (gdb-13.2.tar.xz) = 23664644 diff --git a/devel/gdb/files/commit-1163a4b7a3 b/devel/gdb/files/commit-1163a4b7a3 deleted file mode 100644 index 143697ee..00000000 --- a/devel/gdb/files/commit-1163a4b7a3 +++ /dev/null @@ -1,419 +0,0 @@ -commit 1163a4b7a38a79ebd153dc5ee76ce93877d21dbd -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Support the fs_base and gs_base registers on i386. - - As on amd64, these registers hold the base address of the fs and gs - segments, respectively. For i386 these two registers are 32 bits. - - gdb/ChangeLog: - - * amd64-fbsd-nat.c (amd64_fbsd_nat_target::read_description): - Update calls to i386_target_description to add 'segments' - parameter. - * amd64-tdep.c (amd64_init_abi): Set tdep->fsbase_regnum. Don't - add segment base registers. - * arch/i386.c (i386_create_target_description): Add 'segments' - parameter to enable segment base registers. - * arch/i386.h (i386_create_target_description): Likewise. - * features/i386/32bit-segments.xml: New file. - * features/i386/32bit-segments.c: Generate. - * i386-fbsd-nat.c (i386_fbsd_nat_target::read_description): Update - call to i386_target_description to add 'segments' parameter. - * i386-fbsd-tdep.c (i386fbsd_core_read_description): Likewise. - * i386-go32-tdep.c (i386_go32_init_abi): Likewise. - * i386-linux-tdep.c (i386_linux_read_description): Likewise. - * i386-tdep.c (i386_validate_tdesc_p): Add segment base registers - if feature is present. - (i386_gdbarch_init): Pass I386_NUM_REGS to set_gdbarch_num_regs. - Add 'segments' parameter to call to i386_target_description. - (i386_target_description): Add 'segments' parameter to enable - segment base registers. - (_initialize_i386_tdep) [GDB_SELF_TEST]: Add 'segments' parameter - to call to i386_target_description. - * i386-tdep.h (struct gdbarch_tdep): Add 'fsbase_regnum'. - (enum i386_regnum): Add I386_FSBASE_REGNUM and I386_GSBASE_REGNUM. - Define I386_NUM_REGS. - (i386_target_description): Add 'segments' parameter to enable - segment base registers. - - gdb/gdbserver/ChangeLog: - - * linux-x86-tdesc.c (i386_linux_read_description): Update call to - i386_create_target_description for 'segments' parameter. - * lynx-i386-low.c (lynx_i386_arch_setup): Likewise. - * nto-x86-low.c (nto_x86_arch_setup): Likewise. - * win32-i386-low.c (i386_arch_setup): Likewise. - -diff --git gdb/amd64-fbsd-nat.c gdb/amd64-fbsd-nat.c -index 74ef240766..9fff763dd3 100644 ---- gdb/amd64-fbsd-nat.c -+++ gdb/amd64-fbsd-nat.c -@@ -190,13 +190,13 @@ amd64_fbsd_nat_target::read_description () - if (is64) - return amd64_target_description (xcr0, true); - else -- return i386_target_description (xcr0); -+ return i386_target_description (xcr0, false); - } - #endif - if (is64) - return amd64_target_description (X86_XSTATE_SSE_MASK, true); - else -- return i386_target_description (X86_XSTATE_SSE_MASK); -+ return i386_target_description (X86_XSTATE_SSE_MASK, false); - } - - #if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO) -diff --git gdb/amd64-tdep.c gdb/amd64-tdep.c -index 3f61997d66..d5892954d7 100644 ---- gdb/amd64-tdep.c -+++ gdb/amd64-tdep.c -@@ -3107,15 +3107,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch, - - if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.segments") != NULL) - { -- const struct tdesc_feature *feature = -- tdesc_find_feature (tdesc, "org.gnu.gdb.i386.segments"); -- struct tdesc_arch_data *tdesc_data_segments = -- (struct tdesc_arch_data *) info.tdep_info; -- -- tdesc_numbered_register (feature, tdesc_data_segments, -- AMD64_FSBASE_REGNUM, "fs_base"); -- tdesc_numbered_register (feature, tdesc_data_segments, -- AMD64_GSBASE_REGNUM, "gs_base"); -+ tdep->fsbase_regnum = AMD64_FSBASE_REGNUM; - } - - if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pkeys") != NULL) -diff --git gdb/arch/i386.c gdb/arch/i386.c -index 7d2901333b..ab24cf71cb 100644 ---- gdb/arch/i386.c -+++ gdb/arch/i386.c -@@ -28,11 +28,12 @@ - #include "../features/i386/32bit-avx512.c" - #include "../features/i386/32bit-mpx.c" - #include "../features/i386/32bit-pkeys.c" -+#include "../features/i386/32bit-segments.c" - - /* Create i386 target descriptions according to XCR0. */ - - target_desc * --i386_create_target_description (uint64_t xcr0, bool is_linux) -+i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments) - { - target_desc *tdesc = allocate_target_description (); - -@@ -53,6 +54,9 @@ i386_create_target_description (uint64_t xcr0, bool is_linux) - if (is_linux) - regnum = create_feature_i386_32bit_linux (tdesc, regnum); - -+ if (segments) -+ regnum = create_feature_i386_32bit_segments (tdesc, regnum); -+ - if (xcr0 & X86_XSTATE_AVX) - regnum = create_feature_i386_32bit_avx (tdesc, regnum); - -diff --git gdb/arch/i386.h gdb/arch/i386.h -index fa85438080..9a831cea30 100644 ---- gdb/arch/i386.h -+++ gdb/arch/i386.h -@@ -21,6 +21,7 @@ - #include "common/tdesc.h" - #include - --target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux); -+target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux, -+ bool segments); - - #endif /* ARCH_I386_H */ -diff --git gdb/features/i386/32bit-segments.c gdb/features/i386/32bit-segments.c -new file mode 100644 -index 0000000000..c22c3dfbc3 ---- /dev/null -+++ gdb/features/i386/32bit-segments.c -@@ -0,0 +1,15 @@ -+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: -+ Original: 32bit-segments.xml */ -+ -+#include "common/tdesc.h" -+ -+static int -+create_feature_i386_32bit_segments (struct target_desc *result, long regnum) -+{ -+ struct tdesc_feature *feature; -+ -+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.segments"); -+ tdesc_create_reg (feature, "fs_base", regnum++, 1, NULL, 32, "int"); -+ tdesc_create_reg (feature, "gs_base", regnum++, 1, NULL, 32, "int"); -+ return regnum; -+} -diff --git gdb/features/i386/32bit-segments.xml gdb/features/i386/32bit-segments.xml -new file mode 100644 -index 0000000000..098948e5ec ---- /dev/null -+++ gdb/features/i386/32bit-segments.xml -@@ -0,0 +1,12 @@ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git gdb/gdbserver/linux-x86-tdesc.c gdb/gdbserver/linux-x86-tdesc.c -index 04bccc84ed..8f24a3d72d 100644 ---- gdb/gdbserver/linux-x86-tdesc.c -+++ gdb/gdbserver/linux-x86-tdesc.c -@@ -87,7 +87,7 @@ i386_linux_read_description (uint64_t xcr0) - - if (*tdesc == NULL) - { -- *tdesc = i386_create_target_description (xcr0, true); -+ *tdesc = i386_create_target_description (xcr0, true, false); - - init_target_desc (*tdesc, i386_expedite_regs); - } -diff --git gdb/gdbserver/lynx-i386-low.c gdb/gdbserver/lynx-i386-low.c -index bc1027dc52..e47f6b92f6 100644 ---- gdb/gdbserver/lynx-i386-low.c -+++ gdb/gdbserver/lynx-i386-low.c -@@ -331,7 +331,7 @@ static void - lynx_i386_arch_setup (void) - { - struct target_desc *tdesc -- = i386_create_target_description (X86_XSTATE_SSE_MASK, false); -+ = i386_create_target_description (X86_XSTATE_SSE_MASK, false, false); - - init_target_desc (tdesc, i386_expedite_regs); - -diff --git gdb/gdbserver/nto-x86-low.c gdb/gdbserver/nto-x86-low.c -index 1b00f7f6cc..cfbe7ba6d8 100644 ---- gdb/gdbserver/nto-x86-low.c -+++ gdb/gdbserver/nto-x86-low.c -@@ -89,7 +89,7 @@ nto_x86_arch_setup (void) - { - the_low_target.num_regs = 16; - struct target_desc *tdesc -- = i386_create_target_description (X86_XSTATE_SSE_MASK, false); -+ = i386_create_target_description (X86_XSTATE_SSE_MASK, false, false); - - init_target_desc (tdesc, i386_expedite_regs); - -diff --git gdb/gdbserver/win32-i386-low.c gdb/gdbserver/win32-i386-low.c -index 3be75d2bf2..7b187d3bea 100644 ---- gdb/gdbserver/win32-i386-low.c -+++ gdb/gdbserver/win32-i386-low.c -@@ -439,7 +439,7 @@ i386_arch_setup (void) - false, false); - const char **expedite_regs = amd64_expedite_regs; - #else -- tdesc = i386_create_target_description (X86_XSTATE_SSE_MASK, false); -+ tdesc = i386_create_target_description (X86_XSTATE_SSE_MASK, false, false); - const char **expedite_regs = i386_expedite_regs; - #endif - -diff --git gdb/i386-fbsd-nat.c gdb/i386-fbsd-nat.c -index 2309b76506..7106e90801 100644 ---- gdb/i386-fbsd-nat.c -+++ gdb/i386-fbsd-nat.c -@@ -160,7 +160,7 @@ i386_fbsd_nat_target::read_description () - if (x86bsd_xsave_len == 0) - xcr0 = X86_XSTATE_SSE_MASK; - -- return i386_target_description (xcr0); -+ return i386_target_description (xcr0, false); - } - #endif - -diff --git gdb/i386-fbsd-tdep.c gdb/i386-fbsd-tdep.c -index 236edd692a..2f28bad728 100644 ---- gdb/i386-fbsd-tdep.c -+++ gdb/i386-fbsd-tdep.c -@@ -267,7 +267,7 @@ i386fbsd_core_read_description (struct gdbarch *gdbarch, - struct target_ops *target, - bfd *abfd) - { -- return i386_target_description (i386fbsd_core_read_xcr0 (abfd)); -+ return i386_target_description (i386fbsd_core_read_xcr0 (abfd), false); - } - - /* Similar to i386_supply_fpregset, but use XSAVE extended state. */ -diff --git gdb/i386-go32-tdep.c gdb/i386-go32-tdep.c -index 06833c346c..30db72d880 100644 ---- gdb/i386-go32-tdep.c -+++ gdb/i386-go32-tdep.c -@@ -35,7 +35,7 @@ i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - - /* DJGPP does not support the SSE registers. */ - if (!tdesc_has_registers (info.target_desc)) -- tdep->tdesc = i386_target_description (X86_XSTATE_X87_MASK); -+ tdep->tdesc = i386_target_description (X86_XSTATE_X87_MASK, false); - - /* Native compiler is GCC, which uses the SVR4 register numbering - even in COFF and STABS. See the comment in i386_gdbarch_init, -diff --git gdb/i386-linux-tdep.c gdb/i386-linux-tdep.c -index da81715061..fa6b86f1c8 100644 ---- gdb/i386-linux-tdep.c -+++ gdb/i386-linux-tdep.c -@@ -694,7 +694,7 @@ i386_linux_read_description (uint64_t xcr0) - [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]; - - if (*tdesc == NULL) -- *tdesc = i386_create_target_description (xcr0, true); -+ *tdesc = i386_create_target_description (xcr0, true, false); - - return *tdesc; - } -diff --git gdb/i386-tdep.c gdb/i386-tdep.c -index bc9ba752ed..4e63832b0e 100644 ---- gdb/i386-tdep.c -+++ gdb/i386-tdep.c -@@ -8175,7 +8175,7 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep, - const struct tdesc_feature *feature_core; - - const struct tdesc_feature *feature_sse, *feature_avx, *feature_mpx, -- *feature_avx512, *feature_pkeys; -+ *feature_avx512, *feature_pkeys, *feature_segments; - int i, num_regs, valid_p; - - if (! tdesc_has_registers (tdesc)) -@@ -8198,6 +8198,9 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep, - /* Try AVX512 registers. */ - feature_avx512 = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.avx512"); - -+ /* Try segment base registers. */ -+ feature_segments = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.segments"); -+ - /* Try PKEYS */ - feature_pkeys = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pkeys"); - -@@ -8307,6 +8310,16 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep, - tdep->mpx_register_names[i]); - } - -+ if (feature_segments) -+ { -+ if (tdep->fsbase_regnum < 0) -+ tdep->fsbase_regnum = I386_FSBASE_REGNUM; -+ valid_p &= tdesc_numbered_register (feature_segments, tdesc_data, -+ tdep->fsbase_regnum, "fs_base"); -+ valid_p &= tdesc_numbered_register (feature_segments, tdesc_data, -+ tdep->fsbase_regnum + 1, "gs_base"); -+ } -+ - if (feature_pkeys) - { - tdep->xcr0 |= X86_XSTATE_PKRU; -@@ -8543,14 +8556,14 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - /* Even though the default ABI only includes general-purpose registers, - floating-point registers and the SSE registers, we have to leave a - gap for the upper AVX, MPX and AVX512 registers. */ -- set_gdbarch_num_regs (gdbarch, I386_PKEYS_NUM_REGS); -+ set_gdbarch_num_regs (gdbarch, I386_NUM_REGS); - - set_gdbarch_gnu_triplet_regexp (gdbarch, i386_gnu_triplet_regexp); - - /* Get the x86 target description from INFO. */ - tdesc = info.target_desc; - if (! tdesc_has_registers (tdesc)) -- tdesc = i386_target_description (X86_XSTATE_SSE_MASK); -+ tdesc = i386_target_description (X86_XSTATE_SSE_MASK, false); - tdep->tdesc = tdesc; - - tdep->num_core_regs = I386_NUM_GREGS + I387_NUM_REGS; -@@ -8592,6 +8605,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - tdep->pkru_regnum = -1; - tdep->num_pkeys_regs = 0; - -+ /* No segment base registers. */ -+ tdep->fsbase_regnum = -1; -+ - tdesc_data = tdesc_data_alloc (); - - set_gdbarch_relocate_instruction (gdbarch, i386_relocate_instruction); -@@ -8717,20 +8733,21 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - /* Return the target description for a specified XSAVE feature mask. */ - - const struct target_desc * --i386_target_description (uint64_t xcr0) -+i386_target_description (uint64_t xcr0, bool segments) - { - static target_desc *i386_tdescs \ -- [2/*SSE*/][2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/] = {}; -+ [2/*SSE*/][2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {}; - target_desc **tdesc; - - tdesc = &i386_tdescs[(xcr0 & X86_XSTATE_SSE) ? 1 : 0] - [(xcr0 & X86_XSTATE_AVX) ? 1 : 0] - [(xcr0 & X86_XSTATE_MPX) ? 1 : 0] - [(xcr0 & X86_XSTATE_AVX512) ? 1 : 0] -- [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]; -+ [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0] -+ [segments ? 1 : 0]; - - if (*tdesc == NULL) -- *tdesc = i386_create_target_description (xcr0, false); -+ *tdesc = i386_create_target_description (xcr0, false, segments); - - return *tdesc; - } -@@ -9072,7 +9089,7 @@ Show Intel Memory Protection Extensions specific variables."), - - for (auto &a : xml_masks) - { -- auto tdesc = i386_target_description (a.mask); -+ auto tdesc = i386_target_description (a.mask, false); - - selftests::record_xml_tdesc (a.xml, tdesc); - } -diff --git gdb/i386-tdep.h gdb/i386-tdep.h -index 2532306e5c..c0d494824c 100644 ---- gdb/i386-tdep.h -+++ gdb/i386-tdep.h -@@ -200,6 +200,10 @@ struct gdbarch_tdep - /* PKEYS register names. */ - const char **pkeys_register_names; - -+ /* Register number for %fsbase. Set this to -1 to indicate the -+ absence of segment base registers. */ -+ int fsbase_regnum; -+ - /* Target description. */ - const struct target_desc *tdesc; - -@@ -296,7 +300,9 @@ enum i386_regnum - I386_K7_REGNUM = I386_K0_REGNUM + 7, - I386_ZMM0H_REGNUM, /* %zmm0h */ - I386_ZMM7H_REGNUM = I386_ZMM0H_REGNUM + 7, -- I386_PKRU_REGNUM -+ I386_PKRU_REGNUM, -+ I386_FSBASE_REGNUM, -+ I386_GSBASE_REGNUM - }; - - /* Register numbers of RECORD_REGMAP. */ -@@ -337,6 +343,7 @@ enum record_i386_regnum - #define I386_MPX_NUM_REGS (I386_BNDSTATUS_REGNUM + 1) - #define I386_AVX512_NUM_REGS (I386_ZMM7H_REGNUM + 1) - #define I386_PKEYS_NUM_REGS (I386_PKRU_REGNUM + 1) -+#define I386_NUM_REGS (I386_GSBASE_REGNUM + 1) - - /* Size of the largest register. */ - #define I386_MAX_REGISTER_SIZE 64 -@@ -440,7 +447,8 @@ extern int i386_svr4_reg_to_regnum (struct gdbarch *gdbarch, int reg); - - extern int i386_process_record (struct gdbarch *gdbarch, - struct regcache *regcache, CORE_ADDR addr); --extern const struct target_desc *i386_target_description (uint64_t xcr0); -+extern const struct target_desc *i386_target_description (uint64_t xcr0, -+ bool segments); - - /* Return true iff the current target is MPX enabled. */ - extern int i386_mpx_enabled (void); diff --git a/devel/gdb/files/commit-36c53a0262 b/devel/gdb/files/commit-36c53a0262 deleted file mode 100644 index 3eaa2ea9..00000000 --- a/devel/gdb/files/commit-36c53a0262 +++ /dev/null @@ -1,60 +0,0 @@ -commit 36c53a0262f84ad11d738471789dadfa9c4eb320 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Remove code disabled since at least 1999 from lookup_struct_elt_type. - - Update the comment above the function to reflect the code removal and - document the existing behavior. - - gdb/ChangeLog: - - * gdbtypes.c (lookup_struct_elt_type): Update comment and - remove disabled code block. - -diff --git gdb/gdbtypes.c gdb/gdbtypes.c -index 09284ef259..5924b15520 100644 ---- gdb/gdbtypes.c -+++ gdb/gdbtypes.c -@@ -1644,8 +1644,7 @@ lookup_template_type (char *name, struct type *type, - return (SYMBOL_TYPE (sym)); - } - --/* Given a type TYPE, lookup the type of the component of type named -- NAME. -+/* Given a type TYPE, lookup the type of the component named NAME. - - TYPE can be either a struct or union, or a pointer or reference to - a struct or union. If it is a pointer or reference, its target -@@ -1653,8 +1652,8 @@ lookup_template_type (char *name, struct type *type, - as specified for the definitions of the expression element types - STRUCTOP_STRUCT and STRUCTOP_PTR. - -- If NOERR is nonzero, return zero if NAME is not suitably defined. -- If NAME is the name of a baseclass type, return that type. */ -+ If NOERR is nonzero, return NULL if there is no component named -+ NAME. */ - - struct type * - lookup_struct_elt_type (struct type *type, const char *name, int noerr) -@@ -1678,20 +1677,6 @@ lookup_struct_elt_type (struct type *type, const char *name, int noerr) - type_name.c_str ()); - } - --#if 0 -- /* FIXME: This change put in by Michael seems incorrect for the case -- where the structure tag name is the same as the member name. -- I.e. when doing "ptype bell->bar" for "struct foo { int bar; int -- foo; } bell;" Disabled by fnf. */ -- { -- char *type_name; -- -- type_name = TYPE_NAME (type); -- if (type_name != NULL && strcmp (type_name, name) == 0) -- return type; -- } --#endif -- - for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) - { - const char *t_field_name = TYPE_FIELD_NAME (type, i); diff --git a/devel/gdb/files/commit-6e056c8178 b/devel/gdb/files/commit-6e056c8178 deleted file mode 100644 index 591208fc..00000000 --- a/devel/gdb/files/commit-6e056c8178 +++ /dev/null @@ -1,166 +0,0 @@ -commit 6e056c817845f3d736a1be6b68c69b439c6c6d25 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Add a new gdbarch method to resolve the address of TLS variables. - - Permit TLS variable addresses to be resolved purely by an ABI rather - than requiring a target method. This doesn't try the target method if - the ABI function is present (even if the ABI function fails) to - simplify error handling. - - gdb/ChangeLog: - - * gdbarch.sh (get_thread_local_address): New method. - * gdbarch.h, gdbarch.c: Regenerate. - * target.c (target_translate_tls_address): Use - gdbarch_get_thread_local_address if present instead of - target::get_thread_local_address. - -diff --git gdb/gdbarch.c gdb/gdbarch.c -index 434ee3bfcf..2b3fcef004 100644 ---- gdb/gdbarch.c -+++ gdb/gdbarch.c -@@ -251,6 +251,7 @@ struct gdbarch - CORE_ADDR deprecated_function_start_offset; - gdbarch_remote_register_number_ftype *remote_register_number; - gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address; -+ gdbarch_get_thread_local_address_ftype *get_thread_local_address; - CORE_ADDR frame_args_skip; - gdbarch_unwind_pc_ftype *unwind_pc; - gdbarch_unwind_sp_ftype *unwind_sp; -@@ -613,6 +614,7 @@ verify_gdbarch (struct gdbarch *gdbarch) - /* Skip verify of deprecated_function_start_offset, invalid_p == 0 */ - /* Skip verify of remote_register_number, invalid_p == 0 */ - /* Skip verify of fetch_tls_load_module_address, has predicate. */ -+ /* Skip verify of get_thread_local_address, has predicate. */ - /* Skip verify of frame_args_skip, invalid_p == 0 */ - /* Skip verify of unwind_pc, invalid_p == 0 */ - /* Skip verify of unwind_sp, invalid_p == 0 */ -@@ -1073,6 +1075,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) - fprintf_unfiltered (file, - "gdbarch_dump: get_syscall_number = <%s>\n", - host_address_to_string (gdbarch->get_syscall_number)); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: gdbarch_get_thread_local_address_p() = %d\n", -+ gdbarch_get_thread_local_address_p (gdbarch)); -+ fprintf_unfiltered (file, -+ "gdbarch_dump: get_thread_local_address = <%s>\n", -+ host_address_to_string (gdbarch->get_thread_local_address)); - fprintf_unfiltered (file, - "gdbarch_dump: gnu_triplet_regexp = <%s>\n", - host_address_to_string (gdbarch->gnu_triplet_regexp)); -@@ -3018,6 +3026,30 @@ set_gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, - gdbarch->fetch_tls_load_module_address = fetch_tls_load_module_address; - } - -+int -+gdbarch_get_thread_local_address_p (struct gdbarch *gdbarch) -+{ -+ gdb_assert (gdbarch != NULL); -+ return gdbarch->get_thread_local_address != NULL; -+} -+ -+CORE_ADDR -+gdbarch_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset) -+{ -+ gdb_assert (gdbarch != NULL); -+ gdb_assert (gdbarch->get_thread_local_address != NULL); -+ if (gdbarch_debug >= 2) -+ fprintf_unfiltered (gdb_stdlog, "gdbarch_get_thread_local_address called\n"); -+ return gdbarch->get_thread_local_address (gdbarch, ptid, lm_addr, offset); -+} -+ -+void -+set_gdbarch_get_thread_local_address (struct gdbarch *gdbarch, -+ gdbarch_get_thread_local_address_ftype get_thread_local_address) -+{ -+ gdbarch->get_thread_local_address = get_thread_local_address; -+} -+ - CORE_ADDR - gdbarch_frame_args_skip (struct gdbarch *gdbarch) - { -diff --git gdb/gdbarch.h gdb/gdbarch.h -index 75618376ab..abb72e752b 100644 ---- gdb/gdbarch.h -+++ gdb/gdbarch.h -@@ -649,6 +649,18 @@ typedef CORE_ADDR (gdbarch_fetch_tls_load_module_address_ftype) (struct objfile - extern CORE_ADDR gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, struct objfile *objfile); - extern void set_gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address); - -+/* Return the thread-local address at OFFSET in the thread-local -+ storage for the thread PTID and the shared library or executable -+ file given by LM_ADDR. If that block of thread-local storage hasn't -+ been allocated yet, this function may throw an error. LM_ADDR may -+ be zero for statically linked multithreaded inferiors. */ -+ -+extern int gdbarch_get_thread_local_address_p (struct gdbarch *gdbarch); -+ -+typedef CORE_ADDR (gdbarch_get_thread_local_address_ftype) (struct gdbarch *gdbarch, ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset); -+extern CORE_ADDR gdbarch_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset); -+extern void set_gdbarch_get_thread_local_address (struct gdbarch *gdbarch, gdbarch_get_thread_local_address_ftype *get_thread_local_address); -+ - extern CORE_ADDR gdbarch_frame_args_skip (struct gdbarch *gdbarch); - extern void set_gdbarch_frame_args_skip (struct gdbarch *gdbarch, CORE_ADDR frame_args_skip); - -diff --git gdb/gdbarch.sh gdb/gdbarch.sh -index 48fcebd19a..63bfbad7d9 100755 ---- gdb/gdbarch.sh -+++ gdb/gdbarch.sh -@@ -602,6 +602,14 @@ m;int;remote_register_number;int regno;regno;;default_remote_register_number;;0 - - # Fetch the target specific address used to represent a load module. - F;CORE_ADDR;fetch_tls_load_module_address;struct objfile *objfile;objfile -+ -+# Return the thread-local address at OFFSET in the thread-local -+# storage for the thread PTID and the shared library or executable -+# file given by LM_ADDR. If that block of thread-local storage hasn't -+# been allocated yet, this function may throw an error. LM_ADDR may -+# be zero for statically linked multithreaded inferiors. -+ -+M;CORE_ADDR;get_thread_local_address;ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset;ptid, lm_addr, offset - # - v;CORE_ADDR;frame_args_skip;;;0;;;0 - m;CORE_ADDR;unwind_pc;struct frame_info *next_frame;next_frame;;default_unwind_pc;;0 -diff --git gdb/target.c gdb/target.c -index 8579c19d05..c27157d209 100644 ---- gdb/target.c -+++ gdb/target.c -@@ -698,8 +698,9 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) - { - volatile CORE_ADDR addr = 0; - struct target_ops *target = current_top_target (); -+ struct gdbarch *gdbarch = target_gdbarch (); - -- if (gdbarch_fetch_tls_load_module_address_p (target_gdbarch ())) -+ if (gdbarch_fetch_tls_load_module_address_p (gdbarch)) - { - ptid_t ptid = inferior_ptid; - -@@ -708,10 +709,14 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) - CORE_ADDR lm_addr; - - /* Fetch the load module address for this objfile. */ -- lm_addr = gdbarch_fetch_tls_load_module_address (target_gdbarch (), -+ lm_addr = gdbarch_fetch_tls_load_module_address (gdbarch, - objfile); - -- addr = target->get_thread_local_address (ptid, lm_addr, offset); -+ if (gdbarch_get_thread_local_address_p (gdbarch)) -+ addr = gdbarch_get_thread_local_address (gdbarch, ptid, lm_addr, -+ offset); -+ else -+ addr = target->get_thread_local_address (ptid, lm_addr, offset); - } - /* If an error occurred, print TLS related messages here. Otherwise, - throw the error to some higher catcher. */ -@@ -766,8 +771,6 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) - } - END_CATCH - } -- /* It wouldn't be wrong here to try a gdbarch method, too; finding -- TLS is an ABI-specific thing. But we don't do that yet. */ - else - error (_("Cannot find thread-local variables on this target")); - diff --git a/devel/gdb/files/commit-8399425f5f b/devel/gdb/files/commit-8399425f5f deleted file mode 100644 index 6545579f..00000000 --- a/devel/gdb/files/commit-8399425f5f +++ /dev/null @@ -1,69 +0,0 @@ -commit 8399425f5f472ad8e630bb30ad2dbefeddbb68b7 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Support TLS variables on FreeBSD/powerpc. - - Derive the pointer to the DTV array from the %r2 register on 32-bit - powerpc and %r13 on 64-bit powerpc. - - gdb/ChangeLog: - - * ppc-fbsd-tdep.c (ppcfbsd_get_thread_local_address): New. - (ppcfbsd_init_abi): Install gdbarch - "fetch_tls_load_module_address" and "get_thread_local_address" - methods. - -diff --git gdb/ppc-fbsd-tdep.c gdb/ppc-fbsd-tdep.c -index c21a52c898..290bd1fd88 100644 ---- gdb/ppc-fbsd-tdep.c -+++ gdb/ppc-fbsd-tdep.c -@@ -279,6 +279,39 @@ ppcfbsd_return_value (struct gdbarch *gdbarch, struct value *function, - regcache, readbuf, writebuf); - } - -+/* Implement the "get_thread_local_address" gdbarch method. */ -+ -+static CORE_ADDR -+ppcfbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, -+ CORE_ADDR lm_addr, CORE_ADDR offset) -+{ -+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+ struct regcache *regcache; -+ int tp_offset, tp_regnum; -+ -+ regcache = get_thread_arch_regcache (ptid, gdbarch); -+ -+ if (tdep->wordsize == 4) -+ { -+ tp_offset = 0x7008; -+ tp_regnum = PPC_R0_REGNUM + 2; -+ } -+ else -+ { -+ tp_offset = 0x7010; -+ tp_regnum = PPC_R0_REGNUM + 13; -+ } -+ target_fetch_registers (regcache, tp_regnum); -+ -+ ULONGEST tp; -+ if (regcache->cooked_read (tp_regnum, &tp) != REG_VALID) -+ error (_("Unable to fetch tcb pointer")); -+ -+ /* tp points to the end of the TCB block. The first member of the -+ TCB is the pointer to the DTV array. */ -+ CORE_ADDR dtv_addr = tp - tp_offset; -+ return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset); -+} - - static void - ppcfbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) -@@ -322,6 +355,8 @@ ppcfbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - - set_gdbarch_fetch_tls_load_module_address (gdbarch, - svr4_fetch_objfile_link_map); -+ set_gdbarch_get_thread_local_address (gdbarch, -+ ppcfbsd_get_thread_local_address); - } - - void diff --git a/devel/gdb/files/commit-945f3901b5 b/devel/gdb/files/commit-945f3901b5 deleted file mode 100644 index 221445b3..00000000 --- a/devel/gdb/files/commit-945f3901b5 +++ /dev/null @@ -1,224 +0,0 @@ -commit 945f3901b5889e57edf5a2ee25acb51f0078a719 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Add a helper function to resolve TLS variable addresses for FreeBSD. - - The fbsd_get_thread_local_address function accepts the base address of - a thread's DTV array and the base address of an object file's link map - and uses this to compute a TLS variable's address. FreeBSD - architectures use an architecture-specific method to determine the - address of the DTV array pointer and call this helper function to - perform the rest of the address calculation. - - * fbsd-tdep.c (fbsd_pspace_data_handle): New variable. - (struct fbsd_pspace_data): New type. - (get_fbsd_pspace_data, fbsd_pspace_data_cleanup) - (fbsd_read_integer_by_name, fbsd_fetch_rtld_offsets) - (fbsd_get_tls_index, fbsd_get_thread_local_address): New function. - (_initialize_fbsd_tdep): Initialize 'fbsd_pspace_data_handle'. - * fbsd-tdep.c (fbsd_get_thread_local_address): New prototype. - -diff --git gdb/fbsd-tdep.c gdb/fbsd-tdep.c -index d971d3a653..f06836216d 100644 ---- gdb/fbsd-tdep.c -+++ gdb/fbsd-tdep.c -@@ -24,6 +24,7 @@ - #include "regcache.h" - #include "regset.h" - #include "gdbthread.h" -+#include "objfiles.h" - #include "xml-syscall.h" - #include - #include -@@ -444,6 +445,41 @@ get_fbsd_gdbarch_data (struct gdbarch *gdbarch) - gdbarch_data (gdbarch, fbsd_gdbarch_data_handle)); - } - -+/* Per-program-space data for FreeBSD architectures. */ -+static const struct program_space_data *fbsd_pspace_data_handle; -+ -+struct fbsd_pspace_data -+{ -+ /* Offsets in the runtime linker's 'Obj_Entry' structure. */ -+ LONGEST off_linkmap; -+ LONGEST off_tlsindex; -+ bool rtld_offsets_valid; -+}; -+ -+static struct fbsd_pspace_data * -+get_fbsd_pspace_data (struct program_space *pspace) -+{ -+ struct fbsd_pspace_data *data; -+ -+ data = ((struct fbsd_pspace_data *) -+ program_space_data (pspace, fbsd_pspace_data_handle)); -+ if (data == NULL) -+ { -+ data = XCNEW (struct fbsd_pspace_data); -+ set_program_space_data (pspace, fbsd_pspace_data_handle, data); -+ } -+ -+ return data; -+} -+ -+/* The cleanup callback for FreeBSD architecture per-program-space data. */ -+ -+static void -+fbsd_pspace_data_cleanup (struct program_space *pspace, void *data) -+{ -+ xfree (data); -+} -+ - /* This is how we want PTIDs from core files to be printed. */ - - static const char * -@@ -1932,6 +1968,121 @@ fbsd_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread) - internal_error (__FILE__, __LINE__, _("fbsd_get_sycall_number called")); - } - -+/* Read an integer symbol value from the current target. */ -+ -+static LONGEST -+fbsd_read_integer_by_name (struct gdbarch *gdbarch, const char *name) -+{ -+ bound_minimal_symbol ms = lookup_minimal_symbol (name, NULL, NULL); -+ if (ms.minsym == NULL) -+ error (_("Unable to resolve symbol '%s'"), name); -+ -+ gdb_byte buf[4]; -+ if (target_read_memory (BMSYMBOL_VALUE_ADDRESS (ms), buf, sizeof buf) != 0) -+ error (_("Unable to read value of '%s'"), name); -+ -+ return extract_signed_integer (buf, sizeof buf, gdbarch_byte_order (gdbarch)); -+} -+ -+/* Lookup offsets of fields in the runtime linker's 'Obj_Entry' -+ structure needed to determine the TLS index of an object file. */ -+ -+static void -+fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) -+{ -+ TRY -+ { -+ /* Fetch offsets from debug symbols in rtld. */ -+ struct symbol *obj_entry_sym -+ = lookup_symbol_in_language ("Struct_Obj_Entry", NULL, STRUCT_DOMAIN, -+ language_c, NULL).symbol; -+ if (obj_entry_sym == NULL) -+ error (_("Unable to find Struct_Obj_Entry symbol")); -+ data->off_linkmap = lookup_struct_elt (SYMBOL_TYPE(obj_entry_sym), -+ "linkmap", 0).offset / 8; -+ data->off_tlsindex = lookup_struct_elt (SYMBOL_TYPE(obj_entry_sym), -+ "tlsindex", 0).offset / 8; -+ data->rtld_offsets_valid = true; -+ return; -+ } -+ CATCH (e, RETURN_MASK_ERROR) -+ { -+ data->off_linkmap = -1; -+ } -+ END_CATCH -+ -+ TRY -+ { -+ /* Fetch offsets from global variables in libthr. Note that -+ this does not work for single-threaded processes that are not -+ linked against libthr. */ -+ data->off_linkmap = fbsd_read_integer_by_name (gdbarch, -+ "_thread_off_linkmap"); -+ data->off_tlsindex = fbsd_read_integer_by_name (gdbarch, -+ "_thread_off_tlsindex"); -+ data->rtld_offsets_valid = true; -+ return; -+ } -+ CATCH (e, RETURN_MASK_ERROR) -+ { -+ data->off_linkmap = -1; -+ } -+ END_CATCH -+} -+ -+/* Helper function to read the TLS index of an object file associated -+ with a link map entry at LM_ADDR. */ -+ -+static LONGEST -+fbsd_get_tls_index (struct gdbarch *gdbarch, CORE_ADDR lm_addr) -+{ -+ struct fbsd_pspace_data *data = get_fbsd_pspace_data (current_program_space); -+ -+ if (!data->rtld_offsets_valid) -+ fbsd_fetch_rtld_offsets (gdbarch, data); -+ -+ if (data->off_linkmap == -1) -+ throw_error (TLS_GENERIC_ERROR, -+ _("Cannot fetch runtime linker structure offsets")); -+ -+ /* Simulate container_of to convert from LM_ADDR to the Obj_Entry -+ pointer and then compute the offset of the tlsindex member. */ -+ CORE_ADDR tlsindex_addr = lm_addr - data->off_linkmap + data->off_tlsindex; -+ -+ gdb_byte buf[4]; -+ if (target_read_memory (tlsindex_addr, buf, sizeof buf) != 0) -+ throw_error (TLS_GENERIC_ERROR, -+ _("Cannot find thread-local variables on this target")); -+ -+ return extract_signed_integer (buf, sizeof buf, gdbarch_byte_order (gdbarch)); -+} -+ -+/* See fbsd-tdep.h. */ -+ -+CORE_ADDR -+fbsd_get_thread_local_address (struct gdbarch *gdbarch, CORE_ADDR dtv_addr, -+ CORE_ADDR lm_addr, CORE_ADDR offset) -+{ -+ LONGEST tls_index = fbsd_get_tls_index (gdbarch, lm_addr); -+ -+ gdb_byte buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT]; -+ if (target_read_memory (dtv_addr, buf, sizeof buf) != 0) -+ throw_error (TLS_GENERIC_ERROR, -+ _("Cannot find thread-local variables on this target")); -+ -+ const struct builtin_type *builtin = builtin_type (gdbarch); -+ CORE_ADDR addr = gdbarch_pointer_to_address (gdbarch, -+ builtin->builtin_data_ptr, buf); -+ -+ addr += (tls_index + 1) * TYPE_LENGTH (builtin->builtin_data_ptr); -+ if (target_read_memory (addr, buf, sizeof buf) != 0) -+ throw_error (TLS_GENERIC_ERROR, -+ _("Cannot find thread-local variables on this target")); -+ -+ addr = gdbarch_pointer_to_address (gdbarch, builtin->builtin_data_ptr, buf); -+ return addr + offset; -+} -+ - /* To be called from GDB_OSABI_FREEBSD handlers. */ - - void -@@ -1957,4 +2108,6 @@ _initialize_fbsd_tdep (void) - { - fbsd_gdbarch_data_handle = - gdbarch_data_register_post_init (init_fbsd_gdbarch_data); -+ fbsd_pspace_data_handle -+ = register_program_space_data_with_cleanup (NULL, fbsd_pspace_data_cleanup); - } -diff --git gdb/fbsd-tdep.h gdb/fbsd-tdep.h -index efd7c2c78f..0e29508c9f 100644 ---- gdb/fbsd-tdep.h -+++ gdb/fbsd-tdep.h -@@ -60,4 +60,15 @@ extern void fbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start, - int kve_flags, int kve_protection, - const void *kve_path); - -+/* Helper function to fetch the address of a thread-local variable. -+ DTV_ADDR is the base address of the thread's dtv array. LM_ADDR is -+ the address of the link_map structure for the associated object -+ file. OFFSET is the offset of the variable in the object file's -+ thread-local variable block. */ -+ -+extern CORE_ADDR fbsd_get_thread_local_address (struct gdbarch *gdbarch, -+ CORE_ADDR dtv_addr, -+ CORE_ADDR lm_addr, -+ CORE_ADDR offset); -+ - #endif /* fbsd-tdep.h */ diff --git a/devel/gdb/files/commit-a980a7d24b9 b/devel/gdb/files/commit-a980a7d24b9 new file mode 100644 index 00000000..f818c93f --- /dev/null +++ b/devel/gdb/files/commit-a980a7d24b9 @@ -0,0 +1,37 @@ +commit a980a7d24b9ab416a70880182d4e6b4975967d38 +Author: John Baldwin +Date: Fri Mar 10 12:01:40 2023 -0800 + + PR gdb/30214: Prefer local include paths to system include paths + + Some systems may install binutils headers into a system location + (e.g. /usr/local/include on FreeBSD) which may also include headers + for other external packages used by GDB such as zlib or zstd. If a + system include path such as /usr/local/include is added before local + include paths to directories within a clone or release tarball, then + headers from the external binutils package are used which can result + in build failures if the external binutils package is out of sync with + the version of GDB being built. + + To fix, sort the include paths in INTERNAL_CFLAGS_BASE to add CFLAGS + for "local" componenets before external components. + + Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30214 + Reviewed-By: Tom Tromey + (cherry picked from commit a2fbb6903889c8fe32f4f3b890ef4b8c565d6b84) + +diff --git gdb/Makefile.in gdb/Makefile.in +index 321a58c4635..fa7c81a0fab 100644 +--- gdb/Makefile.in ++++ gdb/Makefile.in +@@ -629,8 +629,8 @@ INTERNAL_CPPFLAGS = $(CPPFLAGS) @GUILE_CPPFLAGS@ @PYTHON_CPPFLAGS@ \ + # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros. + INTERNAL_CFLAGS_BASE = \ + $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \ +- $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \ +- $(ZSTD_CFLAGS) $(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \ ++ $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(BFD_CFLAGS) $(INCLUDE_CFLAGS) \ ++ $(READLINE_CFLAGS) $(ZLIBINC) $(ZSTD_CFLAGS) $(LIBDECNUMBER_CFLAGS) \ + $(INTL_CFLAGS) $(INCGNU) $(INCSUPPORT) $(LIBBACKTRACE_INC) \ + $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS) $(SRCHIGH_CFLAGS) \ + $(TOP_CFLAGS) $(PTHREAD_CFLAGS) $(DEBUGINFOD_CFLAGS) diff --git a/devel/gdb/files/commit-ae61525fcf4 b/devel/gdb/files/commit-ae61525fcf4 new file mode 100644 index 00000000..202f695b --- /dev/null +++ b/devel/gdb/files/commit-ae61525fcf4 @@ -0,0 +1,128 @@ +commit ae61525fcf456ab395d55c45492a106d1275873a +Author: Simon Marchi +Date: 2023-02-23 12:35:40 -0500 + + gdbsupport: ignore -Wenum-constexpr-conversion in enum-flags.h + + When building with clang 16, we get: + + CXX gdb.o + In file included from /home/smarchi/src/binutils-gdb/gdb/gdb.c:19: + In file included from /home/smarchi/src/binutils-gdb/gdb/defs.h:65: + /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/enum-flags.h:95:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion] + integer_for_size(T (-1) < T (0))>::type + ^ + + The error message does not make it clear in the context of which enum + flag this fails (i.e. what is T in this context), but it doesn't really + matter, we have similar warning/errors for many of them, if we let the + build go through. + + clang is right that the value -1 is invalid for the enum type we cast -1 + to. However, we do need this expression in order to select an integer + type with the appropriate signedness. That is, with the same signedness + as the underlying type of the enum. + + I first wondered if that was really needed, if we couldn't use + std::underlying_type for that. It turns out that the comment just above + says: + + /* Note that std::underlying_type is not what we want here, + since that returns unsigned int even when the enum decays to signed + int. */ + + I was surprised, because std::is_signed> + returns the right thing. So I tried replacing all this with + std::underlying_type, see if that would work. Doing so causes some + build failures in unittests/enum-flags-selftests.c: + + CXX unittests/enum-flags-selftests.o + /home/smarchi/src/binutils-gdb/gdb/unittests/enum-flags-selftests.c:254:1: error: static assertion failed due to requirement 'gdb::is_same, selftests::enum_flags_tests::RE, enum_flags, selftests::enum_flags_tests::RE2, enum_flags, selftests::enum_fla + gs_tests::URE, int>, selftests::enum_flags_tests::check_valid_expr254::archetype, selftests::enum_flags_tests::RE, enum_flags, selfte + sts::enum_flags_tests::RE2, enum_flags, selftests::enum_flags_tests::URE, unsigned int>>::value == true': + CHECK_VALID (true, int, true ? EF () : EF2 ()) + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /home/smarchi/src/binutils-gdb/gdb/unittests/enum-flags-selftests.c:91:3: note: expanded from macro 'CHECK_VALID' + CHECK_VALID_EXPR_6 (EF, RE, EF2, RE2, UEF, URE, VALID, EXPR_TYPE, EXPR) + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/valid-expr.h:105:3: note: expanded from macro 'CHECK_VALID_EXPR_6' + CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, \ + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/valid-expr.h:66:3: note: expanded from macro 'CHECK_VALID_EXPR_INT' + static_assert (gdb::is_detected_exact, \ + ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + This is a bit hard to decode, but basically enumerations have the + following funny property that they decay into a signed int, even if + their implicit underlying type is unsigned. This code: + + enum A {}; + enum B {}; + + int main() { + std::cout << std::is_signed::type>::value + << std::endl; + std::cout << std::is_signed::type>::value + << std::endl; + auto result = true ? A() : B(); + std::cout << std::is_signed::value << std::endl; + } + + produces: + + 0 + 0 + 1 + + So, the "CHECK_VALID" above checks that this property works for enum flags the + same way as it would if you were using their underlying enum types. And + somehow, changing integer_for_size to use std::underlying_type breaks that. + + Since the current code does what we want, and I don't see any way of doing it + differently, ignore -Wenum-constexpr-conversion around it. + + Change-Id: Ibc82ae7bbdb812102ae3f1dd099fc859dc6f3cc2 + +diff --git gdbsupport/enum-flags.h gdbsupport/enum-flags.h +index 700037f6126..41ac7838f06 100644 +--- gdbsupport/enum-flags.h ++++ gdbsupport/enum-flags.h +@@ -91,9 +91,12 @@ template<> struct integer_for_size<8, 1> { typedef int64_t type; }; + template + struct enum_underlying_type + { ++ DIAGNOSTIC_PUSH ++ DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION + typedef typename + integer_for_size(T (-1) < T (0))>::type + type; ++ DIAGNOSTIC_POP + }; + + namespace enum_flags_detail +diff --git include/diagnostics.h include/diagnostics.h +index d3ff27bc008..41e6db65391 100644 +--- include/diagnostics.h ++++ include/diagnostics.h +@@ -76,6 +76,11 @@ + # define DIAGNOSTIC_ERROR_SWITCH \ + DIAGNOSTIC_ERROR ("-Wswitch") + ++# if __has_warning ("-Wenum-constexpr-conversion") ++# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION \ ++ DIAGNOSTIC_IGNORE ("-Wenum-constexpr-conversion") ++# endif ++ + #elif defined (__GNUC__) /* GCC */ + + # define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \ +@@ -155,4 +160,8 @@ + # define DIAGNOSTIC_ERROR_SWITCH + #endif + ++#ifndef DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION ++# define DIAGNOSTIC_IGNORE_ENUM_CONSTEXPR_CONVERSION ++#endif ++ + #endif /* DIAGNOSTICS_H */ diff --git a/devel/gdb/files/commit-b0f87ed032 b/devel/gdb/files/commit-b0f87ed032 deleted file mode 100644 index d43bf667..00000000 --- a/devel/gdb/files/commit-b0f87ed032 +++ /dev/null @@ -1,60 +0,0 @@ -commit b0f87ed032bb68a9965de81cbf9fd676a83b9174 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Support TLS variables on FreeBSD/riscv. - - Derive the pointer to the DTV array from the tp register. - - gdb/ChangeLog: - - * riscv-fbsd-tdep.c (riscv_fbsd_get_thread_local_address): New. - (riscv_fbsd_init_abi): Install gdbarch - "fetch_tls_load_module_address" and "get_thread_local_address" - methods. - -diff --git gdb/riscv-fbsd-tdep.c gdb/riscv-fbsd-tdep.c -index 97ad28f59a..3125a2285e 100644 ---- gdb/riscv-fbsd-tdep.c -+++ gdb/riscv-fbsd-tdep.c -@@ -174,6 +174,28 @@ static const struct tramp_frame riscv_fbsd_sigframe = - riscv_fbsd_sigframe_init - }; - -+/* Implement the "get_thread_local_address" gdbarch method. */ -+ -+static CORE_ADDR -+riscv_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, -+ CORE_ADDR lm_addr, CORE_ADDR offset) -+{ -+ struct regcache *regcache; -+ -+ regcache = get_thread_arch_regcache (ptid, gdbarch); -+ -+ target_fetch_registers (regcache, RISCV_TP_REGNUM); -+ -+ ULONGEST tp; -+ if (regcache->cooked_read (RISCV_TP_REGNUM, &tp) != REG_VALID) -+ error (_("Unable to fetch %%tp")); -+ -+ /* %tp points to the end of the TCB which contains two pointers. -+ The first pointer in the TCB points to the DTV array. */ -+ CORE_ADDR dtv_addr = tp - (gdbarch_ptr_bit (gdbarch) / 8) * 2; -+ return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset); -+} -+ - /* Implement the 'init_osabi' method of struct gdb_osabi_handler. */ - - static void -@@ -193,6 +215,11 @@ riscv_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - - set_gdbarch_iterate_over_regset_sections - (gdbarch, riscv_fbsd_iterate_over_regset_sections); -+ -+ set_gdbarch_fetch_tls_load_module_address (gdbarch, -+ svr4_fetch_objfile_link_map); -+ set_gdbarch_get_thread_local_address (gdbarch, -+ riscv_fbsd_get_thread_local_address); - } - - void diff --git a/devel/gdb/files/commit-cd250a1898 b/devel/gdb/files/commit-cd250a1898 deleted file mode 100644 index c50c0f57..00000000 --- a/devel/gdb/files/commit-cd250a1898 +++ /dev/null @@ -1,30 +0,0 @@ -commit cd250a1898bb6fdb41f4a1063dbcfac04affcd11 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Update comment for target::get_thread_local_address. - - There isn't an 'objfile' parameter, instead 'load_module_addr' is used - to indicate the executable or shared library. Also, the function - throws errors rather than returning error values. - - gdb/ChangeLog: - - * target.h (target::get_thread_local_address): Update comment. - -diff --git gdb/target.h gdb/target.h -index c95151a404..5fe6aa74b0 100644 ---- gdb/target.h -+++ gdb/target.h -@@ -718,9 +718,9 @@ struct target_ops - TARGET_DEFAULT_NORETURN (tcomplain ()); - /* Return the thread-local address at OFFSET in the - thread-local storage for the thread PTID and the shared library -- or executable file given by OBJFILE. If that block of -+ or executable file given by LOAD_MODULE_ADDR. If that block of - thread-local storage hasn't been allocated yet, this function -- may return an error. LOAD_MODULE_ADDR may be zero for statically -+ may throw an error. LOAD_MODULE_ADDR may be zero for statically - linked multithreaded inferiors. */ - virtual CORE_ADDR get_thread_local_address (ptid_t ptid, - CORE_ADDR load_module_addr, diff --git a/devel/gdb/files/commit-ce25aa57a3 b/devel/gdb/files/commit-ce25aa57a3 deleted file mode 100644 index 17e7c705..00000000 --- a/devel/gdb/files/commit-ce25aa57a3 +++ /dev/null @@ -1,64 +0,0 @@ -commit ce25aa57a3cdd028be5868423e6e55506ccd1053 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Support TLS variables on FreeBSD/i386. - - Derive the pointer to the DTV array from the gs_base register. As - with FreeBSD/amd64, gs_base is currently only available via the native - target. - - gdb/ChangeLog: - - * i386-fbsd-tdep.c (i386fbsd_get_thread_local_address): New. - (i386fbsd_init_abi): Install gdbarch - "fetch_tls_load_module_address" and "get_thread_local_address" - methods. - -diff --git gdb/i386-fbsd-tdep.c gdb/i386-fbsd-tdep.c -index ac57e7383d..f274847174 100644 ---- gdb/i386-fbsd-tdep.c -+++ gdb/i386-fbsd-tdep.c -@@ -320,6 +320,30 @@ i386fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, - "XSAVE extended state", cb_data); - } - -+/* Implement the get_thread_local_address gdbarch method. */ -+ -+static CORE_ADDR -+i386fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, -+ CORE_ADDR lm_addr, CORE_ADDR offset) -+{ -+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+ struct regcache *regcache; -+ -+ if (tdep->fsbase_regnum == -1) -+ error (_("Unable to fetch %%gsbase")); -+ -+ regcache = get_thread_arch_regcache (ptid, gdbarch); -+ -+ target_fetch_registers (regcache, tdep->fsbase_regnum + 1); -+ -+ ULONGEST gsbase; -+ if (regcache->cooked_read (tdep->fsbase_regnum + 1, &gsbase) != REG_VALID) -+ error (_("Unable to fetch %%gsbase")); -+ -+ CORE_ADDR dtv_addr = gsbase + gdbarch_ptr_bit (gdbarch) / 8; -+ return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset); -+} -+ - static void - i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - { -@@ -418,6 +442,11 @@ i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - - set_gdbarch_core_read_description (gdbarch, - i386fbsd_core_read_description); -+ -+ set_gdbarch_fetch_tls_load_module_address (gdbarch, -+ svr4_fetch_objfile_link_map); -+ set_gdbarch_get_thread_local_address (gdbarch, -+ i386fbsd_get_thread_local_address); - } - - void diff --git a/devel/gdb/files/commit-dd6876c91c b/devel/gdb/files/commit-dd6876c91c deleted file mode 100644 index 6204f9d5..00000000 --- a/devel/gdb/files/commit-dd6876c91c +++ /dev/null @@ -1,237 +0,0 @@ -commit dd6876c91cd40cc105b1a91f418ca2c80683b314 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Support fs_base and gs_base on FreeBSD/i386. - - The i386 BSD native target uses the same ptrace operations - (PT_[GS]ET[FG]SBASE) as the amd64 BSD native target to fetch and store - the registers. - - The amd64 BSD native now uses 'tdep->fsbase_regnum' instead of - hardcoding AMD64_FSBASE_REGNUM and AMD64_GSBASE_REGNUM to support - 32-bit targets. In addition, the store operations explicitly zero the - new register value before fetching it from the register cache to - ensure 32-bit values are zero-extended. - - gdb/ChangeLog: - - * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Use - tdep->fsbase_regnum instead of constants for fs_base and gs_base. - (amd64bsd_store_inferior_registers): Likewise. - * amd64-fbsd-nat.c (amd64_fbsd_nat_target::read_description): - Enable segment base registers. - * i386-bsd-nat.c (i386bsd_fetch_inferior_registers): Use - PT_GETFSBASE and PT_GETGSBASE. - (i386bsd_store_inferior_registers): Use PT_SETFSBASE and - PT_SETGSBASE. - * i386-fbsd-nat.c (i386_fbsd_nat_target::read_description): Enable - segment base registers. - * i386-fbsd-tdep.c (i386fbsd_core_read_description): Likewise. - -diff --git gdb/amd64-bsd-nat.c gdb/amd64-bsd-nat.c -index a2a91abb91..35763a5b95 100644 ---- gdb/amd64-bsd-nat.c -+++ gdb/amd64-bsd-nat.c -@@ -43,6 +43,9 @@ amd64bsd_fetch_inferior_registers (struct regcache *regcache, int regnum) - { - struct gdbarch *gdbarch = regcache->arch (); - pid_t pid = get_ptrace_pid (regcache->ptid ()); -+#if defined(PT_GETFSBASE) || defined(PT_GETGSBASE) -+ const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+#endif - - if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum)) - { -@@ -57,27 +60,27 @@ amd64bsd_fetch_inferior_registers (struct regcache *regcache, int regnum) - } - - #ifdef PT_GETFSBASE -- if (regnum == -1 || regnum == AMD64_FSBASE_REGNUM) -+ if (regnum == -1 || regnum == tdep->fsbase_regnum) - { - register_t base; - - if (ptrace (PT_GETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) - perror_with_name (_("Couldn't get segment register fs_base")); - -- regcache->raw_supply (AMD64_FSBASE_REGNUM, &base); -+ regcache->raw_supply (tdep->fsbase_regnum, &base); - if (regnum != -1) - return; - } - #endif - #ifdef PT_GETGSBASE -- if (regnum == -1 || regnum == AMD64_GSBASE_REGNUM) -+ if (regnum == -1 || regnum == tdep->fsbase_regnum + 1) - { - register_t base; - - if (ptrace (PT_GETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) - perror_with_name (_("Couldn't get segment register gs_base")); - -- regcache->raw_supply (AMD64_GSBASE_REGNUM, &base); -+ regcache->raw_supply (tdep->fsbase_regnum + 1, &base); - if (regnum != -1) - return; - } -@@ -116,6 +119,9 @@ amd64bsd_store_inferior_registers (struct regcache *regcache, int regnum) - { - struct gdbarch *gdbarch = regcache->arch (); - pid_t pid = get_ptrace_pid (regcache->ptid ()); -+#if defined(PT_SETFSBASE) || defined(PT_SETGSBASE) -+ const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); -+#endif - - if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum)) - { -@@ -134,11 +140,13 @@ amd64bsd_store_inferior_registers (struct regcache *regcache, int regnum) - } - - #ifdef PT_SETFSBASE -- if (regnum == -1 || regnum == AMD64_FSBASE_REGNUM) -+ if (regnum == -1 || regnum == tdep->fsbase_regnum) - { - register_t base; - -- regcache->raw_collect (AMD64_FSBASE_REGNUM, &base); -+ /* Clear the full base value to support 32-bit targets. */ -+ base = 0; -+ regcache->raw_collect (tdep->fsbase_regnum, &base); - - if (ptrace (PT_SETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) - perror_with_name (_("Couldn't write segment register fs_base")); -@@ -147,11 +155,13 @@ amd64bsd_store_inferior_registers (struct regcache *regcache, int regnum) - } - #endif - #ifdef PT_SETGSBASE -- if (regnum == -1 || regnum == AMD64_GSBASE_REGNUM) -+ if (regnum == -1 || regnum == tdep->fsbase_regnum + 1) - { - register_t base; - -- regcache->raw_collect (AMD64_GSBASE_REGNUM, &base); -+ /* Clear the full base value to support 32-bit targets. */ -+ base = 0; -+ regcache->raw_collect (tdep->fsbase_regnum + 1, &base); - - if (ptrace (PT_SETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) - perror_with_name (_("Couldn't write segment register gs_base")); -diff --git gdb/amd64-fbsd-nat.c gdb/amd64-fbsd-nat.c -index 9fff763dd3..cc676d3214 100644 ---- gdb/amd64-fbsd-nat.c -+++ gdb/amd64-fbsd-nat.c -@@ -190,13 +190,13 @@ amd64_fbsd_nat_target::read_description () - if (is64) - return amd64_target_description (xcr0, true); - else -- return i386_target_description (xcr0, false); -+ return i386_target_description (xcr0, true); - } - #endif - if (is64) - return amd64_target_description (X86_XSTATE_SSE_MASK, true); - else -- return i386_target_description (X86_XSTATE_SSE_MASK, false); -+ return i386_target_description (X86_XSTATE_SSE_MASK, true); - } - - #if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO) -diff --git gdb/i386-bsd-nat.c gdb/i386-bsd-nat.c -index 009a8dc1b2..a10b496096 100644 ---- gdb/i386-bsd-nat.c -+++ gdb/i386-bsd-nat.c -@@ -144,6 +144,33 @@ i386bsd_fetch_inferior_registers (struct regcache *regcache, int regnum) - return; - } - -+#ifdef PT_GETFSBASE -+ if (regnum == -1 || regnum == I386_FSBASE_REGNUM) -+ { -+ register_t base; -+ -+ if (ptrace (PT_GETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) -+ perror_with_name (_("Couldn't get segment register fs_base")); -+ -+ regcache->raw_supply (I386_FSBASE_REGNUM, &base); -+ if (regnum != -1) -+ return; -+ } -+#endif -+#ifdef PT_GETGSBASE -+ if (regnum == -1 || regnum == I386_GSBASE_REGNUM) -+ { -+ register_t base; -+ -+ if (ptrace (PT_GETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) -+ perror_with_name (_("Couldn't get segment register gs_base")); -+ -+ regcache->raw_supply (I386_GSBASE_REGNUM, &base); -+ if (regnum != -1) -+ return; -+ } -+#endif -+ - if (regnum == -1 || regnum >= I386_ST0_REGNUM) - { - struct fpreg fpregs; -@@ -211,6 +238,33 @@ i386bsd_store_inferior_registers (struct regcache *regcache, int regnum) - return; - } - -+#ifdef PT_SETFSBASE -+ if (regnum == -1 || regnum == I386_FSBASE_REGNUM) -+ { -+ register_t base; -+ -+ regcache->raw_collect (I386_FSBASE_REGNUM, &base); -+ -+ if (ptrace (PT_SETFSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) -+ perror_with_name (_("Couldn't write segment register fs_base")); -+ if (regnum != -1) -+ return; -+ } -+#endif -+#ifdef PT_SETGSBASE -+ if (regnum == -1 || regnum == I386_GSBASE_REGNUM) -+ { -+ register_t base; -+ -+ regcache->raw_collect (I386_GSBASE_REGNUM, &base); -+ -+ if (ptrace (PT_SETGSBASE, pid, (PTRACE_TYPE_ARG3) &base, 0) == -1) -+ perror_with_name (_("Couldn't write segment register gs_base")); -+ if (regnum != -1) -+ return; -+ } -+#endif -+ - if (regnum == -1 || regnum >= I386_ST0_REGNUM) - { - struct fpreg fpregs; -diff --git gdb/i386-fbsd-nat.c gdb/i386-fbsd-nat.c -index 7106e90801..be5d4c67be 100644 ---- gdb/i386-fbsd-nat.c -+++ gdb/i386-fbsd-nat.c -@@ -160,7 +160,7 @@ i386_fbsd_nat_target::read_description () - if (x86bsd_xsave_len == 0) - xcr0 = X86_XSTATE_SSE_MASK; - -- return i386_target_description (xcr0, false); -+ return i386_target_description (xcr0, true); - } - #endif - -diff --git gdb/i386-fbsd-tdep.c gdb/i386-fbsd-tdep.c -index 2f28bad728..ac57e7383d 100644 ---- gdb/i386-fbsd-tdep.c -+++ gdb/i386-fbsd-tdep.c -@@ -267,7 +267,7 @@ i386fbsd_core_read_description (struct gdbarch *gdbarch, - struct target_ops *target, - bfd *abfd) - { -- return i386_target_description (i386fbsd_core_read_xcr0 (abfd), false); -+ return i386_target_description (i386fbsd_core_read_xcr0 (abfd), true); - } - - /* Similar to i386_supply_fpregset, but use XSAVE extended state. */ diff --git a/devel/gdb/files/commit-df22c1e5d5 b/devel/gdb/files/commit-df22c1e5d5 deleted file mode 100644 index 70c27c69..00000000 --- a/devel/gdb/files/commit-df22c1e5d5 +++ /dev/null @@ -1,36 +0,0 @@ -commit df22c1e5d53c38f38bce6072bb46de240f9e0e2b -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Handle an edge case for minisym TLS variable lookups. - - If a TLS variable is provided by a minisym from a separate debug file, - the separate debug file is passed to - gdbarch_fetch_tls_load_module_address. However, the object files - stored in the shared object list are the original object files, not - the separate debug object files. In this case, - svr4_fetch_objfile_link_map was failing to find the link map entry - since the debug object file is not in its internal list, only the - original object file. - - gdb/ChangeLog: - - * solib-svr4.c (svr4_fetch_objfile_link_map): Look for - objfile->separate_debug_objfile_backlink if not NULL. - -diff --git gdb/solib-svr4.c gdb/solib-svr4.c -index 84693c1766..14a471b6dc 100644 ---- gdb/solib-svr4.c -+++ gdb/solib-svr4.c -@@ -1551,6 +1551,11 @@ svr4_fetch_objfile_link_map (struct objfile *objfile) - if (objfile == symfile_objfile) - return info->main_lm_addr; - -+ /* If OBJFILE is a separate debug object file, look for the -+ original object file. */ -+ if (objfile->separate_debug_objfile_backlink != NULL) -+ objfile = objfile->separate_debug_objfile_backlink; -+ - /* The other link map addresses may be found by examining the list - of shared libraries. */ - for (so = master_so_list (); so; so = so->next) diff --git a/devel/gdb/files/commit-ef0bd2046f b/devel/gdb/files/commit-ef0bd2046f deleted file mode 100644 index 464156bc..00000000 --- a/devel/gdb/files/commit-ef0bd2046f +++ /dev/null @@ -1,165 +0,0 @@ -commit ef0bd2046f58fac69577892c2d3b44b20d027476 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Add a more general version of lookup_struct_elt_type. - - lookup_struct_elt is a new function which returns a tuple of - information about a component of a structure or union. The returned - tuple contains a pointer to the struct field object for the component - as well as a bit offset of that field within the structure. If the - field names a field in an anonymous substructure, the offset is the - "global" offset relative to the original structure type. If noerr is - set, then the returned tuple will set the field pointer to NULL to - indicate a missing component rather than throwing an error. - - lookup_struct_elt_type is now reimplemented in terms of this new - function. It simply returns the type of the returned field. - - gdb/ChangeLog: - - * gdbtypes.c (lookup_struct_elt): New function. - (lookup_struct_elt_type): Reimplement via lookup_struct_elt. - * gdbtypes.h (struct struct_elt): New type. - (lookup_struct_elt): New prototype. - -diff --git gdb/gdbtypes.c gdb/gdbtypes.c -index 5924b15520..db470dafac 100644 ---- gdb/gdbtypes.c -+++ gdb/gdbtypes.c -@@ -1644,19 +1644,10 @@ lookup_template_type (char *name, struct type *type, - return (SYMBOL_TYPE (sym)); - } - --/* Given a type TYPE, lookup the type of the component named NAME. -+/* See gdbtypes.h. */ - -- TYPE can be either a struct or union, or a pointer or reference to -- a struct or union. If it is a pointer or reference, its target -- type is automatically used. Thus '.' and '->' are interchangable, -- as specified for the definitions of the expression element types -- STRUCTOP_STRUCT and STRUCTOP_PTR. -- -- If NOERR is nonzero, return NULL if there is no component named -- NAME. */ -- --struct type * --lookup_struct_elt_type (struct type *type, const char *name, int noerr) -+struct_elt -+lookup_struct_elt (struct type *type, const char *name, int noerr) - { - int i; - -@@ -1683,39 +1674,47 @@ lookup_struct_elt_type (struct type *type, const char *name, int noerr) - - if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) - { -- return TYPE_FIELD_TYPE (type, i); -+ return {&TYPE_FIELD (type, i), TYPE_FIELD_BITPOS (type, i)}; - } - else if (!t_field_name || *t_field_name == '\0') - { -- struct type *subtype -- = lookup_struct_elt_type (TYPE_FIELD_TYPE (type, i), name, 1); -- -- if (subtype != NULL) -- return subtype; -+ struct_elt elt -+ = lookup_struct_elt (TYPE_FIELD_TYPE (type, i), name, 1); -+ if (elt.field != NULL) -+ { -+ elt.offset += TYPE_FIELD_BITPOS (type, i); -+ return elt; -+ } - } - } - - /* OK, it's not in this class. Recursively check the baseclasses. */ - for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) - { -- struct type *t; -- -- t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, 1); -- if (t != NULL) -- { -- return t; -- } -+ struct_elt elt = lookup_struct_elt (TYPE_BASECLASS (type, i), name, 1); -+ if (elt.field != NULL) -+ return elt; - } - - if (noerr) -- { -- return NULL; -- } -+ return {nullptr, 0}; - - std::string type_name = type_to_string (type); - error (_("Type %s has no component named %s."), type_name.c_str (), name); - } - -+/* See gdbtypes.h. */ -+ -+struct type * -+lookup_struct_elt_type (struct type *type, const char *name, int noerr) -+{ -+ struct_elt elt = lookup_struct_elt (type, name, noerr); -+ if (elt.field != NULL) -+ return FIELD_TYPE (*elt.field); -+ else -+ return NULL; -+} -+ - /* Store in *MAX the largest number representable by unsigned integer type - TYPE. */ - -diff --git gdb/gdbtypes.h gdb/gdbtypes.h -index a6d4f64e9b..66051cf02c 100644 ---- gdb/gdbtypes.h -+++ gdb/gdbtypes.h -@@ -1873,6 +1873,44 @@ extern struct type *allocate_stub_method (struct type *); - - extern const char *type_name_or_error (struct type *type); - -+struct struct_elt -+{ -+ /* The field of the element, or NULL if no element was found. */ -+ struct field *field; -+ -+ /* The bit offset of the element in the parent structure. */ -+ LONGEST offset; -+}; -+ -+/* Given a type TYPE, lookup the field and offset of the component named -+ NAME. -+ -+ TYPE can be either a struct or union, or a pointer or reference to -+ a struct or union. If it is a pointer or reference, its target -+ type is automatically used. Thus '.' and '->' are interchangable, -+ as specified for the definitions of the expression element types -+ STRUCTOP_STRUCT and STRUCTOP_PTR. -+ -+ If NOERR is nonzero, the returned structure will have field set to -+ NULL if there is no component named NAME. -+ -+ If the component NAME is a field in an anonymous substructure of -+ TYPE, the returned offset is a "global" offset relative to TYPE -+ rather than an offset within the substructure. */ -+ -+extern struct_elt lookup_struct_elt (struct type *, const char *, int); -+ -+/* Given a type TYPE, lookup the type of the component named NAME. -+ -+ TYPE can be either a struct or union, or a pointer or reference to -+ a struct or union. If it is a pointer or reference, its target -+ type is automatically used. Thus '.' and '->' are interchangable, -+ as specified for the definitions of the expression element types -+ STRUCTOP_STRUCT and STRUCTOP_PTR. -+ -+ If NOERR is nonzero, return NULL if there is no component named -+ NAME. */ -+ - extern struct type *lookup_struct_elt_type (struct type *, const char *, int); - - extern struct type *make_pointer_type (struct type *, struct type **); diff --git a/devel/gdb/files/commit-f5424cfa7e b/devel/gdb/files/commit-f5424cfa7e deleted file mode 100644 index 2dc05f55..00000000 --- a/devel/gdb/files/commit-f5424cfa7e +++ /dev/null @@ -1,63 +0,0 @@ -commit f5424cfa7e9337a6cb02a1f83c9feea0995c5350 -Author: John Baldwin -Date: Tue Mar 12 13:39:02 2019 -0700 - - Support TLS variables on FreeBSD/amd64. - - Use the fs_base register to fetch the address of a thread's tcb and - calculate the address of the DTV array. This value is then passed to - fbsd_get_thread_local_address to compute the final variable address. - - Note that fs_base is currently only available via the native target as - core dumps on FreeBSD do not store the value of fs_base. - - gdb/ChangeLog: - - * amd64-fbsd-tdep.c (amd64fbsd_get_thread_local_address): New. - (amd64fbsd_init_abi): Install gdbarch - "fetch_tls_load_module_address" and "get_thread_local_address" - methods. - -diff --git gdb/amd64-fbsd-tdep.c gdb/amd64-fbsd-tdep.c -index 403e65022d..7e2e9edf21 100644 ---- gdb/amd64-fbsd-tdep.c -+++ gdb/amd64-fbsd-tdep.c -@@ -204,6 +204,26 @@ amd64fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, - &amd64fbsd_xstateregset, "XSAVE extended state", cb_data); - } - -+/* Implement the get_thread_local_address gdbarch method. */ -+ -+static CORE_ADDR -+amd64fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, -+ CORE_ADDR lm_addr, CORE_ADDR offset) -+{ -+ struct regcache *regcache; -+ -+ regcache = get_thread_arch_regcache (ptid, gdbarch); -+ -+ target_fetch_registers (regcache, AMD64_FSBASE_REGNUM); -+ -+ ULONGEST fsbase; -+ if (regcache->cooked_read (AMD64_FSBASE_REGNUM, &fsbase) != REG_VALID) -+ error (_("Unable to fetch %%fsbase")); -+ -+ CORE_ADDR dtv_addr = fsbase + gdbarch_ptr_bit (gdbarch) / 8; -+ return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset); -+} -+ - static void - amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - { -@@ -241,6 +261,11 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - /* FreeBSD uses SVR4-style shared libraries. */ - set_solib_svr4_fetch_link_map_offsets - (gdbarch, svr4_lp64_fetch_link_map_offsets); -+ -+ set_gdbarch_fetch_tls_load_module_address (gdbarch, -+ svr4_fetch_objfile_link_map); -+ set_gdbarch_get_thread_local_address (gdbarch, -+ amd64fbsd_get_thread_local_address); - } - - void diff --git a/devel/gdb/files/extrapatch-guile22 b/devel/gdb/files/extrapatch-guile22 deleted file mode 100644 index f488e20c..00000000 --- a/devel/gdb/files/extrapatch-guile22 +++ /dev/null @@ -1,717 +0,0 @@ -2018-01-21 Doug Evans - - PR guile/21104 - * configure.ac: Add guile-2.2 back. - * configure: Regenerate. - * guile/scm-ports.c (PORTS_V22): New macro. - (ioscm_memory_port) [!PORTS_V22]: Make read_buf_size,write_buf_size - !PORTS_V22 only. - (port_type_t): New type. - (stdio_port_type): Renamed from stdio_port_desc. - (stdio_port_type_name): Renamed from stdio_port_desc_name. - (memory_port_type): Renamed from memory_port_desc. - (memmory_port_type_name): Renamed from memory_port_desc_name. - (natural_buf_size) [PORTS_V22]: New variable. - (ioscm_open_port): New argument stream. All callers updated. - (ioscm_read, ioscm_write) [PORTS_V22]: New functions. - (ioscm_init_gdb_stdio_port) [PORTS_V22]: Adapt for use in Guile >= 2.2. - (gdbscm_is_stdio_port): New function. - (gdbscm_stdio_port_p): Call it. - (gdbscm_get_natural_buffer_sizes, gdbscm_memory_port_seek) - (gdbscm_memory_port_read, gdbscm_memory_port_write) [PORTS_V22]: New - functions. - (gdbscm_memory_port_print): Adapt for use in Guile >= 2.2. - (ioscm_init_memory_port_type): Ditto. - (ioscm_init_memory_stream): Replaces ioscm_init_memory_port. - (ioscm_init_memory_port_buffers): New function. - (gdbscm_open_memory): Update. - (gdbscm_is_memory_port): Adapt for use in Guile >= 2.2. - (port_functions) [!PORTS_V22]: Only define Guile functions - memory-port-read-buffer-size, set-memory-port-read-buffer-size!, - memory-port-write-buffer-size, set-memory-port-write-buffer-size! - for Guile < 2.2. - (gdbscm_initialize_ports): Only initialize out_of_range_buf_size if - !PORTS_V22. - ---- gdb/configure.orig 2019-06-26 13:50:46 UTC -+++ gdb/configure -@@ -10985,7 +10985,7 @@ fi - - - --try_guile_versions="guile-2.0" -+try_guile_versions="guile-2.0 guile-2.2" - have_libguile=no - case "${with_guile}" in - no) ---- gdb/guile/scm-ports.c.orig 2019-05-11 18:19:03 UTC -+++ gdb/guile/scm-ports.c -@@ -36,6 +36,13 @@ - #endif - #endif - -+/* Guile ports radically changed in Guile 2.2. -+ Note: We don't support Guile < 2.0. -+ TODO(dje): Suggest deprecating and then removing Guile 2.0 support -+ at some point in the future. */ -+#define PORTS_V22 (SCM_MAJOR_VERSION > 2 \ -+ || SCM_MAJOR_VERSION == 2 && SCM_MINOR_VERSION >= 2) -+ - /* A ui-file for sending output to Guile. */ - - class ioscm_file_port : public ui_file -@@ -66,12 +73,14 @@ typedef struct - This value is always in the range [0, size]. */ - ULONGEST current; - -+#if !PORTS_V22 - /* The size of the internal r/w buffers. - Scheme ports aren't a straightforward mapping to memory r/w. - Generally the user specifies how much to r/w and all access is - unbuffered. We don't try to provide equivalent access, but we allow - the user to specify these values to help get something similar. */ - unsigned read_buf_size, write_buf_size; -+#endif - } ioscm_memory_port; - - /* Copies of the original system input/output/error ports. -@@ -80,11 +89,17 @@ static SCM orig_input_port_scm; - static SCM orig_output_port_scm; - static SCM orig_error_port_scm; - --/* This is the stdio port descriptor, scm_ptob_descriptor. */ --static scm_t_bits stdio_port_desc; -+#if PORTS_V22 -+typedef scm_t_port_type *port_type_t; -+#else -+typedef scm_t_bits port_type_t; -+#endif - -+/* This is the stdio port type. */ -+static port_type_t stdio_port_type; -+ - /* Note: scm_make_port_type takes a char * instead of a const char *. */ --static /*const*/ char stdio_port_desc_name[] = "gdb:stdio-port"; -+static /*const*/ char stdio_port_type_name[] = "gdb:stdio-port"; - - /* Names of each gdb port. */ - static const char input_port_name[] = "gdb:stdin"; -@@ -101,12 +116,19 @@ static SCM error_port_scm; - /* Internal enum for specifying output port. */ - enum oport { GDB_STDOUT, GDB_STDERR }; - --/* This is the memory port descriptor, scm_ptob_descriptor. */ --static scm_t_bits memory_port_desc; -+/* This is the memory port type. */ -+static port_type_t memory_port_type; - - /* Note: scm_make_port_type takes a char * instead of a const char *. */ --static /*const*/ char memory_port_desc_name[] = "gdb:memory-port"; -+static /*const*/ char memory_port_type_name[] = "gdb:memory-port"; - -+#if PORTS_V22 -+ -+/* The maximum values to use for get_natural_buffer_sizes. */ -+static const unsigned natural_buf_size = 16; -+ -+#else -+ - /* The default amount of memory to fetch for each read/write request. - Scheme ports don't provide a way to specify the size of a read, - which is important to us to minimize the number of inferior interactions, -@@ -120,6 +142,8 @@ static const unsigned default_write_buf_size = 16; - static const unsigned min_memory_port_buf_size = 1; - static const unsigned max_memory_port_buf_size = 4096; - -+#endif -+ - /* "out of range" error message for buf sizes. */ - static char *out_of_range_buf_size; - -@@ -132,7 +156,7 @@ static SCM size_keyword; - Newer versions of Guile (2.1.x) have scm_c_make_port. */ - - static SCM --ioscm_open_port (scm_t_bits port_type, long mode_bits) -+ioscm_open_port (port_type_t port_type, long mode_bits, scm_t_bits stream) - { - SCM port; - -@@ -140,9 +164,12 @@ ioscm_open_port (scm_t_bits port_type, long mode_bits) - scm_i_scm_pthread_mutex_lock (&scm_i_port_table_mutex); - #endif - -+#if PORTS_V22 -+ port = scm_c_make_port (port_type, mode_bits, stream); -+#else - port = scm_new_port_table_entry (port_type); -- - SCM_SET_CELL_TYPE (port, port_type | mode_bits); -+#endif - - #if 0 /* TODO: Guile doesn't export this. What to do? */ - scm_i_pthread_mutex_unlock (&scm_i_port_table_mutex); -@@ -150,6 +177,23 @@ ioscm_open_port (scm_t_bits port_type, long mode_bits) - - return port; - } -+ -+/* Like fputstrn_filtered, but don't escape characters, except nul. -+ Also like fputs_filtered, but a length is specified. */ -+ -+static void -+fputsn_filtered (const char *s, size_t size, struct ui_file *stream) -+{ -+ size_t i; -+ -+ for (i = 0; i < size; ++i) -+ { -+ if (s[i] == '\0') -+ fputs_filtered ("\\000", stream); -+ else -+ fputc_filtered (s[i], stream); -+ } -+} - - /* Support for connecting Guile's stdio ports to GDB's stdio ports. */ - -@@ -218,6 +262,73 @@ ioscm_input_waiting (SCM port) - } - } - -+#if PORTS_V22 -+ -+static size_t -+ioscm_read (SCM port, SCM dst, size_t start, size_t count) -+{ -+ /* Borrowed from libguile/fports.c. */ -+ auto ptr = reinterpret_cast(SCM_BYTEVECTOR_CONTENTS (dst) + start); -+ ssize_t ret; -+ -+ /* If we're called on stdout,stderr, punt. */ -+ if (! scm_is_eq (port, input_port_scm)) -+ return 0; /* EOF */ -+ -+ gdb_flush (gdb_stdout); -+ gdb_flush (gdb_stderr); -+ -+ retry: -+ ret = ui_file_read (gdb_stdin, ptr, count); -+ if (ret < 0) -+ { -+ if (errno == EINTR) -+ { -+ scm_async_tick (); -+ goto retry; -+ } -+ if (errno == EWOULDBLOCK || errno == EAGAIN) -+ { -+ /* See the discussion of non-blocking I/O in the Guile manual. */ -+ return -1; -+ } -+ scm_syserror ("ioscm_read"); -+ } -+ return ret; -+} -+ -+static size_t -+ioscm_write (SCM port, SCM src, size_t start, size_t count) -+{ -+ /* Borrowed from libguile/fports.c. */ -+ auto ptr = reinterpret_cast(SCM_BYTEVECTOR_CONTENTS (src) + start); -+ ssize_t ret; -+ -+ /* If we're called on stdin, punt. */ -+ if (scm_is_eq (port, input_port_scm)) -+ { -+ errno = EIO; -+ scm_syserror("ioscm_write"); -+ } -+ -+ TRY -+ { -+ if (scm_is_eq (port, error_port_scm)) -+ fputsn_filtered (ptr, count, gdb_stderr); -+ else -+ fputsn_filtered (ptr, count, gdb_stdout); -+ } -+ CATCH (except, RETURN_MASK_ALL) -+ { -+ GDBSCM_HANDLE_GDB_EXCEPTION (except); -+ } -+ END_CATCH -+ -+ return count; -+} -+ -+#else /* !PORTS_V22 */ -+ - /* The scm_t_ptob_descriptor.fill_input "method". */ - - static int -@@ -245,23 +356,6 @@ ioscm_fill_input (SCM port) - return *pt->read_buf; - } - --/* Like fputstrn_filtered, but don't escape characters, except nul. -- Also like fputs_filtered, but a length is specified. */ -- --static void --fputsn_filtered (const char *s, size_t size, struct ui_file *stream) --{ -- size_t i; -- -- for (i = 0; i < size; ++i) -- { -- if (s[i] == '\0') -- fputs_filtered ("\\000", stream); -- else -- fputc_filtered (s[i], stream); -- } --} -- - /* Write to gdb's stdout or stderr. */ - - static void -@@ -301,6 +395,8 @@ ioscm_flush (SCM port) - gdb_flush (gdb_stdout); - } - -+#endif -+ - /* Initialize the gdb stdio port type. - - N.B. isatty? will fail on these ports, it is only supported for file -@@ -309,13 +405,23 @@ ioscm_flush (SCM port) - static void - ioscm_init_gdb_stdio_port (void) - { -- stdio_port_desc = scm_make_port_type (stdio_port_desc_name, -- ioscm_fill_input, ioscm_write); -+ stdio_port_type = scm_make_port_type (stdio_port_type_name, -+#if PORTS_V22 -+ ioscm_read, -+#else -+ ioscm_fill_input, -+#endif -+ ioscm_write); - -- scm_set_port_input_waiting (stdio_port_desc, ioscm_input_waiting); -- scm_set_port_flush (stdio_port_desc, ioscm_flush); -+ scm_set_port_input_waiting (stdio_port_type, ioscm_input_waiting); -+ -+#if !PORTS_V22 -+ scm_set_port_flush (stdio_port_type, ioscm_flush); -+#endif - } - -+#if !PORTS_V22 -+ - /* Subroutine of ioscm_make_gdb_stdio_port to simplify it. - Set up the buffers of port PORT. - MODE_BITS are the mode bits of PORT. */ -@@ -358,6 +464,8 @@ ioscm_init_stdio_buffers (SCM port, long mode_bits) - pt->write_end = pt->write_buf + pt->write_buf_size; - } - -+#endif -+ - /* Create a gdb stdio port. */ - - static SCM -@@ -388,23 +496,36 @@ ioscm_make_gdb_stdio_port (int fd) - } - - mode_bits = scm_mode_bits ((char *) mode_str); -- port = ioscm_open_port (stdio_port_desc, mode_bits); -+ port = ioscm_open_port (stdio_port_type, mode_bits, 0); - - scm_set_port_filename_x (port, gdbscm_scm_from_c_string (name)); - -+#if !PORTS_V22 - ioscm_init_stdio_buffers (port, mode_bits); -+#endif - - return port; - } - -+/* Return non-zero if OBJ is a stdio port. */ -+ -+static int -+gdbscm_is_stdio_port (SCM obj) -+{ -+ /* This is copied from SCM_FPORTP. */ -+#if PORTS_V22 -+ return SCM_PORTP (obj) && SCM_PORT_TYPE (obj) == stdio_port_type; -+#else -+ return !SCM_IMP (obj) && SCM_TYP16 (obj) == stdio_port_type; -+#endif -+} -+ - /* (stdio-port? object) -> boolean */ - - static SCM --gdbscm_stdio_port_p (SCM scm) -+gdbscm_stdio_port_p (SCM obj) - { -- /* This is copied from SCM_FPORTP. */ -- return scm_from_bool (!SCM_IMP (scm) -- && (SCM_TYP16 (scm) == stdio_port_desc)); -+ return scm_from_bool (gdbscm_is_stdio_port (obj)); - } - - /* GDB's ports are accessed via functions to keep them read-only. */ -@@ -567,6 +688,94 @@ ioscm_lseek_address (ioscm_memory_port *iomem, LONGEST - return 1; - } - -+#if PORTS_V22 -+ -+/* The semantics get weird if the buffer size is larger than the port range, -+ so provide a better default buffer size. */ -+ -+static void -+gdbscm_get_natural_buffer_sizes (SCM port, size_t *read_size, -+ size_t *write_size) -+{ -+ ioscm_memory_port *iomem = (ioscm_memory_port *) SCM_STREAM (port); -+ -+ size_t size = natural_buf_size; -+ if (iomem->size < size) -+ size = iomem->size; -+ *read_size = *write_size = size; -+} -+ -+static scm_t_off -+gdbscm_memory_port_seek (SCM port, scm_t_off offset, int whence) -+{ -+ ioscm_memory_port *iomem = (ioscm_memory_port *) SCM_STREAM (port); -+ scm_t_off result; -+ int rc; -+ -+ if (ioscm_lseek_address (iomem, offset, whence) == 0) -+ { -+ gdbscm_out_of_range_error (FUNC_NAME, 0, -+ gdbscm_scm_from_longest (offset), -+ _("bad seek")); -+ } -+ -+ return iomem->current; -+} -+ -+static size_t -+gdbscm_memory_port_read (SCM port, SCM dst, size_t start, size_t count) -+{ -+ /* Borrowed from libguile/fports.c. */ -+ auto ptr = reinterpret_cast(SCM_BYTEVECTOR_CONTENTS (dst) + start); -+ ioscm_memory_port *iomem = (ioscm_memory_port *) SCM_STREAM (port); -+ size_t to_read; -+ -+ /* "current" is the offset of the first byte we want to read. */ -+ gdb_assert (iomem->current <= iomem->size); -+ if (iomem->current == iomem->size) -+ return 0; /* EOF */ -+ -+ /* Don't read outside the allowed memory range. */ -+ to_read = count; -+ if (to_read > iomem->size - iomem->current) -+ to_read = iomem->size - iomem->current; -+ -+ if (target_read_memory (iomem->start + iomem->current, ptr, to_read) != 0) -+ gdbscm_memory_error (FUNC_NAME, _("error reading memory"), SCM_EOL); -+ -+ iomem->current += to_read; -+ return to_read; -+} -+ -+static size_t -+gdbscm_memory_port_write (SCM port, SCM src, size_t start, size_t count) -+{ -+ /* Borrowed from libguile/fports.c. */ -+ auto ptr = reinterpret_cast(SCM_BYTEVECTOR_CONTENTS (src) + -+ start); -+ ioscm_memory_port *iomem = (ioscm_memory_port *) SCM_STREAM (port); -+ ssize_t ret; -+ -+ /* "current" is the offset of the first byte we want to read. */ -+ gdb_assert (iomem->current <= iomem->size); -+ -+ /* There's no way to indicate a short write, so if the request goes past -+ the end of the port's memory range, flag an error. */ -+ if (count > iomem->size - iomem->current) -+ { -+ gdbscm_out_of_range_error (FUNC_NAME, 0, gdbscm_scm_from_ulongest (count), -+ _("writing beyond end of memory range")); -+ } -+ -+ if (target_write_memory (iomem->start + iomem->current, ptr, count) != 0) -+ gdbscm_memory_error (FUNC_NAME, _("error writing memory"), SCM_EOL); -+ iomem->current += count; -+ -+ return count; -+} -+ -+#else /* !PORTS_V22 */ -+ - /* "fill_input" method for memory ports. */ - - static int -@@ -850,18 +1059,19 @@ gdbscm_memory_port_free (SCM port) - return 0; - } - -+#endif -+ - /* "print" method for memory ports. */ - - static int - gdbscm_memory_port_print (SCM exp, SCM port, scm_print_state *pstate) - { - ioscm_memory_port *iomem = (ioscm_memory_port *) SCM_STREAM (exp); -- char *type = SCM_PTOBNAME (SCM_PTOBNUM (exp)); - - scm_puts ("#<", port); - scm_print_port_mode (exp, port); - /* scm_print_port_mode includes a trailing space. */ -- gdbscm_printf (port, "%s %s-%s", type, -+ gdbscm_printf (port, "%s %s-%s", memory_port_type_name, - hex_string (iomem->start), hex_string (iomem->end)); - scm_putc ('>', port); - return 1; -@@ -872,16 +1082,25 @@ gdbscm_memory_port_print (SCM exp, SCM port, scm_print - static void - ioscm_init_memory_port_type (void) - { -- memory_port_desc = scm_make_port_type (memory_port_desc_name, -+ memory_port_type = scm_make_port_type (memory_port_type_name, -+#if PORTS_V22 -+ gdbscm_memory_port_read, -+#else - gdbscm_memory_port_fill_input, -+#endif - gdbscm_memory_port_write); - -- scm_set_port_end_input (memory_port_desc, gdbscm_memory_port_end_input); -- scm_set_port_flush (memory_port_desc, gdbscm_memory_port_flush); -- scm_set_port_seek (memory_port_desc, gdbscm_memory_port_seek); -- scm_set_port_close (memory_port_desc, gdbscm_memory_port_close); -- scm_set_port_free (memory_port_desc, gdbscm_memory_port_free); -- scm_set_port_print (memory_port_desc, gdbscm_memory_port_print); -+#if PORTS_V22 -+ scm_set_port_get_natural_buffer_sizes (memory_port_type, -+ gdbscm_get_natural_buffer_sizes); -+#else -+ scm_set_port_end_input (memory_port_type, gdbscm_memory_port_end_input); -+ scm_set_port_flush (memory_port_type, gdbscm_memory_port_flush); -+ scm_set_port_free (memory_port_type, gdbscm_memory_port_free); -+ scm_set_port_close (memory_port_type, gdbscm_memory_port_close); -+#endif -+ scm_set_port_seek (memory_port_type, gdbscm_memory_port_seek); -+ scm_set_port_print (memory_port_type, gdbscm_memory_port_print); - } - - /* Helper for gdbscm_open_memory to parse the mode bits. -@@ -921,27 +1140,20 @@ ioscm_parse_mode_bits (const char *func_name, const ch - return mode_bits; - } - --/* Helper for gdbscm_open_memory to finish initializing the port. -- The port has address range [start,end). -- This means that address of 0xff..ff is not accessible. -- I can live with that. */ -- --static void --ioscm_init_memory_port (SCM port, CORE_ADDR start, CORE_ADDR end) -+static scm_t_bits -+ioscm_init_memory_stream (bool buffered, CORE_ADDR start, CORE_ADDR end) - { -- scm_t_port *pt; -- ioscm_memory_port *iomem; -- int buffered = (SCM_CELL_WORD_0 (port) & SCM_BUF0) == 0; -+ auto iomem = reinterpret_cast( -+ scm_gc_malloc_pointerless (sizeof (ioscm_memory_port), "memory port")); - - gdb_assert (start <= end); - -- iomem = (ioscm_memory_port *) scm_gc_malloc_pointerless (sizeof (*iomem), -- "memory port"); -- - iomem->start = start; - iomem->end = end; - iomem->size = end - start; - iomem->current = 0; -+ -+#if !PORTS_V22 - if (buffered) - { - iomem->read_buf_size = default_read_buf_size; -@@ -952,7 +1164,25 @@ ioscm_init_memory_port (SCM port, CORE_ADDR start, COR - iomem->read_buf_size = 1; - iomem->write_buf_size = 1; - } -+#endif - -+ return reinterpret_cast(iomem); -+} -+ -+#if !PORTS_V22 -+ -+/* Helper for gdbscm_open_memory to finish initializing the port. -+ The port has address range [start,end). -+ This means that address of 0xff..ff is not accessible. -+ I can live with that. */ -+ -+static void -+ioscm_init_memory_port_buffers (SCM port) -+{ -+ scm_t_port *pt; -+ auto iomem = reinterpret_cast(SCM_STREAM (port)); -+ bool buffered = (SCM_CELL_WORD_0 (port) & SCM_BUF0) == 0; -+ - pt = SCM_PTAB_ENTRY (port); - /* Match the expectation of `binary-port?'. */ - pt->encoding = NULL; -@@ -972,8 +1202,6 @@ ioscm_init_memory_port (SCM port, CORE_ADDR start, COR - pt->read_pos = pt->read_end = pt->read_buf; - pt->write_pos = pt->write_buf; - pt->write_end = pt->write_buf + pt->write_buf_size; -- -- SCM_SETSTREAM (port, iomem); - } - - /* Re-initialize a memory port, updating its read/write buffer sizes. -@@ -1041,6 +1269,8 @@ ioscm_reinit_memory_port (SCM port, size_t read_buf_si - } - } - -+#endif /* !PORTS_V22 */ -+ - /* (open-memory [#:mode string] [#:start address] [#:size integer]) -> port - Return a port that can be used for reading and writing memory. - MODE is a string, and must be one of "r", "w", or "r+". -@@ -1107,10 +1337,19 @@ gdbscm_open_memory (SCM rest) - end = ~(CORE_ADDR) 0; - - mode_bits = ioscm_parse_mode_bits (FUNC_NAME, mode); -+ /* Edge case: empty range -> unbuffered. -+ There's no need to disallow empty ranges, but we need an unbuffered port -+ to get the semantics right. */ -+ if (size == 0) -+ mode_bits |= SCM_BUF0; - -- port = ioscm_open_port (memory_port_desc, mode_bits); -+ bool buffered = (mode_bits & SCM_BUF0) == 0; -+ auto stream = ioscm_init_memory_stream(buffered, start, end); -+ port = ioscm_open_port (memory_port_type, mode_bits, stream); - -- ioscm_init_memory_port (port, start, end); -+#if !PORTS_V22 -+ ioscm_init_memory_port_buffers (port); -+#endif - - scm_dynwind_end (); - -@@ -1123,7 +1362,12 @@ gdbscm_open_memory (SCM rest) - static int - gdbscm_is_memory_port (SCM obj) - { -- return !SCM_IMP (obj) && (SCM_TYP16 (obj) == memory_port_desc); -+ /* This is copied from SCM_FPORTP. */ -+#if PORTS_V22 -+ return SCM_PORTP (obj) && SCM_PORT_TYPE (obj) == memory_port_type; -+#else -+ return !SCM_IMP (obj) && SCM_TYP16 (obj) == memory_port_type; -+#endif - } - - /* (memory-port? obj) -> boolean */ -@@ -1142,13 +1386,15 @@ gdbscm_memory_port_range (SCM port) - ioscm_memory_port *iomem; - - SCM_ASSERT_TYPE (gdbscm_is_memory_port (port), port, SCM_ARG1, FUNC_NAME, -- memory_port_desc_name); -+ memory_port_type_name); - - iomem = (ioscm_memory_port *) SCM_STREAM (port); - return scm_list_2 (gdbscm_scm_from_ulongest (iomem->start), - gdbscm_scm_from_ulongest (iomem->end)); - } - -+#if !PORTS_V22 -+ - /* (memory-port-read-buffer-size port) -> integer */ - - static SCM -@@ -1157,7 +1403,7 @@ gdbscm_memory_port_read_buffer_size (SCM port) - ioscm_memory_port *iomem; - - SCM_ASSERT_TYPE (gdbscm_is_memory_port (port), port, SCM_ARG1, FUNC_NAME, -- memory_port_desc_name); -+ memory_port_type_name); - - iomem = (ioscm_memory_port *) SCM_STREAM (port); - return scm_from_uint (iomem->read_buf_size); -@@ -1173,7 +1419,7 @@ gdbscm_set_memory_port_read_buffer_size_x (SCM port, S - ioscm_memory_port *iomem; - - SCM_ASSERT_TYPE (gdbscm_is_memory_port (port), port, SCM_ARG1, FUNC_NAME, -- memory_port_desc_name); -+ memory_port_type_name); - SCM_ASSERT_TYPE (scm_is_integer (size), size, SCM_ARG2, FUNC_NAME, - _("integer")); - -@@ -1199,7 +1445,7 @@ gdbscm_memory_port_write_buffer_size (SCM port) - ioscm_memory_port *iomem; - - SCM_ASSERT_TYPE (gdbscm_is_memory_port (port), port, SCM_ARG1, FUNC_NAME, -- memory_port_desc_name); -+ memory_port_type_name); - - iomem = (ioscm_memory_port *) SCM_STREAM (port); - return scm_from_uint (iomem->write_buf_size); -@@ -1215,7 +1461,7 @@ gdbscm_set_memory_port_write_buffer_size_x (SCM port, - ioscm_memory_port *iomem; - - SCM_ASSERT_TYPE (gdbscm_is_memory_port (port), port, SCM_ARG1, FUNC_NAME, -- memory_port_desc_name); -+ memory_port_type_name); - SCM_ASSERT_TYPE (scm_is_integer (size), size, SCM_ARG2, FUNC_NAME, - _("integer")); - -@@ -1232,6 +1478,8 @@ gdbscm_set_memory_port_write_buffer_size_x (SCM port, - - return SCM_UNSPECIFIED; - } -+ -+#endif /* !PORTS_V22 */ - - /* Initialize gdb ports. */ - -@@ -1268,6 +1516,7 @@ Return #t if the object is a memory port." }, - "\ - Return the memory range of the port as (start end)." }, - -+#if !PORTS_V22 - { "memory-port-read-buffer-size", 1, 0, 0, - as_a_scm_t_subr (gdbscm_memory_port_read_buffer_size), - "\ -@@ -1293,6 +1542,7 @@ Set the size of the write buffer for the memory port.\ - \n\ - Arguments: port integer\n\ - Returns: unspecified." }, -+#endif - - END_FUNCTIONS - }; -@@ -1365,9 +1615,11 @@ gdbscm_initialize_ports (void) - start_keyword = scm_from_latin1_keyword ("start"); - size_keyword = scm_from_latin1_keyword ("size"); - -+#if !PORTS_V22 - /* Error message text for "out of range" memory port buffer sizes. */ - - out_of_range_buf_size = xstrprintf ("size not between %u - %u", - min_memory_port_buf_size, - max_memory_port_buf_size); -+#endif - } diff --git a/devel/gdb/files/extrapatch-kgdb b/devel/gdb/files/extrapatch-kgdb index 5ce13579..6d8e6fb9 100644 --- a/devel/gdb/files/extrapatch-kgdb +++ b/devel/gdb/files/extrapatch-kgdb @@ -1,18 +1,8 @@ diff --git gdb/Makefile.in gdb/Makefile.in -index 5614cc3386..b9acc63c3f 100644 +index 321a58c4635..57a45c391ef 100644 --- gdb/Makefile.in +++ gdb/Makefile.in -@@ -230,7 +230,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import - - # Generated headers in the gnulib directory. These must be listed - # so that they are generated before other files are compiled. --GNULIB_H = $(GNULIB_BUILDDIR)/import/string.h @GNULIB_STDINT_H@ -+GNULIB_H = $(GNULIB_BUILDDIR)/import/string.h \ -+ $(GNULIB_BUILDDIR)/import/alloca.h @GNULIB_STDINT_H@ - - # - # CLI sub directory definitons -@@ -632,6 +633,7 @@ TARGET_OBS = @TARGET_OBS@ +@@ -696,6 +696,7 @@ 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 = \ @@ -20,31 +10,45 @@ index 5614cc3386..b9acc63c3f 100644 aarch64-fbsd-tdep.o \ aarch64-linux-tdep.o \ aarch64-newlib-tdep.o \ -@@ -646,6 +648,7 @@ ALL_64_TARGET_OBS = \ +@@ -710,6 +711,7 @@ ALL_64_TARGET_OBS = \ amd64-darwin-tdep.o \ amd64-dicos-tdep.o \ amd64-fbsd-tdep.o \ + amd64fbsd-kern.o \ amd64-linux-tdep.o \ - amd64-nbsd-tdep.o \ + amd64-netbsd-tdep.o \ amd64-obsd-tdep.o \ -@@ -660,6 +663,7 @@ ALL_64_TARGET_OBS = \ +@@ -728,18 +730,21 @@ ALL_64_TARGET_OBS = \ ia64-vms-tdep.o \ + loongarch-linux-tdep.o \ + loongarch-tdep.o \ ++ mipsfbsd-kern.o \ + mips-fbsd-tdep.o \ + mips-linux-tdep.o \ + mips-netbsd-tdep.o \ + mips-sde-tdep.o \ + mips-tdep.o \ mips64-obsd-tdep.o \ ++ riscv-fbsd-kern.o \ + riscv-fbsd-tdep.o \ + riscv-linux-tdep.o \ + riscv-none-tdep.o \ + riscv-ravenscar-thread.o \ + riscv-tdep.o \ sparc64-fbsd-tdep.o \ + sparc64fbsd-kern.o \ sparc64-linux-tdep.o \ - sparc64-nbsd-tdep.o \ + sparc64-netbsd-tdep.o \ sparc64-obsd-tdep.o \ -@@ -676,6 +680,7 @@ ALL_TARGET_OBS = \ +@@ -764,6 +769,7 @@ ALL_TARGET_OBS = \ + arch/loongarch.o \ arch/ppc-linux-common.o \ - arch/riscv.o \ arm-bsd-tdep.o \ + arm-fbsd-kern.o \ arm-fbsd-tdep.o \ arm-linux-tdep.o \ - arm-nbsd-tdep.o \ -@@ -693,6 +698,8 @@ ALL_TARGET_OBS = \ + arm-netbsd-tdep.o \ +@@ -781,6 +787,8 @@ ALL_TARGET_OBS = \ csky-linux-tdep.o \ csky-tdep.o \ dicos-tdep.o \ @@ -53,77 +57,31 @@ index 5614cc3386..b9acc63c3f 100644 fbsd-tdep.o \ frv-linux-tdep.o \ frv-tdep.o \ -@@ -709,6 +716,7 @@ ALL_TARGET_OBS = \ +@@ -795,6 +803,7 @@ ALL_TARGET_OBS = \ + i386-bsd-tdep.o \ i386-darwin-tdep.o \ i386-dicos-tdep.o \ - i386-fbsd-tdep.o \ + i386fbsd-kern.o \ + i386-fbsd-tdep.o \ i386-gnu-tdep.o \ i386-go32-tdep.o \ - i386-linux-tdep.o \ -@@ -732,6 +740,7 @@ ALL_TARGET_OBS = \ - mep-tdep.o \ - microblaze-linux-tdep.o \ - microblaze-tdep.o \ -+ mipsfbsd-kern.o \ - mips-fbsd-tdep.o \ - mips-linux-tdep.o \ - mips-nbsd-tdep.o \ -@@ -750,6 +759,7 @@ ALL_TARGET_OBS = \ +@@ -832,6 +841,7 @@ ALL_TARGET_OBS = \ + obsd-tdep.o \ or1k-linux-tdep.o \ or1k-tdep.o \ - ppc-fbsd-tdep.o \ + ppcfbsd-kern.o \ + ppc-fbsd-tdep.o \ ppc-linux-tdep.o \ - ppc-nbsd-tdep.o \ - ppc-obsd-tdep.o \ -@@ -757,6 +767,7 @@ ALL_TARGET_OBS = \ - ppc-sysv-tdep.o \ - ppc64-tdep.o \ - ravenscar-thread.o \ -+ riscv-fbsd-kern.o \ - riscv-fbsd-tdep.o \ - riscv-linux-tdep.o \ - riscv-tdep.o \ -@@ -1629,7 +1640,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 - @$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do - - # Rule for compiling .c files in the top-level gdb directory. -@@ -1894,6 +1905,12 @@ ifneq ($(CODESIGN_CERT),) - $(ECHO_SIGN) $(CODESIGN) -s $(CODESIGN_CERT) gdb$(EXEEXT) - endif - -+kgdb$(EXEEXT): kgdb-main.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS) -+ $(SILENCE) rm -f kgdb$(EXEEXT) -+ $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \ -+ -o kgdb$(EXEEXT) kgdb-main.o $(LIBGDB_OBS) \ -+ $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) -+ - # Convenience rule to handle recursion. - $(LIBGNU) $(GNULIB_H): all-lib - all-lib: $(GNULIB_BUILDDIR)/Makefile -@@ -1940,6 +1957,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)/* -@@ -2154,6 +2172,7 @@ force_update: - MAKEOVERRIDES = - - ALLDEPFILES = \ + ppc-netbsd-tdep.o \ +@@ -1622,6 +1632,7 @@ ALLDEPFILES = \ + arch/riscv.c \ + arch/tic6x.c \ + aarch32-tdep.c \ + aarch64-fbsd-kern.c \ aarch64-fbsd-nat.c \ aarch64-fbsd-tdep.c \ aarch64-linux-nat.c \ -@@ -2173,6 +2192,7 @@ ALLDEPFILES = \ +@@ -1641,6 +1652,7 @@ ALLDEPFILES = \ amd64-bsd-nat.c \ amd64-darwin-tdep.c \ amd64-dicos-tdep.c \ @@ -131,15 +89,15 @@ index 5614cc3386..b9acc63c3f 100644 amd64-fbsd-nat.c \ amd64-fbsd-tdep.c \ amd64-linux-nat.c \ -@@ -2187,6 +2207,7 @@ ALLDEPFILES = \ +@@ -1656,6 +1668,7 @@ ALLDEPFILES = \ + arc-linux-nat.c \ arc-tdep.c \ - arm.c \ arm-bsd-tdep.c \ + arm-fbsd-kern.c \ arm-fbsd-nat.c \ arm-fbsd-tdep.c \ - arm-get-next-pcs.c \ -@@ -2207,6 +2228,9 @@ ALLDEPFILES = \ + arm-linux-nat.c \ +@@ -1675,6 +1688,9 @@ ALLDEPFILES = \ csky-tdep.c \ darwin-nat.c \ dicos-tdep.c \ @@ -149,7 +107,7 @@ index 5614cc3386..b9acc63c3f 100644 fbsd-nat.c \ fbsd-tdep.c \ fork-child.c \ -@@ -2228,6 +2252,7 @@ ALLDEPFILES = \ +@@ -1695,6 +1711,7 @@ ALLDEPFILES = \ i386-darwin-nat.c \ i386-darwin-tdep.c \ i386-dicos-tdep.c \ @@ -157,7 +115,7 @@ index 5614cc3386..b9acc63c3f 100644 i386-fbsd-nat.c \ i386-fbsd-tdep.c \ i386-gnu-nat.c \ -@@ -2264,6 +2289,7 @@ ALLDEPFILES = \ +@@ -1735,6 +1752,7 @@ ALLDEPFILES = \ microblaze-linux-tdep.c \ microblaze-tdep.c \ mingw-hdep.c \ @@ -165,15 +123,15 @@ index 5614cc3386..b9acc63c3f 100644 mips-fbsd-nat.c \ mips-fbsd-tdep.c \ mips-linux-nat.c \ -@@ -2283,6 +2309,7 @@ ALLDEPFILES = \ - obsd-nat.c \ +@@ -1755,6 +1773,7 @@ ALLDEPFILES = \ obsd-tdep.c \ + or1k-linux-nat.c \ posix-hdep.c \ + ppcfbsd-kern.c \ ppc-fbsd-nat.c \ ppc-fbsd-tdep.c \ ppc-linux-nat.c \ -@@ -2297,6 +2324,7 @@ ALLDEPFILES = \ +@@ -1769,6 +1788,7 @@ ALLDEPFILES = \ procfs.c \ ravenscar-thread.c \ remote-sim.c \ @@ -181,7 +139,7 @@ index 5614cc3386..b9acc63c3f 100644 riscv-fbsd-nat.c \ riscv-fbsd-tdep.c \ riscv-linux-nat.c \ -@@ -2333,6 +2361,7 @@ ALLDEPFILES = \ +@@ -1805,6 +1825,7 @@ ALLDEPFILES = \ sparc-sol2-nat.c \ sparc-sol2-tdep.c \ sparc-tdep.c \ @@ -189,7 +147,37 @@ index 5614cc3386..b9acc63c3f 100644 sparc64-fbsd-nat.c \ sparc64-fbsd-tdep.c \ sparc64-linux-nat.c \ -@@ -2596,7 +2625,7 @@ endif +@@ -1891,7 +1912,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 + @$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=$(SUBDIRS)" subdir_do + + # Rule for compiling .c files in the top-level gdb directory. +@@ -2154,6 +2175,12 @@ ifneq ($(CODESIGN_CERT),) + $(ECHO_SIGN) $(CODESIGN) -s $(CODESIGN_CERT) gdb$(EXEEXT) + endif + ++kgdb$(EXEEXT): kgdb-main.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS) ++ $(SILENCE) rm -f kgdb$(EXEEXT) ++ $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \ ++ -o kgdb$(EXEEXT) kgdb-main.o $(LIBGDB_OBS) \ ++ $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) ++ + # 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". +@@ -2189,6 +2216,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)/* +@@ -2608,7 +2636,7 @@ endif # A list of all the objects we might care about in this build, for # dependency tracking. @@ -199,13 +187,16 @@ index 5614cc3386..b9acc63c3f 100644 # All the .deps files to include. diff --git gdb/config.in gdb/config.in -index ea907d2b56..ee9146fd4e 100644 +index 736e6be1c48..7df4d954db0 100644 --- gdb/config.in +++ gdb/config.in -@@ -219,6 +219,9 @@ - /* Define to 1 if your system has the kinfo_getvmmap function. */ - #undef HAVE_KINFO_GETVMMAP +@@ -223,6 +223,12 @@ + /* Define to 1 if you have the `kinfo_getfile' function. */ + #undef HAVE_KINFO_GETFILE ++/* Define to 1 if your system has the kvm_kerndisp function. */ ++#undef HAVE_KVM_DISP ++ +/* Define to 1 if your system has the kvm_open2 function. */ +#undef HAVE_KVM_OPEN2 + @@ -213,17 +204,17 @@ index ea907d2b56..ee9146fd4e 100644 #undef HAVE_LANGINFO_CODESET diff --git gdb/configure gdb/configure -index 854837c50a..1f2da364cf 100755 +index bdc84be9c01..607ee3618cc 100755 --- gdb/configure +++ gdb/configure -@@ -8107,6 +8107,66 @@ $as_echo "#define HAVE_KINFO_GETFILE 1" >>confdefs.h - fi +@@ -19476,6 +19476,126 @@ fi + +# kgdb needs kvm_open2 for cross-debugging +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kvm_open2" >&5 +$as_echo_n "checking for library containing kvm_open2... " >&6; } -+if test "${ac_cv_search_kvm_open2+set}" = set; then : ++if ${ac_cv_search_kvm_open2+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS @@ -257,11 +248,11 @@ index 854837c50a..1f2da364cf 100755 +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext -+ if test "${ac_cv_search_kvm_open2+set}" = set; then : ++ if ${ac_cv_search_kvm_open2+:} false; then : + break +fi +done -+if test "${ac_cv_search_kvm_open2+set}" = set; then : ++if ${ac_cv_search_kvm_open2+:} false; then : + +else + ac_cv_search_kvm_open2=no @@ -279,28 +270,93 @@ index 854837c50a..1f2da364cf 100755 + +fi + ++ ++# kgdb needs kvm_kerndisp for relocatable kernels ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kvm_kerndisp" >&5 ++$as_echo_n "checking for library containing kvm_kerndisp... " >&6; } ++if ${ac_cv_search_kvm_kerndisp+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_func_search_save_LIBS=$LIBS ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char kvm_kerndisp (); ++int ++main () ++{ ++return kvm_kerndisp (); ++ ; ++ return 0; ++} ++_ACEOF ++for ac_lib in '' kvm; do ++ if test -z "$ac_lib"; then ++ ac_res="none required" ++ else ++ ac_res=-l$ac_lib ++ LIBS="-l$ac_lib $ac_func_search_save_LIBS" ++ fi ++ if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_search_kvm_kerndisp=$ac_res ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext ++ if ${ac_cv_search_kvm_kerndisp+:} false; then : ++ break ++fi ++done ++if ${ac_cv_search_kvm_kerndisp+:} false; then : ++ ++else ++ ac_cv_search_kvm_kerndisp=no ++fi ++rm conftest.$ac_ext ++LIBS=$ac_func_search_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_kvm_kerndisp" >&5 ++$as_echo "$ac_cv_search_kvm_kerndisp" >&6; } ++ac_res=$ac_cv_search_kvm_kerndisp ++if test "$ac_res" != no; then : ++ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" ++ ++$as_echo "#define HAVE_KVM_DISP 1" >>confdefs.h ++ ++fi ++ + - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" + # Check whether --with-zstd was given. + if test "${with_zstd+set}" = set; then : diff --git gdb/configure.ac gdb/configure.ac -index 1527585839..37e8ce54b0 100644 +index c81df8c4967..b3e1b3b5283 100644 --- gdb/configure.ac +++ gdb/configure.ac -@@ -511,6 +511,11 @@ AC_SEARCH_LIBS(kinfo_getfile, util util-freebsd, - [AC_DEFINE(HAVE_KINFO_GETFILE, 1, - [Define to 1 if your system has the kinfo_getfile function. ])]) +@@ -472,6 +472,16 @@ AC_SEARCH_LIBS(socketpair, socket) + AM_ZLIB + AC_ZSTD +# kgdb needs kvm_open2 for cross-debugging +AC_SEARCH_LIBS(kvm_open2, kvm, + [AC_DEFINE(HAVE_KVM_OPEN2, 1, + [Define to 1 if your system has the kvm_open2 function. ])]) ++ ++# kgdb needs kvm_kerndisp for relocatable kernels ++AC_SEARCH_LIBS(kvm_kerndisp, kvm, ++ [AC_DEFINE(HAVE_KVM_DISP, 1, ++ [Define to 1 if your system has the kvm_kerndisp function. ])]) + AM_ICONV # GDB may fork/exec the iconv program to get the list of supported character diff --git gdb/configure.nat gdb/configure.nat -index 64ee101d83..f32e6328e0 100644 +index aabcdeff989..6aeee4b61fa 100644 --- gdb/configure.nat +++ gdb/configure.nat @@ -63,7 +63,8 @@ case ${gdb_host} in @@ -314,19 +370,19 @@ index 64ee101d83..f32e6328e0 100644 LOADLIBES='-lkvm' ;; diff --git gdb/configure.tgt gdb/configure.tgt -index 27f122ad04..5fa0d0179e 100644 +index e84e222ba0d..cd3ef37fac6 100644 --- gdb/configure.tgt +++ gdb/configure.tgt -@@ -98,7 +98,7 @@ esac +@@ -115,7 +115,7 @@ esac case "${targ}" in *-*-freebsd* | *-*-kfreebsd*-gnu) - os_obs="fbsd-tdep.o solib-svr4.o";; + os_obs="fbsd-tdep.o solib-svr4.o fbsd-kld.o fbsd-kthr.o";; *-*-netbsd* | *-*-knetbsd*-gnu) - os_obs="nbsd-tdep.o solib-svr4.o";; + os_obs="netbsd-tdep.o solib-svr4.o";; *-*-openbsd*) -@@ -115,7 +115,7 @@ aarch64*-*-elf | aarch64*-*-rtems*) +@@ -132,7 +132,7 @@ aarch64*-*-elf | aarch64*-*-rtems*) aarch64*-*-freebsd*) # Target: FreeBSD/aarch64 @@ -335,7 +391,7 @@ index 27f122ad04..5fa0d0179e 100644 ;; aarch64*-*-linux*) -@@ -168,7 +168,7 @@ arm*-*-linux*) +@@ -188,7 +188,7 @@ arm*-*-linux*) ;; arm*-*-freebsd*) # Target: FreeBSD/arm @@ -344,7 +400,7 @@ index 27f122ad04..5fa0d0179e 100644 ;; arm*-*-netbsd* | arm*-*-knetbsd*-gnu) # Target: NetBSD/arm -@@ -267,7 +267,11 @@ i[34567]86-*-dicos*) +@@ -280,7 +280,11 @@ i[34567]86-*-dicos*) ;; i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu) # Target: FreeBSD/i386 @@ -357,16 +413,16 @@ index 27f122ad04..5fa0d0179e 100644 ;; i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu) # Target: NetBSD/i386 -@@ -421,7 +425,7 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu) +@@ -420,7 +424,7 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu) ;; mips*-*-freebsd*) # Target: MIPS running FreeBSD - gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o" + gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o mipsfbsd-kern.o" - gdb_sim=../sim/mips/libsim.a ;; mips64*-*-openbsd*) -@@ -488,7 +492,7 @@ or1k-*-* | or1knd-*-*) + # Target: OpenBSD/mips64 +@@ -478,7 +482,7 @@ or1k-*-* | or1knd-*-*) powerpc*-*-freebsd*) # Target: FreeBSD/powerpc gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \ @@ -375,7 +431,7 @@ index 27f122ad04..5fa0d0179e 100644 ravenscar-thread.o ppc-ravenscar-thread.o" ;; -@@ -543,7 +547,7 @@ s390*-*-linux*) +@@ -527,7 +531,7 @@ s390*-*-linux*) riscv*-*-freebsd*) # Target: FreeBSD/riscv @@ -384,7 +440,7 @@ index 27f122ad04..5fa0d0179e 100644 ;; riscv*-*-linux*) -@@ -622,6 +626,7 @@ sparc64-*-linux*) +@@ -592,6 +596,7 @@ sparc64-*-linux*) sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu) # Target: FreeBSD/sparc64 gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64-fbsd-tdep.o \ @@ -392,7 +448,7 @@ index 27f122ad04..5fa0d0179e 100644 ravenscar-thread.o sparc-ravenscar-thread.o" ;; sparc-*-netbsd* | sparc-*-knetbsd*-gnu) -@@ -749,8 +754,8 @@ x86_64-*-linux*) +@@ -708,8 +713,8 @@ x86_64-*-linux*) ;; x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) # Target: FreeBSD/amd64 @@ -403,35 +459,11 @@ index 27f122ad04..5fa0d0179e 100644 ;; x86_64-*-mingw* | x86_64-*-cygwin*) # Target: MingW/amd64 -diff --git gdb/defs.h gdb/defs.h -index a44e186907..c4bfd42073 100644 ---- gdb/defs.h -+++ gdb/defs.h -@@ -484,6 +484,7 @@ enum gdb_osabi - GDB_OSABI_SOLARIS, - GDB_OSABI_LINUX, - GDB_OSABI_FREEBSD, -+ GDB_OSABI_FREEBSD_KERNEL, - GDB_OSABI_NETBSD, - GDB_OSABI_OPENBSD, - GDB_OSABI_WINCE, -diff --git gdb/gnulib/configure gdb/gnulib/configure -index 340c622cb3..bf0c4dd5d9 100644 ---- gdb/gnulib/configure -+++ gdb/gnulib/configure -@@ -18579,6 +18579,7 @@ else - case "$host_os" in - # Guess all is fine on glibc systems. - *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;; -+ freebsd*) gl_cv_func_gettimeofday_clobber="guessing no" ;; - # If we don't know, assume the worst. - *) gl_cv_func_gettimeofday_clobber="guessing yes" ;; - esac diff --git gdb/osabi.c gdb/osabi.c -index 5d4bbcdff8..a982b22624 100644 +index d18802ac3a4..4f3aa6a52da 100644 --- gdb/osabi.c +++ gdb/osabi.c -@@ -66,6 +66,7 @@ static const struct osabi_names gdb_osabi_names[] = +@@ -67,6 +67,7 @@ static const struct osabi_names gdb_osabi_names[] = { "Solaris", NULL }, { "GNU/Linux", "linux(-gnu[^-]*)?" }, { "FreeBSD", NULL }, @@ -439,11 +471,23 @@ index 5d4bbcdff8..a982b22624 100644 { "NetBSD", NULL }, { "OpenBSD", NULL }, { "WindowsCE", NULL }, +diff --git gdb/osabi.h gdb/osabi.h +index 35f14ec433c..1276d34d5f7 100644 +--- gdb/osabi.h ++++ gdb/osabi.h +@@ -31,6 +31,7 @@ enum gdb_osabi + GDB_OSABI_SOLARIS, + GDB_OSABI_LINUX, + GDB_OSABI_FREEBSD, ++ GDB_OSABI_FREEBSD_KERNEL, + GDB_OSABI_NETBSD, + GDB_OSABI_OPENBSD, + GDB_OSABI_WINCE, diff --git gdb/regcache.c gdb/regcache.c -index 6e3eee9663..49ca1e1535 100644 +index 56b6d047874..47637c628a7 100644 --- gdb/regcache.c +++ gdb/regcache.c -@@ -1003,6 +1003,22 @@ reg_buffer::raw_supply_zeroed (int regnum) +@@ -1112,6 +1112,22 @@ reg_buffer::raw_supply_zeroed (int regnum) m_register_status[regnum] = REG_VALID; } @@ -463,14 +507,14 @@ index 6e3eee9663..49ca1e1535 100644 + m_register_status[regnum] = REG_VALID; +} + - /* See common/common-regcache.h. */ + /* See gdbsupport/common-regcache.h. */ void diff --git gdb/regcache.h gdb/regcache.h -index 2b703ea4a4..d06e001957 100644 +index b9ffab9950d..f32d7a3bd00 100644 --- gdb/regcache.h +++ gdb/regcache.h -@@ -224,6 +224,8 @@ public: +@@ -237,6 +237,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); diff --git a/devel/gdb/files/kgdb/aarch64-fbsd-kern.c b/devel/gdb/files/kgdb/aarch64-fbsd-kern.c index 0831be8f..68b12130 100644 --- a/devel/gdb/files/kgdb/aarch64-fbsd-kern.c +++ b/devel/gdb/files/kgdb/aarch64-fbsd-kern.c @@ -22,8 +22,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: head/devel/gdb/files/kgdb/aarch64-fbsd-kern.c 503200 2019-06-01 00:44:08Z jhb $ */ /* Target-dependent code for FreeBSD/aarch64 kernels. */ @@ -32,6 +30,7 @@ #include "aarch64-tdep.h" #include "frame-unwind.h" +#include "gdbarch.h" #include "gdbcore.h" #include "osabi.h" #include "regcache.h" @@ -42,11 +41,44 @@ #include "kgdb.h" +struct aarch64fbsd_info +{ + int osreldate; +}; + +/* Per-program-space data key. */ +static const registry::key aarch64fbsd_pspace_data; + +static void +aarch64fbsd_pspace_data_cleanup (struct program_space *pspace, void *arg) +{ + struct aarch64fbsd_info *info = (struct aarch64fbsd_info *)arg; + + xfree (info); +} + +/* Get the current aarch64_fbsd data. If none is found yet, add it + now. This function always returns a valid object. */ + +static struct aarch64fbsd_info * +get_aarch64fbsd_info (void) +{ + struct aarch64fbsd_info *info; + + info = aarch64fbsd_pspace_data.get (current_program_space); + if (info != nullptr) + return info; + + info = aarch64fbsd_pspace_data.emplace (current_program_space); + + info->osreldate = parse_and_eval_long ("osreldate"); + return info; +} + static const struct regcache_map_entry aarch64_fbsd_pcbmap[] = { - { 30, AARCH64_X0_REGNUM, 8 }, /* x0 ... x29 */ + { 11, AARCH64_X0_REGNUM + 19, 8 }, /* x19 ... x29 */ { 1, AARCH64_PC_REGNUM, 8 }, - { 1, REGCACHE_MAP_SKIP, 8 }, { 1, AARCH64_SP_REGNUM, 8 }, { 0 } }; @@ -57,29 +89,92 @@ static const struct regset aarch64_fbsd_pcbregset = regcache_supply_regset, regcache_collect_regset }; +/* In kernels prior to __FreeBSD_version 1400084, struct pcb used an + alternate layout. */ + +static const struct regcache_map_entry aarch64_fbsd13_pcbmap[] = + { + { 30, AARCH64_X0_REGNUM, 8 }, /* x0 ... x29 */ + { 1, AARCH64_PC_REGNUM, 8 }, + { 1, REGCACHE_MAP_SKIP, 8 }, + { 1, AARCH64_SP_REGNUM, 8 }, + { 0 } + }; + +static const struct regset aarch64_fbsd13_pcbregset = + { + aarch64_fbsd13_pcbmap, + regcache_supply_regset, regcache_collect_regset + }; + static void aarch64_fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) { + const struct regset *pcbregset; + struct aarch64fbsd_info *info = get_aarch64fbsd_info(); gdb_byte buf[8 * 33]; + if (info->osreldate >= 1400084) + pcbregset = &aarch64_fbsd_pcbregset; + else + pcbregset = &aarch64_fbsd13_pcbregset; + if (target_read_memory (pcb_addr, buf, sizeof buf) == 0) - regcache_supply_regset (&aarch64_fbsd_pcbregset, regcache, -1, buf, + regcache_supply_regset (pcbregset, regcache, -1, buf, sizeof (buf)); } +static const struct regcache_map_entry aarch64_fbsd_trapframe_map[] = + { + { 1, AARCH64_SP_REGNUM, 8 }, + { 1, AARCH64_LR_REGNUM, 8 }, + { 1, AARCH64_PC_REGNUM, 8 }, + { 1, AARCH64_CPSR_REGNUM, 8 }, + { 1, REGCACHE_MAP_SKIP, 8 }, /* esr */ + { 1, REGCACHE_MAP_SKIP, 8 }, /* far */ + { 30, AARCH64_X0_REGNUM, 8 }, /* x0 ... x29 */ + { 0 }, + }; + +/* In kernels prior to __FreeBSD_version 1400084, struct trapframe + used an alternate layout. */ + +static const struct regcache_map_entry aarch64_fbsd13_trapframe_map[] = + { + { 1, AARCH64_SP_REGNUM, 8 }, + { 1, AARCH64_LR_REGNUM, 8 }, + { 1, AARCH64_PC_REGNUM, 8 }, + { 1, AARCH64_CPSR_REGNUM, 4 }, + { 1, REGCACHE_MAP_SKIP, 4 }, /* esr */ + { 30, AARCH64_X0_REGNUM, 8 }, /* x0 ... x29 */ + { 0 }, + }; + static struct trad_frame_cache * -aarch64_fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) +aarch64_fbsd_trapframe_cache (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); + struct aarch64fbsd_info *info = get_aarch64fbsd_info(); struct trad_frame_cache *cache; CORE_ADDR func, pc, sp; const char *name; - int i; + int i, tf_size; if (*this_cache != NULL) return ((struct trad_frame_cache *)*this_cache); + const struct regcache_map_entry *trapframe_map; + + if (info->osreldate >= 1400084) + { + trapframe_map = aarch64_fbsd_trapframe_map; + } + else + { + trapframe_map = aarch64_fbsd13_trapframe_map; + } + cache = trad_frame_cache_zalloc (this_frame); *this_cache = cache; @@ -87,23 +182,12 @@ aarch64_fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); find_pc_partial_function (func, &name, NULL, NULL); - if (strcmp(name, "fork_trampoline") == 0 && get_frame_pc (this_frame) == func) - { - /* fork_exit hasn't been called (kthread has never run), so SP - hasn't been initialized yet. The stack pointer is stored in - the X2 in the pcb. */ - sp = get_frame_register_unsigned (this_frame, AARCH64_X0_REGNUM + 2); - } - trad_frame_set_reg_addr (cache, AARCH64_SP_REGNUM, sp); - trad_frame_set_reg_addr (cache, AARCH64_LR_REGNUM, sp + 8); - trad_frame_set_reg_addr (cache, AARCH64_PC_REGNUM, sp + 16); - trad_frame_set_reg_addr (cache, AARCH64_CPSR_REGNUM, sp + 24); - for (i = 0; i < 30; i++) - trad_frame_set_reg_addr (cache, AARCH64_X0_REGNUM + i, sp + 32 + i * 8); + tf_size = regcache_map_entry_size (trapframe_map); + trad_frame_set_reg_regmap (cache, trapframe_map, sp, tf_size); /* Read $PC from trap frame. */ - pc = read_memory_unsigned_integer (sp + 16, 8, byte_order); + pc = read_memory_unsigned_integer (sp + 2 * 8, 8, byte_order); if (pc == 0 && strcmp(name, "fork_trampoline") == 0) { @@ -113,15 +197,15 @@ aarch64_fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) else { /* Construct the frame ID using the function start. */ - trad_frame_set_id (cache, frame_id_build (sp + 8 * 34, func)); + trad_frame_set_id (cache, frame_id_build (sp + tf_size, func)); } return cache; } static void -aarch64_fbsd_trapframe_this_id (struct frame_info *this_frame, - void **this_cache, struct frame_id *this_id) +aarch64_fbsd_trapframe_this_id (frame_info_ptr this_frame, + void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = aarch64_fbsd_trapframe_cache (this_frame, this_cache); @@ -130,8 +214,8 @@ aarch64_fbsd_trapframe_this_id (struct frame_info *this_frame, } static struct value * -aarch64_fbsd_trapframe_prev_register (struct frame_info *this_frame, - void **this_cache, int regnum) +aarch64_fbsd_trapframe_prev_register (frame_info_ptr this_frame, + void **this_cache, int regnum) { struct trad_frame_cache *cache = aarch64_fbsd_trapframe_cache (this_frame, this_cache); @@ -141,7 +225,7 @@ aarch64_fbsd_trapframe_prev_register (struct frame_info *this_frame, static int aarch64_fbsd_trapframe_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, + frame_info_ptr this_frame, void **this_prologue_cache) { const char *name; @@ -156,6 +240,7 @@ aarch64_fbsd_trapframe_sniffer (const struct frame_unwind *self, } static const struct frame_unwind aarch64_fbsd_trapframe_unwind = { + "aarch64 FreeBSD kernel trap", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, aarch64_fbsd_trapframe_this_id, @@ -169,29 +254,22 @@ static const struct frame_unwind aarch64_fbsd_trapframe_unwind = { static void aarch64_fbsd_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); frame_unwind_prepend_unwinder (gdbarch, &aarch64_fbsd_trapframe_unwind); - set_solib_ops (gdbarch, &kld_so_ops); + set_gdbarch_so_ops (gdbarch, &kld_so_ops); /* Enable longjmp. */ tdep->jb_pc = 13; fbsd_vmcore_set_supply_pcb (gdbarch, aarch64_fbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr (gdbarch, kgdb_trgt_stop_pcb); - - /* The kernel is linked at a virtual address with the upper 4 bits - set, so all 64 bits of virtual addresses need to be treated as - significant. */ - set_gdbarch_significant_addr_bit (gdbarch, 64); } -/* Provide a prototype to silence -Wmissing-prototypes. */ -extern initialize_file_ftype _initialize_aarch64_kgdb_tdep; - +void _initialize_aarch64_kgdb_tdep (); void -_initialize_aarch64_kgdb_tdep (void) +_initialize_aarch64_kgdb_tdep () { gdbarch_register_osabi_sniffer(bfd_arch_aarch64, bfd_target_elf_flavour, diff --git a/devel/gdb/files/kgdb/amd64fbsd-kern.c b/devel/gdb/files/kgdb/amd64fbsd-kern.c index ecf1f5b0..7c71bf91 100644 --- a/devel/gdb/files/kgdb/amd64fbsd-kern.c +++ b/devel/gdb/files/kgdb/amd64fbsd-kern.c @@ -24,9 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/amd64fbsd-kern.c 503200 2019-06-01 00:44:08Z jhb $"); - #include "defs.h" #include "frame-unwind.h" #include "gdbcore.h" @@ -37,7 +34,7 @@ __FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/amd64fbsd-kern.c 503200 2019-06-01 #include "symtab.h" #include "trad-frame.h" #include "amd64-tdep.h" -#include "common/x86-xstate.h" +#include "gdbsupport/x86-xstate.h" #ifdef __amd64__ #include @@ -131,7 +128,7 @@ static const int amd64fbsd_trapframe_offset[] = { #define TRAPFRAME_SIZE 192 static struct trad_frame_cache * -amd64fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) +amd64fbsd_trapframe_cache (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); @@ -182,7 +179,7 @@ amd64fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) } static void -amd64fbsd_trapframe_this_id (struct frame_info *this_frame, +amd64fbsd_trapframe_this_id (frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = @@ -192,7 +189,7 @@ amd64fbsd_trapframe_this_id (struct frame_info *this_frame, } static struct value * -amd64fbsd_trapframe_prev_register (struct frame_info *this_frame, +amd64fbsd_trapframe_prev_register (frame_info_ptr this_frame, void **this_cache, int regnum) { struct trad_frame_cache *cache = @@ -203,7 +200,7 @@ amd64fbsd_trapframe_prev_register (struct frame_info *this_frame, static int amd64fbsd_trapframe_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, + frame_info_ptr this_frame, void **this_prologue_cache) { const char *name; @@ -218,6 +215,7 @@ amd64fbsd_trapframe_sniffer (const struct frame_unwind *self, } static const struct frame_unwind amd64fbsd_trapframe_unwind = { + "amd64 FreeBSD kernel trap", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, amd64fbsd_trapframe_this_id, @@ -235,14 +233,15 @@ amd64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) frame_unwind_prepend_unwinder(gdbarch, &amd64fbsd_trapframe_unwind); - set_solib_ops(gdbarch, &kld_so_ops); + set_gdbarch_so_ops(gdbarch, &kld_so_ops); fbsd_vmcore_set_supply_pcb(gdbarch, amd64fbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); } +void _initialize_amd64_kgdb_tdep (); void -_initialize_amd64_kgdb_tdep(void) +_initialize_amd64_kgdb_tdep () { gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_FREEBSD_KERNEL, amd64fbsd_kernel_init_abi); diff --git a/devel/gdb/files/kgdb/arm-fbsd-kern.c b/devel/gdb/files/kgdb/arm-fbsd-kern.c index 8516ced3..0caa5af9 100644 --- a/devel/gdb/files/kgdb/arm-fbsd-kern.c +++ b/devel/gdb/files/kgdb/arm-fbsd-kern.c @@ -22,8 +22,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: head/devel/gdb/files/kgdb/arm-fbsd-kern.c 475318 2018-07-25 17:28:36Z jhb $ */ /* Target-dependent code for FreeBSD/arm kernels. */ @@ -73,13 +71,17 @@ arm_fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) regcache->raw_supply_unsigned(ARM_PS_REGNUM, 0); } +#define PSR_MODE 0x0000001f /* mode mask */ +#define PSR_USR32_MODE 0x00000010 + static struct trad_frame_cache * -arm_fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) +arm_fbsd_trapframe_cache (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); struct trad_frame_cache *cache; - CORE_ADDR addr, func, pc, sp; + uint32_t psr; + CORE_ADDR func, pc, sp; const char *name; int i; @@ -94,10 +96,21 @@ arm_fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) find_pc_partial_function (func, &name, NULL, NULL); + /* Read $PSR to determine where SP and LR are. */ + psr = read_memory_unsigned_integer (sp, 4, byte_order); + for (i = 0; i <= 12; i++) trad_frame_set_reg_addr (cache, ARM_A1_REGNUM + i, sp + 4 + i * 4); - trad_frame_set_reg_addr (cache, ARM_SP_REGNUM, sp + 14 * 4); - trad_frame_set_reg_addr (cache, ARM_LR_REGNUM, sp + 15 * 4); + if ((psr & PSR_MODE) == PSR_USR32_MODE) + { + trad_frame_set_reg_addr (cache, ARM_SP_REGNUM, sp + 14 * 4); + trad_frame_set_reg_addr (cache, ARM_LR_REGNUM, sp + 15 * 4); + } + else + { + trad_frame_set_reg_addr (cache, ARM_SP_REGNUM, sp + 16 * 4); + trad_frame_set_reg_addr (cache, ARM_LR_REGNUM, sp + 17 * 4); + } trad_frame_set_reg_addr (cache, ARM_PC_REGNUM, sp + 18 * 4); trad_frame_set_reg_addr (cache, ARM_PS_REGNUM, sp); @@ -119,8 +132,8 @@ arm_fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) } static void -arm_fbsd_trapframe_this_id (struct frame_info *this_frame, - void **this_cache, struct frame_id *this_id) +arm_fbsd_trapframe_this_id (frame_info_ptr this_frame, + void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = arm_fbsd_trapframe_cache (this_frame, this_cache); @@ -129,8 +142,8 @@ arm_fbsd_trapframe_this_id (struct frame_info *this_frame, } static struct value * -arm_fbsd_trapframe_prev_register (struct frame_info *this_frame, - void **this_cache, int regnum) +arm_fbsd_trapframe_prev_register (frame_info_ptr this_frame, + void **this_cache, int regnum) { struct trad_frame_cache *cache = arm_fbsd_trapframe_cache (this_frame, this_cache); @@ -140,8 +153,8 @@ arm_fbsd_trapframe_prev_register (struct frame_info *this_frame, static int arm_fbsd_trapframe_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, - void **this_prologue_cache) + frame_info_ptr this_frame, + void **this_prologue_cache) { const char *name; @@ -156,6 +169,7 @@ arm_fbsd_trapframe_sniffer (const struct frame_unwind *self, } static const struct frame_unwind arm_fbsd_trapframe_unwind = { + "arm FreeBSD kernel trap", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, arm_fbsd_trapframe_this_id, @@ -169,11 +183,11 @@ static const struct frame_unwind arm_fbsd_trapframe_unwind = { static void arm_fbsd_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); frame_unwind_prepend_unwinder (gdbarch, &arm_fbsd_trapframe_unwind); - set_solib_ops (gdbarch, &kld_so_ops); + set_gdbarch_so_ops (gdbarch, &kld_so_ops); tdep->jb_pc = 24; tdep->jb_elt_size = 4; @@ -185,11 +199,9 @@ arm_fbsd_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_software_single_step (gdbarch, arm_software_single_step); } -/* Provide a prototype to silence -Wmissing-prototypes. */ -extern initialize_file_ftype _initialize_arm_kgdb_tdep; - +void _initialize_arm_kgdb_tdep (); void -_initialize_arm_kgdb_tdep (void) +_initialize_arm_kgdb_tdep () { gdbarch_register_osabi_sniffer(bfd_arch_arm, bfd_target_elf_flavour, diff --git a/devel/gdb/files/kgdb/fbsd-kld.c b/devel/gdb/files/kgdb/fbsd-kld.c index ed481c4c..55121d87 100644 --- a/devel/gdb/files/kgdb/fbsd-kld.c +++ b/devel/gdb/files/kgdb/fbsd-kld.c @@ -24,9 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/fbsd-kld.c 503200 2019-06-01 00:44:08Z jhb $"); - #include "defs.h" #include "command.h" #include "completer.h" @@ -59,15 +56,7 @@ struct kld_info { struct target_so_ops kld_so_ops; /* Per-program-space data key. */ -static const struct program_space_data *kld_pspace_data; - -static void -kld_pspace_data_cleanup (struct program_space *pspace, void *arg) -{ - struct kld_info *info = (struct kld_info *)arg; - - xfree (info); -} +static const registry::key kld_pspace_data; /* Get the current kld data. If none is found yet, add it now. This function always returns a valid object. */ @@ -77,18 +66,15 @@ get_kld_info (void) { struct kld_info *info; - info = (struct kld_info *) - program_space_data (current_program_space, kld_pspace_data); - if (info != NULL) - return info; + info = kld_pspace_data.get (current_program_space); + if (info == nullptr) + info = kld_pspace_data.emplace (current_program_space); - info = XCNEW (struct kld_info); - set_program_space_data (current_program_space, kld_pspace_data, info); return info; } static int -kld_ok (char *path) +kld_ok (const char *path) { struct stat sb; @@ -106,66 +92,61 @@ static const char *kld_suffixes[] = { ".debug", ".symbols", "", - NULL }; -static int -check_kld_path (char *path, size_t path_size) +static bool +check_kld_path (std::string &path) { - const char **suffix; - char *ep; - - ep = path + strlen(path); - suffix = kld_suffixes; - while (*suffix != NULL) { - if (strlcat(path, *suffix, path_size) < path_size) { - if (kld_ok(path)) - return (1); - } - - /* Restore original path to remove suffix. */ - *ep = '\0'; - suffix++; - } - return (0); + for (const char *suffix : kld_suffixes) { + std::string new_path = path + suffix; + if (kld_ok (new_path.c_str ())) { + path = new_path; + return true; + } + } + return false; } /* * 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 int -find_kld_path (const char *filename, char *path, size_t path_size) +static gdb::optional +find_kld_path (const char *filename) { - struct kld_info *info; - gdb::unique_xmalloc_ptr module_path; - char *module_dir, *cp; - int error; - - info = get_kld_info(); - if (exec_bfd) { - std::string kernel_dir = ldirname(bfd_get_filename(exec_bfd)); - if (!kernel_dir.empty()) { - snprintf(path, path_size, "%s/%s", kernel_dir.c_str(), - filename); - if (check_kld_path(path, path_size)) - return (1); - } + bfd *exec_bfd = current_program_space->exec_bfd (); + if (exec_bfd != nullptr) + { + std::string kernel_dir = ldirname (bfd_get_filename (exec_bfd)); + if (!kernel_dir.empty ()) + { + std::string path = string_printf("%s/%s", kernel_dir.c_str (), + filename); + if (check_kld_path (path)) + return path; } - if (info->module_path_addr != 0) { - target_read_string(info->module_path_addr, &module_path, - PATH_MAX, &error); - if (error == 0) { - cp = module_path.get(); - while ((module_dir = strsep(&cp, ";")) != NULL) { - snprintf(path, path_size, "%s/%s", module_dir, - filename); - if (check_kld_path(path, path_size)) - return (1); - } - } + } + + struct kld_info *info = get_kld_info (); + if (info->module_path_addr != 0) + { + gdb::unique_xmalloc_ptr module_path + = target_read_string(info->module_path_addr, PATH_MAX); + + if (module_path != nullptr) + { + char *cp = module_path.get(); + char *module_dir; + while ((module_dir = strsep(&cp, ";")) != NULL) + { + std::string path = string_printf("%s/%s", module_dir, filename); + if (check_kld_path (path)) + return path; + } } - return (0); + } + + return {}; } /* @@ -178,7 +159,7 @@ read_pointer (CORE_ADDR address) gdb_byte ptr_buf[8]; int arch_size; - arch_size = bfd_get_arch_size (exec_bfd); + 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; @@ -193,28 +174,23 @@ read_pointer (CORE_ADDR address) static int find_kld_address (const char *arg, CORE_ADDR *address) { - struct kld_info *info; - CORE_ADDR kld; - gdb::unique_xmalloc_ptr kld_filename; - const char *filename; - int error; - - info = get_kld_info(); + struct kld_info *info = get_kld_info(); if (info->linker_files_addr == 0 || info->off_address == 0 || info->off_filename == 0 || info->off_next == 0) return (0); - filename = lbasename(arg); - for (kld = read_pointer(info->linker_files_addr); kld != 0; + const char *filename = lbasename(arg); + for (CORE_ADDR kld = read_pointer(info->linker_files_addr); kld != 0; kld = read_pointer(kld + info->off_next)) { /* Try to read this linker file's filename. */ - target_read_string(read_pointer(kld + info->off_filename), - &kld_filename, PATH_MAX, &error); - if (error) + gdb::unique_xmalloc_ptr kld_filename = + target_read_string (read_pointer (kld + info->off_filename), + PATH_MAX); + if (kld_filename == nullptr) continue; /* Compare this kld's filename against our passed in name. */ - if (strcmp(kld_filename.get(), filename) != 0) + if (strcmp(kld_filename.get (), filename) != 0) continue; /* @@ -242,24 +218,17 @@ adjust_section_address (struct target_section *sec, CORE_ADDR *curr_base) } *curr_base = align_power(*curr_base, - bfd_get_section_alignment(abfd, asect)); + bfd_section_alignment(asect)); sec->addr = *curr_base; - sec->endaddr = sec->addr + bfd_section_size(abfd, asect); + sec->endaddr = sec->addr + bfd_section_size(asect); *curr_base = sec->endaddr; } static void -load_kld (char *path, CORE_ADDR base_addr, int from_tty) +load_kld (const char *path, CORE_ADDR base_addr, int from_tty) { - struct target_section *sections = NULL, *sections_end = NULL, *s; - struct cleanup *cleanup; - gdb_bfd_ref_ptr bfd; - CORE_ADDR curr_addr; - symfile_add_flags add_flags; - int i; - /* Open the kld. */ - bfd = gdb_bfd_openr(path, gnutarget); + gdb_bfd_ref_ptr bfd = gdb_bfd_openr(path, gnutarget); if (bfd == NULL) error("\"%s\": can't open: %s", path, bfd_errmsg(bfd_get_error())); @@ -272,56 +241,52 @@ load_kld (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. */ - if (build_section_table (bfd.get(), §ions, §ions_end)) - error("\"%s\": can't find file sections", path); - cleanup = make_cleanup(xfree, sections); - curr_addr = base_addr; - for (s = sections; s < sections_end; s++) - adjust_section_address(s, &curr_addr); + target_section_table sections = build_section_table (bfd.get()); + CORE_ADDR curr_addr = base_addr; + for (target_section &s : sections) + adjust_section_address(&s, &curr_addr); /* Build a section addr info to pass to symbol_file_add(). */ section_addr_info sap - = build_section_addr_info_from_section_table (sections, - sections_end); + = build_section_addr_info_from_section_table (sections); printf_unfiltered("add symbol table from file \"%s\" at\n", path); - for (i = 0; i < sap.size(); i++) - printf_unfiltered("\t%s_addr = %s\n", sap[i].name.c_str(), - paddress(target_gdbarch(), sap[i].addr)); + for (const other_sections &s : sap) + printf_unfiltered("\t%s_addr = %s\n", s.name.c_str(), + paddress(target_gdbarch(), s.addr)); if (from_tty && (!query("%s", ""))) error("Not confirmed."); - add_flags = 0; + symfile_add_flags add_flags = 0; if (from_tty) add_flags |= SYMFILE_VERBOSE; - symbol_file_add_from_bfd(bfd.get(), path, add_flags, &sap, + symbol_file_add_from_bfd(bfd, path, add_flags, &sap, OBJF_USERLOADED, NULL); - - do_cleanups(cleanup); } static void kgdb_add_kld_cmd (const char *arg, int from_tty) { - char path[PATH_MAX]; CORE_ADDR base_addr; - if (!exec_bfd) + if (current_program_space->exec_bfd () == nullptr) error("No kernel symbol file"); /* Try to open the raw path to handle absolute paths first. */ - snprintf(path, sizeof(path), "%s", arg); - if (!check_kld_path(path, sizeof(path))) { + std::string path (arg); + if (!check_kld_path(path)) { /* * If that didn't work, look in the various possible * paths for the module. */ - if (!find_kld_path(arg, path, sizeof(path))) { + gdb::optional found = find_kld_path (arg); + if (!found) { error("Unable to locate kld"); return; } + path = std::move(*found); } if (!find_kld_address(arg, &base_addr)) { @@ -329,7 +294,7 @@ kgdb_add_kld_cmd (const char *arg, int from_tty) return; } - load_kld(path, base_addr, from_tty); + load_kld(path.c_str (), base_addr, from_tty); reinit_frame_cache(); } @@ -340,7 +305,7 @@ kld_relocate_section_addresses (struct so_list *so, struct target_section *sec) lm_info_kld *li = (lm_info_kld *) so->lm_info; static CORE_ADDR curr_addr; - if (sec == so->sections) + if (sec == &so->sections->front()) curr_addr = li->base_address; adjust_section_address(sec, &curr_addr); @@ -379,44 +344,58 @@ kld_solib_create_inferior_hook (int from_tty) struct kld_info *info; info = get_kld_info(); - + /* * Compute offsets of relevant members in struct linker_file * and the addresses of global variables. Newer kernels * include constants we can use without requiring debug - * symbols. If those aren't present, fall back to using - * home-grown offsetof() equivalents. + * symbols. */ - TRY { + try { info->off_address = parse_and_eval_long("kld_off_address"); info->off_filename = parse_and_eval_long("kld_off_filename"); info->off_pathname = parse_and_eval_long("kld_off_pathname"); info->off_next = parse_and_eval_long("kld_off_next"); - } CATCH(e, RETURN_MASK_ERROR) { - TRY { - info->off_address = parse_and_eval_address( - "&((struct linker_file *)0)->address"); - info->off_filename = parse_and_eval_address( - "&((struct linker_file *)0)->filename"); - info->off_pathname = parse_and_eval_address( - "&((struct linker_file *)0)->pathname"); - info->off_next = parse_and_eval_address( - "&((struct linker_file *)0)->link.tqe_next"); - } CATCH(e2, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { + try { + struct symbol *linker_file_sym = + lookup_symbol_in_language ("struct linker_file", + NULL, STRUCT_DOMAIN, language_c, NULL).symbol; + if (linker_file_sym == NULL) + error (_( + "Unable to find struct linker_file symbol")); + + info->off_address = + lookup_struct_elt (linker_file_sym->type (), + "address", 0).offset / 8; + info->off_filename = + lookup_struct_elt (linker_file_sym->type (), + "filename", 0).offset / 8; + info->off_pathname = + lookup_struct_elt (linker_file_sym->type (), + "pathname", 0).offset / 8; + + struct type *link_type = + lookup_struct_elt_type (linker_file_sym->type (), + "link", 0); + if (link_type == NULL) + error (_("Unable to find link type")); + + info->off_next = + lookup_struct_elt (link_type, "tqe_next", + 0).offset / 8; + } catch (const gdb_exception_error &e2) { return; } - END_CATCH } - END_CATCH - TRY { + try { info->module_path_addr = parse_and_eval_address("linker_path"); info->linker_files_addr = kgdb_lookup("linker_files"); info->kernel_file_addr = kgdb_lookup("linker_kernel_file"); - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { return; } - END_CATCH solib_add(NULL, from_tty, auto_solib_add); } @@ -424,33 +403,27 @@ kld_solib_create_inferior_hook (int from_tty) static struct so_list * kld_current_sos (void) { - struct so_list *head, **prev, *newobj; - struct kld_info *info; - CORE_ADDR kld, kernel; - gdb::unique_xmalloc_ptr path; - int error; - - info = get_kld_info(); + struct kld_info *info = get_kld_info(); 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); - head = NULL; - prev = &head; + struct so_list *head = NULL; + struct so_list **prev = &head; /* * Walk the list of linker files creating so_list entries for * each non-kernel file. */ - kernel = read_pointer(info->kernel_file_addr); - for (kld = read_pointer(info->linker_files_addr); kld != 0; + CORE_ADDR kernel = read_pointer(info->kernel_file_addr); + for (CORE_ADDR kld = read_pointer(info->linker_files_addr); kld != 0; kld = read_pointer(kld + info->off_next)) { /* Skip the main kernel file. */ if (kld == kernel) continue; - newobj = XCNEW (struct so_list); + struct so_list *newobj = XCNEW (struct so_list); lm_info_kld *li = new lm_info_kld; li->base_address = 0; @@ -458,11 +431,11 @@ kld_current_sos (void) newobj->lm_info = li; /* Read the base filename and store it in so_original_name. */ - target_read_string(read_pointer(kld + info->off_filename), - &path, sizeof(newobj->so_original_name), &error); - if (error != 0) { - warning("kld_current_sos: Can't read filename: %s\n", - safe_strerror(error)); + gdb::unique_xmalloc_ptr path = + target_read_string (read_pointer (kld + info->off_filename), + sizeof(newobj->so_original_name)); + if (path == nullptr) { + warning("kld_current_sos: Can't read filename\n"); free_so(newobj); continue; } @@ -473,18 +446,14 @@ kld_current_sos (void) * Try to read the pathname (if it exists) and store * it in so_name. */ - if (find_kld_path(newobj->so_original_name, newobj->so_name, - sizeof(newobj->so_name))) { - /* we found the kld */; - } else if (info->off_pathname != 0) { - target_read_string(read_pointer(kld + + if (info->off_pathname != 0) { + path = target_read_string (read_pointer (kld + info->off_pathname), - &path, sizeof(newobj->so_name), &error); - if (error != 0) { + sizeof(newobj->so_name)); + if (path == nullptr) { warning( - "kld_current_sos: Can't read pathname for \"%s\": %s\n", - newobj->so_original_name, - safe_strerror(error)); + "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)); } else { @@ -531,22 +500,21 @@ static int kld_find_and_open_solib (const char *solib, unsigned o_flags, gdb::unique_xmalloc_ptr *temp_pathname) { - char path[PATH_MAX]; - int fd; - - temp_pathname->reset (NULL); - if (!find_kld_path(solib, path, sizeof(path))) { - errno = ENOENT; - return (-1); - } - fd = open(path, o_flags, 0); - if (fd >= 0) - temp_pathname->reset(xstrdup(path)); - return (fd); + temp_pathname->reset (NULL); + gdb::optional found = find_kld_path (solib); + if (!found) { + errno = ENOENT; + return (-1); + } + int fd = open(found->c_str (), o_flags, 0); + if (fd >= 0) + temp_pathname->reset (xstrdup (found->c_str ())); + return (fd); } +void _initialize_kld_target (); void -_initialize_kld_target(void) +_initialize_kld_target () { struct cmd_list_element *c; @@ -565,7 +533,4 @@ _initialize_kld_target(void) "Usage: add-kld FILE\n\ Load the symbols from the kernel loadable module FILE."); set_cmd_completer(c, filename_completer); - - kld_pspace_data = register_program_space_data_with_cleanup (NULL, - kld_pspace_data_cleanup); } diff --git a/devel/gdb/files/kgdb/fbsd-kthr.c b/devel/gdb/files/kgdb/fbsd-kthr.c index 2a8b52ba..4bfadac8 100644 --- a/devel/gdb/files/kgdb/fbsd-kthr.c +++ b/devel/gdb/files/kgdb/fbsd-kthr.c @@ -24,14 +24,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/fbsd-kthr.c 503436 2019-06-04 04:17:26Z glebius $"); - #include #include #include -#include +#include "defs.h" #include "gdbcore.h" #include "objfiles.h" #include "value.h" @@ -47,7 +44,8 @@ static LONGEST mp_maxid; static struct kthr *first, *last; struct kthr *curkthr; -static int proc_off_p_pid, proc_off_p_comm, proc_off_p_list, proc_off_p_threads; +static int proc_off_p_pid, proc_off_p_comm, proc_off_p_hash, proc_off_p_list; +static int proc_off_p_threads; static int thread_off_td_tid, thread_off_td_oncpu, thread_off_td_pcb; static int thread_off_td_name, thread_off_td_plist; static int thread_oncpu_size; @@ -60,7 +58,7 @@ kgdb_lookup(const char *sym) msym = lookup_minimal_symbol(sym, NULL, NULL); if (msym.minsym == NULL) return (0); - return (BMSYMBOL_VALUE_ADDRESS(msym)); + return (msym.value_address ()); } /* @@ -95,61 +93,105 @@ kgdb_thr_first(void) } static void -kgdb_thr_add_procs(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int)) +kgdb_thr_add_proc(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int)) { struct gdbarch *gdbarch = target_gdbarch (); struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct kthr *kt; - CORE_ADDR pcb, pnext, tdaddr, tdnext; + CORE_ADDR pcb, tdaddr, tdnext; ULONGEST oncpu; LONGEST pid, tid; + try { + tdaddr = read_memory_typed_address (paddr + proc_off_p_threads, + ptr_type); + pid = read_memory_integer (paddr + proc_off_p_pid, 4, byte_order); + } catch (const gdb_exception_error &e) { + return; + } + + while (tdaddr != 0) { + try { + tid = read_memory_integer (tdaddr + thread_off_td_tid, + 4, byte_order); + oncpu = read_memory_unsigned_integer (tdaddr + + thread_off_td_oncpu, thread_oncpu_size, byte_order); + pcb = read_memory_typed_address (tdaddr + + thread_off_td_pcb, ptr_type); + tdnext = read_memory_typed_address (tdaddr + + thread_off_td_plist, ptr_type); + } catch (const gdb_exception_error &e) { + return; + } + kt = XNEW (struct kthr); + if (last == NULL) + first = last = kt; + else + last->next = kt; + kt->next = NULL; + kt->kaddr = tdaddr; + if (tid == dumptid) + kt->pcb = dumppcb; + else if (cpu_stopped(oncpu)) + kt->pcb = cpu_pcb_addr(oncpu); + else + kt->pcb = pcb; + kt->tid = tid; + kt->pid = pid; + kt->paddr = paddr; + kt->cpu = oncpu; + last = kt; + tdaddr = tdnext; + } +} + +static void +kgdb_thr_add_procs_hash(CORE_ADDR pidhashtbl, CORE_ADDR (*cpu_pcb_addr) (u_int)) +{ + struct gdbarch *gdbarch = target_gdbarch (); + struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + CORE_ADDR paddr, pnext; + ULONGEST i, pidhash; + + pidhash = parse_and_eval_long("pidhash"); + for (i = 0; i < pidhash; i++) { + try { + paddr = read_memory_typed_address (pidhashtbl + + i * ptr_type->length (), ptr_type); + } catch (const gdb_exception_error &e) { + continue; + } + while (paddr != 0) { + try { + pnext = read_memory_typed_address (paddr + + proc_off_p_hash, ptr_type); + } catch (const gdb_exception_error &e) { + break; + } + kgdb_thr_add_proc(paddr, cpu_pcb_addr); + paddr = pnext; + } + } +} + +static void +kgdb_thr_add_procs_list(CORE_ADDR paddr, CORE_ADDR (*cpu_pcb_addr) (u_int)) +{ + struct gdbarch *gdbarch = target_gdbarch (); + struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + CORE_ADDR pnext; + while (paddr != 0) { - TRY { - tdaddr = read_memory_typed_address (paddr + - proc_off_p_threads, ptr_type); - pid = read_memory_integer (paddr + proc_off_p_pid, 4, - byte_order); + try { pnext = read_memory_typed_address (paddr + proc_off_p_list, ptr_type); - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { break; - } END_CATCH - while (tdaddr != 0) { - TRY { - tid = read_memory_integer (tdaddr + - thread_off_td_tid, 4, byte_order); - oncpu = read_memory_unsigned_integer (tdaddr + - thread_off_td_oncpu, thread_oncpu_size, - byte_order); - pcb = read_memory_typed_address (tdaddr + - thread_off_td_pcb, ptr_type); - tdnext = read_memory_typed_address (tdaddr + - thread_off_td_plist, ptr_type); - } CATCH(e, RETURN_MASK_ERROR) { - break; - } END_CATCH - kt = XNEW (struct kthr); - if (last == NULL) - first = last = kt; - else - last->next = kt; - kt->next = NULL; - kt->kaddr = tdaddr; - if (tid == dumptid) - kt->pcb = dumppcb; - else if (cpu_stopped(oncpu)) - kt->pcb = cpu_pcb_addr(oncpu); - else - kt->pcb = pcb; - kt->tid = tid; - kt->pid = pid; - kt->paddr = paddr; - kt->cpu = oncpu; - last = kt; - tdaddr = tdnext; } + kgdb_thr_add_proc(paddr, cpu_pcb_addr); paddr = pnext; } } @@ -169,30 +211,21 @@ kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int)) } last = NULL; - addr = kgdb_lookup("allproc"); - if (addr == 0) - return (NULL); - TRY { - paddr = read_memory_typed_address (addr, ptr_type); - } CATCH(e, RETURN_MASK_ERROR) { - return (NULL); - } END_CATCH - dumppcb = kgdb_lookup("dumppcb"); if (dumppcb == 0) return (NULL); - TRY { + try { dumptid = parse_and_eval_long("dumptid"); - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { dumptid = -1; - } END_CATCH + } - TRY { + try { mp_maxid = parse_and_eval_long("mp_maxid"); - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { mp_maxid = 0; - } END_CATCH + } stopped_cpus = kgdb_lookup("stopped_cpus"); /* @@ -201,7 +234,7 @@ kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int)) * kernels, try to extract these offsets using debug symbols. If * that fails, use native values. */ - TRY { + try { proc_off_p_pid = parse_and_eval_long("proc_off_p_pid"); proc_off_p_comm = parse_and_eval_long("proc_off_p_comm"); proc_off_p_list = parse_and_eval_long("proc_off_p_list"); @@ -212,29 +245,52 @@ kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int)) thread_off_td_pcb = parse_and_eval_long("thread_off_td_pcb"); thread_off_td_plist = parse_and_eval_long("thread_off_td_plist"); thread_oncpu_size = 4; - } CATCH(e, RETURN_MASK_ERROR) { - TRY { - proc_off_p_pid = parse_and_eval_address( - "&((struct proc *)0)->p_pid"); - proc_off_p_comm = parse_and_eval_address( - "&((struct proc *)0)->p_comm"); - proc_off_p_list = parse_and_eval_address( - "&((struct proc *)0)->p_list"); - proc_off_p_threads = parse_and_eval_address( - "&((struct proc *)0)->p_threads"); - thread_off_td_tid = parse_and_eval_address( - "&((struct thread *)0)->td_tid"); - thread_off_td_name = parse_and_eval_address( - "&((struct thread *)0)->td_name"); - thread_off_td_oncpu = parse_and_eval_address( - "&((struct thread *)0)->td_oncpu"); - thread_off_td_pcb = parse_and_eval_address( - "&((struct thread *)0)->td_pcb"); - thread_off_td_plist = parse_and_eval_address( - "&((struct thread *)0)->td_plist"); - thread_oncpu_size = parse_and_eval_long( - "sizeof(((struct thread *)0)->td_oncpu)"); - } CATCH(e2, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { + try { + struct symbol *proc_sym = + lookup_symbol_in_language ("struct proc", NULL, + STRUCT_DOMAIN, language_c, NULL).symbol; + if (proc_sym == NULL) + error (_("Unable to find struct proc symbol")); + + proc_off_p_pid = + lookup_struct_elt (proc_sym->type (), "p_pid", + 0).offset / 8; + proc_off_p_comm = + lookup_struct_elt (proc_sym->type (), "p_comm", + 0).offset / 8; + proc_off_p_list = + lookup_struct_elt (proc_sym->type (), "p_list", + 0).offset / 8; + proc_off_p_threads = + lookup_struct_elt (proc_sym->type (), + "p_threads", 0).offset / 8; + + struct symbol *thread_sym = + lookup_symbol_in_language ("struct thread", NULL, + STRUCT_DOMAIN, language_c, NULL).symbol; + if (thread_sym == NULL) + error (_("Unable to find struct thread symbol")); + + thread_off_td_tid = + lookup_struct_elt (proc_sym->type (), "td_tid", + 0).offset / 8; + thread_off_td_name = + lookup_struct_elt (proc_sym->type (), "td_name", + 0).offset / 8; + thread_off_td_pcb = + lookup_struct_elt (proc_sym->type (), "td_pcb", + 0).offset / 8; + thread_off_td_plist = + lookup_struct_elt (proc_sym->type (), "td_plist", + 0).offset / 8; + + struct_elt td_oncpu = + lookup_struct_elt (proc_sym->type (), "td_oncpu", + 0); + thread_off_td_oncpu = td_oncpu.offset / 8; + thread_oncpu_size = FIELD_BITSIZE(*td_oncpu.field) / 8; + } catch (const gdb_exception_error &e2) { proc_off_p_pid = offsetof(struct proc, p_pid); proc_off_p_comm = offsetof(struct proc, p_comm); proc_off_p_list = offsetof(struct proc, p_list); @@ -246,17 +302,53 @@ kgdb_thr_init(CORE_ADDR (*cpu_pcb_addr) (u_int)) thread_off_td_plist = offsetof(struct thread, td_plist); thread_oncpu_size = sizeof(((struct thread *)0)->td_oncpu); - } END_CATCH - } END_CATCH + } + } + + /* + * Handle p_hash separately. + */ + try { + proc_off_p_hash = parse_and_eval_long("proc_off_p_hash"); + } catch (const gdb_exception_error &e) { + try { + struct symbol *proc_sym = + lookup_symbol_in_language ("struct proc", NULL, + STRUCT_DOMAIN, language_c, NULL).symbol; + if (proc_sym == NULL) + error (_("Unable to find struct proc symbol")); + + proc_off_p_hash = + lookup_struct_elt (proc_sym->type (), "p_hash", + 0).offset / 8; + } catch (const gdb_exception_error &e2) { + proc_off_p_hash = offsetof(struct proc, p_hash); + } + } - kgdb_thr_add_procs(paddr, cpu_pcb_addr); addr = kgdb_lookup("zombproc"); if (addr != 0) { - TRY { + addr = kgdb_lookup("allproc"); + try { + paddr = read_memory_typed_address (addr, ptr_type); + kgdb_thr_add_procs_list(paddr, cpu_pcb_addr); + } catch (const gdb_exception_error &e) { + return (NULL); + } + + try { paddr = read_memory_typed_address (addr, ptr_type); - kgdb_thr_add_procs(paddr, cpu_pcb_addr); - } CATCH(e, RETURN_MASK_ERROR) { - } END_CATCH + kgdb_thr_add_procs_list(paddr, cpu_pcb_addr); + } catch (const gdb_exception_error &e) { + } + } else { + addr = kgdb_lookup("pidhashtbl"); + try { + addr = read_memory_typed_address (addr, ptr_type); + kgdb_thr_add_procs_hash(addr, cpu_pcb_addr); + } catch (const gdb_exception_error &e) { + return (NULL); + } } curkthr = kgdb_thr_lookup_tid(dumptid); if (curkthr == NULL) @@ -317,27 +409,27 @@ kgdb_thr_next(struct kthr *kt) const char * kgdb_thr_extra_thread_info(int tid) { - char comm[MAXCOMLEN + 1]; - char td_name[MAXCOMLEN + 1]; - struct kthr *kt; - static char buf[64]; - - kt = kgdb_thr_lookup_tid(tid); - if (kt == NULL) - return (NULL); - snprintf(buf, sizeof(buf), "PID=%d", kt->pid); - TRY { - read_memory_string (kt->paddr + proc_off_p_comm, comm, - sizeof(comm)); - strlcat(buf, ": ", sizeof(buf)); - strlcat(buf, comm, sizeof(buf)); - read_memory_string (kt->kaddr + thread_off_td_name, td_name, - sizeof(td_name)); - if (strcmp(comm, td_name) != 0) { - strlcat(buf, "/", sizeof(buf)); - strlcat(buf, td_name, sizeof(buf)); - } - } CATCH(e, RETURN_MASK_ERROR) { - } END_CATCH - return (buf); + static char buf[64]; + + struct kthr *kt = kgdb_thr_lookup_tid(tid); + if (kt == nullptr) + return (nullptr); + + snprintf(buf, sizeof (buf), "PID=%d", kt->pid); + gdb::unique_xmalloc_ptr comm + = target_read_string (kt->paddr + proc_off_p_comm, MAXCOMLEN + 1); + if (comm != nullptr) + { + strlcat(buf, ": ", sizeof (buf)); + strlcat(buf, comm.get (), sizeof (buf)); + + gdb::unique_xmalloc_ptr td_name + = target_read_string (kt->kaddr + thread_off_td_name, MAXCOMLEN + 1); + if (td_name != nullptr && strcmp (comm.get (), td_name.get ()) != 0) + { + strlcat(buf, "/", sizeof (buf)); + strlcat(buf, td_name.get (), sizeof (buf)); + } + } + return (buf); } diff --git a/devel/gdb/files/kgdb/fbsd-kvm.c b/devel/gdb/files/kgdb/fbsd-kvm.c index 0c6ad673..bd4f71fe 100644 --- a/devel/gdb/files/kgdb/fbsd-kvm.c +++ b/devel/gdb/files/kgdb/fbsd-kvm.c @@ -24,16 +24,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/fbsd-kvm.c 503200 2019-06-01 00:44:08Z jhb $"); - #include "defs.h" #include "command.h" #include "elf-bfd.h" #include "filenames.h" #include "gdbcore.h" #include "gdbthread.h" -#include "gdb_obstack.h" +#include "gdbsupport/gdb_obstack.h" #include "inferior.h" #include "objfiles.h" #include "osabi.h" @@ -42,6 +39,9 @@ __FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/fbsd-kvm.c 503200 2019-06-01 00:44 #include "target.h" #include "value.h" #include "readline/tilde.h" +#include "gdbsupport/buildargv.h" +#include "gdbsupport/pathstuff.h" +#include "gdbsupport/gdb_tilde_expand.h" #include #include @@ -52,26 +52,26 @@ __FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/fbsd-kvm.c 503200 2019-06-01 00:44 static CORE_ADDR stoppcbs; static LONGEST pcb_size; -static char *vmcore; - -/* Per-architecture data key. */ -static struct gdbarch_data *fbsd_vmcore_data; +static std::string vmcore; struct fbsd_vmcore_ops { /* Supply registers for a pcb to a register cache. */ - void (*supply_pcb)(struct regcache *, CORE_ADDR); + void (*supply_pcb)(struct regcache *, CORE_ADDR) = nullptr; /* Return address of pcb for thread running on a CPU. */ - CORE_ADDR (*cpu_pcb_addr)(u_int); + CORE_ADDR (*cpu_pcb_addr)(u_int) = nullptr; }; -static void * -fbsd_vmcore_init (struct obstack *obstack) -{ - struct fbsd_vmcore_ops *ops; +/* Per-architecture data key. */ +static const registry::key fbsd_vmcore_data; - ops = OBSTACK_ZALLOC (obstack, struct fbsd_vmcore_ops); +static struct fbsd_vmcore_ops * +get_fbsd_vmcore_ops (struct gdbarch *gdbarch) +{ + struct fbsd_vmcore_ops *ops = fbsd_vmcore_data.get (gdbarch); + if (ops == nullptr) + ops = fbsd_vmcore_data.emplace (gdbarch); return ops; } @@ -83,8 +83,7 @@ fbsd_vmcore_set_supply_pcb (struct gdbarch *gdbarch, void (*supply_pcb) (struct regcache *, CORE_ADDR)) { - struct fbsd_vmcore_ops *ops = (struct fbsd_vmcore_ops *) - gdbarch_data (gdbarch, fbsd_vmcore_data); + struct fbsd_vmcore_ops *ops = get_fbsd_vmcore_ops (gdbarch); ops->supply_pcb = supply_pcb; } @@ -96,8 +95,7 @@ void fbsd_vmcore_set_cpu_pcb_addr (struct gdbarch *gdbarch, CORE_ADDR (*cpu_pcb_addr) (u_int)) { - struct fbsd_vmcore_ops *ops = (struct fbsd_vmcore_ops *) - gdbarch_data (gdbarch, fbsd_vmcore_data); + struct fbsd_vmcore_ops *ops = get_fbsd_vmcore_ops (gdbarch); ops->cpu_pcb_addr = cpu_pcb_addr; } @@ -138,14 +136,16 @@ kgdb_dmesg(void) */ if (kgdb_quiet) return; - TRY { + try { bufp = parse_and_eval_address("msgbufp->msg_ptr"); size = parse_and_eval_long("msgbufp->msg_size"); rseq = parse_and_eval_long("msgbufp->msg_rseq"); wseq = parse_and_eval_long("msgbufp->msg_wseq"); - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { + return; + } + if (size == 0) return; - } END_CATCH rseq = MSGBUF_SEQ_TO_POS(size, rseq); wseq = MSGBUF_SEQ_TO_POS(size, wseq); if (rseq == wseq) @@ -180,16 +180,17 @@ fbsd_kernel_osabi_sniffer(bfd *abfd) case ELFOSABI_NONE: { enum gdb_osabi osabi = GDB_OSABI_UNKNOWN; - bfd_map_over_sections (abfd, - generic_elf_osabi_sniff_abi_tag_sections, - &osabi); + for (asection *sect : gdb_bfd_sections (abfd)) + generic_elf_osabi_sniff_abi_tag_sections (abfd, sect, &osabi); /* - * aarch64 kernels don't have the right note tag for - * kernels so just look for /red/herring anyway. + * aarch64 and RISC-V kernels don't have the right + * note tag for kernels so just look for /red/herring + * anyway. */ if (osabi == GDB_OSABI_UNKNOWN && - elf_elfheader(abfd)->e_machine == EM_AARCH64) + ((elf_elfheader(abfd)->e_machine == EM_AARCH64) || + (elf_elfheader(abfd)->e_machine == EM_RISCV))) break; if (osabi != GDB_OSABI_FREEBSD) return (GDB_OSABI_UNKNOWN); @@ -202,7 +203,7 @@ fbsd_kernel_osabi_sniffer(bfd *abfd) /* FreeBSD ELF kernels have an interpreter path of "/red/herring". */ bufp = buf; s = bfd_get_section_by_name(abfd, ".interp"); - if (s != NULL && bfd_section_size(abfd, s) == sizeof(buf) && + if (s != NULL && bfd_section_size(s) == sizeof(buf) && bfd_get_full_section_contents(abfd, s, &bufp) && memcmp(buf, KERNEL_INTERP, sizeof(buf)) == 0) return (GDB_OSABI_FREEBSD_KERNEL); @@ -240,15 +241,14 @@ public: void files_info () override; bool thread_alive (ptid_t ptid) override; - void update_thread_list () override; - const char *pid_to_str (ptid_t) override; + std::string pid_to_str (ptid_t) override; const char *extra_thread_info (thread_info *) override; bool has_all_memory () override { return false; } bool has_memory () override; bool has_stack () override; bool has_registers () override; - bool has_execution (ptid_t) override { return false; } + bool has_execution (inferior *inf) override { return false; } }; /* Target ops for libkvm interface. */ @@ -263,7 +263,7 @@ kgdb_resolve_symbol(const char *name, kvaddr_t *kva) ms = lookup_minimal_symbol (name, NULL, NULL); if (ms.minsym == NULL) return (1); - *kva = BMSYMBOL_VALUE_ADDRESS (ms); + *kva = ms.value_address (); return (0); } #endif @@ -271,26 +271,26 @@ 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 = (struct fbsd_vmcore_ops *) - gdbarch_data (target_gdbarch(), fbsd_vmcore_data); + struct fbsd_vmcore_ops *ops = get_fbsd_vmcore_ops (target_gdbarch ()); char kvm_err[_POSIX2_LINE_MAX]; struct inferior *inf; struct cleanup *old_chain; struct kthr *kt; kvm_t *nkvm; - char *temp, *kernel, *filename; + const char *kernel; + std::string filename; + int osreldate; bool writeable; if (ops == NULL || ops->supply_pcb == NULL || ops->cpu_pcb_addr == NULL) error ("ABI doesn't support a vmcore target"); target_preopen (from_tty); - kernel = get_exec_file (1); + kernel = get_exec_file (0); if (kernel == NULL) error ("Can't open a vmcore without a kernel"); writeable = false; - filename = NULL; if (args != NULL) { gdb_argv built_argv (args); @@ -301,35 +301,53 @@ fbsd_kvm_target_open (const char *args, int from_tty) else error (_("Invalid argument")); } else { - if (filename != NULL) + if (!filename.empty ()) error (_("Invalid argument")); - filename = tilde_expand (*argv); - if (!IS_ABSOLUTE_PATH (filename)) { - temp = concat (current_directory, "/", - filename, NULL); - xfree(filename); - filename = temp; - } + filename = gdb_tilde_expand (*argv); + if (!IS_ABSOLUTE_PATH (filename)) + filename = gdb_abspath (filename.c_str ()); } } } - old_chain = make_cleanup (xfree, filename); - #ifdef HAVE_KVM_OPEN2 - nkvm = kvm_open2(kernel, filename, + nkvm = kvm_open2(kernel, filename.c_str (), writeable ? O_RDWR : O_RDONLY, kvm_err, kgdb_resolve_symbol); #else - nkvm = kvm_openfiles(kernel, filename, NULL, + nkvm = kvm_openfiles(kernel, filename.c_str (), NULL, writeable ? O_RDWR : O_RDONLY, kvm_err); #endif - if (nkvm == NULL) + if (nkvm == NULL) { error ("Failed to open vmcore: %s", kvm_err); + } /* Don't free the filename now and close any previous vmcore. */ - discard_cleanups(old_chain); - unpush_target(&fbsd_kvm_ops); + current_inferior ()->unpush_target (&fbsd_kvm_ops); + +#ifdef HAVE_KVM_DISP + /* Relocate kernel objfile if needed. */ + struct objfile *symfile_objfile = + current_program_space->symfile_object_file; + if (symfile_objfile != nullptr && + (bfd_get_file_flags(symfile_objfile->obfd.get ()) & + (EXEC_P | DYNAMIC)) != 0) { + CORE_ADDR displacement = kvm_kerndisp(nkvm); + if (displacement != 0) { + section_offsets new_offsets (symfile_objfile->section_offsets.size (), + displacement); + objfile_relocate(symfile_objfile, new_offsets); + } + } +#endif + + kvm = nkvm; + vmcore = std::move(filename); + current_inferior()->push_target (&fbsd_kvm_ops); + + /* Pop the target automatically upon failure. */ + target_unpush_up unpusher; + unpusher.reset (&fbsd_kvm_ops); /* * Determine the first address in KVA. Newer kernels export @@ -338,27 +356,45 @@ fbsd_kvm_target_open (const char *args, int from_tty) * symbol that is valid on all platforms, but kernbase is close * for most platforms. */ - TRY { + try { kernstart = parse_and_eval_address("vm_maxuser_address") + 1; - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { kernstart = kgdb_lookup("kernbase"); - } END_CATCH + } + + try { + CORE_ADDR osreldatesym = kgdb_lookup("osreldate"); + osreldate = read_memory_unsigned_integer(osreldatesym, 4, + gdbarch_byte_order (target_gdbarch ())); + } catch (const gdb_exception_error &e) { + error ("Failed to look up osreldate"); + } /* - * Lookup symbols needed for stoppcbs[] handling, but don't + * Look up symbols needed for stoppcbs handling, but don't * fail if they aren't present. */ stoppcbs = kgdb_lookup("stoppcbs"); - TRY { + if (osreldate > 1400088) { + /* stoppcbs is now a pointer rather than an array. */ + try { + stoppcbs = read_memory_typed_address(stoppcbs, + builtin_type(target_gdbarch())->builtin_data_ptr); + } catch (const gdb_exception_error &e) { + stoppcbs = 0; + } + } + + try { pcb_size = parse_and_eval_long("pcb_size"); - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { pcb_size = 0; - } END_CATCH + } if (pcb_size == 0) { - TRY { + try { pcb_size = parse_and_eval_long("sizeof(struct pcb)"); - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { #ifdef HAVE_KVM_OPEN2 if (kvm_native(nkvm)) pcb_size = sizeof(struct pcb); @@ -367,13 +403,9 @@ fbsd_kvm_target_open (const char *args, int from_tty) #else pcb_size = sizeof(struct pcb); #endif - } END_CATCH + } } - kvm = nkvm; - vmcore = filename; - push_target (&fbsd_kvm_ops); - kgdb_dmesg(); inf = current_inferior(); @@ -382,19 +414,24 @@ fbsd_kvm_target_open (const char *args, int from_tty) inf->fake_pid_p = 1; } solib_create_inferior_hook(0); - init_thread_list(); kt = kgdb_thr_init(ops->cpu_pcb_addr); + thread_info *curthr = nullptr; while (kt != NULL) { - add_thread_silent(fbsd_vmcore_ptid(kt->tid)); + thread_info *thr = add_thread_silent(&fbsd_kvm_ops, + fbsd_vmcore_ptid(kt->tid)); + if (kt == curkthr) + curthr = thr; kt = kgdb_thr_next(kt); } - if (curkthr != 0) - inferior_ptid = fbsd_vmcore_ptid(curkthr->tid); + switch_to_thread (curthr); target_fetch_registers (get_current_regcache (), -1); reinit_frame_cache (); print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1); + + /* Keep the target pushed. */ + unpusher.release (); } void @@ -402,16 +439,17 @@ fbsd_kvm_target::close() { if (kvm != NULL) { + switch_to_no_thread (); + exit_inferior_silent (current_inferior ()); + clear_solib(); if (kvm_close(kvm) != 0) - warning("cannot close \"%s\": %s", vmcore, + warning("cannot close \"%s\": %s", vmcore.c_str (), kvm_geterr(kvm)); kvm = NULL; - xfree(vmcore); - vmcore = NULL; + vmcore.clear (); } - inferior_ptid = null_ptid; } #if 0 @@ -424,7 +462,7 @@ kgdb_trgt_detach(struct target_ops *ops, const char *args, int from_tty) unpush_target(&kgdb_trgt_ops); reinit_frame_cache(); if (from_tty) - printf_filtered("No vmcore file now.\n"); + gdb_printf("No vmcore file now.\n"); } #endif @@ -457,42 +495,15 @@ void fbsd_kvm_target::files_info() { - printf_filtered ("\t`%s', ", vmcore); - wrap_here (" "); - printf_filtered ("file type %s.\n", "FreeBSD kernel vmcore"); + gdb_printf ("\t`%s', ", vmcore.c_str ()); + gdb_stdout->wrap_here (8); + gdb_printf ("file type %s.\n", "FreeBSD kernel vmcore"); } -void -fbsd_kvm_target::update_thread_list() -{ - /* - * XXX: We should probably rescan the thread list here and update - * it if there are any changes. One nit though is that we'd have - * to detect exited threads. - */ - gdb_assert(kvm != NULL); -#if 0 - prune_threads(); -#endif -#if 0 - struct target_ops *tb; - - if (kvm != NULL) - return; - - tb = find_target_beneath(ops); - if (tb->to_update_thread_list != NULL) - tb->to_update_thread_list(tb); -#endif -} - -const char * +std::string fbsd_kvm_target::pid_to_str(ptid_t ptid) { - static char buf[33]; - - snprintf(buf, sizeof(buf), "Thread %ld", ptid.tid()); - return (buf); + return string_printf (_("Thread %ld"), ptid.tid ()); } bool @@ -504,13 +515,12 @@ fbsd_kvm_target::thread_alive(ptid_t ptid) void fbsd_kvm_target::fetch_registers(struct regcache *regcache, int regnum) { - struct fbsd_vmcore_ops *ops = (struct fbsd_vmcore_ops *) - gdbarch_data (target_gdbarch(), fbsd_vmcore_data); + struct fbsd_vmcore_ops *ops = get_fbsd_vmcore_ops (target_gdbarch ()); struct kthr *kt; if (ops->supply_pcb == NULL) return; - kt = kgdb_thr_lookup_tid(inferior_ptid.tid()); + kt = kgdb_thr_lookup_tid(regcache->ptid().tid()); if (kt == NULL) return; ops->supply_pcb(regcache, kt->pcb); @@ -547,30 +557,12 @@ fbsd_kvm_target::xfer_partial(enum target_object object, } } -#if 0 -static int -kgdb_trgt_insert_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, - struct bp_target_info *bp_tgt) -{ - - return 0; -} - -static int -kgdb_trgt_remove_breakpoint(struct target_ops *ops, struct gdbarch *gdbarch, - struct bp_target_info *bp_tgt, enum remove_bp_reason reason) -{ - - return 0; -} -#endif - static void kgdb_switch_to_thread(const char *arg, int tid) { struct thread_info *tp; - tp = find_thread_ptid (fbsd_vmcore_ptid (tid)); + tp = find_thread_ptid (&fbsd_kvm_ops, fbsd_vmcore_ptid (tid)); if (tp == NULL) error ("invalid tid"); thread_select (arg, tp); @@ -622,13 +614,13 @@ kgdb_set_tid_cmd (const char *arg, int from_tty) kgdb_switch_to_thread(arg, addr); } +void _initialize_kgdb_target (); void -_initialize_kgdb_target(void) +_initialize_kgdb_target () { - add_target(fbsd_kvm_target_info, fbsd_kvm_target_open); - - fbsd_vmcore_data = gdbarch_data_register_pre_init(fbsd_vmcore_init); + add_target(fbsd_kvm_target_info, fbsd_kvm_target_open, + filename_completer); add_com ("proc", class_obscure, kgdb_set_proc_cmd, "Set current process context"); diff --git a/devel/gdb/files/kgdb/i386fbsd-kern.c b/devel/gdb/files/kgdb/i386fbsd-kern.c index aea4d72a..d6e1075d 100644 --- a/devel/gdb/files/kgdb/i386fbsd-kern.c +++ b/devel/gdb/files/kgdb/i386fbsd-kern.c @@ -24,9 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/i386fbsd-kern.c 480613 2018-09-24 17:23:35Z jhb $"); - #include "defs.h" #include "frame-unwind.h" #include "gdbcore.h" @@ -53,15 +50,7 @@ struct i386fbsd_info { }; /* Per-program-space data key. */ -static const struct program_space_data *i386fbsd_pspace_data; - -static void -i386fbsd_pspace_data_cleanup (struct program_space *pspace, void *arg) -{ - struct i386fbsd_info *info = (struct i386fbsd_info *)arg; - - xfree (info); -} +static const registry::key i386fbsd_pspace_data; /* Get the current i386fbsd data. If none is found yet, add it now. This function always returns a valid object. */ @@ -71,13 +60,11 @@ get_i386fbsd_info (void) { struct i386fbsd_info *info; - info = (struct i386fbsd_info *) - program_space_data (current_program_space, i386fbsd_pspace_data); - if (info != NULL) + info = i386fbsd_pspace_data.get (current_program_space); + if (info != nullptr) return info; - info = XCNEW (struct i386fbsd_info); - set_program_space_data (current_program_space, i386fbsd_pspace_data, info); + info = i386fbsd_pspace_data.emplace (current_program_space); /* * In revision 1.117 of i386/i386/exception.S trap handlers @@ -211,18 +198,18 @@ i386fbsd_fetch_tss(void) * change it to be relative to cpu0prvpage instead. */ if (trunc_page(tss) == 0xffc00000) { - TRY { + try { cpu0prvpage = parse_and_eval_address("cpu0prvpage"); - } CATCH(e, RETURN_MASK_ERROR) { + } catch (const gdb_exception_error &e) { return (0); - } END_CATCH + } tss = cpu0prvpage + (tss & PAGE_MASK); } return (tss); } static struct trad_frame_cache * -i386fbsd_dblfault_cache (struct frame_info *this_frame, void **this_cache) +i386fbsd_dblfault_cache (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); @@ -252,8 +239,8 @@ i386fbsd_dblfault_cache (struct frame_info *this_frame, void **this_cache) } static void -i386fbsd_dblfault_this_id (struct frame_info *this_frame, - void **this_cache, struct frame_id *this_id) +i386fbsd_dblfault_this_id (frame_info_ptr this_frame, + void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = i386fbsd_dblfault_cache (this_frame, this_cache); @@ -262,8 +249,8 @@ i386fbsd_dblfault_this_id (struct frame_info *this_frame, } static struct value * -i386fbsd_dblfault_prev_register (struct frame_info *this_frame, - void **this_cache, int regnum) +i386fbsd_dblfault_prev_register (frame_info_ptr this_frame, + void **this_cache, int regnum) { struct trad_frame_cache *cache = i386fbsd_dblfault_cache (this_frame, this_cache); @@ -273,8 +260,8 @@ i386fbsd_dblfault_prev_register (struct frame_info *this_frame, static int i386fbsd_dblfault_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, - void **this_prologue_cache) + frame_info_ptr this_frame, + void **this_prologue_cache) { const char *name; @@ -283,6 +270,7 @@ i386fbsd_dblfault_sniffer (const struct frame_unwind *self, } static const struct frame_unwind i386fbsd_dblfault_unwind = { + "i386 FreeBSD double fault", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, i386fbsd_dblfault_this_id, @@ -314,7 +302,7 @@ static const int i386fbsd_trapframe_offset[] = { #define TRAPFRAME_SIZE 72 static struct trad_frame_cache * -i386fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) +i386fbsd_trapframe_cache (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); @@ -409,8 +397,8 @@ i386fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) } static void -i386fbsd_trapframe_this_id (struct frame_info *this_frame, - void **this_cache, struct frame_id *this_id) +i386fbsd_trapframe_this_id (frame_info_ptr this_frame, + void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = i386fbsd_trapframe_cache (this_frame, this_cache); @@ -419,8 +407,8 @@ i386fbsd_trapframe_this_id (struct frame_info *this_frame, } static struct value * -i386fbsd_trapframe_prev_register (struct frame_info *this_frame, - void **this_cache, int regnum) +i386fbsd_trapframe_prev_register (frame_info_ptr this_frame, + void **this_cache, int regnum) { struct trad_frame_cache *cache = i386fbsd_trapframe_cache (this_frame, this_cache); @@ -430,8 +418,8 @@ i386fbsd_trapframe_prev_register (struct frame_info *this_frame, static int i386fbsd_trapframe_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, - void **this_prologue_cache) + frame_info_ptr this_frame, + void **this_prologue_cache) { const char *name; @@ -442,6 +430,7 @@ i386fbsd_trapframe_sniffer (const struct frame_unwind *self, } static const struct frame_unwind i386fbsd_trapframe_unwind = { + "i386 FreeBSD kernel trap", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, i386fbsd_trapframe_this_id, @@ -461,14 +450,15 @@ i386fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) #endif frame_unwind_prepend_unwinder(gdbarch, &i386fbsd_trapframe_unwind); - set_solib_ops(gdbarch, &kld_so_ops); + set_gdbarch_so_ops(gdbarch, &kld_so_ops); fbsd_vmcore_set_supply_pcb(gdbarch, i386fbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); } +void _initialize_i386_kgdb_tdep (); void -_initialize_i386_kgdb_tdep(void) +_initialize_i386_kgdb_tdep () { /* This is used for both i386 and amd64, but amd64 always includes this target, so just include it here. */ @@ -478,9 +468,6 @@ _initialize_i386_kgdb_tdep(void) gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD_KERNEL, i386fbsd_kernel_init_abi); - i386fbsd_pspace_data = register_program_space_data_with_cleanup (NULL, - i386fbsd_pspace_data_cleanup); - #ifdef __i386__ /* * FreeBSD/i386 kernels prior to the introduction of AVX diff --git a/devel/gdb/files/kgdb/kgdb-main.c b/devel/gdb/files/kgdb/kgdb-main.c index e75c82e9..22a21902 100644 --- a/devel/gdb/files/kgdb/kgdb-main.c +++ b/devel/gdb/files/kgdb/kgdb-main.c @@ -24,9 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/kgdb-main.c 480613 2018-09-24 17:23:35Z jhb $"); - #include #include #include @@ -50,6 +47,7 @@ __FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/kgdb-main.c 480613 2018-09-24 17:2 #include #include #include +#include "serial.h" #include #include #include diff --git a/devel/gdb/files/kgdb/kgdb.1 b/devel/gdb/files/kgdb/kgdb.1 index 09209bf6..a338a777 100644 --- a/devel/gdb/files/kgdb/kgdb.1 +++ b/devel/gdb/files/kgdb/kgdb.1 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: head/devel/gdb/files/kgdb/kgdb.1 440447 2017-05-08 19:02:25Z jhb $ -.\" .Dd October 11, 2006 .Dt KGDB 1 .Os diff --git a/devel/gdb/files/kgdb/kgdb.h b/devel/gdb/files/kgdb/kgdb.h index 6f87418e..772e33d4 100644 --- a/devel/gdb/files/kgdb/kgdb.h +++ b/devel/gdb/files/kgdb/kgdb.h @@ -22,8 +22,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: head/devel/gdb/files/kgdb/kgdb.h 480613 2018-09-24 17:23:35Z jhb $ */ #ifndef _KGDB_H_ diff --git a/devel/gdb/files/kgdb/mipsfbsd-kern.c b/devel/gdb/files/kgdb/mipsfbsd-kern.c index 80d1527c..761c969d 100644 --- a/devel/gdb/files/kgdb/mipsfbsd-kern.c +++ b/devel/gdb/files/kgdb/mipsfbsd-kern.c @@ -23,13 +23,8 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * from: src/gnu/usr.bin/gdb/kgdb/trgt_alpha.c,v 1.2.2.1 2005/09/15 05:32:10 marcel */ -#include -__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/trgt_mips.c 249878 2013-04-25 04:53:01Z imp $"); - #include "defs.h" #include "frame-unwind.h" #include "osabi.h" @@ -129,7 +124,7 @@ mipsfbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) } static struct trad_frame_cache * -mipsfbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) +mipsfbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); size_t regsize = mips_isa_regsize (gdbarch); @@ -208,7 +203,7 @@ mipsfbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) } static void -mipsfbsd_trapframe_this_id (struct frame_info *this_frame, +mipsfbsd_trapframe_this_id (frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = @@ -218,7 +213,7 @@ mipsfbsd_trapframe_this_id (struct frame_info *this_frame, } static struct value * -mipsfbsd_trapframe_prev_register (struct frame_info *this_frame, +mipsfbsd_trapframe_prev_register (frame_info_ptr this_frame, void **this_cache, int regnum) { struct trad_frame_cache *cache = @@ -229,7 +224,7 @@ mipsfbsd_trapframe_prev_register (struct frame_info *this_frame, static int mipsfbsd_trapframe_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, + frame_info_ptr this_frame, void **this_prologue_cache) { const char *name; @@ -241,6 +236,7 @@ mipsfbsd_trapframe_sniffer (const struct frame_unwind *self, } static const struct frame_unwind mipsfbsd_trapframe_unwind = { + "mips FreeBSD kernel trap", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, mipsfbsd_trapframe_this_id, @@ -262,32 +258,25 @@ mipsfbsd_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) break; case MIPS_ABI_N32: set_gdbarch_long_double_bit (gdbarch, 128); - /* These floatformats should probably be renamed. MIPS uses - the same 128-bit IEEE floating point format that IA-64 uses, - except that the quiet/signalling NaN bit is reversed (GDB - does not distinguish between quiet and signalling NaNs). */ - set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); + set_gdbarch_long_double_format (gdbarch, floatformats_ieee_quad); break; case MIPS_ABI_N64: set_gdbarch_long_double_bit (gdbarch, 128); - /* These floatformats should probably be renamed. MIPS uses - the same 128-bit IEEE floating point format that IA-64 uses, - except that the quiet/signalling NaN bit is reversed (GDB - does not distinguish between quiet and signalling NaNs). */ - set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad); + set_gdbarch_long_double_format (gdbarch, floatformats_ieee_quad); break; } frame_unwind_prepend_unwinder (gdbarch, &mipsfbsd_trapframe_unwind); - set_solib_ops (gdbarch, &kld_so_ops); + set_gdbarch_so_ops (gdbarch, &kld_so_ops); fbsd_vmcore_set_supply_pcb (gdbarch, mipsfbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr (gdbarch, kgdb_trgt_stop_pcb); } +void _initialize_mips_kgdb_tdep (); void -_initialize_mips_kgdb_tdep (void) +_initialize_mips_kgdb_tdep () { gdbarch_register_osabi_sniffer(bfd_arch_mips, bfd_target_elf_flavour, diff --git a/devel/gdb/files/kgdb/ppcfbsd-kern.c b/devel/gdb/files/kgdb/ppcfbsd-kern.c index 0a3ad866..fa04f776 100644 --- a/devel/gdb/files/kgdb/ppcfbsd-kern.c +++ b/devel/gdb/files/kgdb/ppcfbsd-kern.c @@ -24,9 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/ppcfbsd-kern.c 503200 2019-06-01 00:44:08Z jhb $"); - #include "defs.h" #include "frame-unwind.h" #include "gdbcore.h" @@ -45,39 +42,55 @@ __FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/ppcfbsd-kern.c 503200 2019-06-01 0 #include "kgdb.h" +#define PCB_OFF_R12 0 +#define PCB_OFF_CR 20 +#define PCB_OFF_SP 21 +#define PCB_OFF_TOC 22 +#define PCB_OFF_LR 23 + #ifdef __powerpc__ +_Static_assert(offsetof(struct pcb, pcb_context) + == PCB_OFF_R12 * sizeof(register_t), "r12 offset"); +_Static_assert(offsetof(struct pcb, pcb_cr) == PCB_OFF_CR * sizeof(register_t), + "cr offset"); +_Static_assert(offsetof(struct pcb, pcb_sp) == PCB_OFF_SP * sizeof(register_t), + "sp offset"); +_Static_assert(offsetof(struct pcb, pcb_toc) == PCB_OFF_TOC * sizeof(register_t), + "toc offset"); +_Static_assert(offsetof(struct pcb, pcb_lr) == PCB_OFF_LR * sizeof(register_t), + "lr offset"); +#endif + static void ppcfbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) { - struct pcb pcb; - struct gdbarch_tdep *tdep; - int i; - - tdep = gdbarch_tdep (regcache->arch ()); - - if (target_read_memory(pcb_addr, (gdb_byte *)&pcb, sizeof(pcb)) != 0) - memset(&pcb, 0, sizeof(pcb)); - - /* - * r14-r31 are saved in the pcb - */ - for (i = 14; i <= 31; i++) { - regcache->raw_supply(tdep->ppc_gp0_regnum + i, - (char *)&pcb.pcb_context[i]); - } - - /* r1 is saved in the sp field */ - regcache->raw_supply(tdep->ppc_gp0_regnum + 1, - (char *)&pcb.pcb_sp); - if (tdep->wordsize == 8) - /* r2 is saved in the toc field */ - regcache->raw_supply(tdep->ppc_gp0_regnum + 2, - (char *)&pcb.pcb_toc); - - regcache->raw_supply(tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr); - regcache->raw_supply(tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr); + ppc_gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + gdb_byte buf[24 * tdep->wordsize]; + int i; + + /* Always give a value for PC in case the PCB isn't readable. */ + regcache->raw_supply_zeroed (PPC_PC_REGNUM); + if (target_read_memory (pcb_addr, buf, sizeof buf) != 0) + return; + + /* r12 - r31 */ + for (i = 0; i < 20; i++) + regcache->raw_supply (tdep->ppc_gp0_regnum + 12 + i, + buf + tdep->wordsize * i); + + /* r1 is saved in the sp field */ + regcache->raw_supply (tdep->ppc_gp0_regnum + 1, + buf + tdep->wordsize * PCB_OFF_SP); + + if (tdep->wordsize == 8) + /* r2 is saved in the toc field */ + regcache->raw_supply (tdep->ppc_gp0_regnum + 2, + buf + tdep->wordsize * PCB_OFF_TOC); + + regcache->raw_supply (tdep->ppc_lr_regnum, buf + tdep->wordsize * PCB_OFF_LR); + regcache->raw_supply (PPC_PC_REGNUM, buf + tdep->wordsize * PCB_OFF_LR); + regcache->raw_supply (tdep->ppc_cr_regnum, buf + tdep->wordsize * PCB_OFF_CR); } -#endif #define OFF_FIXREG 0 #define OFF_LR 32 @@ -105,10 +118,10 @@ _Static_assert(offsetof(struct trapframe, srr0) #endif static struct trad_frame_cache * -ppcfbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) +ppcfbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); struct trad_frame_cache *cache; CORE_ADDR base; int i; @@ -142,13 +155,13 @@ ppcfbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) /* Construct the frame ID using the function start. */ trad_frame_set_id (cache, frame_id_build (base, get_frame_func (this_frame))); - + return cache; } static void -ppcfbsd_trapframe_this_id (struct frame_info *this_frame, - void **this_cache, struct frame_id *this_id) +ppcfbsd_trapframe_this_id (frame_info_ptr this_frame, + void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = ppcfbsd_trapframe_cache (this_frame, this_cache); @@ -157,8 +170,8 @@ ppcfbsd_trapframe_this_id (struct frame_info *this_frame, } static struct value * -ppcfbsd_trapframe_prev_register (struct frame_info *this_frame, - void **this_cache, int regnum) +ppcfbsd_trapframe_prev_register (frame_info_ptr this_frame, + void **this_cache, int regnum) { struct trad_frame_cache *cache = ppcfbsd_trapframe_cache (this_frame, this_cache); @@ -168,16 +181,17 @@ ppcfbsd_trapframe_prev_register (struct frame_info *this_frame, static int ppcfbsd_trapframe_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, - void **this_cache) + frame_info_ptr this_frame, + void **this_cache) { CORE_ADDR pc; const char *name; pc = get_frame_func (this_frame); find_pc_partial_function (pc, &name, NULL, NULL); - if (name && (strcmp(name, "asttrapexit") == 0 - || strcmp(name, "trapexit") == 0)) + if (name && (strcmp(name, "trapagain") == 0 + || strcmp(name, "trapexit") == 0 + || strcmp(name, "dbtrap") == 0)) return 1; return 0; @@ -185,6 +199,7 @@ ppcfbsd_trapframe_sniffer (const struct frame_unwind *self, static const struct frame_unwind ppcfbsd_trapframe_unwind = { + "ppc FreeBSD kernel trap", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, ppcfbsd_trapframe_this_id, @@ -196,19 +211,14 @@ static const struct frame_unwind ppcfbsd_trapframe_unwind = static void ppcfbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); frame_unwind_prepend_unwinder(gdbarch, &ppcfbsd_trapframe_unwind); - set_solib_ops(gdbarch, &kld_so_ops); + set_gdbarch_so_ops(gdbarch, &kld_so_ops); -#ifdef __powerpc__ - if (tdep->wordsize == sizeof(register_t)) - { - fbsd_vmcore_set_supply_pcb(gdbarch, ppcfbsd_supply_pcb); - fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); - } -#endif + fbsd_vmcore_set_supply_pcb(gdbarch, ppcfbsd_supply_pcb); + fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); /* FreeBSD doesn't support the 128-bit `long double' from the psABI. */ set_gdbarch_long_double_bit (gdbarch, 64); @@ -228,8 +238,9 @@ ppcfbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) } } +void _initialize_ppc_kgdb_tdep (); void -_initialize_ppc_kgdb_tdep(void) +_initialize_ppc_kgdb_tdep () { gdbarch_register_osabi_sniffer(bfd_arch_powerpc, bfd_target_elf_flavour, diff --git a/devel/gdb/files/kgdb/riscv-fbsd-kern.c b/devel/gdb/files/kgdb/riscv-fbsd-kern.c index 8df24bd7..2e77e48a 100644 --- a/devel/gdb/files/kgdb/riscv-fbsd-kern.c +++ b/devel/gdb/files/kgdb/riscv-fbsd-kern.c @@ -22,8 +22,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: head/devel/gdb/files/kgdb/riscv-fbsd-kern.c 503200 2019-06-01 00:44:08Z jhb $ */ /* Target-dependent code for FreeBSD/riscv64 kernels. */ @@ -32,6 +30,7 @@ #include "riscv-tdep.h" #include "frame-unwind.h" +#include "gdbarch.h" #include "gdbcore.h" #include "osabi.h" #include "regcache.h" @@ -48,11 +47,8 @@ static const struct regcache_map_entry riscv_fbsd_pcbmap[] = { 1, RISCV_SP_REGNUM, 0 }, { 1, RISCV_GP_REGNUM, 0 }, { 1, RISCV_TP_REGNUM, 0 }, - { 3, 5, 0 }, /* t0 - t2 */ - { 4, 28, 0 }, /* t3 - t6 */ { 2, RISCV_FP_REGNUM, 0 }, /* s0 - s1 */ { 10, 18, 0 }, /* s2 - s11 */ - { 8, RISCV_A0_REGNUM, 0 }, /* a0 - a7 */ { 0 } }; @@ -65,7 +61,7 @@ static const struct regset riscv_fbsd_pcbregset = static void riscv_fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) { - gdb_byte buf[31 * 8]; + gdb_byte buf[16 * riscv_abi_xlen (regcache->arch ())]; /* Always give a value for PC in case the PCB isn't readable. */ regcache->raw_supply_zeroed (RISCV_PC_REGNUM); @@ -100,7 +96,7 @@ static const struct regcache_map_entry riscv_fbsd_tfmap[] = }; static struct trad_frame_cache * -riscv_fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) +riscv_fbsd_trapframe_cache (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); @@ -140,8 +136,8 @@ riscv_fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) } static void -riscv_fbsd_trapframe_this_id (struct frame_info *this_frame, - void **this_cache, struct frame_id *this_id) +riscv_fbsd_trapframe_this_id (frame_info_ptr this_frame, + void **this_cache, struct frame_id *this_id) { struct trad_frame_cache *cache = riscv_fbsd_trapframe_cache (this_frame, this_cache); @@ -150,8 +146,8 @@ riscv_fbsd_trapframe_this_id (struct frame_info *this_frame, } static struct value * -riscv_fbsd_trapframe_prev_register (struct frame_info *this_frame, - void **this_cache, int regnum) +riscv_fbsd_trapframe_prev_register (frame_info_ptr this_frame, + void **this_cache, int regnum) { struct trad_frame_cache *cache = riscv_fbsd_trapframe_cache (this_frame, this_cache); @@ -161,8 +157,8 @@ riscv_fbsd_trapframe_prev_register (struct frame_info *this_frame, static int riscv_fbsd_trapframe_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, - void **this_prologue_cache) + frame_info_ptr this_frame, + void **this_prologue_cache) { const char *name; @@ -173,6 +169,7 @@ riscv_fbsd_trapframe_sniffer (const struct frame_unwind *self, } static const struct frame_unwind riscv_fbsd_trapframe_unwind = { + "riscv FreeBSD kernel trap", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, riscv_fbsd_trapframe_this_id, @@ -188,7 +185,7 @@ riscv_fbsd_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { frame_unwind_prepend_unwinder (gdbarch, &riscv_fbsd_trapframe_unwind); - set_solib_ops (gdbarch, &kld_so_ops); + set_gdbarch_so_ops (gdbarch, &kld_so_ops); set_gdbarch_software_single_step (gdbarch, riscv_software_single_step); @@ -196,11 +193,9 @@ riscv_fbsd_kernel_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) fbsd_vmcore_set_cpu_pcb_addr (gdbarch, kgdb_trgt_stop_pcb); } -/* Provide a prototype to silence -Wmissing-prototypes. */ -extern initialize_file_ftype _initialize_riscv_kgdb_tdep; - +void _initialize_riscv_kgdb_tdep (); void -_initialize_riscv_kgdb_tdep (void) +_initialize_riscv_kgdb_tdep () { gdbarch_register_osabi_sniffer(bfd_arch_riscv, bfd_target_elf_flavour, diff --git a/devel/gdb/files/kgdb/sparc64fbsd-kern.c b/devel/gdb/files/kgdb/sparc64fbsd-kern.c index 3ce94352..115c934a 100644 --- a/devel/gdb/files/kgdb/sparc64fbsd-kern.c +++ b/devel/gdb/files/kgdb/sparc64fbsd-kern.c @@ -24,10 +24,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/devel/gdb/files/kgdb/sparc64fbsd-kern.c 464493 2018-03-14 14:33:21Z pizzamig $"); - #include "defs.h" +#include "gdbarch.h" #include "gdbcore.h" #include "osabi.h" #include "regcache.h" @@ -81,7 +79,7 @@ _Static_assert(offsetof(struct trapframe, tf_out) == OFF_TF_OUT, #endif static struct sparc_frame_cache * -sparc64fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) +sparc64fbsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache) { struct sparc_frame_cache *cache; CORE_ADDR fp, sp, trapframe_addr; @@ -99,24 +97,25 @@ sparc64fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache) cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); - cache->saved_regs[SPARC_SP_REGNUM].addr = trapframe_addr + OFF_TF_SP; + cache->saved_regs[SPARC_SP_REGNUM].set_addr (trapframe_addr + OFF_TF_SP); #ifdef notyet - cache->saved_regs[SPARC64_STATE_REGNUM].addr = trapframe_addr + OFF_TF_TSTATE; + cache->saved_regs[SPARC64_STATE_REGNUM].set_addr (trapframe_addr + + OFF_TF_TSTATE); #endif - cache->saved_regs[SPARC64_PC_REGNUM].addr = trapframe_addr + OFF_TF_TPC; - cache->saved_regs[SPARC64_NPC_REGNUM].addr = trapframe_addr + OFF_TF_TNPC; + cache->saved_regs[SPARC64_PC_REGNUM].set_addr (trapframe_addr + OFF_TF_TPC); + cache->saved_regs[SPARC64_NPC_REGNUM].set_addr (trapframe_addr + OFF_TF_TNPC); for (regnum = SPARC_O0_REGNUM; regnum <= SPARC_O7_REGNUM; regnum++) - cache->saved_regs[regnum].addr = - trapframe_addr + OFF_TF_OUT + (regnum - SPARC_O0_REGNUM) * 8; + cache->saved_regs[regnum].set_addr (trapframe_addr + OFF_TF_OUT + + (regnum - SPARC_O0_REGNUM) * 8); for (regnum = SPARC_L0_REGNUM; regnum <= SPARC_I7_REGNUM; regnum++) - cache->saved_regs[regnum].addr = - sp + BIAS + (regnum - SPARC_L0_REGNUM) * 8; + cache->saved_regs[regnum].set_addr (sp + BIAS + + (regnum - SPARC_L0_REGNUM) * 8); return cache; } static void -sparc64fbsd_trapframe_this_id (struct frame_info *this_frame, +sparc64fbsd_trapframe_this_id (frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id) { struct sparc_frame_cache *cache = @@ -126,7 +125,7 @@ sparc64fbsd_trapframe_this_id (struct frame_info *this_frame, } static struct value * -sparc64fbsd_trapframe_prev_register (struct frame_info *this_frame, +sparc64fbsd_trapframe_prev_register (frame_info_ptr this_frame, void **this_cache, int regnum) { struct sparc_frame_cache *cache = @@ -137,7 +136,7 @@ sparc64fbsd_trapframe_prev_register (struct frame_info *this_frame, static int sparc64fbsd_trapframe_sniffer (const struct frame_unwind *self, - struct frame_info *this_frame, + frame_info_ptr this_frame, void **this_cache) { CORE_ADDR pc; @@ -156,6 +155,7 @@ sparc64fbsd_trapframe_sniffer (const struct frame_unwind *self, static const struct frame_unwind sparc64fbsd_trapframe_unwind = { + "sparc64 FreeBSD kernel trap", SIGTRAMP_FRAME, default_frame_unwind_stop_reason, sparc64fbsd_trapframe_this_id, @@ -294,7 +294,7 @@ sparc64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) frame_unwind_prepend_unwinder(gdbarch, &sparc64fbsd_trapframe_unwind); - set_solib_ops(gdbarch, &kld_so_ops); + set_gdbarch_so_ops(gdbarch, &kld_so_ops); #ifdef __sparc64__ fbsd_vmcore_set_supply_pcb(gdbarch, sparc64fbsd_supply_pcb); @@ -302,8 +302,9 @@ sparc64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) #endif } +void _initialize_sparc64_kgdb_tdep (); void -_initialize_sparc64_kgdb_tdep(void) +_initialize_sparc64_kgdb_tdep () { gdbarch_register_osabi_sniffer(bfd_arch_sparc, bfd_target_elf_flavour, diff --git a/devel/gdb/files/patch-fixes b/devel/gdb/files/patch-fixes deleted file mode 100644 index 1d7714c9..00000000 --- a/devel/gdb/files/patch-fixes +++ /dev/null @@ -1,10 +0,0 @@ ---- gdb/compile/compile-loc2c.c.orig 2019-02-26 20:51:50.000000000 -0800 -+++ gdb/compile/compile-loc2c.c 2019-05-24 16:07:42.382379000 -0700 -@@ -657,6 +657,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *s - uint64_t uoffset, reg; - int64_t offset; - -+ uoffset = 0; - print_spaces (indent - 2, stream); - if (info[op_ptr - base].label) - { diff --git a/devel/gdb/files/patch-gdb_amd64-bsd-nat.c b/devel/gdb/files/patch-gdb_amd64-bsd-nat.c deleted file mode 100644 index 1f16ba31..00000000 --- a/devel/gdb/files/patch-gdb_amd64-bsd-nat.c +++ /dev/null @@ -1,30 +0,0 @@ ---- gdb/amd64-bsd-nat.c.orig 2017-09-14 09:28:17 UTC -+++ gdb/amd64-bsd-nat.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - - #include "amd64-tdep.h" - #include "amd64-nat.h" -@@ -95,12 +96,19 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, - if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum)) - { - struct reg regs; -+ register_t old_rflags; - - if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) - perror_with_name (_("Couldn't get registers")); - -+ old_rflags = regs.r_rflags; - amd64_collect_native_gregset (regcache, ®s, regnum); - -+ /* This is a workaround about the PSL_USERCHANGE posix limitation. */ -+ if ((regs.r_rflags ^ old_rflags ) & ~PSL_USERCHANGE) -+ { -+ regs.r_rflags ^= (regs.r_rflags ^ old_rflags ) & ~PSL_USERCHANGE; -+ } - if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) - perror_with_name (_("Couldn't write registers")); - diff --git a/devel/gdb/files/patch-gdb_configure b/devel/gdb/files/patch-gdb_configure deleted file mode 100644 index 86fde3bb..00000000 --- a/devel/gdb/files/patch-gdb_configure +++ /dev/null @@ -1,16 +0,0 @@ ---- gdb/configure.orig 2019-05-11 11:19:02.000000000 -0700 -+++ gdb/configure 2019-05-24 16:21:50.559870000 -0700 -@@ -15511,10 +15511,10 @@ fi - - # The options we'll try to enable. - build_warnings="-Wall -Wpointer-arith \ ---Wno-unused -Wunused-value -Wunused-variable -Wunused-function \ -+-Wno-unused \ - -Wno-switch -Wno-char-subscripts \ ---Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable \ ---Wno-sign-compare -Wno-error=maybe-uninitialized \ -+-Wempty-body \ -+-Wno-sign-compare \ - -Wno-mismatched-tags \ - -Wno-error=deprecated-register \ - -Wsuggest-override \ diff --git a/devel/gdb/files/patch-gdb_common_common-defs.h b/devel/gdb/files/patch-gdb_gdbsupport_common-defs.h similarity index 53% rename from devel/gdb/files/patch-gdb_common_common-defs.h rename to devel/gdb/files/patch-gdb_gdbsupport_common-defs.h index 6d19eeb0..475c8bfa 100644 --- a/devel/gdb/files/patch-gdb_common_common-defs.h +++ b/devel/gdb/files/patch-gdb_gdbsupport_common-defs.h @@ -1,6 +1,6 @@ ---- gdb/common/common-defs.h.orig 2017-09-12 12:25:12 UTC -+++ gdb/common/common-defs.h -@@ -44,9 +44,15 @@ +--- gdbsupport/common-defs.h.orig 2020-02-08 04:50:14.000000000 -0800 ++++ gdbsupport/common-defs.h 2020-02-27 10:06:21.899297000 -0800 +@@ -55,9 +55,15 @@ Must do this before including any system header, since other system headers may include stdint.h/inttypes.h. */ @@ -14,5 +14,5 @@ #define __STDC_FORMAT_MACROS 1 +#endif - #include - #include + /* Some distros enable _FORTIFY_SOURCE by default, which on occasion + has caused build failures with -Wunused-result when a patch is diff --git a/devel/gdb/files/patch-gdb_gnulib_import_stddef.in.h b/devel/gdb/files/patch-gdb_gnulib_import_stddef.in.h deleted file mode 100644 index 5cc0aca5..00000000 --- a/devel/gdb/files/patch-gdb_gnulib_import_stddef.in.h +++ /dev/null @@ -1,11 +0,0 @@ ---- gdb/gnulib/import/stddef.in.h.orig 2017-09-14 09:28:17 UTC -+++ gdb/gnulib/import/stddef.in.h -@@ -84,7 +84,7 @@ - /* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is - a hack in case the configure-time test was done with g++ even though - we are currently compiling with gcc. */ --#if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T) -+#if 0 - /* On the x86, the maximum storage alignment of double, long, etc. is 4, - but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8, - and the C11 standard allows this. Work around this problem by diff --git a/devel/gdb/files/patch-gdb_i386-fbsd-nat.c b/devel/gdb/files/patch-gdb_i386-fbsd-nat.c index bba42ea4..e037c13f 100644 --- a/devel/gdb/files/patch-gdb_i386-fbsd-nat.c +++ b/devel/gdb/files/patch-gdb_i386-fbsd-nat.c @@ -1,23 +1,23 @@ ---- gdb/i386-fbsd-nat.c 2017-09-14 09:28:17 UTC -+++ gdb/i386-fbsd-nat.c -@@ -43,8 +43,6 @@ public: - const struct target_desc *read_description () override; - #endif +--- gdb/i386-fbsd-nat.c.orig 2022-05-02 12:03:48.925048000 -0700 ++++ gdb/i386-fbsd-nat.c 2022-05-02 12:04:43.474983000 -0700 +@@ -41,8 +41,6 @@ class i386_fbsd_nat_target final : public x86_fbsd_nat + void store_registers (struct regcache *, int) override; -- void resume (ptid_t, int, enum gdb_signal) override; + const struct target_desc *read_description () override; - - #if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO) - bool supports_stopped_by_hw_breakpoint () override; - #endif -@@ -52,6 +50,7 @@ public: +- void resume (ptid_t, int, enum gdb_signal) override; + }; static i386_fbsd_nat_target the_i386_fbsd_nat_target; +@@ -227,6 +225,7 @@ i386_fbsd_nat_target::store_registers (struct regcache + perror_with_name (_("Couldn't write floating point status")); + } +#if 0 /* Resume execution of the inferior process. If STEP is nonzero, single-step it. If SIGNAL is nonzero, give it that signal. */ -@@ -98,6 +97,7 @@ i386_fbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal) +@@ -273,6 +272,7 @@ i386_fbsd_nat_target::resume (ptid_t ptid, int step, e gdb_signal_to_host (signal)) == -1) perror_with_name (("ptrace")); } diff --git a/devel/gdb/files/patch-gdb_inflow.c b/devel/gdb/files/patch-gdb_inflow.c new file mode 100644 index 00000000..ffac898e --- /dev/null +++ b/devel/gdb/files/patch-gdb_inflow.c @@ -0,0 +1,14 @@ +--- gdb/inflow.c.orig 2021-07-03 10:52:57.144161000 +0200 ++++ gdb/inflow.c 2021-07-03 10:55:06.776399000 +0200 +@@ -881,7 +881,10 @@ + pass_signal (int signo) + { + #ifndef _WIN32 +- kill (inferior_ptid.pid (), SIGINT); ++ if (inferior_ptid.pid () ) ++ kill (inferior_ptid.pid (), SIGINT); ++ else ++ kill (current_inferior ()->pid, SIGINT); + #endif + } + diff --git a/devel/gdb/files/patch-gdb_python_python-config.py b/devel/gdb/files/patch-gdb_python_python-config.py index cec2729a..d3bfb30d 100644 --- a/devel/gdb/files/patch-gdb_python_python-config.py +++ b/devel/gdb/files/patch-gdb_python_python-config.py @@ -1,11 +1,11 @@ ---- gdb/python/python-config.py 2017-09-14 09:28:17 UTC -+++ gdb/python/python-config.py -@@ -59,6 +59,8 @@ for opt in opt_flags: +--- gdb/python/python-config.py.orig 2021-07-03 10:41:10.000000000 -0700 ++++ gdb/python/python-config.py 2021-09-16 14:01:52.807472000 -0700 +@@ -65,6 +65,8 @@ for opt in opt_flags: - elif opt in ('--libs', '--ldflags'): - libs = ['-lpython' + pyver + abiflags] + elif opt in ("--libs", "--ldflags"): + libs = ["-lpython" + pyver + abiflags] + if getvar('LDFLAGS') is not None: + libs.extend(getvar('LDFLAGS').split()) - if getvar('LIBS') is not None: - libs.extend(getvar('LIBS').split()) - if getvar('SYSLIBS') is not None: + if getvar("LIBS") is not None: + libs.extend(getvar("LIBS").split()) + if getvar("SYSLIBS") is not None: diff --git a/devel/gdb/files/patch-gnulib_import_stddef.in.h b/devel/gdb/files/patch-gnulib_import_stddef.in.h new file mode 100644 index 00000000..b5d867ac --- /dev/null +++ b/devel/gdb/files/patch-gnulib_import_stddef.in.h @@ -0,0 +1,11 @@ +--- gnulib/import/stddef.in.h.orig 2023-02-01 20:45:52.000000000 -0800 ++++ gnulib/import/stddef.in.h 2023-02-24 09:49:57.368290000 -0800 +@@ -116,7 +116,7 @@ + && defined __cplusplus + # include + #else +-# if ! (@HAVE_MAX_ALIGN_T@ || (defined _GCC_MAX_ALIGN_T && !defined __clang__)) ++# if 0 + # if !GNULIB_defined_max_align_t + /* On the x86, the maximum storage alignment of double, long, etc. is 4, + but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8, diff --git a/devel/gdb/files/patch-include_libiberty.h b/devel/gdb/files/patch-include_libiberty.h deleted file mode 100644 index 26afe105..00000000 --- a/devel/gdb/files/patch-include_libiberty.h +++ /dev/null @@ -1,11 +0,0 @@ ---- include/libiberty.h 2017-09-14 09:28:17 UTC -+++ include/libiberty.h -@@ -109,7 +109,7 @@ - || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) \ - || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) \ - || defined (__DragonFly__) || defined (HAVE_DECL_BASENAME) --extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1); -+#include - #else - /* Do not allow basename to be used if there is no prototype seen. We - either need to use the above prototype or have one from diff --git a/devel/gdb/files/patch-libiberty_configure b/devel/gdb/files/patch-libiberty_configure deleted file mode 100644 index fb52c901..00000000 --- a/devel/gdb/files/patch-libiberty_configure +++ /dev/null @@ -1,12 +0,0 @@ ---- libiberty/configure.orig 2017-09-12 12:10:11 UTC -+++ libiberty/configure -@@ -4398,8 +4398,7 @@ - ac_libiberty_warn_cflags= - save_CFLAGS="$CFLAGS" - for real_option in -W -Wall -Wwrite-strings -Wc++-compat \ -- -Wstrict-prototypes \ -- -Wshadow=local; do -+ -Wstrict-prototypes ; do - # Do the check with the no- prefix removed since gcc silently - # accepts any -Wno-* option on purpose - case $real_option in diff --git a/devel/gdb/pkg-plist b/devel/gdb/pkg-plist index 923e55e3..71cf3fb5 100644 --- a/devel/gdb/pkg-plist +++ b/devel/gdb/pkg-plist @@ -9,6 +9,7 @@ share/gdb/syscalls/i386-linux.xml share/gdb/syscalls/mips-n32-linux.xml share/gdb/syscalls/mips-n64-linux.xml share/gdb/syscalls/mips-o32-linux.xml +share/gdb/syscalls/netbsd.xml share/gdb/syscalls/ppc-linux.xml share/gdb/syscalls/ppc64-linux.xml share/gdb/syscalls/s390-linux.xml diff --git a/media/libv4l/Makefile b/media/libv4l/Makefile index 8a27c47a..50a02329 100644 --- a/media/libv4l/Makefile +++ b/media/libv4l/Makefile @@ -15,6 +15,8 @@ COMMENT?= Video4Linux library USES= tar:bzip2 WRKSRC= ${WRKDIR}/v4l-utils-${PORTVERSION} +USES+= compiler:c11 + GNU_CONFIGURE= yes CPPFLAGS+= -I${LOCALBASE}/include -I${WRKSRC}/include LDFLAGS+= -L${LOCALBASE}/lib @@ -22,7 +24,7 @@ USES+= gmake pkgconfig USE_LDCONFIG= yes CONFIGURE_ARGS= --enable-libdvbv5 \ --disable-qv4l2 \ - --without-libudev + --without-libudev --with-gnu-ld INSTALL_TARGET= install-strip CONFIGURE_ARGS+=--disable-v4l-utils --enable-libv4l diff --git a/media/libv4l/files/patch-x-lib-libdvbv5-dvb-v5.h b/media/libv4l/files/patch-x-lib-libdvbv5-dvb-v5.h new file mode 100644 index 00000000..da2d2ef0 --- /dev/null +++ b/media/libv4l/files/patch-x-lib-libdvbv5-dvb-v5.h @@ -0,0 +1,36 @@ +--- ./lib/libdvbv5/dvb-v5.h.orig 2024-01-07 22:46:34.945012000 +0200 ++++ ./lib/libdvbv5/dvb-v5.h 2024-01-07 22:53:39.034516000 +0200 +@@ -14,17 +14,20 @@ + char *name; + }; + extern struct fe_status_name fe_status_name[7]; +-const char *fe_code_rate_name[14]; +-const char *fe_modulation_name[15]; +-const char *fe_transmission_mode_name[10]; +-const unsigned fe_bandwidth_name[8]; +-const char *fe_guard_interval_name[12]; +-const char *fe_hierarchy_name[6]; +-const char *fe_voltage_name[4]; +-const char *fe_tone_name[3]; +-const char *fe_inversion_name[4]; +-const char *fe_pilot_name[4]; +-const char *fe_rolloff_name[5]; +-const char *dvb_v5_name[71]; +-const char *delivery_system_name[20]; ++ ++extern const char *fe_code_rate_name[14]; ++extern const char *fe_modulation_name[15]; ++extern const char *fe_transmission_mode_name[10]; ++extern const unsigned fe_bandwidth_name[8]; ++extern const char *fe_guard_interval_name[12]; ++extern const char *fe_hierarchy_name[6]; ++extern const char *fe_voltage_name[4]; ++extern const char *fe_tone_name[3]; ++extern const char *fe_inversion_name[4]; ++extern const char *fe_pilot_name[4]; ++extern const char *fe_rolloff_name[5]; ++extern const char *dvb_v5_name[71]; ++extern const char *delivery_system_name[20]; ++ ++ + #endif diff --git a/system/dpkg/Makefile b/system/dpkg/Makefile index bb431d0c..f235cf3b 100644 --- a/system/dpkg/Makefile +++ b/system/dpkg/Makefile @@ -2,7 +2,7 @@ # #$id$ # PORTNAME= dpkg -PORTVERSION= 1.19.6 #1.18.10 +PORTVERSION= 1.19.8 #1.18.10 CATEGORIES= archivers sysutils MASTER_SITES= DEBIAN_POOL DISTNAME= dpkg_${PORTVERSION} @@ -14,6 +14,7 @@ COMMENT= Debian package maintenance system RUN_DEPENDS+= gtar:arch/gtar RUN_DEPENDS+= gpatch:text/gpatch +USE_CXXSTD= c++14 GNU_CONFIGURE= yes USES= gmake perl5 pkgconfig tar:xz shebangfix CPE_VENDOR= debian diff --git a/system/dpkg/distinfo b/system/dpkg/distinfo index 1018416f..736da49b 100644 --- a/system/dpkg/distinfo +++ b/system/dpkg/distinfo @@ -1,2 +1,3 @@ -SHA256 (dpkg_1.19.6.tar.xz) = 4eb1a12d1f5bd55478d2eab530dd188733e425f301e3b8c030f645f48ef43768 -SIZE (dpkg_1.19.6.tar.xz) = 4802832 +TIMESTAMP = 1704653980 +SHA256 (dpkg_1.19.8.tar.xz) = 2632c00b0cf0ea19ed7bd6700e6ec5faca93f0045af629d356dc03ad74ae6f10 +SIZE (dpkg_1.19.8.tar.xz) = 4701260