binutils-gdb.git
12 months agoregen config
Alan Modra [Fri, 11 Aug 2023 23:51:31 +0000 (09:21 +0930)]
regen config

This regenerates config files changed by the previous 44 commits.
Note that subject lines in these commits mostly match the gcc git
originating commit.

12 months agotoplevel: Substitute GDCFLAGS instead of using CFLAGS
Arsen Arsenović [Mon, 7 Aug 2023 11:07:48 +0000 (13:07 +0200)]
toplevel: Substitute GDCFLAGS instead of using CFLAGS

r14-2875-g1ed21e23d6d4da ("Use substituted GDCFLAGS") already
implemented this change, but only on the generated file rather than in
the template it is generated from.

* Makefile.tpl: Substitute @GDCFLAGS@ instead of using
$(CFLAGS).

12 months agoUse substituted GDCFLAGS
Andreas Schwab [Mon, 7 Aug 2023 11:07:47 +0000 (13:07 +0200)]
Use substituted GDCFLAGS

Use the substituted value for GCDFLAGS instead of hardcoding $(CFLAGS) so
that the subdir configure scripts use the configured value.

* configure.ac (GDCFLAGS): Set default from ${CFLAGS}.

12 months agogccrs: Add gcc-check-target check-rust
Philip Herron [Mon, 7 Aug 2023 11:07:46 +0000 (13:07 +0200)]
gccrs: Add gcc-check-target check-rust

This allows us to invoke the rust testsuite.

* Makefile.def: Add Rust language.

12 months agoPR bootstrap/106472: Add libgo depends on libbacktrace to Makefile.def
Roger Sayle [Mon, 7 Aug 2023 11:07:45 +0000 (13:07 +0200)]
PR bootstrap/106472: Add libgo depends on libbacktrace to Makefile.def

This patch fixes PR bootstrap/106472 by adding a missing dependency
to Makefile.def to allow make bootstrap when configured using
"--enable-languages=go" (and not using make with multiple threads).

2022-07-31  Roger Sayle  <roger@nextmovesoftware.com>

PR bootstrap/106472
* Makefile.def (dependencies): Make configure-target-libgo depend
upon all-target-libbacktrace.

12 months agoRevert "Fix PR 67102: Add libstdc++ dependancy to libffi" [PR67102]
Thomas Schwinge [Mon, 7 Aug 2023 11:07:44 +0000 (13:07 +0200)]
Revert "Fix PR 67102: Add libstdc++ dependancy to libffi" [PR67102]

12 months agoDisable warnings as errors for STAGEautofeedback.
Eugene Rozenfeld [Mon, 7 Aug 2023 11:07:43 +0000 (13:07 +0200)]
Disable warnings as errors for STAGEautofeedback.

Compilation during STAGEautofeedback produces additional warnings
since inlining decisions with -fauto-profile are different from
other builds.

This patches disables warnings as errors for STAGEautofeedback.

Tested on x86_64-pc-linux-gnu.

* Makefile.tpl: Disable warnings as errors for STAGEautofeedback

12 months agoFix autoprofiledbootstrap build
Eugene Rozenfeld [Mon, 7 Aug 2023 11:07:42 +0000 (13:07 +0200)]
Fix autoprofiledbootstrap build

* Makefile.tpl: Define PROFILE_MERGER

12 months agoFix collection and processing of autoprofile data for target libs
Eugene Rozenfeld [Mon, 7 Aug 2023 11:07:41 +0000 (13:07 +0200)]
Fix collection and processing of autoprofile data for target libs

cc1, cc1plus, and lto  built during STAGEautoprofile need to be built with
debug info since they are used to build target libs. -gtoggle was
turning off debug info for this stage.

create_gcov should be passed prev-gcc/cc1, prev-gcc/cc1plus, and prev-gcc/lto
instead of stage1-gcc/cc1, stage1-gcc/cc1plus, and stage1-gcc/lto when
processing profile data collected while building target libraries.

Tested on x86_64-pc-linux-gnu.

* Makefile.tpl: Remove -gtoggle for STAGEautoprofile

12 months agoCollect both user and kernel events for autofdo tests and autoprofiledbootstrap
Eugene Rozenfeld [Mon, 7 Aug 2023 11:07:40 +0000 (13:07 +0200)]
Collect both user and kernel events for autofdo tests and autoprofiledbootstrap

When we collect just user events for autofdo with lbr we get some events where branch
sources are kernel addresses and branch targets are user addresses. Without kernel MMAP
events create_gcov can't make sense of kernel addresses. Currently create_gcov fails if
it can't map at least 95% of events. We sometimes get below this threshold with just
user events. The change is to collect both user events and kernel events.

Tested on x86_64-pc-linux-gnu.

* Makefile.tpl: Collect both kernel and user events for autofdo

12 months agod: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
Iain Buclaw [Mon, 7 Aug 2023 11:07:39 +0000 (13:07 +0200)]
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)

The D front-end is now itself written in D, in order to build GDC, you
will need a working GDC compiler (GCC version 9.1 or later).

GCC changes:

    - Add support for bootstrapping the D front-end.

These add the required components in order to have a D front-end written
in D itself.  Because the compiler front-end only depends on the core
runtime modules, only libdruntime is built for the bootstrap stages.

D front-end changes:

    - Import dmd v2.098.0-beta.1.

Druntime changes:

    - Import druntime v2.098.0-beta.1.

Phobos changes:

    - Import phobos v2.098.0-beta.1.

The jump from v2.076.1 to v2.098.0 covers nearly 4 years worth of
development on the D programming language and run-time libraries.

* Makefile.def: Add bootstrap to libbacktrace, libphobos, zlib, and
libatomic.
* Makefile.tpl (POSTSTAGE1_HOST_EXPORTS): Fix command for GDC.
(STAGE1_CONFIGURE_FLAGS): Add --with-libphobos-druntime-only if
target-libphobos-bootstrap.
(STAGE2_CONFIGURE_FLAGS): Likewise.

12 months agoMakefile.def: drop remnants of unused libelf
Sergei Trofimovich [Mon, 7 Aug 2023 11:07:38 +0000 (13:07 +0200)]
Makefile.def: drop remnants of unused libelf

