]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
12 months agoaarch64: Add support for virtual features
Andrew Carlotti [Fri, 21 Jun 2024 18:31:06 +0000 (19:31 +0100)] 
aarch64: Add support for virtual features

These features will be used to gate instructions that can be enabled by
either of two (or more) different sets of command line feature flags.

This patch add a postprocessing step to the feature parsing code to
set the value of the virtual bits.

12 months agoaarch64: Move struct definition towards its usage
Andrew Carlotti [Fri, 21 Jun 2024 18:30:39 +0000 (19:30 +0100)] 
aarch64: Move struct definition towards its usage

12 months agoPrefer htab_traverse_noresize
Tom Tromey [Wed, 5 Jun 2024 16:38:10 +0000 (10:38 -0600)] 
Prefer htab_traverse_noresize

A few spots in gdb were using htab_traverse.  IMO this is almost never
useful and htab_traverse_noresize should be preferred.

12 months agoRemove hashtab_obstack_allocate
Tom Tromey [Wed, 5 Jun 2024 15:51:08 +0000 (09:51 -0600)] 
Remove hashtab_obstack_allocate

I think that hashtabs should never be obstack-allocated.  In the past
this was convenient sometimes, because any new data structure needed a
corresponding cleanup.  However, with the switch to C++, resource
management has become much simpler; for example, a local variable can
simply be of type htab_up rather than hashtab_t, and the problem is
solved.

This patch removes hashtab_obstack_allocate to try to prevent this
anti-pattern from being used again.

12 months agoDon't obstack-allocate the call site hash table
Tom Tromey [Wed, 5 Jun 2024 15:38:53 +0000 (09:38 -0600)] 
Don't obstack-allocate the call site hash table

The call site hash table is the last hash table using obstack
allocation.  In one large (non-public) test case, these hash tables
take a substiantial amount of memory.  Some of this memory is wasted
-- whenever the hash table is resized, the old table is not freed.

This patch fixes the problem by changing this hash table to be
heap-allocated.  This means that resizing will no longer "leak"
memory.

12 months agoAdd compunit_symtab::forget_cached_source_info
Tom Tromey [Wed, 5 Jun 2024 15:06:30 +0000 (09:06 -0600)] 
Add compunit_symtab::forget_cached_source_info

It seemed cleaner to me for compunit_symtab to have a
forget_cached_source_info method, then for the objfile to know how to
do this.

12 months agoMake symtab members private
Tom Tromey [Wed, 5 Jun 2024 14:55:21 +0000 (08:55 -0600)] 
Make symtab members private

This rearranges symtab so that the private members appear at the end,
and then adds the "private" keyword.

12 months agoRename symtab::fullname
Tom Tromey [Wed, 5 Jun 2024 14:51:01 +0000 (08:51 -0600)] 
Rename symtab::fullname

This renames symtab::fullname to m_fullname and adds new accessor
methods.

12 months agoDon't obstack-allocate the CU dependency hash table
Tom Tromey [Wed, 5 Jun 2024 14:19:34 +0000 (08:19 -0600)] 
Don't obstack-allocate the CU dependency hash table

The CU dependency hash table is obstack-allocated, but there's no need
to do this.

12 months agoDon't obstack-allocate the DIE hash
Tom Tromey [Wed, 5 Jun 2024 14:16:32 +0000 (08:16 -0600)] 
Don't obstack-allocate the DIE hash

The DIE hash table is currently allocated on an obstack.  There's no
need to do this, and I think it's better to simply heap-allocate the
hash table.

This patch implements this.  I also removed store_in_ref_table as
well, inlining it into its sole caller, as I think this is clearer.

12 months agolibdep plugin: fix bugs in parser and drop escaping
Harmen Stoppels [Mon, 24 Jun 2024 15:00:14 +0000 (16:00 +0100)] 
libdep plugin: fix bugs in parser and drop escaping

  PR ld/31906
  * libdep_plugin.c (str2vec): Fix bug where null byte was not copied on memmove during quote handling and escaping, causing repeat of the last character in the last argument.
  Fix buffer overflow in **res when arguments were separated by `\t` instead of ` `.
  Remove handling of the escape character `\`, as it made it impossible to specify paths containing `\`
  -- the implementation merely dropped `\`, and was affected by the memmove bug, so this should not be breaking; just single and double quotes are sufficient to deal with white space and quote characters, there is no need for escaping.
  Handle syntax errors   on unterminated quotes.
  Make the parser linear time instead of   quadratic.

12 months agoUpdated Spanish translations for the bfd and binutils sub-directories
Nick Clifton [Mon, 24 Jun 2024 14:03:22 +0000 (15:03 +0100)] 
Updated Spanish translations for the bfd and binutils sub-directories

12 months agold: Improve the documentation describing the -o option.
Nick Clifton [Mon, 24 Jun 2024 14:00:14 +0000 (15:00 +0100)] 
ld: Improve the documentation describing the -o option.

  PR 31761

12 months agogas, aarch64: Add SME2 lutv2 extension
saurabh.jha@arm.com [Fri, 21 Jun 2024 15:30:59 +0000 (16:30 +0100)] 
gas, aarch64: Add SME2 lutv2 extension

Introduces instructions for the SME2 lutv2 extension for AArch64. They
are documented in the following document:

  * ARM DDI0602

For both luti4 instructions, we introduced an operand called
SME_Znx2_BIT_INDEX. We use the existing function parse_vector_reg_list
for parsing but modified that function so that it can accept operands
without qualifiers and rejects instructions that have operands with
qualifiers but are not supposed to have operands with qualifiers.
For disassembly, we modified print_register_list so that it could
accept register lists without qualifiers.

For one luti4 instruction, we introduced a SME_Zdnx4_STRIDED. It is
similar to SME_Ztx4_STRIDED and we could use existing code for parsing,
encoding, and disassembly.

For movt instruction, we introduced an operand called SME_ZT0_INDEX2_12.
This is a ZT0 register with a bit index encoded in [13:12]. It is
similar to SME_ZT0_INDEX.

We also introduced an iclass named sme_size_12_b so that we can encode
size bits [13:12] correctly when only 'b' is allowed as qualifier.

12 months agoInclude needed unordered_map header
Martin Simmons [Mon, 24 Jun 2024 11:34:59 +0000 (12:34 +0100)] 
Include needed unordered_map header

Compiling on FreeBSD 13.2 with the default clang version 14.0.5 and top level
configure options --with-python=/usr/local/bin/python3.9 gives this error:

  CXX    ada-exp.o
./../binutils-gdb/gdb/ada-exp.y:100:8: error: no template named 'unordered_map' in namespace 'std'
  std::unordered_map<std::string, std::vector<ada_index_var_operation *>>
  ~~~~~^
1 error generated.

This change fixes it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31918
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/doc: fix parallel build of pdf and dvi files
Andrew Burgess [Wed, 8 May 2024 18:12:57 +0000 (19:12 +0100)] 
gdb/doc: fix parallel build of pdf and dvi files

When building with 'make -j20 -C gdb/doc all-doc' I often see problems
caused from trying to build some dvi files in parallel with some pdf
files.  The problem files are: gdb.dvi and gdb.pdf; stabs.dvi and
stabs.pdf; and annotate.dvi and annotate.pdf.

The problem is that building these files create temporary files in the
local directory.  There's already a race here that two make threads
might try to create these files at the same time.

But it gets worse, to avoid issues where a failed build could leave
these temporary files in a corrupted state, and so prevent the next
build from succeeding, the recipe for each of these files deletes all
the temporary files first, this obviously causes problems if some
other thread has already started the build and is relying on these
temporary files.

To work around this problem I propose we start using the --build and
--build-dir options for texi2dvi (which is the same tool used to
create the pdf files).  These options were added in texinfo 4.9 which
was released in June 2007.  We already require using a version of
texinfo after 4.9 (I tried to build with 4.13 and the doc build failed
as some of the texinfo constructs were not understood), so this patch
has not changed the minimum required version at all.

The --build flag allows the temporary files to be placed into a
sub-directory, and the --build-dir option allows us to control the
name of that sub-directory.

What we do is create a unique sub-directory for each target that
invokes texi2dvi, all of the unique sub-directories are created within
a single directory texi2dvi_tmpdir, and so after a complete doc build,
we are left with a build tree like this:

  build/gdb/doc/
  '-- texi2dvi_tmpdir/
      |-- annotate_dvi/
      |-- annotate_pdf/
      |-- gdb_dvi/
      |-- gdb_pdf/
      |-- stabs_dvi/
      '-- stabs_pdf/

I've left out all the individual files that live within these
directories for simplicity.

To avoid corrupted temporary files preventing a future build to
complete, each recipe deletes its associated sub-directory from within
texi2dvi_tmpdir/ before it attempts a build, this ensures a fresh
start each time.

And the mostlyclean target deletes texi2dvi_tmpdir/ and all its
sub-directories, ensuring that everything is cleaned up.

For me, with this fix in place, I can now run 'make -j20 -C gdb/doc
all-doc' without seeing any build problems.

Approved-By: Pedro Alves <pedro@palves.net>
12 months agogdb/doc: fix parallel build of refcard related targets
Andrew Burgess [Wed, 8 May 2024 17:55:18 +0000 (18:55 +0100)] 
gdb/doc: fix parallel build of refcard related targets

There are two problems we encounter when trying to build the refcard
related target in parallel, i.e.:

  $ make -j20 -C gdb/doc/ refcard.dvi refcard.ps refcard.pdf

These problems are:

(1) The refcard.dvi and refcard.pdf targets both try and generate the
    tmp.sed and sedref.tex files.  If two make threads end up trying
    to create these files at the same time then the result is these
    files become corrupted.

    I've fixed this by creating a new rule that creates sedref.tex,
    both refcard.dvi and refcard.pdf now depend on this, and make will
    build sedref.tex just once.  The tmp.sed file is now generated as
    refcard.sed, this is generated and deleted as a temporary file
    within the sedref.tex recipe.

(2) Having created sedref.tex the recipes for refcard.dvi and
    refcard.pdf both run various LaTeX based tools with sedref.tex as
    the input file.  The problem with this is that these tools all
    rely on creating temporary files calls sedref.*.

    If the refcard.dvi and refcard.pdf rules run at the same time then
    these temporary files clash and overwrite each other causing the
    build to fail.

    We already copy the result file in order to rename it, our input
    file is sedref.tex which results in an output file named
    sedref.dvi or sedref.pdf, but we actually want refcard.dvi or
    refcard.pdf.  So within the recipe for refcard.dvi I copy the
    input file from sedref.tex to sedref_dvi.tex.  Now all the temp
    files are named sedref_dvi.* and the output is sedref_dvi.dvi, I
    then rename this new output file to refcard.dvi.

    I've done the same thing for refcard.pdf, but I copy the input
    to sedref_pdf.tex.

    In this way the temp files no longer clash, and both recipes can
    safely run in parallel.

After this commit I was able to reliably build all of the refcard
targets in parallel.  There should be no change in the final file.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/doc: also look in srcdir when running TEXI2POD
Andrew Burgess [Thu, 30 May 2024 16:08:31 +0000 (17:08 +0100)] 
gdb/doc: also look in srcdir when running TEXI2POD

In gdb/doc/Makefile.in the TEXI2POD variable is used to invoke
texi2pod.pl, which process the .texinfo files.  This also handles the
'include' directives within the .texinfo files.

Like the texi2dvi and texi2pdf tools, texi2pod.pl handles the -I flag
to add search directories for resolving 'include' directives within
.texinfo files.

When GDB runs TEXI2POD we include gdb-cfg.texi, which then includes
GDBvn.texi.

When building from a git checkout the gdb-cfg.texi files and
GDBvn.texi files will be created in the build directory, which is
where texi2pod.pl is invoked, so the files will be found just fine.

However, for a GDB release we ship gdb-cfg.texi and GDBvn.texi in the
source tree, along with the generated manual (.1 and .5) files.

So when building a release, what normally happens is that we spot that
the .1 and .5 man files are up to date, and don't run the recipe to
regenerate these files.

However, if we deliberately touch the *.texinfo files in a release
source tree, and then try to rebuild the man files, we'll get an error
like this:

  make: Entering directory '/tmp/release-build/build/gdb/doc'
    TEXI2POD gdb.1
  cannot find GDBvn.texi at ../../../gdb-16.0.50.20240529/gdb/doc/../../etc/texi2pod.pl line 251, <GEN0> line 16.
  make: *** [Makefile:664: gdb.1] Error 2
  make: Leaving directory '/tmp/release-build/build/gdb/doc'

The problem is that texi2pod.pl doesn't know to look in the source
tree for the GDBvn.texi file.

If we compare this to the recipe for creating (for example) gdb.dvi,
which uses texi2dvi, this recipe adds '-I $(srcdir)' to the texi2dvi
command line, which allows texi2dvi to find GDBvn.texi in the source
tree.

In this commit I add a similar -I option to the texi2pod.pl command
line.  After this, given a GDB release, it is possible to edit (or
just touch) the gdb.texinfo file and rebuild the man pages, the
GDBvn.texi will be picked up from the source tree.

If however a dependency for GDBvn.texi is changed in a release tree
then GDBvn.texi will be regenerated into the build directory and this
will be picked up in preference to the GDBvn.texi in the source tree,
just as you would want.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/doc: allow for version.subst in the source tree
Andrew Burgess [Thu, 30 May 2024 13:41:48 +0000 (14:41 +0100)] 
gdb/doc: allow for version.subst in the source tree

In a git checkout of the source code we don't have a version.subst
file in the gdb/doc directory.  When building the GDB docs the
version.subst file is generated on demand (we have a recipe for that).

However, in a release tar file we do include a copy of the
version.subst file in the source tree, as a result the version.subst
recipe will not be run.

If, in a release build, we force the running of any recipe that
depends on version.subst then we run into a problem.  For example,
slightly confusingly, if we 'touch gdb/doc/version.subst' within the
unpacked source tree of a release, then 'make -C gdb/doc GDBvn.texi'
in the build tree, we'll see:

  make: Entering directory '/tmp/build/build/gdb/doc'
    GEN    GDBvn.texi
  sed: can't read version.subst: No such file or directory
  make: Leaving directory '/tmp/build/build/gdb/doc'

The problem is that every reference to version.subst in GDB's Makefile
assumes that the version.subst file will always be in the build
directory.

Handily version.subst is always the first dependency in every recipe
that uses that file.  As such we can replace references to
version.subst with $<, make will expand this to the location where the
dependency was found.

In the case of the man page generation, the reference to version.subst
is hidden inside POD2MAN.  It seemed a little confusing adding a use
of  $< within POD2MAN, so I've moved the use into the recipe, which I
think is clearer.

I've also added comments for the two rules that I've modified to
explain our use of $<.

After this change it is possible to rebuild the man pages even when
version.subst is located in the source tree.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/doc: merge rules for building .1 and .5 man pages
Andrew Burgess [Thu, 6 Jun 2024 17:29:23 +0000 (18:29 +0100)] 
gdb/doc: merge rules for building .1 and .5 man pages

We have two rules, one each for building the .1 and .5 man pages.  The
only actual difference is that one rule passes --section=1 and the
other passes --section=5 (see the definitions of POD2MAN1 and POD2MAN5
respectively.

I figure by using the suffix from the target of the rule we can
combine these two rules into one.

I use:

  $(subst .,,$(suffix $@))

This gets the suffix from the target, either '.1' or '.5', and the
'subst' removes the '.' leaving '1' or '5'.

Now that I'm not using a static pattern rule for building the man
pages, the advice in the 'make' documentation is to not use $*, so
I've moved away from that to instead use $(basename $@), e.g. for
'gdbinit.5' this gives 'gdbinit', which is what we want.

There should be no difference in what is created after this change.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/doc: don't try to copy GDBvn.texi from the source tree
Andrew Burgess [Fri, 10 May 2024 13:41:03 +0000 (14:41 +0100)] 
gdb/doc: don't try to copy GDBvn.texi from the source tree

The build recipe for gdb.dvi and gdb.pdf contains instructions for
copying the GDBvn.texi file from the source tree into the build
directory if the GDBvn.texi file doesn't already exist in the build
directory.

The gdb.dvi and gdb.pdf targets also have a dependency on GDBvn.texi,
and we have a recipe for building GDBvn.texi.

What's happening here is this:

  - In a git checkout of the source tree there is no GDBvn.texi in the
    source tree, the GDBvn.texi dependency will trigger a rebuild of
    GDBvn.texi, which is then used to build gdb.dvi and/or gdb.pdf.

  - In a release tar file we do include a copy of GDBvn.texi.  This
    file will appear to be up to date, and so no copy of GDBvn.texi is
    created within the build directory.  Now when building gdb.dvi
    and/or gdb.pdf we copy (or symlink) the version of GDBvn.texi from
    the source tree into the build directory.

However, copying GDBvn.texi from the source directory is completely
unnecessary.  The gdb.dvi/gdb.pdf recipes both invoke texi2dvi and
pass '-I $(srcdir)' as an argument, this means that texi2dvi will look
in the $(srcdir) to find included files, including GDBvn.texi.

As such I believe we can remove the code that copies GDBvn.texi from
the source tree into the build tree.

I've tested with a release build; creating a release with:

  ./src-release gdb

Then in an empty directory, unpacking the resulting .tar file,
creating a parallel build directory and doing the usual configure,
make, and 'make install'.

Having done this I can then 'touch gdb/doc/*.texinfo' in the unpacked
source tree, and do 'make -C gdb/doc pdf dvi' to rebuild all the pdf
and dvi files, this works fine without having to either build or copy
GDBvn.texi into the build directory.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/i386: fix tdesc rejection issue for targets without PTRACE_GETREGSET
Andrew Burgess [Fri, 21 Jun 2024 10:43:58 +0000 (11:43 +0100)] 
gdb/i386: fix tdesc rejection issue for targets without PTRACE_GETREGSET

After the x86 target description changes that I committed recently,
the first commit in the series being:

  commit 8a29222b85f28a2201db50a34ac4144f961311db
  Date:   Sat Jan 27 10:40:35 2024 +0000

      gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition

and the last commit in the series being:

  commit 646d754d14c2fe70a492a893506a74b0463b6ae8
  Author: Andrew Burgess <aburgess@redhat.com>
  Date:   Tue Jan 30 15:37:23 2024 +0000

      gdb/gdbserver: share x86/linux tdesc caching

The sourceware buildbot highlighted a regression on i386.  On the GDB
side we'd see this:

  Remote debugging using :54321
  warning: Architecture rejected target-supplied description
  Remote connection closed
  (gdb)

while on the gdbserver side we'd see this:

  $ ./gdbserver/gdbserver --once :54321 ~/empty
  Process /srv/aburgess/empty created; pid = 31406
  Listening on port 54321
  Remote debugging from host ::1, port 39488
  ../../src/gdbserver/regcache.cc:272: A problem internal to GDBserver has been detected.
  Unknown register st0 requested
  Aborted (core dumped)

When I tried to reproduce this regression on my local i386 VM the
issue would not reproduce.

I eventually tracked the problem down to x86_linux_tdesc_for_tid in
gdb/nat/x86-linux-tdesc.c.  In this function we have this line:

  /* Check if PTRACE_GETREGSET works.  */
  if (ptrace (PTRACE_GETREGSET, tid,
              (unsigned int) NT_X86_XSTATE, &iov) < 0)
    {
      ... handle failure ...
    }
  else
    {
      ... handle success ...
    }

The problem is that on my VM the PTRACE_GETREGSET feature is
supported, while on sourceware's buildbot machine this feature is not
supported.

I did a quick search and it seems like the 'xsave' feature in
/proc/cpuinfo might be the indicator for whether PTRACE_GETREGSET is
supported or not, and indeed my machine has the 'xsave' feature while
the sourceware machine does not.

The point of divergence then is this ptrace call, on my machine the
call succeeds and we extract the xcr0 value from the iov vector, while
on the sourceware machine the ptrace call fails and we use a default
xcr0 value of 0.

This xcr0 value is then passed to i386_linux_read_description at the
end of x86_linux_tdesc_for_tid.

In gdb/arch/i386-linux-tdesc.c we find i386_linux_read_description
which does some caching but calls i386_create_target_description to
actually create the target descriptions when needed.  The xcr0 value
is masked to only the bits that are interesting, but given a value of
0 we'll just pass 0 through to i386_create_target_description.

In gdb/arch/i386.c we find i386_create_target_description which checks
the xcr0 bits and builds the target description.  What we can see is
that if no bits are set in the xcr0 value then no features will be
added to the created target description.  This featureless target
description is then transmitted back to GDB, which is then rejected
due to lack of essential core registers.

So, how did things work prior to the above commit series?  There are
three places of interest, on the GDB side there is
x86_linux_nat_target::read_description and
i386_linux_core_read_description.  Then on the gdbserver side there is
x86_linux_read_description.

All of these locations have a call to i386_linux_read_description
followed by a check if the return value was nullptr.  If we do get
back nullptr then we perform another call to
i386_linux_read_description with a default xcr0 value.

Looking in i386_linux_read_description we see a specific check for
xcr0 being 0 in which case we return nullptr.

And so, prior to the above series, if xcr0 was 0 due to
PTRACE_GETREGSET being unavailable we'd use a default xcr0 value.

After the above series this is no longer the case, the 'xcr0 == 0'
check has been removed from i386_linux_read_description and the
calling code is streamlined to remove the use of default xcr0 values.

The fix I propose here is to setup the default xcr0 value at the point
where we find that PTRACE_GETREGSET is unavailable.  The default value
used is X86_XSTATE_SSE_MASK.  This is the default used in
x86_linux_nat_target::read_description (for GDB) and in
x86_linux_read_description (for gdbserver).  The above commit series
already fixed i386_linux_core_read_description to ensure that the
correct default xcr0 value was used, this case is a little special in
that it uses different defaults depending on which sections are
present in the core file, so that case always needed to be handled
differently.

The choice of X86_XSTATE_SSE_MASK corresponds to the default used for
i386 before the above series was committed.  This mask includes the
X87 and SSE bits only, neither of these bits are checked for on amd64
or x32, so this default doesn't change the behaviour on these targets.

By setting the default xcr0 value at this early stage we ensure that
the cached xcr0 value on the gdbserver side is correct.  This is
critical as this cached xcr0 value is passed through to the in process
agent (IPA).  If we leave the cached xcr0 value as 0 and apply the
defaults later in the series we also have to encode the knowledge of
the default into the IPA, this just means we have the default encoded
in multiple locations, which seems like a bad idea.  The approach used
in this patch means the default is present in just one location.

This commit should fix the i386 regressions seen on the sourceware
buildbot.

In addition to the fix in nat/x86-linux-tdesc.c I've also fixed the
layout of the declaration of x86_linux_tdesc_for_tid in the header
file.

Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Mon, 24 Jun 2024 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoaarch64: Enable +cssc for armv8.9-a
Andrew Carlotti [Fri, 12 Apr 2024 12:35:00 +0000 (13:35 +0100)] 
aarch64: Enable +cssc for armv8.9-a

FEAT_CSSC is mandatory in the architecture from Armv8.9.

12 months agoAutomatic date update in version.in
GDB Administrator [Sun, 23 Jun 2024 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogdb/testsuite: analyze-racy-logs.py cleanup
Simon Marchi [Thu, 25 Apr 2024 17:42:42 +0000 (13:42 -0400)] 
gdb/testsuite: analyze-racy-logs.py cleanup

 - Add type annotations
 - Use a raw string in one spot (where we call re.sub), to avoid an
   "invalid escape sequence" warning.
 - Remove unused "os" import.

Change-Id: I0149cbb73ad2b05431f032fa9d9530282cb01e90
Reviewed-By: Guinevere Larsen <blarsen@redhat.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Sat, 22 Jun 2024 00:00:24 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months ago[gdb/testsuite] Fix regexp in gdb.threads/stepi-over-clone.exp
Tom de Vries [Fri, 21 Jun 2024 14:53:19 +0000 (16:53 +0200)] 
[gdb/testsuite] Fix regexp in gdb.threads/stepi-over-clone.exp

On fedora rawhide, I ran into:
...
(gdb) continue^M
Continuing.^M
^M
Catchpoint 2 (call to syscall clone3), 0x000000000042097d in __clone3 ()^M
(gdb) FAIL: gdb.threads/stepi-over-clone.exp: continue
...

Fix this by updating a regexp to also recognize __clone3.

Tested on x86_64-linux.

Tested-By: Guinevere Larsen <blarsen@redhat.com>
12 months ago[gdb/tdep] Fix gdb.base/watchpoint-running.exp on {arm,ppc64le}-linux
Pedro Alves [Fri, 21 Jun 2024 13:14:08 +0000 (15:14 +0200)] 
[gdb/tdep] Fix gdb.base/watchpoint-running.exp on {arm,ppc64le}-linux

When running test-case gdb.base/watchpoint-running on ppc64le-linux (and
similar on arm-linux), we get:
...
(gdb) watch global_var^M
warning: Error when detecting the debug register interface. \
  Debug registers will be unavailable.^M
Watchpoint 2: global_var^M
(gdb) FAIL: $exp: all-stop: hardware: watch global_var
FAIL: $exp: all-stop: hardware: watchpoint hit (timeout)
...

The problem is that ppc_linux_dreg_interface::detect fails to detect the
hardware watchpoint interface, because the calls to ptrace return with errno
set to ESRCH.

This is a feature of ptrace: if a call is done while the tracee is not
ptrace-stopped, it returns ESRCH.

Indeed, in the test-case "watch global_var" is executed while the inferior is
running, and that triggers the first call to ppc_linux_dreg_interface::detect.

And because the detection failure is cached, subsequent attempts at setting
hardware watchpoints will also fail, even if the tracee is ptrace-stopped.

The way to fix this is to make sure that ppc_linux_dreg_interface::detect is
called when we know that the thread is ptrace-stopped, which in the current
setup is best addressed by using target-specific post_attach and
post_startup_inferior overrides.  However, as we can see in
aarch64_linux_nat_target, that causes code duplication.

Fix this by:
- defining a new target hook low_init_process, called from
  linux_init_ptrace_procfs, which is called from both
  linux_nat_target::post_attach and linux_nat_target::post_startup_inferior,
- adding implementations for ppc_linux_nat_target and arm_linux_nat_target
  that detect the hardware watchpoint interface,
- replacing the aarch64_linux_nat_target implementations of post_attach and
  post_startup_inferior with a low_init_process implementation.

Tested on ppc64le-linux, arm-linux, aarch64-linux and x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
Approved-By: Luis Machado <luis.machado@arm.com>
PR tdep/31834
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31834
PR tdep/31705
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31705

12 months agox86: optimize {,V}PEXTR{D,Q} with immediate of 0
Jan Beulich [Fri, 21 Jun 2024 12:40:44 +0000 (14:40 +0200)] 
x86: optimize {,V}PEXTR{D,Q} with immediate of 0

Such are equivalent to simple moves, which are up to 3 bytes shorter to
encode (and perhaps also cheaper to execute).

12 months agox86: optimize left-shift-by-1
Jan Beulich [Fri, 21 Jun 2024 12:39:52 +0000 (14:39 +0200)] 
x86: optimize left-shift-by-1

These can be replaced by adds when acting on a register operand.

While for the scalar forms there's no gain in encoding size, ADD
generally has higher throughput than SHL. EFLAGS set by ADD are a
superset of those set by SHL (AF in particular is undefined there).

For the SIMD cases the transformation also reduced code size, by
eliminating the 1-byte immediate from the resulting encoding. Note
that this transformation is not applied by gcc13 (according to my
observations), so would - as of now - even improve compiler generated
code.

12 months agox86/APX: fix disassembly of byte register operands
Jan Beulich [Fri, 21 Jun 2024 06:36:03 +0000 (08:36 +0200)] 
x86/APX: fix disassembly of byte register operands

Like for REX/REX2, EVEX-prefixed insns access the low bytes of all
registers; %ah...%bh are inaccessible. Reflect this correctly in output,
by leveraging REX machinery we already have to this effect.

12 months agox86: %riz, %rip, and %eip don't require REX
Jan Beulich [Fri, 21 Jun 2024 06:35:23 +0000 (08:35 +0200)] 
x86: %riz, %rip, and %eip don't require REX

While these can't be used as register operands, they can be used for
memory operand addressing. Such uses do not prevent conversion: The
RegRex64 checks in check_Rex_required() for base and index registers
were simply wrong. They specifically also aren't needed for byte
registers, as those won't pass i386_index_check() anyway.

12 months agox86: don't suppress errors when optimizing
Jan Beulich [Fri, 21 Jun 2024 06:33:57 +0000 (08:33 +0200)] 
x86: don't suppress errors when optimizing

Blindly ignoring any mnemonic suffix can't be quite right: Bad suffix /
operand combinations still want flagging. Simply avoid optimizing in
such situations.

12 months agogas: terminate buffer SB in do_repeat()
Jan Beulich [Fri, 21 Jun 2024 06:32:53 +0000 (08:32 +0200)] 
gas: terminate buffer SB in do_repeat()

PR gas/31903

While elsewhere having realized that "one" doesn't point to a nul-
terminated string, it somehow didn't occur to me that the pre-existing
strstr() could have been wrong, and hence I blindly added a new use of
the function. Add the (already prior to 1e3c814459d8 ["gas: extend \+
support to .rept"]) missing call to sb_terminate(), leveraging that to
simplify the other two places where the lack of nul termination was
previously worked around.

12 months agoRISC-V: Remove implicit enablement of Zvknha from Zvkn.
Feng Wang [Fri, 21 Jun 2024 01:58:00 +0000 (01:58 +0000)] 
RISC-V: Remove implicit enablement of Zvknha from Zvkn.

Accroding to the Crypto spec, the Zvkned,Zvknhb,Zvkb and Zvkt are
included in the Zvkn.  So the Zvknha should be removed from Zvkn.

bfd/ChangeLog:

* elfxx-riscv.c: Remove zvknha from zvkn.

12 months agoAutomatic date update in version.in
GDB Administrator [Fri, 21 Jun 2024 00:00:42 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoHandle "info symbol" in Rust language mode
Tom Tromey [Wed, 27 Mar 2024 16:43:57 +0000 (10:43 -0600)] 
Handle "info symbol" in Rust language mode

When I changed the Rust parser to handle 128-bit ints, this
inadvertently broke some other gdb commands.  For example, "info
symbol 0xffffffffffffffff" now fails, because the resulting value is
128 bits, but this is rejected by extract_integer.

This patch fixes the problem by changing extract_integer to allow
over-long integers as long as the high bytes are either 0, or (for
signed types) 0xff.

Regression tested on x86-64 Fedora 38.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31565
Approved-By: Andrew Burgess <aburgess@redhat.com>
12 months ago[gdb/testsuite] Fix gdb.python/py-format-address.exp on arm
Tom de Vries [Thu, 20 Jun 2024 14:54:47 +0000 (16:54 +0200)] 
[gdb/testsuite] Fix gdb.python/py-format-address.exp on arm

When running test-case gdb.python/py-format-address.exp on arm-linux, I get:
...
(gdb) python print("Got: " + gdb.format_address(0x103dd))^M
Got: 0x103dd <main at py-format-address.c:30>^M
(gdb) FAIL: $exp: symbol_filename=on: gdb.format_address, \
result should have an offset
...

What is expected here is:
...
Got: 0x103dd <main+1 at py-format-address.c:30>^M
...

Main starts at main_addr:
...
(gdb) print /x &main^M
$1 = 0x103dc^M
...
and we obtained next_addr 0x103dd by adding 1 to it:
...
set next_addr [format 0x%x [expr $main_addr + 1]]
...

Adding 1 to $main_addr results in an address for a thumb function starting at
address 0x103dc, which is incorrect because main is an arm function (because
I'm running with target board unix/-marm).

At some point during the call to format_addr, arm_addr_bits_remove removes
the thumb bit, which causes the +1 offset to be dropped, causing the FAIL.

Fix this by using the address of the breakpoint on main, provided it's not at
the very start of main.

Tested on arm-linux.

PR testsuite/31452
Bug: https://www.sourceware.org/bugzilla/show_bug.cgi?id=31452

12 months ago[gdb/testsuite] Fix duplicates in gdb.base/watchpoint-unaligned.exp
Tom de Vries [Thu, 20 Jun 2024 13:37:48 +0000 (15:37 +0200)] 
[gdb/testsuite] Fix duplicates in gdb.base/watchpoint-unaligned.exp

When running test-case gdb.base/watchpoint-unaligned.exp on ppc64le-linux, we
get:
...
XFAIL: $exp: rwatch data.u.size1[3] (PRMS breakpoints/23131)
XFAIL: $exp: rwatch data.u.size1[4] (PRMS breakpoints/23131)
  ...
UNTESTED: $exp: wpcount(4)
XFAIL: $exp: rwatch data.u.size1[3] (PRMS breakpoints/23131)
DUPLICATE: $exp: rwatch data.u.size1[3] (PRMS breakpoints/23131)
XFAIL: $exp: rwatch data.u.size1[4] (PRMS breakpoints/23131)
DUPLICATE: $exp: rwatch data.u.size1[4] (PRMS breakpoints/23131)
  ...
UNTESTED: $exp: wpcount(7)
...

Fix this by using foreach_with_prefix.

Tested on ppc64le-linux.

12 months ago[gdb/testsuite] Fix duplicates in gdb.opt/inline-cmds.exp
Tom de Vries [Thu, 20 Jun 2024 13:37:48 +0000 (15:37 +0200)] 
[gdb/testsuite] Fix duplicates in gdb.opt/inline-cmds.exp

With test-case gdb.opt/inline-cmds.exp on ppc64le-linux, I ran into:
...
PASS: gdb.opt/inline-cmds.exp: finish from marker
 ...
PASS: gdb.opt/inline-cmds.exp: finish from marker
DUPLICATE: gdb.opt/inline-cmds.exp: finish from marker
...

Fix this by issuing less passes.

Tested on ppc64le-linux.

12 months ago[gdb/testsuite] Fix duplicates in gdb.fortran/huge.exp
Tom de Vries [Thu, 20 Jun 2024 13:37:48 +0000 (15:37 +0200)] 
[gdb/testsuite] Fix duplicates in gdb.fortran/huge.exp

With test-case gdb.fortran/huge.exp, on a system without fortran compiler, I
ran into a number of duplicates:
...
Running /home/vries/gdb/src/gdb/testsuite/gdb.fortran/huge.exp ...
gdb compile failed, default_target_compile: Can't find gfortran.
UNTESTED: gdb.fortran/huge.exp: huge.exp
  ...
gdb compile failed, default_target_compile: Can't find gfortran.
UNTESTED: gdb.fortran/huge.exp: huge.exp
DUPLICATE: gdb.fortran/huge.exp: huge.exp
UNSUPPORTED: gdb.fortran/huge.exp: require failed: expr $compilation_succeeded
...

Fix this by wrapping the compile in a with_test_prefix, getting us instead:
...
gdb compile failed, default_target_compile: Can't find gfortran.
UNTESTED: gdb.fortran/huge.exp: CRASH_GDB=2097152: huge.exp
  ...
gdb compile failed, default_target_compile: Can't find gfortran.
UNTESTED: gdb.fortran/huge.exp: CRASH_GDB=16: huge.exp
UNSUPPORTED: gdb.fortran/huge.exp: require failed: expr $compilation_succeeded
...

Tested on x86_64-linux.

12 months agoRevert "Remove LIBINTL_DEP"
Alan Modra [Thu, 20 Jun 2024 11:44:24 +0000 (21:14 +0930)] 
Revert "Remove LIBINTL_DEP"

This reverts commit e874cbd3879843a83e4bcc4b54cd7107387b1df6.
The patch was wrong.  LIBINTL_DEP is needed with an in-tree gettext.

12 months agoRemove LIBINTL_DEP
Alan Modra [Wed, 19 Jun 2024 23:35:27 +0000 (09:05 +0930)] 
Remove LIBINTL_DEP

The intl directory in the source no longer exists.  LIBINTL_DEP is
thus always empty.  Remove references to it.

config/
* gettext-sister.m4: Don't AC_SUBST LIBINTL_DEP.
bfd/
* Makefile.in: Regenerate.
* configure: Regenerate.
binutils/
* Makefile.am (*_DEPENDENCIES): Remove LIBINTL_DEP.
* Makefile.in: Regenerate.
* configure: Regenerate.
gas/
* Makefile.am (as_new_DEPENDENCIES): Remove LIBINTL_DEP.
* Makefile.in: Regenerate.
* configure: Regenerate.
gdb/
* Makefile.in (INTL_DEPS): Don't set or reference.
* configure: Regenerate.
gdbserver/
* Makefile.in (INTL_DEPS): Don't set or reference.
gdbsupport/
* Makefile.in: Regenerate.
* configure: Regenerate.
gold/
* Makefile.am (deps_var): Remove LIBINTL_DEP.
(incremental_dump_DEPENDENCIES, dwp_DEPENDENCIES): Likewise.
* Makefile.in: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.am (DEPENDENCIES): Remove LIBINTL_DEP.
* testsuite/Makefile.in: Regenerate.
gprof/
* Makefile.am (gprof_DEPENDENCIES): Remove LIBINTL_DEP.
* Makefile.in: Regenerate.
* configure: Regenerate.
ld/
* Makefile.am (ld_new_DEPENDENCIES): Remove LIBINTL_DEP.
* Makefile.in: Regenerate.
* configure: Regenerate.
libctf/
* Makefile.in: Regenerate.
* configure: Regenerate.
opcodes/
* configure.ac (BUILD_LIBS): Remove LIBINTL.
(BUILD_LIB_DEPS): Remove LIBINTL_DEP.
* Makefile.in: Regenerate.
* configure: Regenerate.

12 months agoLoongArch: TLS IE needs only one dynamic reloc
Xi Ruoyao [Wed, 19 Jun 2024 06:04:18 +0000 (14:04 +0800)] 
LoongArch: TLS IE needs only one dynamic reloc

As the comment in the code says, TLS_IE needs only one dynamic reloc.
But commit b67a17aa7c0c ("LoongArch: Fix the issue of excessive
relocation generated by GD and IE") has incorrectly allocated the space
for two dynamic relocs, causing libc.so to contain 8 R_LARCH_NONE.

Adjust tlsdesc-dso.d for the offset changes and add two tests to ensure
there are no R_LARCH_NONE with TLS.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
12 months agoAutomatic date update in version.in
GDB Administrator [Thu, 20 Jun 2024 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agold: Remove JANSSON_LIBS from ld_new_DEPENDENCIES
H.J. Lu [Wed, 19 Jun 2024 21:24:35 +0000 (14:24 -0700)] 
ld: Remove JANSSON_LIBS from ld_new_DEPENDENCIES

Remove JANSSON_LIBS from ld_new_DEPENDENCIES since ld_new_DEPENDENCIES
should only contain binutils dependencies.

PR ld/31909
* Makefile.am (ld_new_DEPENDENCIES): Remove JANSSON_LIBS.
* Makefile.in: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
12 months ago[gdb/build] Redo poisoning of PyObject_CallMethod
Tom de Vries [Wed, 19 Jun 2024 17:18:23 +0000 (19:18 +0200)] 
[gdb/build] Redo poisoning of PyObject_CallMethod

In commit 764af878259 ("[gdb/python] Add typesafe wrapper around
PyObject_CallMethod") I added poisoning of PyObject_CallMethod:
...
/* Poison PyObject_CallMethod.  The typesafe wrapper gdbpy_call_method should be
   used instead.  */
template<typename... Args>
PyObject *
PyObject_CallMethod (Args...);
...

The idea was that subsequent code would be forced to use gdbpy_call_method
instead of PyObject_CallMethod.

However, that caused build issues with gcc 14 and python 3.13:
...
/usr/bin/ld: python/py-disasm.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<unsigned int, long long>(_object*, char const*, unsigned int, long long)':
/data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x384f): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, unsigned int, long long>(_object*, char*, char*, unsigned int, long long)'
/usr/bin/ld: python/py-tui.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<int>(_object*, char const*, int)':
/data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x1235): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, int>(_object*, char*, char*, int)'
/usr/bin/ld: python/py-tui.o: in function `gdb::ref_ptr<_object, gdbpy_ref_policy<_object> > gdbpy_call_method<int, int, int>(_object*, char const*, int, int, int)':
/data/vries/gdb/src/gdb/python/python-internal.h:207:(.text+0x12b0): undefined reference to `_object* PyObject_CallMethod<_object*, char*, char*, int, int, int>(_object*, char*, char*, int, int, int)'
collect2: error: ld returned 1 exit status
...

Fix this by poisoning without using templates.

Tested on x86_64-linux.

12 months ago[gdb/symtab] Fix target type of complex long double on arm
Tom de Vries [Wed, 19 Jun 2024 15:32:55 +0000 (17:32 +0200)] 
[gdb/symtab] Fix target type of complex long double on arm

When running test-case gdb.base/complex-parts.exp on arm-linux, I get:
...
(gdb) p $_cimag (z3)^M
$6 = 6.5^M
(gdb) PASS: gdb.base/complex-parts.exp: long double imaginary: p $_cimag (z3)
ptype $^M
type = double^M
(gdb) FAIL: gdb.base/complex-parts.exp: long double imaginary: ptype $
...

Given that z3 is a complex long double, the test-case expects the type of the
imaginary part of z3 to be long double, but it's double instead.

This is due to the fact that the dwarf info doesn't specify an explicit target
type:
...
    <5b>   DW_AT_name        : z3
    <60>   DW_AT_type        : <0xa4>
  ...
 <1><a4>: Abbrev Number: 2 (DW_TAG_base_type)
    <a5>   DW_AT_byte_size   : 16
    <a6>   DW_AT_encoding    : 3        (complex float)
    <a7>   DW_AT_name        : complex long double
...
and consequently we're guessing in dwarf2_init_complex_target_type based on
the size:
...
case 64:
  tt = builtin_type (gdbarch)->builtin_double;
  break;
case 96: /* The x86-32 ABI specifies 96-bit long double.  */
case 128:
  tt = builtin_type (gdbarch)->builtin_long_double;
  break;
...

For arm-linux, complex long double is 16 bytes, so the target type is assumed
to be 8 bytes, which is handled by the "case 64", which gets us double
instead of long double.

Fix this by searching for "long" in the name_hint parameter, and using long
double instead.

Note that base types in dwarf are not allowed to contain references to other
types, and the complex types are base types, so the missing explicit target
type is standard-conformant.

A gcc PR was filed to add this as a dwarf extension (
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115272 ).

Tested on arm-linux.

12 months agolibctf: fix testsuite bugs revealed by -Wall
Nick Alcock [Wed, 19 Jun 2024 13:06:26 +0000 (14:06 +0100)] 
libctf: fix testsuite bugs revealed by -Wall

Most of these are harmless, but some of the type confusions and especially
a missing ctf_strerror() on an error path were actual bugs that could
have resulted in test failures crashing rather than printing an error
message.

libctf/
* testsuite/libctf-lookup/enumerator-iteration.c: Fix type
        confusion, signedness confusion and a missing ctf_errmsg().
* testsuite/libctf-regression/libctf-repeat-cu-main.c: Return 0 from
        the test function.
* testsuite/libctf-regression/open-error-free.c: Fix signedness
        confusion.
* testsuite/libctf-regression/zrewrite.c: Remove unused label.

12 months agogdb/python/python-internal.h: avoid uninitialized constexpr
Lancelot SIX [Tue, 18 Jun 2024 08:29:14 +0000 (09:29 +0100)] 
gdb/python/python-internal.h: avoid uninitialized constexpr

The following recent change introduced a regression when building using
clang++:

    commit 764af878259768bb70c65bdf3f3285c2d6409bbd
    Date:   Wed Jun 12 18:58:49 2024 +0200

        [gdb/python] Add typesafe wrapper around PyObject_CallMethod

The error message is:

    ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char'
    constexpr char gdbpy_method_format;
                   ^
                                       = '\0'
      CXX    python/py-block.o
    1 error generated.
    make[2]: *** [Makefile:1959: python/py-arch.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    In file included from ../../gdb/python/py-auto-load.c:25:
    ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char'
    constexpr char gdbpy_method_format;
                   ^
                                       = '\0'
    1 error generated.
    make[2]: *** [Makefile:1959: python/py-auto-load.o] Error 1
    In file included from ../../gdb/python/py-block.c:23:
    ../../gdb/python/python-internal.h:151:16: error: default initialization of an object of const type 'const char'
    constexpr char gdbpy_method_format;
                   ^
                                       = '\0'
    1 error generated.

This patch fixes this by changing gdbpy_method_format to be a templated
struct, and only have its specializations define the static constexpr
member "format".  This way, we avoid having an uninitialized constexpr
expression, regardless of it being instantiated or not.

Reviewed-By: Tom de Vries <tdevries@suse.de>
Change-Id: I5bec241144f13500ef78daea30f00d01e373692d

12 months agox86: Remove the secondary encoding for ctest.
Cui, Lili [Wed, 19 Jun 2024 03:40:02 +0000 (11:40 +0800)] 
x86: Remove the secondary encoding for ctest.

There are two encodings for each opcode F6/F7 in ctest, but the second one
is never used, so remove it to reduce the size of opcode_tbl.h.

opcodes/ChangeLog:

        * i386-opc.tbl: Removed the secondary insn template for ctest.
        * i386-tbl.h: Regenerated.

12 months ago[gdb/testsuite] Fix gdb.dwarf2/shortpiece.exp on s390x
Tom de Vries [Wed, 19 Jun 2024 08:04:22 +0000 (10:04 +0200)] 
[gdb/testsuite] Fix gdb.dwarf2/shortpiece.exp on s390x

On s390x-linux, I run into:
...
(gdb) p (short []) s1^M
$3 = {0, 1, 0, <optimized out>}^M
(gdb) FAIL: gdb.dwarf2/shortpiece.exp: p (short []) s1
...
while this is expected:
...
(gdb) p (short []) s1^M
$3 = {1, 0, 0, <optimized out>}^M
(gdb) PASS: gdb.dwarf2/shortpiece.exp: p (short []) s1
...

The type of s1 is:
...
(gdb) ptype s1
type = struct S {
    myint a;
    myushort b;
}
...
so the difference is due the fact that viewing an int as two shorts gives
different results depending on the endianness.

Fix this by allowing both results.

Tested on x86_64-linux and s390x-linux.

Approved-By: Tom Tromey <tom@tromey.com>
12 months ago[gdb/testsuite] Add string cat for tcl version < 8.6.2
Tom de Vries [Wed, 19 Jun 2024 07:56:44 +0000 (09:56 +0200)] 
[gdb/testsuite] Add string cat for tcl version < 8.6.2

I noticed that we started using "string cat", which has been available since
tcl version 8.6.2.

Add a local implementation for use with older tcl versions.

Tested on x86_64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
12 months ago[gdb/tdep] Simplify ARM_LINUX_JB_PC_EABI
Tom de Vries [Wed, 19 Jun 2024 07:52:01 +0000 (09:52 +0200)] 
[gdb/tdep] Simplify ARM_LINUX_JB_PC_EABI

In commit 1a7d840a216 ("[gdb/tdep] Fix ARM_LINUX_JB_PC_EABI"), in absense of
osabi settings for newlib and uclibc for arm, I chose a best-effort approach
using ifdefs.

Post-commit review [1] pointed out that this may be causing more problems than
it's worth.

Fix this by removing the ifdefs and simply defining ARM_LINUX_JB_PC_EABI to 1.

Rebuild on x86_64-linux with --enable-targets=all.

Fixes: 1a7d840a216 ("[gdb/tdep] Fix ARM_LINUX_JB_PC_EABI")
[1] https://sourceware.org/pipermail/gdb-patches/2024-June/209779.html

12 months agoAutomatic date update in version.in
GDB Administrator [Wed, 19 Jun 2024 00:00:24 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months ago[gdb/build] Add GPL header comment to gdb/features/feature_to_c.awk
Tom de Vries [Tue, 18 Jun 2024 15:26:22 +0000 (17:26 +0200)] 
[gdb/build] Add GPL header comment to gdb/features/feature_to_c.awk

Commit 97033da5070 ("[gdb/build] Cleanup gdb/features/feature_to_c.sh")
factored out new file gdb/features/feature_to_c.awk out of
gdb/features/feature_to_c.sh, but failed to add the GPL header comment, so add
this now.

Tested on x86_64-linux.

12 months agolibctf, include: new functions for looking up enumerators
Nick Alcock [Tue, 11 Jun 2024 19:58:00 +0000 (20:58 +0100)] 
libctf, include: new functions for looking up enumerators

Three new functions for looking up the enum type containing a given
enumeration constant, and optionally that constant's value.

The simplest, ctf_lookup_enumerator, looks up a root-visible enumerator by
name in one dict: if the dict contains multiple such constants (which is
possible for dicts created by older versions of the libctf deduplicator),
ECTF_DUPLICATE is returned.

The next simplest, ctf_lookup_enumerator_next, is an iterator which returns
all enumerators with a given name in a given dict, whether root-visible or
not.

The most elaborate, ctf_arc_lookup_enumerator_next, finds all
enumerators with a given name across all dicts in an entire CTF archive,
whether root-visible or not, starting looking in the shared parent dict;
opened dicts are cached (as with all other ctf_arc_*lookup functions) so
that repeated use does not incur repeated opening costs.

All three of these return enumerator values as int64_t: unfortunately, API
compatibility concerns prevent us from doing the same with the other older
enum-related functions, which all return enumerator constant values as ints.
We may be forced to add symbol-versioning compatibility aliases that fix the
other functions in due course, bumping the soname for platforms that do not
support such things.

ctf_arc_lookup_enumerator_next is implemented as a nested ctf_archive_next
iterator, and inside that, a nested ctf_lookup_enumerator_next iterator
within each dict.  To aid in this, add support to ctf_next_t iterators for
iterators that are implemented in terms of two simultaneous nested iterators
at once.  (It has always been possible for callers to use as many nested or
semi-overlapping ctf_next_t iterators as they need, which is one of the
advantages of this style over the _iter style that calls a function for each
thing iterated over: the iterator change here permits *ctf_next_t iterators
themselves* to be implemented by iterating using multiple other iterators as
part of their internal operation, transparently to the caller.)

Also add a testcase that tests all these functions (which is fairly easy
because ctf_arc_lookup_enumerator_next is implemented in terms of
ctf_lookup_enumerator_next) in addition to enumeration addition in
ctf_open()ed dicts, ctf_add_enumerator duplicate enumerator addition, and
conflicting enumerator constant deduplication.

include/
* ctf-api.h (ctf_lookup_enumerator): New.
(ctf_lookup_enumerator_next): Likewise.
(ctf_arc_lookup_enumerator_next): Likewise.

libctf/
* libctf.ver: Add them.
* ctf-impl.h (ctf_next_t) <ctn_next_inner>: New.
* ctf-util.c (ctf_next_copy): Copy it.
        (ctf_next_destroy): Destroy it.
* ctf-lookup.c (ctf_lookup_enumerator): New.
(ctf_lookup_enumerator_next): New.
* ctf-archive.c (ctf_arc_lookup_enumerator_next): New.
* testsuite/libctf-lookup/enumerator-iteration.*: New test.
* testsuite/libctf-lookup/enum-ctf-2.c: New test CTF, used by the
  above.

12 months agoinclude: libctf: comment improvements
Nick Alcock [Tue, 11 Jun 2024 19:55:35 +0000 (20:55 +0100)] 
include: libctf: comment improvements

Describe a bit more clearly what effects a type being non-root-
visible has.  More consistently use the term non-root-visible
rather than hidden.  Document ctf_enum_iter.

include/
* ctf-api.h (ctf_enum_iter): Document.
        (ctf_type_iter): Hidden, not non-root.  Mention that
        parent dictionaries are not traversed.

12 months agolibctf: make the ctf_next ctn_fp non-const
Nick Alcock [Tue, 11 Jun 2024 19:47:56 +0000 (20:47 +0100)] 
libctf: make the ctf_next ctn_fp non-const

This was always an error, because the ctn_fp routinely has errors set on it,
which is not something you can (or should) do to a const object.

libctf/
* ctf-impl.h (ctf_next_) <cu.ctn_fp>: Make non-const.

12 months agolibctf: prohibit addition of enums with overlapping enumerator constants
Nick Alcock [Tue, 11 Jun 2024 19:33:03 +0000 (20:33 +0100)] 
libctf: prohibit addition of enums with overlapping enumerator constants

libctf has long prohibited addition of enums with overlapping constants in a
single enum, but now that we are properly considering enums with overlapping
constants to be conflciting types, we can go further and prohibit addition
of enumeration constants to a dict if they already exist in any enum in that
dict: the same rules as C itself.

We do this in a fashion vaguely similar to what we just did in the
deduplicator, by considering enumeration constants as identifiers and adding
them to the core type/identifier namespace, ctf_dict_t.ctf_names.  This is a
little fiddly, because we do not want to prohibit opening of existing dicts
into which the deduplicator has stuffed enums with overlapping constants!
We just want to prohibit the addition of *new* enumerators that violate that
rule.  Even then, it's fine to add overlapping enumerator constants as long
as at least one of them is in a non-root type.  (This is essential for
proper deduplicator operation in cu-mapped mode, where multiple compilation
units can be smashed into one dict, with conflicting types marked as
hidden: these types may well contain overlapping enumerators.)

So, at open time, keep track of all enums observed, then do a third pass
through the enums alone, adding each enumerator either to the ctf_names
table as a mapping from the enumerator name to the enum it is part of (if
not already present), or to a new ctf_conflicting_enums hashtable that
tracks observed duplicates. (The latter is not used yet, but will be soon.)

(We need to do a third pass because it's quite possible to have an enum
containing an enumerator FOO followed by a type FOO: since they're processed
in order, the enumerator would be processed before the type, and at that
stage it seems nonconflicting.  The easiest fix is to run through the
enumerators after all type names are interned.)

At ctf_add_enumerator time, if the enumerator to which we are adding a type
is root-visible, check for an already-present name and error out if found,
then intern the new name in the ctf_names table as is done at open time.

(We retain the existing code which scans the enum itself for duplicates
because it is still an error to add an enumerator twice to a
non-root-visible enum type; but we only need to do this if the enum is
non-root-visible, so the cost of enum addition is reduced.)

Tested in an upcoming commit.

libctf/
* ctf-impl.h (ctf_dict_t) <ctf_names>: Augment comment.
        <ctf_conflicting_enums>: New.
(ctf_dynset_elements): New.
* ctf-hash.c (ctf_dynset_elements): Implement it.
* ctf-open.c (init_static_types): Split body into...
        (init_static_types_internal): ... here.  Count enumerators;
        keep track of observed enums in pass 2; populate ctf_names and
        ctf_conflicting_enums with enumerators in a third pass.
(ctf_dict_close): Free ctf_conflicting_enums.
* ctf-create.c (ctf_add_enumerator): Prohibit addition of duplicate
        enumerators in root-visible enum types.

include/
* ctf-api.h (CTF_ADD_NONROOT): Describe what non-rootness
        means for enumeration constants.
(ctf_add_enumerator):  The name is not a misnomer.
        We now require that enumerators have unique names.
        Document the non-rootness of enumerators.

12 months agolibctf: suppress spurious failure of malloc-counting tests under valgrind
Nick Alcock [Wed, 12 Jun 2024 10:08:39 +0000 (11:08 +0100)] 
libctf: suppress spurious failure of malloc-counting tests under valgrind

The libctf-regression/open-error-free.c test works by interposing malloc
and counting mallocs and frees across libctf operations.  This only
works under suitably-interposable mallocs on systems supporting
dlsym (RTLD_NEXT, ...), so its operation is restricted to glibc
systems for now, but also it interacts badly with valgrind, which
interposes malloc itself.  Detect a running valgrind and skip the test.

Add new facilities allowing libctf lookup tests to declare themselves
unsupported, by printing "UNSUPPORTED: " and then some meaningful
message instead of their normal output.

libctf/
* configure.ac: Check for <valgrind/valgrind.h>.
* config.h.in: Regenerate.
* configure: Likewise.
* testsuite/lib/ctf-lib.exp (run_lookup_test): Add support for
UNSUPPORTED tests.
* testsuite/libctf-regression/open-error-free.c: When running
under valgrind, this test is unsupported.

12 months agolibctf: fix dict leak on archive-wide symbol lookup error path
Nick Alcock [Wed, 12 Jun 2024 11:28:45 +0000 (12:28 +0100)] 
libctf: fix dict leak on archive-wide symbol lookup error path

If a lookup fails for a reason unrelated to a lack of type data for this
symbol, we return with an error; but we fail to close the dict we opened
most recently, which is leaked.

libctf/
* ctf-archive.c (ctf_arc_lookup_sym_or_name): Close dict.

12 months agolibctf: don't leak enums if ctf_add_type fails
Nick Alcock [Tue, 11 Jun 2024 19:11:29 +0000 (20:11 +0100)] 
libctf: don't leak enums if ctf_add_type fails

If ctf_add_type failed in the middle of enumerator addition, the
destination would end up containing the source enum type and some
but not all of its enumerator constants.

Use snapshots to roll back the enum addition as a whole if this happens.
Before now, it's been pretty unlikely, but in an upcoming commit we will ban
addition of enumerators that already exist in a given dict, making failure
of ctf_add_enumerator and thus of this part of ctf_add_type much more
likely.

libctf/
* ctf-create.c (ctf_add_type_internal): Roll back if enum or
          enumerator addition fails.

12 months agolibctf: dedup: enums with overlapping enumerators are conflicting
Nick Alcock [Tue, 11 Jun 2024 18:51:33 +0000 (19:51 +0100)] 
libctf: dedup: enums with overlapping enumerators are conflicting

The CTF deduplicator was not considering enumerators inside enum types to be
things that caused type conflicts, so if the following two TUs were linked
together, you would end up with the following in the resulting dict:

1.c:
enum foo { A, B };

2.c:
enum bar { A, B };

linked:

enum foo { A, B };
enum bar { A, B };

This does work -- but it's not something that's valid C, and the general
point of the shared dict is that it is something that you could potentially
get from any valid C TU.

So consider such types to be conflicting, but obviously don't consider
actually identical enums to be conflicting, even though they too have (all)
their identifiers in common.  This involves surprisingly little code. The
deduplicator detects conflicting types by counting types in a hash table of
hash tables:

decorated identifier -> (type hash -> count)

where the COUNT is the number of times a given hash has been observed: any
name with more than one hash associated with it is considered conflicting
(the count is used to identify the most common such name for promotion to
the shared dict).

Before now, those identifiers were all the identifiers of types (possibly
decorated with their namespace on the front for enumerator identifiers), but
we can equally well put *enumeration constant names* in there, undecorated
like the identifiers of types in the global namespace, with the type hash
being the hash of each enum containing that enumerator.  The existing
conflicting-type-detection code will then accurately identify distinct enums
with enumeration constants in common.  The enum that contains the most
commonly-appearing enumerators will be promoted to the shared dict.

libctf/
* ctf-impl.h (ctf_dedup_t) <cd_name_counts>: Extend comment.
* ctf-dedup.c (ctf_dedup_count_name): New, split out of...
(ctf_dedup_populate_mappings): ... here.  Call it for all
* enumeration constants in an enum as well as types.

ld/
* testsuite/ld-ctf/enum-3.c: New test CTF.
* testsuite/ld-ctf/enum-4.c: Likewise.
* testsuite/ld-ctf/overlapping-enums.d: New test.
* testsuite/ld-ctf/overlapping-enums-2.d: Likewise.

12 months agolibctf: doc: fix ctf_stype_t typedef string in spec
Nick Alcock [Tue, 11 Jun 2024 18:48:17 +0000 (19:48 +0100)] 
libctf: doc: fix ctf_stype_t typedef string in spec

12 months agoinclude: fix libctf ECTF_NOENUMNAM error message
Nick Alcock [Tue, 11 Jun 2024 18:46:57 +0000 (19:46 +0100)] 
include: fix libctf ECTF_NOENUMNAM error message

ECTF_NOENUMNAM is emitted when enumerator constant names don't exist.
Call them that, not 'enum elements'.

include/
* ctf-api.h (ECTF_NOENUMNAM): fix error message.

12 months agolibctf: strtab corruption when strings are added to ctf_open()ed dicts
Nick Alcock [Tue, 11 Jun 2024 18:37:54 +0000 (19:37 +0100)] 
libctf: strtab corruption when strings are added to ctf_open()ed dicts

ctf_str_add_ref and ctf_str_add_movable_ref take a string and are supposed
to return a strtab offset.  These offsets are "provisional": the ref
mechanism records the address of the location in which the ref is stored and
modifies it when the strtab is finally written out.  Provisional refs in new
dicts start at 0 and go up via strlen() as new refs are added: this is fine,
because the strtab is empty and none of these values will overlap any
existing string offsets (since there are none).  Unfortunately, when a dict
is ctf_open()ed, we fail to set the initial provisional strtab offset to a
higher value than any existing string offset: it starts at zero again!
It's a shame that we already *have* strings at those offsets...

This is all fixed up once the string is reserialized, but if you look up
newly-added strings before serialization, you get corrupted partial string
results from the existing ctf_open()ed dict.

Observed (and thus regtested) by an upcoming test (in this patch series).

Exposed by the recently-introduced series that permits modification of
ctf_open()ed dicts, which has not been released anywhere.  Before that,
any attempt to do such things would fail with ECTF_RDONLY.

libctf/
* ctf-string.c (ctf_str_create_atoms): Initialize
        ctf_str_prov_offset.

12 months agoreadelf: rename recently added testsuite files
Jan Beulich [Tue, 18 Jun 2024 11:23:36 +0000 (13:23 +0200)] 
readelf: rename recently added testsuite files

Files named *.0 are somewhat odd for testsuite expectations. Rename the
one such file to *.r with a suitable base name suffix, and have its
sibling follow suit in this latter regard.

12 months agoRISC-V: Fixed typo from smscrind to smcsrind in riscv_implicit_subsets.
Nelson Chu [Tue, 18 Jun 2024 08:15:45 +0000 (16:15 +0800)] 
RISC-V: Fixed typo from smscrind to smcsrind in riscv_implicit_subsets.

bfd/
* elfxx-riscv.c (riscv_implicit_subsets): Fixed type from smscrind to
smcsrind.
gas/
* testsuite/gas/riscv/march-imply-smcsrind.d: New testcase.  It fails
without applying this patch.

12 months agoEnsure that the text segment is aligned on disk when using --rosegment.
Nick Clifton [Tue, 18 Jun 2024 08:15:04 +0000 (09:15 +0100)] 
Ensure that the text segment is aligned on disk when using --rosegment.

12 months agogdb: rename offset to high bits in ymm registers
Felix Willgerodt [Mon, 25 Mar 2024 15:57:37 +0000 (16:57 +0100)] 
gdb: rename offset to high bits in ymm registers

The xsave_ymm_avx512_offset data structure contains the xsave
offset to the upper 128 bits of a ymm register.  Similarly, for zmm this
offset is described by xsave_avx512_zmm_h_offset, h indicating the
high bits.  This commit renames the xsave_ymm_avx512_offset to
xsave_ymm_h_avx512_offset - as well as the associated define from
XSAVE_YMM_AVX512_ADDR to XSAVE_YMM_H_AVX512_ADDR - to make this
more consistent.

Note, that the regnum defines already included the 'h' for ymm, like
I387_YMM16H_REGNUM and I387_YMMH_AVX512_END_REGNUM.

Co-authored-by: Nils-Christian Kempke <nils-christian.kempke@intel.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
12 months agoRISC-V: Updated gas/NEWS and gas/doc/c-riscv.texi for vendor extensions.
Nelson Chu [Tue, 18 Jun 2024 07:15:14 +0000 (15:15 +0800)] 
RISC-V: Updated gas/NEWS and gas/doc/c-riscv.texi for vendor extensions.

gas/
* NEWS: Updated for XCvMem, XCvBi, XCvElw, XSfCease.
* doc/c-riscv.texi: Minor typo for XCv* extensions.

12 months agoRISC-V: Add SiFive cease extension v1.0
Hau Hsu [Tue, 18 Jun 2024 06:49:04 +0000 (14:49 +0800)] 
RISC-V: Add SiFive cease extension v1.0

Add SiFive cease extension,
https://sifive.cdn.prismic.io/sifive/767804da-53b2-4893-97d5-b7c030ae0a94_s76mc_core_complex_manual_21G3.pdf

This aligns LLVM:
* https://llvm.org/docs/RISCVUsage.html
* https://github.com/llvm/llvm-project/pull/83896

bfd/ChangeLog:

* elfxx-riscv.c (riscv_supported_vendor_x_ext): Add support for
'xsfcease'.
(riscv_multi_subset_supports): Handle INSN_CLASS_XSFCEASE.
(riscv_multi_subset_supports_ext): Handle INSN_CLASS_XSFCEASE.

gas/ChangeLog:

* doc/c-riscv.texi: Updated.
* testsuite/gas/riscv/march-help.l: Updated.
* testsuite/gas/riscv/sifive-insns.d: Add test case for 'sf.cease'.
* testsuite/gas/riscv/sifive-insns.s: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_SF_CEASE, MASK_SF_CEASE): Define match and
mask encoding for 'sf.cease'.
* opcode/riscv.h (INSN_CLASS_XSFCEASE): Add new instruction class for
'xsfcease'.

opcodes/ChangeLog:

    * riscv-opc.c (riscv_opcodes): Add opcode entry for 'sf.cease'.

12 months agoRISC-V: Support Zacas extension.
Gianluca Guida [Wed, 31 May 2023 16:28:56 +0000 (17:28 +0100)] 
RISC-V: Support Zacas extension.

https://github.com/riscvarchive/riscv-zacas/releases/tag/v1.0

The Zacas extension introduce compare-and-swap instructions to operate
on 32-bit, 64-bit and 128-bit (RV64 only) data values.

It introduces three new instructions:
  - amocas.w (32-bit CAS)
  - amocas.d (64-bit CAS)
  - amocas.q (128-bit CAS, RV64 only)

Like other AMOs in the A extension, Zacas instructions have '.aq',
'.rl' and '.aqrl' variations.

bfd/ChangeLog:

* elfxx-riscv.c (riscv_implicit_subsets): 'A' implied by 'Zacas'.
(riscv_supported_std_z_ext): Add 'Zacas' extension.
(riscv_multi_subset_supports, riscv_multi_subset_supports_ext):
Handle INSN_CLASS_ZACAS case.

gas/ChangeLog:

* NEWS: Updated.
* testsuite/gas/riscv/march-help.l: Updated.
* testsuite/gas/riscv/zacas-32.d: New test (RV32).
        * testsuite/gas/riscv/zacas-fail-32.d: Likewise.
* testsuite/gas/riscv/zacas-64.d: New test (RV64).
        * testsuite/gas/riscv/zacas-fail-64.d: Likewise.
* testsuite/gas/riscv/zacas.s: New test source.
* testsuite/gas/riscv/zacas-fail.s: Likewise.
* testsuite/gas/riscv/zacas-fail-32.l: New file.
* testsuite/gas/riscv/zacas-fail-64.l: Likewise.

include/ChangeLog:

* include/opcode/riscv.h (INSN_CLASS_ZACAS): New definition.
* include/opcode/riscv-opc.h (MATCH_AMOCAS_W, MASK_AMOCAS_W)
(MATCH_AMOCAS_D, MASK_AMOCAS_D, MATCH_AMOCAS_Q, MASK_AMOCAS_Q):
Likewise.
(amocas_w, amocas_d, amocas_q): Declare instructions.

opcodes/ChangeLog:

* riscv-opc.c (match_rs2_rd_even): New function.
(amocas_w, amocas_d, amocas_q, amocas_w.aq)
(amocas_d.aq, amocas_q.aq, amocas_w.rl, amocas_d.rl, amocas_q.rl)
(amocas_w.aqrl, amocas_d.aqrl, amocas_q.aqrl): Add instructions.

12 months agox86: Fix typo in i386-dis-evex-mod.h
Cui, Lili [Tue, 18 Jun 2024 02:47:01 +0000 (10:47 +0800)] 
x86: Fix typo in i386-dis-evex-mod.h

opcodes/ChangeLog:

        * i386-dis-evex-mod.h: Used MOD_EVEX_MAP4_F8_P_1/MOD_EVEX_MAP4_F8_P_3
        instead of MOD_EVEX_MAP4_F8_P1/MOD_EVEX_MAP4_F8_P3.

12 months agoRemove %ME and used %NE for movbe.
Cui, Lili [Tue, 18 Jun 2024 02:46:31 +0000 (10:46 +0800)] 
Remove %ME and used %NE for movbe.

%ME is added specifically for movbe. Now with %NE, we can use
MOD table + %NE to indicate whether a {evex} prefix is needed.

opcodes/ChangeLog:

        * i386-dis-evex-mod.h: Added movbe.
        * i386-dis-evex.h: Let movbe go through the mod table.
        * i386-dis.c (struct dis386): Removed %ME.
        (putop): Removed case ME.

12 months agoSupport APX CCMP and CTEST
Cui, Lili [Tue, 18 Jun 2024 02:45:49 +0000 (10:45 +0800)] 
Support APX CCMP and CTEST

CCMP and CTEST are two new sets of instructions for conditional CMP
and TEST, SCC and OSZC flags are given as suffixes of CCMP or CTEST
in the instruction mnemonic, e.g.:

ccmp<cc> { dfv=sf , cf , of } %eax, %ecx

also add

{evex} cmp/test %eax, %ecx

as an alias for ccmpt.

For the encoder part, add function check_Scc_OszcOperation to parse
'{ dfv=of , sf, sf, cf}', store scc in the lower 4 bits of base_opcode,
and adjust base_opcode to its normal meaning in install_template.

For the decoder part, add 'SC' and 'DF' macros to add scc and oszc flags
suffixes.

gas/ChangeLog:

        * config/tc-i386.c (OSZC_CF): New.
        (OSZC_ZF): Ditto.
        (OSZC_SF): Ditto.
        (OSZC_OF): Ditto.
        (set_oszc_flags): Set oszc flags and report error for using the same oszc flags twice.
        (check_Scc_OszcOperations): Handle SCC OSZC flags.
        (install_template): Add scc and oszc_flags.
        (build_apx_evex_prefix): Encode SCC and oszc flags bits.
        (parse_insn): Handle check_Scc_OszcOperations.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Add ivalid test case.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto.
        * testsuite/gas/i386/x86-64.exp: Add test for ccmp and ctest.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest-intel.d: New test.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest-inval.l: Ditto.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest-inval.s: Ditto.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-ccmp-ctest.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex-reg.h: Add ccmp and ctest.
        * i386-dis-evex.h: Ditto.
        * i386-dis.c (struct instr_info): add scc.
        (struct dis386): Add new micro 'NE','SC' and'DF'.
        (get_valid_dis386): Get scc value and move MAP4 invalid check to print_insn.
        (putop): Handle %NE, %SC and %DF.
        * i386-opc.h (SCC): New.
        * i386-opc.tbl: Add ccmp/ctest and evex format for cmp/test.
        * i386-mnem.h: Regenerated.
        * i386-tbl.h: Ditto.

12 months agoLoongArch: add .option directive
Lulu Cai [Tue, 21 May 2024 02:14:27 +0000 (10:14 +0800)] 
LoongArch: add .option directive

In some cases we may want to use different options only for certain
assembly, so the .option directive is added to control the assembler
options.

.option can accept 4 parameters:

push
pop
  Pushes or pops the current option stack. They limit the scope of
  option changes so that they do not affect other parts of the assembly
  file.

relax
norelax
  Enables or disables relaxation.

12 months agoAutomatic date update in version.in
GDB Administrator [Tue, 18 Jun 2024 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoGAS/testsuite: Make a copy of none.s before operating on it as output
Maciej W. Rozycki [Mon, 17 Jun 2024 22:28:20 +0000 (23:28 +0100)] 
GAS/testsuite: Make a copy of none.s before operating on it as output

The "Output file must be distinct from input" test in gas/all/gas.exp
operates on none.s as output.  Should the test fail it may happen that
GAS will delete the output file requested in which case none.s will be
removed.  Since the test operates directly on the source tree it will be
clobbered as a result.  It has actually been observed in the field in
the form of intermittent:

FAIL: gas/all/none

regressions in a parallel run of many configurations.

Prevent this from happening by copying none.s first to the test object
directory and operating on it instead.  It does not prevent the file
from being removed should the test fail, but the source tree won't be
clobbered in that case.

A nice side effect is that syntactically different paths will now be
used in this test for the input and the output file each, so coverage
will extend to verifying that a file is checked against itself even if
referred to via different paths.  Previously "$srcdir/$subdir/none.s"
was used for both paths and now "tmpdir/none.s" is referred to directly
and via a relative path from "$srcdir/$subdir" respectively.

I note that we have no previous use of the UNRESOLVED test result in the
GAS testsuite, but it seems the correct one should copying none.s fail,
as this is an unexpected situation that requires a human intervention
and the test proper has not been evaluated.

12 months agoGAS/testsuite: Add a helper for paths outside the source dir
Maciej W. Rozycki [Mon, 17 Jun 2024 22:28:20 +0000 (23:28 +0100)] 
GAS/testsuite: Add a helper for paths outside the source dir

Implement a helper to construct a relative path from $srcdir/$subdir,
where `gas_run' operates, to an arbitrary place in the filesystem, for
example a file in the test object directory.