Use of libelf was removed from gcc in r0-104274-g48215350c24d52 ("re PR
lto/46273 (Failed to bootstrap)") around 2010, before gcc-4.6.0.

This change removes unused references to libelf from top-level configure
and Makefile.

* Makefile.def: Drop libelf module and gcc-configure dependency
on it.
* Makefile.tpl (HOST_EXPORTS): Drop unused LIBELFLIBS and
LIBELFINC.

12 months agoDo not use HAVE_DOS_BASED_FILE_SYSTEM for Cygwin.
Martin Liska [Mon, 7 Aug 2023 11:07:37 +0000 (13:07 +0200)]
Do not use HAVE_DOS_BASED_FILE_SYSTEM for Cygwin.

PR gcov-profile/94570
* ltmain.sh: Do not define HAVE_DOS_BASED_FILE_SYSTEM
for CYGWIN.

Co-Authored-By: Jonathan Yong <10walls@gmail.com>
12 months agoFDPIC: Handle arm*-*-uclinuxfdpiceabi in configure scripts
Christophe Lyon [Mon, 7 Aug 2023 11:07:36 +0000 (13:07 +0200)]
FDPIC: Handle arm*-*-uclinuxfdpiceabi in configure scripts

In libtool.m4, we use uclinuxfdpiceabi in cases where ELF shared
libraries support is required, as uclinux does not guarantee that.

* libtool.m4: Handle uclinuxfdpiceabi.

12 months agolibtool.m4: Sort output of 'find' to enable deterministic builds.
Bernhard M. Wiedemann [Mon, 7 Aug 2023 11:07:35 +0000 (13:07 +0200)]
libtool.m4: Sort output of 'find' to enable deterministic builds.

        * libtool.m4: Sort output of 'find' to enable deterministic builds.
* ltmain.sh: Likewise.

12 months agoFix hppa64-hpux11 build to remove source paths from embedded path.
John David Anglin [Mon, 7 Aug 2023 11:07:34 +0000 (13:07 +0200)]
Fix hppa64-hpux11 build to remove source paths from embedded path.

This change adds the +nodefaultrpath ld option to remove all library
paths that were specified with the -L option from the embedded path.

* libtool.m4 (archive_cmds): Add +nodefaultrpath ld option on
hppa64-*-hpux11*.

12 months agoGeneric configury support for shared libs on VxWorks
Olivier Hainque [Mon, 7 Aug 2023 11:07:33 +0000 (13:07 +0200)]
Generic configury support for shared libs on VxWorks

This change adds the configury bits to activate the build of
shared libs on VxWorks ports configured with --enable-shared,
for libraries variants where this is generally supported (rtp,
code model !large - currently not compatible with -fPIC).

Set lt_cv_deplibs_check_method in libtool.m4, so the build of
libraries know how to establish dependencies.  This is useful in
configurations such as aarch64 where proper support of LSE relies
on accurate dependency information between libstdc++ and libgcc_s
to begin with.

* libtool.m4 (*vxworks*): When enable_shared, set dynamic_linker
and friends for rtp !large. Assume the linker has the required
abilities and set lt_cv_deplibs_check_method.

12 months agotoplevel: reconcile few divergences with GCC
Arsen Arsenović [Mon, 7 Aug 2023 11:07:32 +0000 (13:07 +0200)]
toplevel: reconcile few divergences with GCC

* configure.ac: Reorder include.
<is_elf calculation>: Re-add haiku to ELF target list.

12 months agogcc: xtensa: add data alignment properties to dynconfig
Max Filippov [Mon, 7 Aug 2023 11:07:31 +0000 (13:07 +0200)]
gcc: xtensa: add data alignment properties to dynconfig

include/
* xtensa-dynconfig.h (xtensa_config_v4): New struct.
(XCHAL_DATA_WIDTH, XCHAL_UNALIGNED_LOAD_EXCEPTION)
(XCHAL_UNALIGNED_STORE_EXCEPTION, XCHAL_UNALIGNED_LOAD_HW)
(XCHAL_UNALIGNED_STORE_HW, XTENSA_CONFIG_V4_ENTRY_LIST): New
definitions.
(XTENSA_CONFIG_INSTANCE_LIST): Add xtensa_config_v4 instance.
(XTENSA_CONFIG_ENTRY_LIST): Add XTENSA_CONFIG_V4_ENTRY_LIST.

12 months agogcc: xtensa: add XCHAL_HAVE_{CLAMPS, DEPBITS, EXCLUSIVE, XEA3} to dynconfig
Max Filippov [Mon, 7 Aug 2023 11:07:30 +0000 (13:07 +0200)]
gcc: xtensa: add XCHAL_HAVE_{CLAMPS, DEPBITS, EXCLUSIVE, XEA3} to dynconfig

include/
* xtensa-dynconfig.h (xtensa_config_v3): New struct.
(xtensa_get_config_v3): New declaration.
(XCHAL_HAVE_CLAMPS, XCHAL_HAVE_DEPBITS, XCHAL_HAVE_EXCLUSIVE)
(XCHAL_HAVE_XEA3, XTENSA_CONFIG_V3_ENTRY_LIST): New definitions.
(XTENSA_CONFIG_INSTANCE_LIST): Add xtensa_config_v3 instance.
(XTENSA_CONFIG_ENTRY_LIST): Add XTENSA_CONFIG_V3_ENTRY_LIST.

12 months agoMSP430: Add -fno-exceptions multilib
Jozef Lawrynowicz [Mon, 7 Aug 2023 11:07:29 +0000 (13:07 +0200)]
MSP430: Add -fno-exceptions multilib

* config-ml.in (msp430-*-*): Support --disable-no-exceptions configure
flag.

12 months agoAdd D front-end, libphobos library, and D2 testsuite.
Iain Buclaw [Mon, 7 Aug 2023 11:07:28 +0000 (13:07 +0200)]
Add D front-end, libphobos library, and D2 testsuite.

* config-ml.in: Treat GDC and GDCFLAGS like other compiler/flag
environment variables.

Cherry picked from GCC commit b4c522fabd0df7be08882d2207df8b2765026110

12 months agoconfig-ml.in: Suppress output from multi-do recipes
Jonathan Wakely [Mon, 7 Aug 2023 11:07:27 +0000 (13:07 +0200)]
config-ml.in: Suppress output from multi-do recipes

The FIXME comments saying "Leave out until this is tested a bit more"
are from 1997. I think they've been sufficiently tested.

* config-ml.in (multi-do, multi-clean): Add @ to silence recipes.
Remove FIXME comments.

12 months agomh-mingw: drop unused BOOT_CXXFLAGS variable
Sergei Trofimovich [Mon, 7 Aug 2023 11:07:26 +0000 (13:07 +0200)]
mh-mingw: drop unused BOOT_CXXFLAGS variable

gcc's build system has BOOT_CFLAGS and various STAGE<N>_C{,XX}FLAGS
variables. BOOT_CXXFLAGS is not handled anywhere.

config/
* mh-mingw: Drop assignment of unused BOOT_CXXFLAGS variable.

12 months agomh-mingw: Set __USE_MINGW_ACCESS in missed C++ flags variables
Martin Storsjö [Mon, 7 Aug 2023 11:07:25 +0000 (13:07 +0200)]
mh-mingw: Set __USE_MINGW_ACCESS in missed C++ flags variables

This is similar to what was done in
eea4e2ff0a3f5e7f37df204c070cc5d9ef339e6e (where it was added to
STAGE*_CXXFLAGS), but this adds the flag to the CXXFLAGS and
BOOT_CXXFLAGS variables too (as it's already added to CFLAGS and
BOOT_CFLAGS).

2021-04-09  Martin Storsjö  <martin@martin.st>

config/
* mh-mingw: Set __USE_MINGW_ACCESS in missed C++ flags
variables

12 months agoconfigure: Allow host fragments to react to --enable-host-shared.
Iain Sandoe [Mon, 7 Aug 2023 11:07:24 +0000 (13:07 +0200)]
configure: Allow host fragments to react to --enable-host-shared.

This makes the host_shared value available to host makefile
fragments.

It uses this to adjust Darwin's mdynamic-no-pic in the case that
shared host resources are required.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
config/
* mh-darwin: Require a non-shared host configuration to
enable  mdynamic-no-pic where that is supported.

12 months agoDarwin, config: Revise host config fragment.
Iain Sandoe [Mon, 7 Aug 2023 11:07:23 +0000 (13:07 +0200)]
Darwin, config: Revise host config fragment.

There were two uses for the Darwin host config fragment:

The first is to arrange for targets that support mdynamic-no-pic
to be built with that enabled (since it makes a significant
difference to the compiler performance).  We can be more specific
in the application of this, since it only applies to 32b hosts
plus powerpc64-darwin9.

The second was to work around a tool bug where -fno-PIE was not
propagated to the link stage.  This second use is redundant,
since the buggy toolchain cannot bootstrap current GCC sources
anyway.

This makes the host fragment more specific and reduces the number
of toolchains for which it is included which reduces clutter in
configure lines.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
config/
* mh-darwin: Make this specific to handling the
mdynamic-no-pic case.

12 months agogcc: Add 'mcf' thread model support from mcfgthread
LIU Hao [Mon, 7 Aug 2023 11:07:22 +0000 (13:07 +0200)]
gcc: Add 'mcf' thread model support from mcfgthread

This patch adds the new thread model `mcf`, which implements mutexes
and condition variables with the mcfgthread library.

Source code for mcfgthread is available at <https://github.com/lhmouse/mcfgthread>.

config/
* gthr.m4 (GCC_AC_THREAD_HEADER): Add new case for `mcf` thread
model

12 months agoFix PR bootstrap/102389: --with-build-config=bootstrap-lto is broken
Andrew Pinski [Mon, 7 Aug 2023 11:07:21 +0000 (13:07 +0200)]
Fix PR bootstrap/102389: --with-build-config=bootstrap-lto is broken

So the problem here is that now the lto-plugin requires NM that works
with LTO to work so we need to pass down NM just like we do for ranlib
and ar.

config/
* bootstrap-lto-lean.mk: Handle NM like RANLIB AND AR.
* bootstrap-lto.mk: Likewise.

12 months ago32-bit PA-RISC with HP-UX: remove deprecated ports
Martin Liska [Thu, 25 Aug 2022 12:30:51 +0000 (14:30 +0200)]
32-bit PA-RISC with HP-UX: remove deprecated ports

* configure.ac: Drop GCC configury for hpux10
* configure: Likewise.
config/
* mh-pa-hpux10: Drop.

12 months agoMerge modula-2 front end onto gcc.
Gaius Mulley [Mon, 7 Aug 2023 11:07:19 +0000 (13:07 +0200)]
Merge modula-2 front end onto gcc.

This commit merges the devel/modula2 into master.
The libraries reside in libgm2, the compiler in gcc/m2
and the testsuite in gcc/testsuite/gm2.

* configure.ac (target_libraries): Add target-libgm2.
Add NCN_STRICT_CHECK_TARGET_TOOLS entry for gm2.
Add GCC_TARGET_TOOL entry for gm2.  (compare_exclusions)
add gcc/m2/gm2-compiler/M2Version,
gcc/m2/gm2-compiler-boot/SYSTEM and gcc/m2/gm2version.
* Makefile.def (target_modules): Add libgm2.  (flags_to_pass)
Add GM2_FOR_TARGET, GM2FLAGS_FOR_TARGET.  (dependencies) Add
all-target-libgm2 and on=all-target-libatomic.  (languages)
Add entry for language=m2 with gcc-check-target=check-m2
and lib-check-target=check-target-libgm2.
* Makefile.tpl (BUILD_EXPORTS): Add definition for GM2
and GM2FLAGS.  (HOST_EXPORTS) Add definition for GM2.
(BASE_TARGET_EXPORTS) Add definition for GM2.
(GM2_FOR_BUILD) Defined.  (GM2FLAGS) Defined.
(GM2_FOR_TARGET) Defined.  (GM2FLAGS_FOR_TARGET) Defined.
(EXTRA_HOST_FLAGS) Defined.  (POSTSTAGE1_FLAGS_TO_PASS)
Add GM2 and GM2_FOR_BUILD.  (EXTRA_TARGET_FLAGS) Add
GM2 and GM2FLAGS.  (EXTRA_GCC_FLAGS) Add GM2_FOR_TARGET.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
12 months agoAdd TFLAGS to gcc's GCC_FOR_TARGET
Alexandre Oliva [Mon, 7 Aug 2023 11:07:18 +0000 (13:07 +0200)]
Add TFLAGS to gcc's GCC_FOR_TARGET

When the GCC build runs GCC_FOR_TARGET, e.g. for selftests or for
dumping specs, it doesn't use TFLAGS in non-bootstrap scenarios.  This
patch arranges for TFLAGS to be passed from the top level down to gcc
in GCC_FOR_TARGET in this case.

* Makefile.tpl (HOST_EXPORTS): Add TFLAGS to GCC_FOR_TARGET.
(EXTRA_GCC_FLAGS): Likewise.

12 months agoconfigure: Account CXXFLAGS in gcc-plugin.m4.
Iain Sandoe [Mon, 7 Aug 2023 11:07:17 +0000 (13:07 +0200)]
configure: Account CXXFLAGS in gcc-plugin.m4.

We now use a C++ compiler so that we need to process
CXXFLAGS as well as CFLAGS in the gcc-plugin config
fragment.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
config/
* gcc-plugin.m4: Save and process CXXFLAGS.

12 months agoconfigure: use OBJDUMP determined by libtool [PR95648]
David Seifert [Mon, 7 Aug 2023 11:07:16 +0000 (13:07 +0200)]
configure: use OBJDUMP determined by libtool [PR95648]

$ac_cv_prog_OBJDUMP contains the --host OBJDUMP that
libtool has inferred. Current config/gcc-plugin.m4 does
not respect the user's choice for OBJDUMP.

config/
* gcc-plugin.m4: Use libtool's $ac_cv_prog_OBJDUMP.

12 months agoRemove support for Intel MIC offloading
Thomas Schwinge [Mon, 7 Aug 2023 11:07:15 +0000 (13:07 +0200)]
Remove support for Intel MIC offloading

... after its deprecation in GCC 12.

* Makefile.def: Remove module 'liboffloadmic'.
* configure.ac: Remove 'liboffloadmic' handling.

12 months agoconfigure, Darwin: Ensure overrides to host-pie are passed to gcc configure.
Iain Sandoe [Mon, 7 Aug 2023 11:07:14 +0000 (13:07 +0200)]
configure, Darwin: Ensure overrides to host-pie are passed to gcc configure.

The latest versions of Darwin on the Aarch64 platform mandate PIE executables.
On x86_64 it remains optional, but produces tool warnings after Darwin20, so
we default to PIE executables there too.

All (non-PowerPC) 64b Darwin platforms mandate PIC code and therefore force
host_shared on (we issue a diagnostic if the user tries to configure them
non-shared).

However, this also means we cannot test the host_shared setting independently
of the host_pie setting so that the logic for setting PICFLAG must be amended
for Darwin.

For Darwin versions required to have PIE executables, in the event that the
user tries to configure these as --disable-host-pie, we issue a warning and
override the setting.  These versions must also switch host_pie on even if it
is not given in the configure line.  To cater for this we pass the current
value of host_pie, as determined by top-level configure, to the GCC configure.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
* Makefile.def: Pass the enable-host-pie value to GCC configure.
* configure.ac: Adjust the logic for shared and PIE host flags to
ensure that PIE is passed for hosts that require it.

12 months agoconfigure: Only create serdep.tmp if needed
Peter Foley [Mon, 7 Aug 2023 11:07:13 +0000 (13:07 +0200)]
configure: Only create serdep.tmp if needed

There's no reason to create this file if none of the serial configure
options are passed.

* configure.ac: Only create serdep.tmp if needed

12 months agoconfigure: Implement --enable-host-pie
Marek Polacek [Mon, 7 Aug 2023 11:07:12 +0000 (13:07 +0200)]
configure: Implement --enable-host-pie

This patch implements the --enable-host-pie configure option which
makes the compiler executables PIE.  This can be used to enhance
protection against ROP attacks, and can be viewed as part of a wider
trend to harden binaries.

Co-Authored by: Iain Sandoe  <iain@sandoe.co.uk>

* configure.ac (--enable-host-pie): New check.  Set PICFLAG after this
check.

intl/
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check.  Set PICFLAG after this check.

libdecnumber/
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check.  Set PICFLAG after this check.

zlib/
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check.  Set PICFLAG after this check.

12 months agoconfigure: When host-shared, pass --with-pic to in-tree lib configs.
Iain Sandoe [Mon, 7 Aug 2023 11:07:11 +0000 (13:07 +0200)]
configure: When host-shared, pass --with-pic to in-tree lib configs.

If we are building PIC/PIE host executables, and we are building dependent
libs (e.g. GMP) in-tree those libs need to be configured to generate PIC code.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
* Makefile.def: Pass host_libs_picflag to host dependent library
configures.
* configure.ac (host_libs_picflag): New configure variable set to
'--with-pic' when building 'host_shared'.

12 months agoconfigure: Do not build the ununsed libffi shared library.
Iain Sandoe [Mon, 7 Aug 2023 11:07:10 +0000 (13:07 +0200)]
configure: Do not build the ununsed libffi shared library.

We do not use the shared libffi libraray, nor do we install it.
However, on at least Darwin, the shared version will be picked
up for testing, so it is preferrable not to build it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
* Makefile.def: Do not build shared libffi.

12 months agoDarwin : Update libtool and dependencies for Darwin20 [PR97865]
Iain Sandoe [Mon, 7 Aug 2023 11:07:09 +0000 (13:07 +0200)]
Darwin : Update libtool and dependencies for Darwin20 [PR97865]

The change in major version (and the increment from Darwin19 to 20)
caused libtool tests to fail which resulted in incorrect build settings
for shared libraries.

PR target/97865
* libtool.m4: Update handling of Darwin platform link flags
for Darwin20.

12 months agoLoongArch: implement count_{leading,trailing}_zeros
Xi Ruoyao [Mon, 7 Aug 2023 11:07:08 +0000 (13:07 +0200)]
LoongArch: implement count_{leading,trailing}_zeros

LoongArch always support clz and ctz instructions, so we can always use
__builtin_{clz,ctz} for count_{leading,trailing}_zeros.  This improves
the code of libgcc, and also benefits Glibc once we merge longlong.h
there.

Bootstrapped and regtested on loongarch64-linux-gnu.

include/
* longlong.h [__loongarch__] (count_leading_zeros): Define.
[__loongarch__] (count_trailing_zeros): Likewise.
[__loongarch__] (COUNT_LEADING_ZEROS_0): Likewise.

12 months agoUpdated constants from <https://dwarfstd.org/Languages.php>
Meghan Denny [Mon, 7 Aug 2023 11:07:07 +0000 (13:07 +0200)]
Updated constants from <https://dwarfstd.org/Languages.php>

include/
* dwarf2.h: Update with additional languages from dwarf
standard.

12 months agoc++: source position of lambda captures [PR84471]
Jason Merrill [Mon, 7 Aug 2023 11:07:06 +0000 (13:07 +0200)]
c++: source position of lambda captures [PR84471]

include/
* ansidecl.h (ATTRIBUTE_WARN_UNUSED_RESULT): Add __.

12 months agoLibvtv: Add loongarch support.
Lulu Cheng [Mon, 7 Aug 2023 11:07:05 +0000 (13:07 +0200)]
Libvtv: Add loongarch support.

The loongarch64 specification permits page sizes of 4KiB, 16KiB and 64KiB,
but only 16KiB pages are supported for now.

Co-Authored-By: qijingwen <qijingwen@loongson.cn>
include/
* vtv-change-permission.h (defined): Determines whether the macro
__loongarch_lp64 is defined
(VTV_PAGE_SIZE): Set VTV_PAGE_SIZE to 16KiB for loongarch64.

12 months agoAutomatic date update in version.in
GDB Administrator [Sat, 12 Aug 2023 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

12 months agogdb.ada/mi_var_access.exp
Carl Love [Fri, 11 Aug 2023 21:08:37 +0000 (17:08 -0400)]
gdb.ada/mi_var_access.exp

The NUMCHILD value for the "A_String_Access" test differs for X86 and
PowerPC.  The patch substitutes $decimal instead of "1" to match the value
of NUMCHILD.

The test "-var-update A_String_Access" generates different output depending
on the value of VAROBJ_UPDATE_RESULT.TYPE_CHANGED.  If the value is true,
the strings "new_type" and "new_num_children" are printed along with their
values.

The VAROBJ_UPDATE_RESULT.TYPE_CHANGED value is true on PowerPC which
produces the output:

  Expecting: ^(-var-update A_String_Access[
  ]+)?(\^done,changelist=\[\{name="A_String_Access",in_scope="true",type_changed="false",has_more="0"\}\][
  ]+[(]gdb[)]
  [ ]*)
  -var-update A_String_Access
  ^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="true",new_type="pck.string_access",new_num_children="1",has_more="0"}]
  (gdb)
  FAIL: gdb.ada/mi_var_access.exp: update at stop 2 (unexpected output)

The patch adds a second possible result string for the test
$re_varobj_update_result_type to match the case when type_changed is true.

Currently for the mi_var_access.exp test VAROBJ_UPDATE_RESULT.TYPE_CHANGED
is true on PowerPC and false on X86-64.

Fixes 2 failures on PowerPC.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoFix Python documentation for range type fields
Tom Tromey [Fri, 11 Aug 2023 18:22:27 +0000 (12:22 -0600)]
Fix Python documentation for range type fields

GDB's Python documentation claims that range types have two fields,
but this is not true, and attempts to access them hit this error:

      "Type is not a structure, union, enum, or function type."

This patch fixes the documentation.

12 months agoTest GNAT encodings in arr_acc_idx_w_gap.exp
Tom Tromey [Fri, 11 Aug 2023 16:04:49 +0000 (10:04 -0600)]
Test GNAT encodings in arr_acc_idx_w_gap.exp

While working on a GNAT bug, I wanted to also test
arr_acc_idx_w_gap.exp using GNAT encodings.  When the GNAT change is
ready, I plan to add a new case here.

Tested on x86-64 Fedora 36.  I am checking this in.

12 months agoRISC-V: Reflect actual range of vlen for hashing
Tsukasa OI [Fri, 11 Aug 2023 03:12:52 +0000 (03:12 +0000)]
RISC-V: Reflect actual range of vlen for hashing

Before actual vlen handling, fix the riscv_gdbarch_features hashing
function based on the actual valid range of vlen.  In bytes, vlen is 0,
or 4 <= xlen <= 8192.

12 months agoRISC-V: Add reference to Zve32*
Tsukasa OI [Fri, 11 Aug 2023 03:09:58 +0000 (03:09 +0000)]
RISC-V: Add reference to Zve32*

Before actual vlen handling, this commit fixes its description to allow vlen
less than 16 (but 4 or greater), to support vector subset extensions for
embedded environment ('Zve32*').

12 months agogdb: warn unused result for bfd IO functions
Alan Modra [Wed, 9 Aug 2023 00:28:36 +0000 (09:58 +0930)]
gdb: warn unused result for bfd IO functions

This fixes the compilation warnings introduced by my bfdio.c patch.

The removed bfd_seeks in coff_symfile_read date back to 1994, commit
7f4c859520, prior to which the file used stdio rather than bfd to read
symbols.  Since it now uses bfd to read the file there should be no
need to synchronise to bfd's idea of the file position.  I also fixed
a potential uninitialised memory access.

Approved-By: Andrew Burgess <aburgess@redhat.com>
12 months agoFix AIX build break.
Aditya Vidyadhar Kamath [Fri, 11 Aug 2023 08:43:23 +0000 (03:43 -0500)]
Fix AIX build break.

In a recent commit the signature of the scoped_restore_current_inferior_for_memory function was changed and in AIX we did not update the same.

This patch updates it in aix-thread.c file fixed the break and the thread debugging works alright as a result.