12 months agobinutils/testsuite: Add a helper for relative path construction
Maciej W. Rozycki [Mon, 17 Jun 2024 22:28:20 +0000 (23:28 +0100)] 
binutils/testsuite: Add a helper for relative path construction

Implement a helper to construct a relative path between two locations in
the filesystem, for example to make a path from the source to the object
directory for the case where a tool has been set up to look at a given
path and there is a need to point it elsewhere, but an absolute path
will not work.  The helper works on normalized paths internally, so the
result is correct even in the presence of symlinks as intermediate path
components.

So given "/path/to/src/gas/testsuite/gas/all" as the FROM argument and
then "/path/to/obj/gas/testsuite/tmpdir/none.s" as the TO argument the
helper will return "../../../../../obj/gas/testsuite/tmpdir/none.s" in
the absence of symlinks.

12 months ago[gdb/testsuite] Fix duplicates in gdb.fortran/array-{indices,repeat}.exp
Tom de Vries [Mon, 17 Jun 2024 21:26:03 +0000 (23:26 +0200)] 
[gdb/testsuite] Fix duplicates in gdb.fortran/array-{indices,repeat}.exp

When running test-case gdb.fortran/array-indices.exp on a system without
fortran compiler, I run into a duplicate:
...
Running /home/vries/gdb/src/gdb/testsuite/gdb.fortran/array-indices.exp ...
gdb compile failed, default_target_compile: Can't find gfortran.
UNTESTED: gdb.fortran/array-indices.exp: array-indices.exp
gdb compile failed, default_target_compile: Can't find gfortran.
UNTESTED: gdb.fortran/array-indices.exp: array-indices.exp
DUPLICATE: gdb.fortran/array-indices.exp: array-indices.exp
...