12 months agogas: purge md_elf_section_word()
Jan Beulich [Fri, 11 Aug 2023 08:05:32 +0000 (10:05 +0200)]
gas: purge md_elf_section_word()

It's not documented anyway, and having it makes no sense anymore with
obj_elf_section_word() now being TC_SPARC-only. In any event the x86
backing function was dead code.

12 months agox86: pack CPU flags in opcode table
Jan Beulich [Fri, 11 Aug 2023 08:04:49 +0000 (10:04 +0200)]
x86: pack CPU flags in opcode table

The table constantly growing in two dimensions (number of table entries
times number of ISA extension flags) doesn't scale very well. Use a more
compact representation: Only identifiers which need to combine with
other identifiers retain individual flag bits. All others are combined
into an enum, with a new helper added to transform the table entries
into the original i386_cpu_flags layout. This way the table in the final
binary shrinks by almost a third (the generated source code shrinks by
about half), and isn't likely to grow again in that dimension any time
soon.

While moving the 3DNow! fields, drop the stray inner 'a' from their
names.

12 months agowarn unused result for bfd IO functions
Alan Modra [Mon, 7 Aug 2023 11:29:08 +0000 (20:59 +0930)]
warn unused result for bfd IO functions

This patch fixes all the warnings I found in bfd, binutils and ld,
plus some bitrotted COFF_GO32 code that tried to allocate -168ul
bytes.  When the malloc fail was reported these testsuite fails
resulted:

i386-go32  +FAIL: go32 stub
i386-go32  +ERROR: tcl error sourcing /home/alan/src/binutils-gdb/ld/testsuite/ld-i386/i386.exp.
i386-go32  +ERROR: couldn't open "tmpdir/go32stub": no such file or directory
i386-go32  +FAIL: ld-scripts/sane1
i386-go32  +FAIL: ld-scripts/assign-loc
i386-go32  +FAIL: ld-scripts/pr18963

This does result in some warnings in gdb which are fixed in a followup
patch.

bfd/
* bfdio.c (bfd_read, bfd_write): Add ATTRIBUTE_WARN_UNUSED_RESULT.
(bfd_tell, bfd_stat, bfd_seek, bfd_mmap): Likewise.
* bfd-in2.h: Regenerate.
* coff-rs6000.c (xcoff_write_armap_big) Don't ignore bfd_write
return value.
(xcoff_generate_rtinit): Likewise.  Also free data_buffer and
string_table before returning.
* coff64-rs6000.c (xcoff64_generate_rtinit): Likewise.
* coff-stgo32.c (go32exe_check_format): Don't ignore bfd_seek
return value.
* coffcode.h (coff_apply_checksum): Don't ignore bfd_write return.
(coff_write_object_contents <COFF_GO32>): Likewise, and bfd_malloc.
Fix bitrotted code to look for first section with non-zero filepos.
* elf64-ia64-vms.c (elf64_vms_write_shdrs_and_ehdr): Don't ignore
bfd_seek or bfd_write return values.
* pef.c (bfd_pef_scan_section): Likewise.
(bfd_pef_read_header, bfd_pef_xlib_read_header): Likewise.
* vms-misc.c (_bfd_vms_output_end): Likewise.  Return status.
* vms.h (_bfd_vms_output_end): Update prototype.
* vms-alpha.c: Pass _bfd_vms_output_end status up call chains.
* wasm-module.c (wasm_compute_custom_section_file_position): Don't
ignore bfd_seek or bfd_write return values.
(wasm_compute_section_file_positions): Likewise.
* xsym.c (bfd_sym_scan): Don't ignore bfd_seek return value.
(bfd_sym_read_name_table): Likewise.
binutils/
* ar.c (print_contents, extract_file): Don't ignore bfd_seek
return value.
ld/
* pdb.c (create_section_contrib_substream): Don't ignore bfd_seek
return value.
(create_section_header_stream): Likewise.
* pe-dll.c (pe_get16, pe_get32): Add fail param to return results
from bfd_seek and bfd_read.
(pe_implied_import_dll): Handle these fails, and other bfd_seek
and bfd_read return values.

12 months agoRISC-V: Fix opcode entries of "vmsge{,u}.vx"
Tsukasa OI [Sun, 6 Aug 2023 01:37:05 +0000 (01:37 +0000)]
RISC-V: Fix opcode entries of "vmsge{,u}.vx"

Their check_func should be "match_never", not "match_opcode".  The reasons
this error did not cause any disassembler errors are:

1.  The problem will not reproduce if "no-aliases" is specified
    (because macro instructions are handled as aliases).
2.  If not, all affected compressed instructions or their aliases
    precede before "vmsge{,u}.vx" macro instructions.

However, it'll easily break if we reorder opcode entries.  This commit
fixes this issue before the *accident* occurs.

opcodes/ChangeLog:

* riscv-opc.c (riscv_opcodes): Make sure that we never match to
vmsge{,u}.vx instructions unless specified in the assembler.

12 months agoRISC-V: Remove support for non-existing 'Zve32d'
Tsukasa OI [Thu, 3 Aug 2023 01:01:23 +0000 (01:01 +0000)]
RISC-V: Remove support for non-existing 'Zve32d'

Since this "extension" does not exist (on the other hand, 'Zve64d' exists)
and it's not useful if we keep it (as other code portions just ignore
"zve32d"), this commit just removes it.

bfd/ChangeLog:

* elfxx-riscv.c (riscv_supported_std_z_ext): Remove 'Zve32d'
extension from the list.

12 months agoAutomatic date update in version.in
GDB Administrator [Fri, 11 Aug 2023 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in

12 months ago[gdb/symtab] Fix off-by-one error in cooked_indexer::recurse
Tom de Vries [Thu, 10 Aug 2023 19:16:30 +0000 (21:16 +0200)]
[gdb/symtab] Fix off-by-one error in cooked_indexer::recurse

Test-case gdb.dwarf2/pr13961.exp contains:
...
 <1><25>: Abbrev Number: 8 (DW_TAG_class_type)
    <26>   DW_AT_specification: <0x2a>
 <1><2a>: Abbrev Number: 2 (DW_TAG_class_type)
    <2b>   DW_AT_name        : foo
    <2f>   DW_AT_byte_size   : 4
    <30>   DW_AT_decl_file   : 1
    <31>   DW_AT_decl_line   : 1
    <32>   DW_AT_sibling     : <0x44>
...

The DIE at 0x25 contains an intra-CU forward reference, and is deferred during
DIE indexing in the cooked_index, by adding it to m_deferred_entries.

The resulting cooked index entries are:
...
        [25] ((cooked_index_entry *) 0x333b5d0)
        name:       foo
        canonical:  foo
        qualified:  foo
        DWARF tag:  DW_TAG_class_type
        flags:      0x0 []
        DIE offset: 0x2a
        parent:     ((cooked_index_entry *) 0)

        [26] ((cooked_index_entry *) 0x333b630)
        name:       foo
        canonical:  foo
        qualified:  foo::foo
        DWARF tag:  DW_TAG_class_type
        flags:      0x0 []
        DIE offset: 0x25
        parent:     ((cooked_index_entry *) 0x333b5d0) [foo]
...

Notice that 0x2a is the parent of 0x25, and that this is why the qualified
name of 0x25 is "foo::foo", which is incorrect, it's supposed to be "foo".

The parent is set here in cooked_indexer::make_index:
...
  for (const auto &entry : m_deferred_entries)
    {
      void *obj = m_die_range_map.find (entry.spec_offset);
      cooked_index_entry *parent = static_cast<cooked_index_entry *> (obj);
      m_index_storage->add (entry.die_offset, entry.tag, entry.flags,
    entry.name, parent, m_per_cu);
    }
...
and AFAICT, we store in m_die_range_map the parent of the respective
spec_offset DIE (though that's not clear from the comment describing it).

So, the root cause of this is that when we lookup the parent for DIE 0x25, we get
m_die_range_map.find (0x2a) == 0x2a.

This is an off-by-one error, fixed in cooked_indexer::recurse by:
...
-      CORE_ADDR start = form_addr (parent_entry->die_offset,
+      CORE_ADDR start = form_addr (parent_entry->die_offset + 1,
...
which gives us:
...
    [12] ((cooked_index_entry *) 0x41e21f0)
    name:       foo
    canonical:  foo
    qualified:  foo
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x25
    parent:     ((cooked_index_entry *) 0)

    [13] ((cooked_index_entry *) 0x41e2190)
    name:       foo
    canonical:  foo
    qualified:  foo
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x2a
    parent:     ((cooked_index_entry *) 0)
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR symtab/30739
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30739

12 months ago[gdb/symtab] Dump qualified name of cooked_index_entry
Tom de Vries [Thu, 10 Aug 2023 19:16:30 +0000 (21:16 +0200)]
[gdb/symtab] Dump qualified name of cooked_index_entry

When doing "maint print objfiles" for the exec of test-case
gdb.dwarf2/pr13961.exp, we get:
...
    [25] ((cooked_index_entry *) 0x37b25d0)
    name:       foo
    canonical:  foo
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x2a
    parent:     ((cooked_index_entry *) 0)

    [26] ((cooked_index_entry *) 0x37b2630)
    name:       foo
    canonical:  foo
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x25
    parent:     ((cooked_index_entry *) 0x37b25d0) [foo]
...

By following the parent links in the text, we can conclude that the qualified
name of DIE 0x25 is foo::foo (which is incorrect, that's PR symtab/30739).

But it's not evident, and also hard to verify in a test-case.

Add dumping of the qualified name, such that we have:
...
    [25] ((cooked_index_entry *) 0x333b5d0)
    name:       foo
    canonical:  foo
    qualified:  foo
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x2a
    parent:     ((cooked_index_entry *) 0)

    [26] ((cooked_index_entry *) 0x333b630)
    name:       foo
    canonical:  foo
    qualified:  foo::foo
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x25
    parent:     ((cooked_index_entry *) 0x333b5d0) [foo]
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoFix gdb.ada/O2_float_param.exp for PowerPC
Carl Love [Thu, 3 Aug 2023 17:55:51 +0000 (13:55 -0400)]
Fix gdb.ada/O2_float_param.exp for PowerPC

The frame command on Power pc prints the address in hex between the
#0 and in calle.increment.  For example

(gdb) frame
#0  0x0000000010010a88 in callee.increment (val=val@entry=99.0, msg=...)
    at /home/.../gdb/testsuite/gdb.ada/O2_float_param/callee.adb:19
19    procedure Increment (Val : in out Float; Msg: String) is

The printing of the address for the frame is done by function
print_frame in gdb/stack.c.  If SAL.IS_stmt is false for the frame,
function frame_show_address returns true and print_frame prints the
address.  Currently, SAL.IS is false on PowerPC and true on X86-64.

Update the set re string to accept the hex address if it exits.

Fixes two failures on PowerPC.

Patch tested on Power10 with no new regressions.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoChange py-thread-exited.exp to work with gdbserver
Tom Tromey [Mon, 31 Jul 2023 17:30:30 +0000 (11:30 -0600)]
Change py-thread-exited.exp to work with gdbserver

gdbserver does not notify gdb of new threads when they are created.
I'm not sure if this is documented anywhere, but it is mentioned on
this page:

https://sourceware.org/gdb/wiki/LocalRemoteFeatureParity

Search for "Finding new threads in the inferior".

This behavior is a bit unfortunate -- I would think that it would be
better to arrange for such notification if something on the gdb side
is interested.

Meanwhile, this patch fixes py-thread-exited.exp to work around this
problem.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30677

12 months agoPass unique_ptr to add_thread_with_info
Tom Tromey [Thu, 10 Mar 2022 23:56:57 +0000 (16:56 -0700)]
Pass unique_ptr to add_thread_with_info

This changes add_thread_with_info to accept a unique_ptr, making it
clear that it takes ownership of the passed-in pointer.

I can't test the AIX or Darwin changes, but I think they are
relatively obvious.

12 months agoaarch64: Enable Cortex-A520 CPU
Richard Ball [Thu, 10 Aug 2023 14:11:37 +0000 (15:11 +0100)]
aarch64: Enable Cortex-A520 CPU

This patch adds support for the Cortex-A520 CPU to gas.

No regressions on aarch64-none-elf.

gas/ChangeLog:

* NEWS: Update docs.
* config/tc-aarch64.c: Add Cortex-A520.
* doc/c-aarch64.texi: Update docs.

12 months ago[gdb/testsuite] Fix gdb.dwarf2/enqueued-cu-base-addr.exp with cc-with-gnu-debuglink
Tom de Vries [Thu, 10 Aug 2023 13:46:30 +0000 (15:46 +0200)]
[gdb/testsuite] Fix gdb.dwarf2/enqueued-cu-base-addr.exp with cc-with-gnu-debuglink

When running test-case gdb.dwarf2/enqueued-cu-base-addr.exp with target board
cc-with-gnu-debuglink, I run into:
...
(gdb) PASS: gdb.dwarf2/enqueued-cu-base-addr.exp: ptype foo
maint print symbols -objfile enqueued-cu-base-addr^M
(gdb) FAIL: gdb.dwarf2/enqueued-cu-base-addr.exp: CU addr found
...

The problem is that the CU we're trying to print is in objfile
enqueued-cu-base-addr.debug instead of enqueued-cu-base-addr.

Fix this by replacing "-objfile enqueued-cu-base-addr" with "-source cu2".

Tested on x86_64-linux.

12 months ago[gdb/testsuite] Improve failure mode in gdb.dwarf2/enqueued-cu-base-addr.exp
Tom de Vries [Thu, 10 Aug 2023 13:46:30 +0000 (15:46 +0200)]
[gdb/testsuite] Improve failure mode in gdb.dwarf2/enqueued-cu-base-addr.exp

I ran test-case gdb.dwarf2/enqueued-cu-base-addr.exp with target board
cc-with-debug-names, and ran into:
...
FAIL: gdb.dwarf2/enqueued-cu-base-addr.exp: ptype foo (GDB internal error)
FAIL: gdb.dwarf2/enqueued-cu-base-addr.exp: CU addr found
...

The first FAIL is a known issue, PR symtab/29572.

The following FAIL is a consequence of the first FAIL, so require for the
second test that the first test passes.

Tested on x86_64-linux, with target boards unix and cc-with-debug-names.

12 months ago[gdb/symtab] Fix assertion in write_debug_names
Tom de Vries [Thu, 10 Aug 2023 13:46:30 +0000 (15:46 +0200)]
[gdb/symtab] Fix assertion in write_debug_names

When running test-case gdb.dwarf2/pr13961.exp with target-board
cc-with-debug-names, I run into:
...
Running gdb.dwarf2/pr13961.exp ...
gdb compile failed, gdb/dwarf2/index-write.c:1305: internal-error: \
  write_debug_names: Assertion `counter == per_bfd->all_units.size ()' failed.
...

This is a regression since commit 542a33e348a ("Only use the per-BFD object to
 write a DWARF index"), which did:
...
-  gdb_assert (counter == per_objfile->per_bfd->all_comp_units.size ());
+  gdb_assert (counter == per_bfd->all_units.size ());
...

Fix this by reverting to using all_comp_units:
...
  gdb_assert (counter == per_bfd->all_comp_units.size ());
...

Tested on x86_64-linux, using target boards unix and cc-with-debug-names.

PR symtab/30741
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30741

12 months agoAutomatic date update in version.in
GDB Administrator [Thu, 10 Aug 2023 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in

12 months agobpf: use w regs in 32-bit non-fetch atomic pseudo-c
David Faust [Wed, 9 Aug 2023 18:44:38 +0000 (11:44 -0700)]
bpf: use w regs in 32-bit non-fetch atomic pseudo-c

The 32-bit non-fetching atomic instructions treat the source register as
32-bits, which means in the pseudo-c syntax the "w" registers should be
used rather than the "r" registers.

opcodes/

* bpf-opc-c (bpf_opcodes): Use %sw for AAD32, AOR32, AAND32
and AXOR32 pseudo-c dialect asm templates.

gas/

* testsuite/gas/bpf/atomic-be-pseudoc.d: Use "w" for source reg
in non-fetching 32-bit atomic instructions.
* testsuite/gas/bpf/atomic-pseudoc.d: Likewise.
* testsuite/gas/bpf/atomic-pseudoc.s: Likewise.

12 months agogdb, breakpoint: add breakpoint location debugging logs
Mihails Strasuns [Tue, 3 Dec 2019 12:13:25 +0000 (13:13 +0100)]
gdb, breakpoint: add breakpoint location debugging logs

Add new commands:

  set debug breakpoint on|off
  show debug breakpoint

This patch introduces new debugging information that prints
breakpoint location insertion and removal flow.

The debug output looks like:
~~~
(gdb) set debug breakpoint on
(gdb) disassemble main
Dump of assembler code for function main:
   0x0000555555555129 <+0>: endbr64
   0x000055555555512d <+4>: push   %rbp
   0x000055555555512e <+5>: mov    %rsp,%rbp
=> 0x0000555555555131 <+8>: mov    $0x0,%eax
   0x0000555555555136 <+13>: pop    %rbp
   0x0000555555555137 <+14>: ret
End of assembler dump.
(gdb) break *0x0000555555555137
Breakpoint 2 at 0x555555555137: file main.c, line 4.
[breakpoint] update_global_location_list: insert_mode = UGLL_MAY_INSERT
(gdb) c
Continuing.
[breakpoint] update_global_location_list: insert_mode = UGLL_INSERT
[breakpoint] insert_bp_location: Breakpoint 2 (0x5565daddb1e0) at address 0x555555555137 in main at main.c:4
[breakpoint] insert_bp_location: Breakpoint -2 (0x5565dab51c10) at address 0x7ffff7fd37b5
[breakpoint] insert_bp_location: Breakpoint -5 (0x5565dab68f30) at address 0x7ffff7fe509e
[breakpoint] insert_bp_location: Breakpoint -7 (0x5565dab694f0) at address 0x7ffff7fe63f4
[breakpoint] remove_breakpoint_1: Breakpoint 2 (0x5565daddb1e0) at address 0x555555555137 in main at main.c:4 due to regular remove
[breakpoint] remove_breakpoint_1: Breakpoint -2 (0x5565dab51c10) at address 0x7ffff7fd37b5 due to regular remove
[breakpoint] remove_breakpoint_1: Breakpoint -5 (0x5565dab68f30) at address 0x7ffff7fe509e due to regular remove
[breakpoint] remove_breakpoint_1: Breakpoint -7 (0x5565dab694f0) at address 0x7ffff7fe63f4 due to regular remove

Breakpoint 2, 0x0000555555555137 in main () at main.c:4
4 }
~~~

Co-Authored-By: Christina Schimpe <christina.schimpe@intel.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Wed, 9 Aug 2023 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in

12 months agoRename bfd_bread and bfd_bwrite
Alan Modra [Mon, 7 Aug 2023 05:10:35 +0000 (14:40 +0930)]
Rename bfd_bread and bfd_bwrite

These were renamed from bfd_read and bfd_write back in 2001 when they
lost an unnecessary parameter.  Rename them back, and get rid of a few
casts that are only needed without prototyped functions (K&R C).

12 months agoAdd ld makefile dependencies
Alan Modra [Mon, 7 Aug 2023 05:07:41 +0000 (14:37 +0930)]
Add ld makefile dependencies

* Makefile.am (EXTRA_ld_new_SOURCES): Add pep-dll-aarch64.c
and pep-dll-x86_64.c.
* Makefile.in: Regenerate.

12 months agoPR30724, cygwin ld performance regression since 014a602b86
Alan Modra [Sun, 6 Aug 2023 22:58:55 +0000 (08:28 +0930)]
PR30724, cygwin ld performance regression since 014a602b86

According to the reporter of this bug the newlib fseek implementation
is likely slowed down by locking and fflush, only attempting to
optimise seeks when the file is opened read-only.  Thus when writing
the output we get a dramatic slowdown due to commit 014a602b86.

PR 30724
* bfd.c (enum bfd_last_io): New.
(struct bfd): Add last_io field.
* bfd-in2.h: Regenerate.
* bfd-io.c (bfd_bread, bfd_bwrite): Force seek if last_io is
opposite direction.
(bfd_seek): Reinstate optimisation for seek to same position.

12 months ago[gdb/build] Use move capture in gdb_demangle
Tom de Vries [Tue, 8 Aug 2023 22:58:29 +0000 (00:58 +0200)]
[gdb/build] Use move capture in gdb_demangle

Use move capture in gdb_demangle when compiling for c++14 or higher, to save a
std::string copy.

Tested on x86_64-linux.

Reported-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
12 months agold: Fix retain7a.d XFAIL/notarget entry for hppa
Sam James [Tue, 8 Aug 2023 01:19:57 +0000 (02:19 +0100)]
ld: Fix retain7a.d XFAIL/notarget entry for hppa

PR 30733
* ld/testsuite/ld-elf/retain7a.d: Fix XFAIL entry for hppa to match
  hppa{1.1,2.0}*, like hppa2.0-unknown-linux-gnu which Gentoo uses.

Signed-off-by: Sam James <sam@gentoo.org>
12 months agold: Fix relocatable.d XFAIL/notarget entry for hppa
Sam James [Tue, 8 Aug 2023 01:17:57 +0000 (02:17 +0100)]
ld: Fix relocatable.d XFAIL/notarget entry for hppa

PR 30734
* ld/testsuite/ld-elf/relocatable.d: Fix notarget entry for hppa to match
  hppa{1.1,2.0}*, like hppa2.0-unknown-linux-gnu which Gentoo uses.

Signed-off-by: Sam James <sam@gentoo.org>
12 months agoUpdate my name in maintainers file
Guinevere Larsen [Tue, 8 Aug 2023 08:47:32 +0000 (10:47 +0200)]
Update my name in maintainers file

12 months agoGuard against killing unrelated processes in amd64-disp-step.exp
Rainer Orth [Tue, 8 Aug 2023 08:13:58 +0000 (10:13 +0200)]
Guard against killing unrelated processes in amd64-disp-step.exp

When testing current gdb trunk on Solaris/amd64, the whole session was
reliably terminated by make check.  I could trace this to the following
entry in gdb.arch/amd64-disp-step/gdb.log:

FAIL: gdb.arch/amd64-disp-step.exp: add into rcx: send_signal=on: get
inferior pid
Executing on target: kill -ALRM -1    (timeout = 300)
builtin_spawn -ignore SIGHUP kill -ALRM -1

If $inferior_pid doesn't refer to a single process for some reason, this
kill would terminate either a process group or the whole session.

This patch avoids this by ensuring that the pid arg is positive.

Tested on amd64-pc-solaris2.11 and x86_64-pc-linux-gnu.

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
12 months ago[gdb/build] Fix build breaker with -std=c++11
Tom de Vries [Tue, 8 Aug 2023 08:08:04 +0000 (10:08 +0200)]
[gdb/build] Fix build breaker with -std=c++11

When building with -std=c++11 I run into:
...
gdb/dwarf2/cooked-index.c: In member function \
  ‘void cooked_index::start_writing_index(dwarf2_per_bfd*)’:
gdb/dwarf2/cooked-index.c:469:10: error: lambda capture initializers only \
  available with -std=c++14 or -std=gnu++14 [-Werror]
          ctx = std::move (ctx)] ()
          ^~~
...

Fix this by capturing a copy instead when using -std=c++11:
...
    = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd, ctx] ()
...

Tested by building with and without -stdc=++11 on x86_64-linux.

Reported-By: Tom Tromey <tom@tromey.com>
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
12 months agoRISC-V: Update ratified 'Ztso' extension version
Tsukasa OI [Tue, 8 Aug 2023 04:30:41 +0000 (04:30 +0000)]
RISC-V: Update ratified 'Ztso' extension version

Because the 'Ztso' extension is now ratified, it has a version number of 1.0
(not 0.1).  This commit updates the number.

bfd/ChangeLog:

* elfxx-riscv.c (riscv_supported_std_z_ext): Update the version
number of the 'Ztso' extension since it's ratified.

12 months agoAutomatic date update in version.in
GDB Administrator [Tue, 8 Aug 2023 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

12 months agogprofng: 30700 tmpdir/gp-collect-app_F test fails
Vladimir Mezentsev [Thu, 3 Aug 2023 19:56:54 +0000 (12:56 -0700)]
gprofng: 30700 tmpdir/gp-collect-app_F test fails

gprofng/ChangeLog
2023-08-03  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/30700
* testsuite/gprofng.display/gp-collect-app_F.exp: Fix -name argument
for sub-experiment filtering.

12 months agoRISC-V: move comment describing rules for riscv_opcodes[]
Jan Beulich [Mon, 7 Aug 2023 09:56:50 +0000 (11:56 +0200)]
RISC-V: move comment describing rules for riscv_opcodes[]

It makes little sense to have this comment meanwhile over a hundred
lines ahead of the array. In fact until spotting the comment, I was
wondering why those pretty important aspects aren't spelled out
anywhere.

12 months agogdb/fortran: Align intrinsic/variable precedence
Richard Bunt [Mon, 7 Aug 2023 08:12:53 +0000 (09:12 +0100)]
gdb/fortran: Align intrinsic/variable precedence

Fortran allows variables and function to be named after language defined
intrinsics as they are not reserved keywords. For example, the abs maths
intrinsic can be hidden by a user declaring a variable called abs.

The behavior before this patch was to favour the intrinsic, which meant
that any variables named, for example "allocated", could not be
inspected by GDB.

This patch inverts this priority to bring GDB's behaviour closer to the
Fortran language, where the user defined symbol can hide the intrinsic.

Special care was need to prevent any C symbols from overriding either
Fortran intrinsics or user defined variables. This was observed to be
the case when GDB has access to symbols for abs from libm. This was
solved by only allowing symbols not marked with language_fortran to be
overridden.

In total this brings the order of precedence to the following (highest
first):

    1. User defined Fortran variable or function.
    2. Fortran intrinsic.
    3. Symbols from languages other than Fortran.

The sizeof intrinsic is now case insensitive. This is closer to the
Fortran language.  I believe this change is safe enough as it increases
the acceptance of the grammar, rather than restricts it. I.e. it should
not break any existing scripts which rely on it. Unless of course they
rely on SIZEOF being rejected.

GDB built with GCC 13.

No test suite regressions detected. Compilers: GCC, ACfL, Intel, Intel
LLVM, NVHPC; Platforms: x86_64, aarch64.

Existing tests in gdb.fortran cover the invocation of intrinsics
including: intrinsics.exp, shape.exp, rank.exp, lbound-ubound.exp.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Mon, 7 Aug 2023 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

12 months agoAutomatic date update in version.in
GDB Administrator [Sun, 6 Aug 2023 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in

12 months ago[gdb/symtab] Find main language without symtab expansion
Tom de Vries [Sat, 5 Aug 2023 15:57:13 +0000 (17:57 +0200)]
[gdb/symtab] Find main language without symtab expansion

When loading an executable using "file a.out", the language is set according
to a.out, which can involve looking up the language of symbol "main", which
will cause the symtab expansion for the containing CU.

Expansion of lto debug info can be slow, so in commit d3214198119 ("[gdb] Use
partial symbol table to find language for main") a feature was added to avoid
the symtab expansion.

This feature stopped working after commit 7f4307436fd ("Fix "start" for D,
Rust, etc").

[ The commit addresses problems related to command start, which requires finding
the main function:
- for language D, "main" was found instead of "D main", and
- for Rust, the correct function was found, but attributed the wrong name
  (not fully qualified). ]

Reimplement the feature by adding
cooked_index_functions::lookup_global_symbol_language.

Tested on x86_64-linux.

PR symtab/30661
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30661

12 months agoas: Fix typo in manual
David Carew [Fri, 4 Aug 2023 16:18:06 +0000 (09:18 -0700)]
as: Fix typo in manual

The -D flag should enable "debugging"

12 months agoAutomatic date update in version.in
GDB Administrator [Sat, 5 Aug 2023 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in

12 months agoReindent recursive_dump_type
Tom Tromey [Fri, 4 Aug 2023 19:57:55 +0000 (13:57 -0600)]
Reindent recursive_dump_type

I noticed that a 'switch' in recursive_dump_type was incorrect
indented.  This patch fixes the problem.  Tested by rebuilding.

12 months agoConsolidate calls to bfd_set_cacheable
Tom Tromey [Fri, 4 Aug 2023 11:58:35 +0000 (05:58 -0600)]
Consolidate calls to bfd_set_cacheable

I noticed that some spots in gdb call bfd_set_cacheable after opening
a BFD.

The BFD file cache is a bit odd.  BFDs that are opened locally are
unconditionally registered with the cache, and their underlying file
descriptor will always be closed when bfd_cache_close_all is called.
However, only "cacheable" BFDs will be eligible for reopening when
needed -- and by default BFD decides that if a file descriptor is
passed in, then it should not be cacheable.  If a non-cacheable BFD's
file descriptor is closed, there is no offical way to reopen it.

gdb needs to call bfd_cache_close_all, because some systems cannot
start an executable when it has an open file descriptor referencing
it.

However, gdb also will sometimes passes an open file descriptor to the
various BFD open functions.  And, due to lazy DWARF reading, gdb may
also need to reopen these BFDs.

Rather than having all the callers figure out when exactly to set the
cacheable flag, I think it makes sense to consolidate this logic into
the gdb_bfd.c wrapper functions.  It is ok to do this because gdb
always passes a filename to these open functions, so reopening should
work ok.

Regression tested on x86-64 Fedora 38.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
12 months agoRemove extra '.' from error message
Tom Tromey [Fri, 4 Aug 2023 13:20:13 +0000 (07:20 -0600)]
Remove extra '.' from error message

A local gdb test failed with this error message:

 Remote communication error.  Target disconnected.: Arg list too long.

The ".:" seemed weird to me.  This patch removes the ".".

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
12 months agoFix incorrect class name in free_objfile documentation
Tom Tromey [Fri, 4 Aug 2023 15:51:54 +0000 (09:51 -0600)]
Fix incorrect class name in free_objfile documentation

The documentation for the Python free_objfile event registry uses the
wrong class name.  This patch fixes it.  I'm checking this in as
obvious.

12 months agoFix potential infinite loop in bfd_cache_close_all.
Nick Clifton [Fri, 4 Aug 2023 13:19:28 +0000 (14:19 +0100)]
Fix potential infinite loop in bfd_cache_close_all.

  PR 15545 * cache.c (bfd_cache_close_all): Extend description to note that all files will be closed, even those that are not cacheable. Add code to prevent a possible infinite loop.

12 months ago[gdb/testsuite] Extend gdb.base/index-cache.exp further
Tom de Vries [Fri, 4 Aug 2023 13:05:57 +0000 (15:05 +0200)]
[gdb/testsuite] Extend gdb.base/index-cache.exp further

Add lookup of a non-existing symbol to test-case gdb.base/index-cache.exp.

This serves as regression test for PR symtab/30718.

PR symtab/30718
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30718

12 months ago[gdb/testsuite] Move "maint wait-for-index-cache" ALAP in gdb.base/index-cache.exp
Tom de Vries [Fri, 4 Aug 2023 13:05:57 +0000 (15:05 +0200)]
[gdb/testsuite] Move "maint wait-for-index-cache" ALAP in gdb.base/index-cache.exp

In test-case gdb.base/index-cache.exp proc run_test_with_flags contains:
...
clean_restart ${testfile}

# The tests generally want to check the cache, so make sure it
# has completed its work.
gdb_test_no_output "maintenance wait-for-index-cache"
...

This however hides data races between:
- index-cache writing (due to file $exec), and
- symbol lookups (due to subsequent ptype commands).

Fix this by:
- moving the "maintenance wait-for-index-cache" to proc check_cache_stats, and
- moving all calls to proc check_cache_stats ALAP.

Tested on x86_64-linux.

12 months ago[gdb/symtab] Fix data race on dwarf2_per_cu_data::{files_read,is_debug_types}
Tom de Vries [Fri, 4 Aug 2023 13:05:57 +0000 (15:05 +0200)]
[gdb/symtab] Fix data race on dwarf2_per_cu_data::{files_read,is_debug_types}

With gdb build with -fsanitize=thread, and the exec from test-case
gdb.base/index-cache.exp, I run into:
...
$ rm -f ~/.cache/gdb/*; \
  gdb -q -batch -iex "set index-cache enabled on" index-cache \
    -ex "print foobar"
  ...
WARNING: ThreadSanitizer: data race (pid=25018)
  Write of size 1 at 0x7b200000410d by main thread:
    #0 dw2_get_file_names_reader gdb/dwarf2/read.c:2033 (gdb+0x7ab023)
    #1 dw2_get_file_names gdb/dwarf2/read.c:2130 (gdb+0x7ab023)
    #2 dw_expand_symtabs_matching_file_matcher(dwarf2_per_objfile*, gdb::function_view<bool (char const*, bool)>) gdb/dwarf2/read.c:3105 (gdb+0x7ac6e9)
    #3 cooked_index_functions::expand_symtabs_matching(objfile*, gdb::function_view<bool (char const*, bool)>, lookup_name_info const*, gdb::function_view<bool (char const*)>, gdb::function_view<bool (compunit_symtab*)>, enum_flags<block_search_flag_values>, domain_enum, search_domain) gdb/dwarf2/read.c:16812 (gdb+0x7d040f)
    #4 objfile::map_symtabs_matching_filename(char const*, char const*, gdb::function_view<bool (symtab*)>) gdb/symfile-debug.c:219 (gdb+0xda5b6e)
    #5 iterate_over_symtabs(char const*, gdb::function_view<bool (symtab*)>) gdb/symtab.c:648 (gdb+0xdc441d)
    #6 lookup_symtab(char const*) gdb/symtab.c:662 (gdb+0xdc4522)
    #7 classify_name gdb/c-exp.y:3083 (gdb+0x61afec)
    #8 c_yylex gdb/c-exp.y:3251 (gdb+0x61dd13)
    #9 c_yyparse() build/gdb/c-exp.c.tmp:1988 (gdb+0x61f07e)
    #10 c_parse(parser_state*) gdb/c-exp.y:3417 (gdb+0x62d864)
    #11 language_defn::parser(parser_state*) const gdb/language.c:598 (gdb+0x977245)
    #12 parse_exp_in_context gdb/parse.c:414 (gdb+0xb10b1b)
    #13 parse_expression(char const*, innermost_block_tracker*, enum_flags<parser_flag>) gdb/parse.c:462 (gdb+0xb1112e)
    #14 process_print_command_args gdb/printcmd.c:1321 (gdb+0xb4bf8c)
    #15 print_command_1 gdb/printcmd.c:1335 (gdb+0xb4caaa)
    #16 print_command gdb/printcmd.c:1468 (gdb+0xb4cdda)
    #17 do_simple_func gdb/cli/cli-decode.c:95 (gdb+0x65b078)
    #18 cmd_func(cmd_list_element*, char const*, int) gdb/cli/cli-decode.c:2735 (gdb+0x65ed53)
    #19 execute_command(char const*, int) gdb/top.c:575 (gdb+0xe3a7ea)
    #20 catch_command_errors gdb/main.c:518 (gdb+0xa183fd)
    #21 execute_cmdargs gdb/main.c:617 (gdb+0xa185bf)
    #22 captured_main_1 gdb/main.c:1289 (gdb+0xa1aad8)
    #23 captured_main gdb/main.c:1310 (gdb+0xa1b9da)
    #24 gdb_main(captured_main_args*) gdb/main.c:1339 (gdb+0xa1b9da)
    #25 main gdb/gdb.c:39 (gdb+0x42506a)

  Previous read of size 1 at 0x7b200000410d by thread T2:
    #0 write_gdbindex gdb/dwarf2/index-write.c:1214 (gdb+0x75bb30)
    #1 write_dwarf_index(dwarf2_per_bfd*, char const*, char const*, char const*, dw_index_kind) gdb/dwarf2/index-write.c:1469 (gdb+0x75f803)
    #2 index_cache::store(dwarf2_per_bfd*, index_cache_store_context const&) gdb/dwarf2/index-cache.c:173 (gdb+0x755a36)
    #3 cooked_index::maybe_write_index(dwarf2_per_bfd*, index_cache_store_context const&) gdb/dwarf2/cooked-index.c:642 (gdb+0x71c96d)
    #4 operator() gdb/dwarf2/cooked-index.c:471 (gdb+0x71c96d)
    #5 _M_invoke /usr/include/c++/7/bits/std_function.h:316 (gdb+0x71c96d)
    #6 std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 (gdb+0x72a57c)
    #7 void std::__invoke_impl<void, std::function<void ()>&>(std::__invoke_other, std::function<void ()>&) /usr/include/c++/7/bits/invoke.h:60 (gdb+0x72a5db)
    #8 std::__invoke_result<std::function<void ()>&>::type std::__invoke<std::function<void ()>&>(std::function<void ()>&) /usr/include/c++/7/bits/invoke.h:95 (gdb+0x72a5db)
    #9 std::__future_base::_Task_state<std::function<void ()>, std::allocator<int>, void ()>::_M_run()::{lambda()#1}::operator()() const /usr/include/c++/7/future:1421 (gdb+0x72a5db)
    #10 std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_state<std::function<void ()>, std::allocator<int>, void ()>::_M_run()::{lambda()#1}, void>::operator()() const /usr/include/c++/7/future:1362 (gdb+0x72a5db)
    #11 std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_state<std::function<void ()>, std::allocator<int>, void ()>::_M_run()::{lambda()#1}, void> >::_M_invoke(std::_Any_data const&) /usr/include/c++/7/bits/std_function.h:302 (gdb+0x72a5db)
    #12 std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 (gdb+0x724954)
    #13 std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) /usr/include/c++/7/future:561 (gdb+0x724954)
    #14 void std::__invoke_impl<void, void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::__invoke_memfun_deref, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/7/bits/invoke.h:73 (gdb+0x72434a)
    #15 std::__invoke_result<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>::type std::__invoke<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/7/bits/invoke.h:95 (gdb+0x72434a)
    #16 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}::operator()() const /usr/include/c++/7/mutex:672 (gdb+0x72434a)
    #17 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#2}::operator()() const /usr/include/c++/7/mutex:677 (gdb+0x72434a)
    #18 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#2}::_FUN() /usr/include/c++/7/mutex:677 (gdb+0x72434a)
    #19 pthread_once <null> (libtsan.so.0+0x4457c)
    #20 __gthread_once /usr/include/c++/7/x86_64-suse-linux/bits/gthr-default.h:699 (gdb+0x72532b)
    #21 void std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/7/mutex:684 (gdb+0x72532b)
    #22 std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) /usr/include/c++/7/future:401 (gdb+0x174570d)
    #23 std::__future_base::_Task_state<std::function<void ()>, std::allocator<int>, void ()>::_M_run() /usr/include/c++/7/future:1423 (gdb+0x174570d)
    #24 std::packaged_task<void ()>::operator()() /usr/include/c++/7/future:1556 (gdb+0x174570d)
    #25 gdb::thread_pool::thread_function() gdbsupport/thread-pool.cc:242 (gdb+0x174570d)
    #26 void std::__invoke_impl<void, void (gdb::thread_pool::*)(), gdb::thread_pool*>(std::__invoke_memfun_deref, void (gdb::thread_pool::*&&)(), gdb::thread_pool*&&) /usr/include/c++/7/bits/invoke.h:73 (gdb+0x17480c0)
    #27 std::__invoke_result<void (gdb::thread_pool::*)(), gdb::thread_pool*>::type std::__invoke<void (gdb::thread_pool::*)(), gdb::thread_pool*>(void (gdb::thread_pool::*&&)(), gdb::thread_pool*&&) /usr/include/c++/7/bits/invoke.h:95 (gdb+0x17480c0)
    #28 decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void (gdb::thread_pool::*)(), gdb::thread_pool*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) /usr/include/c++/7/thread:234 (gdb+0x17480c0)
    #29 std::thread::_Invoker<std::tuple<void (gdb::thread_pool::*)(), gdb::thread_pool*> >::operator()() /usr/include/c++/7/thread:243 (gdb+0x17480c0)
    #30 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (gdb::thread_pool::*)(), gdb::thread_pool*> > >::_M_run() /usr/include/c++/7/thread:186 (gdb+0x17480c0)
    #31 <null> <null> (libstdc++.so.6+0xdcac2)
  ...
SUMMARY: ThreadSanitizer: data race gdb/dwarf2/read.c:2033 in dw2_get_file_names_reader
...

The race happens when issuing the "file $exec" command.

The race is between:
- a worker thread writing the index cache, and in the process reading
  dwarf2_per_cu_data::is_debug_type, and
- the main thread writing to dwarf2_per_cu_data::files_read.

The two bitfields dwarf2_per_cu_data::files_read and
dwarf2_per_cu_data::is_debug_type share the same bitfield container.

Fix this by making dwarf2_per_cu_data::files_read a packed<bool, 1>.

Tested on x86_64-linux.

PR symtab/30718
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30718

12 months ago[gdb/symtab] Fix data race on dwarf2_per_cu_data::{mark,is_debug_types}
Tom de Vries [Fri, 4 Aug 2023 13:05:57 +0000 (15:05 +0200)]
[gdb/symtab] Fix data race on dwarf2_per_cu_data::{mark,is_debug_types}

With gdb build with -fsanitize=thread, and the exec from test-case
gdb.base/index-cache.exp, I run into:
...
$ rm -f ~/.cache/gdb/*; \
  gdb -q -batch -iex "set index-cache enabled on" index-cache \
    -ex "print foobar"
  ...
WARNING: ThreadSanitizer: data race (pid=23970)
  Write of size 1 at 0x7b200000410d by main thread:
    #0 dw_expand_symtabs_matching_file_matcher(dwarf2_per_objfile*, gdb::function_view<bool (char const*, bool)>) gdb/dwarf2/read.c:3077 (gdb+0x7ac54e)
    #1 cooked_index_functions::expand_symtabs_matching(objfile*, gdb::function_view<bool (char const*, bool)>, lookup_name_info const*, gdb::function_view<bool (char const*)>, gdb::function_view<bool (compunit_symtab*)>, enum_flags<block_search_flag_values>, domain_enum, search_domain) gdb/dwarf2/read.c:16812 (gdb+0x7d039f)
    #2 objfile::map_symtabs_matching_filename(char const*, char const*, gdb::function_view<bool (symtab*)>) gdb/symfile-debug.c:219 (gdb+0xda5aee)
    #3 iterate_over_symtabs(char const*, gdb::function_view<bool (symtab*)>) gdb/symtab.c:648 (gdb+0xdc439d)
    #4 lookup_symtab(char const*) gdb/symtab.c:662 (gdb+0xdc44a2)
    #5 classify_name gdb/c-exp.y:3083 (gdb+0x61afec)
    #6 c_yylex gdb/c-exp.y:3251 (gdb+0x61dd13)
    #7 c_yyparse() build/gdb/c-exp.c.tmp:1988 (gdb+0x61f07e)
    #8 c_parse(parser_state*) gdb/c-exp.y:3417 (gdb+0x62d864)
    #9 language_defn::parser(parser_state*) const gdb/language.c:598 (gdb+0x9771c5)
    #10 parse_exp_in_context gdb/parse.c:414 (gdb+0xb10a9b)
    #11 parse_expression(char const*, innermost_block_tracker*, enum_flags<parser_flag>) gdb/parse.c:462 (gdb+0xb110ae)
    #12 process_print_command_args gdb/printcmd.c:1321 (gdb+0xb4bf0c)
    #13 print_command_1 gdb/printcmd.c:1335 (gdb+0xb4ca2a)
    #14 print_command gdb/printcmd.c:1468 (gdb+0xb4cd5a)
    #15 do_simple_func gdb/cli/cli-decode.c:95 (gdb+0x65b078)
    #16 cmd_func(cmd_list_element*, char const*, int) gdb/cli/cli-decode.c:2735 (gdb+0x65ed53)
    #17 execute_command(char const*, int) gdb/top.c:575 (gdb+0xe3a76a)
    #18 catch_command_errors gdb/main.c:518 (gdb+0xa1837d)
    #19 execute_cmdargs gdb/main.c:617 (gdb+0xa1853f)
    #20 captured_main_1 gdb/main.c:1289 (gdb+0xa1aa58)
    #21 captured_main gdb/main.c:1310 (gdb+0xa1b95a)
    #22 gdb_main(captured_main_args*) gdb/main.c:1339 (gdb+0xa1b95a)
    #23 main gdb/gdb.c:39 (gdb+0x42506a)

  Previous read of size 1 at 0x7b200000410d by thread T1:
    #0 write_gdbindex gdb/dwarf2/index-write.c:1214 (gdb+0x75bb30)
    #1 write_dwarf_index(dwarf2_per_bfd*, char const*, char const*, char const*, dw_index_kind) gdb/dwarf2/index-write.c:1469 (gdb+0x75f803)
    #2 index_cache::store(dwarf2_per_bfd*, index_cache_store_context const&) gdb/dwarf2/index-cache.c:173 (gdb+0x755a36)
    #3 cooked_index::maybe_write_index(dwarf2_per_bfd*, index_cache_store_context const&) gdb/dwarf2/cooked-index.c:642 (gdb+0x71c96d)
    #4 operator() gdb/dwarf2/cooked-index.c:471 (gdb+0x71c96d)
    #5 _M_invoke /usr/include/c++/7/bits/std_function.h:316 (gdb+0x71c96d)
    #6 std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 (gdb+0x72a57c)
    #7 void std::__invoke_impl<void, std::function<void ()>&>(std::__invoke_other, std::function<void ()>&) /usr/include/c++/7/bits/invoke.h:60 (gdb+0x72a5db)
    #8 std::__invoke_result<std::function<void ()>&>::type std::__invoke<std::function<void ()>&>(std::function<void ()>&) /usr/include/c++/7/bits/invoke.h:95 (gdb+0x72a5db)
    #9 std::__future_base::_Task_state<std::function<void ()>, std::allocator<int>, void ()>::_M_run()::{lambda()#1}::operator()() const /usr/include/c++/7/future:1421 (gdb+0x72a5db)
    #10 std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_state<std::function<void ()>, std::allocator<int>, void ()>::_M_run()::{lambda()#1}, void>::operator()() const /usr/include/c++/7/future:1362 (gdb+0x72a5db)
    #11 std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_state<std::function<void ()>, std::allocator<int>, void ()>::_M_run()::{lambda()#1}, void> >::_M_invoke(std::_Any_data const&) /usr/include/c++/7/bits/std_function.h:302 (gdb+0x72a5db)
    #12 std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 (gdb+0x724954)
    #13 std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) /usr/include/c++/7/future:561 (gdb+0x724954)
    #14 void std::__invoke_impl<void, void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::__invoke_memfun_deref, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/7/bits/invoke.h:73 (gdb+0x72434a)
    #15 std::__invoke_result<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>::type std::__invoke<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/7/bits/invoke.h:95 (gdb+0x72434a)
    #16 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}::operator()() const /usr/include/c++/7/mutex:672 (gdb+0x72434a)
    #17 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#2}::operator()() const /usr/include/c++/7/mutex:677 (gdb+0x72434a)
    #18 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#2}::_FUN() /usr/include/c++/7/mutex:677 (gdb+0x72434a)
    #19 pthread_once <null> (libtsan.so.0+0x4457c)
    #20 __gthread_once /usr/include/c++/7/x86_64-suse-linux/bits/gthr-default.h:699 (gdb+0x72532b)
    #21 void std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/7/mutex:684 (gdb+0x72532b)
    #22 std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) /usr/include/c++/7/future:401 (gdb+0x174568d)
    #23 std::__future_base::_Task_state<std::function<void ()>, std::allocator<int>, void ()>::_M_run() /usr/include/c++/7/future:1423 (gdb+0x174568d)
    #24 std::packaged_task<void ()>::operator()() /usr/include/c++/7/future:1556 (gdb+0x174568d)
    #25 gdb::thread_pool::thread_function() gdbsupport/thread-pool.cc:242 (gdb+0x174568d)
    #26 void std::__invoke_impl<void, void (gdb::thread_pool::*)(), gdb::thread_pool*>(std::__invoke_memfun_deref, void (gdb::thread_pool::*&&)(), gdb::thread_pool*&&) /usr/include/c++/7/bits/invoke.h:73 (gdb+0x1748040)
    #27 std::__invoke_result<void (gdb::thread_pool::*)(), gdb::thread_pool*>::type std::__invoke<void (gdb::thread_pool::*)(), gdb::thread_pool*>(void (gdb::thread_pool::*&&)(), gdb::thread_pool*&&) /usr/include/c++/7/bits/invoke.h:95 (gdb+0x1748040)
    #28 decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void (gdb::thread_pool::*)(), gdb::thread_pool*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) /usr/include/c++/7/thread:234 (gdb+0x1748040)
    #29 std::thread::_Invoker<std::tuple<void (gdb::thread_pool::*)(), gdb::thread_pool*> >::operator()() /usr/include/c++/7/thread:243 (gdb+0x1748040)
    #30 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (gdb::thread_pool::*)(), gdb::thread_pool*> > >::_M_run() /usr/include/c++/7/thread:186 (gdb+0x1748040)
    #31 <null> <null> (libstdc++.so.6+0xdcac2)
  ...
SUMMARY: ThreadSanitizer: data race gdb/dwarf2/read.c:3077 in dw_expand_symtabs_matching_file_matcher(dwarf2_per_objfile*, gdb::function_view<bool (char const*, bool)>)
...

The race happens when issuing the "file $exec" command.

The race is between:
- a worker thread writing the index cache, and in the process reading
  dwarf2_per_cu_data::is_debug_type, and
- the main thread writing to dwarf2_per_cu_data::mark.

The two bitfields dwarf2_per_cu_data::mark and
dwarf2_per_cu_data::is_debug_type share the same bitfield container.

Fix this by making dwarf2_per_cu_data::mark a packed<unsigned int, 1>.

Tested on x86_64-linux.

PR symtab/30718
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30718