Fix this by adding a with_test_prefix at the toplevel.

Likewise in gdb.fortran/array-repeat.exp.

Tested on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
12 months agoPR31898 bug in processing DW_RLE_startx_endx
Alan Modra [Mon, 17 Jun 2024 06:21:13 +0000 (15:51 +0930)] 
PR31898 bug in processing DW_RLE_startx_endx

PR 31898
* dwarf.c (display_debug_rnglists_list): Correct fetch of "end"
indexed address.  Remove excess parens.

12 months agoError messages emitted during bfd_check_format_matches
Alan Modra [Fri, 14 Jun 2024 22:13:08 +0000 (07:43 +0930)] 
Error messages emitted during bfd_check_format_matches

Error/warning messages are only printed for the target that
successfully matched, which makes sense for warnings, but not so much
for errors where the errors cause no target to match.  I noticed this
when looking at the pr20520 testcase again with objdump, which just
reports "file format not recognized" omitting the five "SHT_GROUP
section [index n] has no SHF_GROUP sections" messages.  They are
omitted because multiple ELF targets match the object file.  This is
going to be true for all ELF objects due to at least the proper ELF
target and the generic ELF target matching.

* format.c (print_and_clear_messages): Print messages if all
targets with messages have exactly the same set of messages.

12 months agoAutomatic date update in version.in
GDB Administrator [Mon, 17 Jun 2024 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoMake tui_register_info::highlight private
Tom Tromey [Fri, 31 May 2024 20:25:09 +0000 (14:25 -0600)] 
Make tui_register_info::highlight private

This changes tui_register_info::highlight to be private, renaming it
to m_highlight.

12 months agoAutomatic date update in version.in
GDB Administrator [Sun, 16 Jun 2024 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoRemove a call to fflush
Tom Tromey [Thu, 23 May 2024 17:54:52 +0000 (11:54 -0600)] 
Remove a call to fflush

This TUI code calls fflush on stdout, but I don't believe this is
useful in gdb.

12 months ago[gdb/build] Cleanup gdb/features/feature_to_c.sh
Tom de Vries [Sat, 15 Jun 2024 06:10:44 +0000 (08:10 +0200)] 
[gdb/build] Cleanup gdb/features/feature_to_c.sh

Clean up script gdb/features/feature_to_c.sh by:
- fixing shellcheck warnings,
- moving an embedded awk script out of the file, reducing the amount of
  escaping in the awk script, making it more readable and maintainable, and
- adding emacs / vi settings for local tab size 2 (copied from ./ltmain.sh).

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
12 months ago[gdb/testsuite] Clean up lib/dg-add-core-file-count.sh
Tom de Vries [Sat, 15 Jun 2024 06:10:44 +0000 (08:10 +0200)] 
[gdb/testsuite] Clean up lib/dg-add-core-file-count.sh

Fix shellcheck warnings in script lib/dg-add-core-file-count.sh.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
12 months ago[gdb/testsuite] Clean up formatting in gdb/contrib/cc-with-tweaks.sh
Tom de Vries [Sat, 15 Jun 2024 06:10:44 +0000 (08:10 +0200)] 
[gdb/testsuite] Clean up formatting in gdb/contrib/cc-with-tweaks.sh

In emacs, on gdb/contrib/cc-with-tweaks.sh, do:
- M-x whitespace-cleanup,
- M-x mark-whole-buffer and M-x indent-region, and
- and undo the unwanted changes in the header comment.

Only whitespace changes.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
12 months ago[gdb/testsuite] Clean up gdb/contrib/cc-with-tweaks.sh
Tom de Vries [Sat, 15 Jun 2024 06:10:44 +0000 (08:10 +0200)] 
[gdb/testsuite] Clean up gdb/contrib/cc-with-tweaks.sh

Fix shellcheck warnings in script gdb/contrib/cc-with-tweaks.sh.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
12 months ago[gdb/testsuite] Clean up gdb/contrib/expect-read1.sh
Tom de Vries [Sat, 15 Jun 2024 06:10:44 +0000 (08:10 +0200)] 
[gdb/testsuite] Clean up gdb/contrib/expect-read1.sh

Clean up script gdb/contrib/expect-read1.sh by:
- fixing shellcheck warnings,
- using mktemp (which takes TMPDIR into account) instead of a hardcoded
  "/tmp/expect-read1.$$.so",
- adding comments, and
- adding emacs / vi settings for local tab size 2 (copied from ./ltmain.sh).

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Sat, 15 Jun 2024 00:00:22 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agox86: Add -z isa-level-report=[none|all|needed|used]
H.J. Lu [Wed, 12 Jun 2024 03:55:05 +0000 (20:55 -0700)] 
x86: Add -z isa-level-report=[none|all|needed|used]

Add -z isa-level-report=[none|all|needed|used] to the x86 ELF linker to
report needed and used x86-64 ISA levels.

bfd/

PR ld/31868
* elf-linker-x86.h (elf_x86_isa_level_report): New.
(elf_linker_x86_params): Add isa_level_report.
* elfxx-x86.c (report_isa_level): New.
(_bfd_x86_elf_link_setup_gnu_properties): Check
-z isa-level-report=[none|all|needed|used] to report needed and
used x86-64 ISA level.

ld/

PR ld/31868
* NEWS: Mention -z isa-level-report=[none|all|needed|used].
* ld.texi: Document -z isa-level-report=[none|all|needed|used].
* emulparams/elf32_x86_64.sh: Source x86-64-level-report.sh.
* emulparams/elf_i386.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* emulparams/x86-64-level-report.sh: New file.
* testsuite/ld-i386/pr31868a.d: Likewise.
* testsuite/ld-i386/pr31868b.d: Likewise.
* testsuite/ld-i386/pr31868c.d: Likewise.
* testsuite/ld-x86-64/pr31868a-x32.d: Likewise.
* testsuite/ld-x86-64/pr31868a.d: Likewise.
* testsuite/ld-x86-64/pr31868a.l: Likewise.
* testsuite/ld-x86-64/pr31868a.s: Likewise.
* testsuite/ld-x86-64/pr31868b-x32.d: Likewise.
* testsuite/ld-x86-64/pr31868b.d: Likewise.
* testsuite/ld-x86-64/pr31868b.l: Likewise.
* testsuite/ld-x86-64/pr31868b.s: Likewise.
* testsuite/ld-x86-64/pr31868c-x32.d: Likewise.
* testsuite/ld-x86-64/pr31868c.d: Likewise.
* testsuite/ld-x86-64/pr31868c.l: Likewise.
* testsuite/ld-i386/i386.exp: Run PR ld/31868 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
12 months agold: Align --no-error-execstack help output
H.J. Lu [Fri, 14 Jun 2024 20:27:31 +0000 (13:27 -0700)] 
ld: Align --no-error-execstack help output

* lexsup.c (elf_static_list_options): Align --no-error-execstack
help output.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
12 months agoSimplify ada_lookup_encoded_symbol
Tom Tromey [Mon, 3 Jun 2024 18:52:54 +0000 (12:52 -0600)] 
Simplify ada_lookup_encoded_symbol

This patch simplifies ada_lookup_encoded_symbol by having it return
its result, rather than returning void and having an out parameter.

12 months agoIntroduce language_defn::lookup_symbol_local
Tom Tromey [Thu, 23 May 2024 16:30:16 +0000 (10:30 -0600)] 
Introduce language_defn::lookup_symbol_local

This introduces the new method language_defn::lookup_symbol_local, and
then changes lookup_symbol_local to use it.  This removes an explicit
language check from this function, and makes it easier for other
languages to hook into this code.