]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
10 months agoAutomatic date update in version.in
GDB Administrator [Fri, 16 Aug 2024 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoRevert "Arm: correct macro use in gas testsuite"
H.J. Lu [Wed, 14 Aug 2024 16:54:36 +0000 (09:54 -0700)] 
Revert "Arm: correct macro use in gas testsuite"

This reverts commit cfa18744d435b55bbbbc5ef1ae1df67e84aa1777.

commit 6ae8a30d44f016cafb46a75843b5109316eb1996
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 9 11:59:31 2024 +0200

    gas: have scrubber retain more whitespace

has been reverted to fix PR gas/32073.

10 months agoRevert "bfin: correct macro use in gas testsuite"
H.J. Lu [Wed, 14 Aug 2024 16:54:35 +0000 (09:54 -0700)] 
Revert "bfin: correct macro use in gas testsuite"

This reverts commit a1b7023447d19d70bc36d71b7627f457dbfae5ce.

commit 6ae8a30d44f016cafb46a75843b5109316eb1996
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 9 11:59:31 2024 +0200

    gas: have scrubber retain more whitespace

has been reverted to fix PR gas/32073.

10 months agoRevert "ia64: correct macro use in gas testsuite"
H.J. Lu [Wed, 14 Aug 2024 16:54:34 +0000 (09:54 -0700)] 
Revert "ia64: correct macro use in gas testsuite"

This reverts commit 2231ac9b9e88191178001d0ae5845e292acb2a56.

commit 6ae8a30d44f016cafb46a75843b5109316eb1996
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 9 11:59:31 2024 +0200

    gas: have scrubber retain more whitespace

has been reverted to fix PR gas/32073.

10 months agoRevert "MIPS: correct macro use in gas and ld testsuites"
H.J. Lu [Wed, 14 Aug 2024 16:54:33 +0000 (09:54 -0700)] 
Revert "MIPS: correct macro use in gas and ld testsuites"

This reverts commit c0e9aca554e33e900efbd6425c1830f0a20012f5.

commit 6ae8a30d44f016cafb46a75843b5109316eb1996
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 9 11:59:31 2024 +0200

    gas: have scrubber retain more whitespace

has been reverted to fix PR gas/32073.

10 months agoAdd another constructor to scoped_restore_current_language
Tom Tromey [Wed, 14 Aug 2024 17:22:58 +0000 (11:22 -0600)] 
Add another constructor to scoped_restore_current_language

While working on something else, I noticed that this is relatively
common:

  scoped_restore_current_language save;
  set_language (something);

This patch adds a second constructor to
scoped_restore_current_language to simplify this idiom.

Reviewed-By: Tom de Vries <tdevries@suse.de>
10 months agogas: pru: Fix trailing whitespace handling
Dimitar Dimitrov [Mon, 12 Aug 2024 19:25:57 +0000 (22:25 +0300)] 
gas: pru: Fix trailing whitespace handling

With commit 6ae8a30d44f016cafb46a75843b5109316eb1996, arguments followed
by a C-style comment ended up with a trailing space.  That extra space
character confused the PRU register name matching, leading to spurious
errors about unrecognized registers.  This affected existing code like
newlib's setjmp.s for pru.

Fix by stripping the trailing whitespace for any argument.

Even with 6ae8a30d44f016cafb46a75843b5109316eb1996 reverted, this patch
is safe to be applied.

Successfully regression-tested with GCC and newlib testsuites for pru-unknown-elf.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
10 months agolto: Don't include unused LTO archive members in output
H.J. Lu [Thu, 15 Aug 2024 03:50:02 +0000 (20:50 -0700)] 
lto: Don't include unused LTO archive members in output

When plugin_object_p is called by elf_link_is_defined_archive_symbol to
check if a symbol in archive is a real definition, set archive member
plugin_format to bfd_plugin_yes_unused to avoid including the unused LTO
archive members in linker output.  When plugin_object_p is called as
known used, call plugin claim_file if plugin_format is bfd_plugin_unknown
or bfd_plugin_yes_unused.

To get the proper support for archives with LTO common symbols with GCC,
the GCC fix for

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116361

is needed.

bfd/

PR ld/32083
* archures.c (bfd_arch_get_compatible): Treat bfd_plugin_yes_unused
the same as bfd_plugin_yes.
* elflink.c (elf_link_is_defined_archive_symbol): Likewise.
* bfd.c (bfd_plugin_format): Add bfd_plugin_yes_unused.
* plugin.c (try_claim): Try claim_file_v2 first.
* bfd-in2.h: Regenerated.

ld/

PR ld/32083
* plugin.c (plugin_call_claim_file): Add an argument to return
if LDPT_REGISTER_CLAIM_FILE_HOOK_V2 is used.
(plugin_object_p): When KNOWN_USED is false, we call plugin
claim_file if plugin_format is bfd_plugin_unknown and set
plugin_format to bfd_plugin_yes_unused on LTO object.  When
KNOWN_USED is true, we call plugin claim_file if plugin_format
is bfd_plugin_unknown or bfd_plugin_yes_unused.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
10 months agogprofng: fix typo in src/collctrl.cc
Vladimir Mezentsev [Wed, 14 Aug 2024 05:55:34 +0000 (22:55 -0700)] 
gprofng: fix typo in src/collctrl.cc

gprofng/ChangeLog
2024-08-13  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* src/collctrl.cc (read_cpuinfo): Fix typo.

10 months agoAutomatic date update in version.in
GDB Administrator [Thu, 15 Aug 2024 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoLog gdb version and configuration in DAP
Tom Tromey [Fri, 26 Jul 2024 14:36:28 +0000 (08:36 -0600)] 
Log gdb version and configuration in DAP

I think it would be useful for gdb's DAP logs to come with the version
and configuration information.  This might make debugging some bug
reports a little simpler.

10 months agoNotify Python when breakpoint symbol changes
Tom Tromey [Mon, 8 Jul 2024 17:28:37 +0000 (11:28 -0600)] 
Notify Python when breakpoint symbol changes

A DAP user noticed that breakpoints set by address were never updated
to show their location after the DAP launch request.  It turns out
that gdb does not emit the breakpoint-modified event when this sort of
breakpoint is updated.

This patch changes gdb to notify the breakpoint-modified observer when
a breakpoint location's symbol changes.  This in turn causes the DAP
event to be emitted.

Reviewed-by: Keith Seitz <keiths@redhat.com>
10 months agoFix failure with C++ exceptions in DAP
Tom Tromey [Fri, 5 Jul 2024 16:53:43 +0000 (10:53 -0600)] 
Fix failure with C++ exceptions in DAP

While working on earlier patches, I noticed that the DAP C++ exception
test had some strange results in the log.  Digging into this, I found
that while the Ada catchpoints emit a "bkptno" field in the MI result,
the C++ ones do not -- but the DAP code was relying on this.

This patch fixes the problem by changing which field is examined, and
then updates the tests to verify this.

Reviewed-by: Keith Seitz <keiths@redhat.com>
10 months agoMake DAP instruction breakpoints unverified
Tom Tromey [Fri, 5 Jul 2024 15:57:03 +0000 (09:57 -0600)] 
Make DAP instruction breakpoints unverified

Currently, when a DAP client uses setInstructionBreakpoints, the
resulting breakpoints are created as "verified", even though there is
no symbol file and thus the breakpoint can't possibly have a source
location.

This patch changes the DAP code to assume that all breakpoints are
unverified before launch.

Reviewed-by: Keith Seitz <keiths@redhat.com>
10 months agoIntroduce exec_mi_and_log for DAP
Tom Tromey [Fri, 5 Jul 2024 16:31:27 +0000 (10:31 -0600)] 
Introduce exec_mi_and_log for DAP

This adds a new exec_mi_and_log function that wraps gdb.execute_mi and
logs the command.  This can be handy when debugging DAP.

Reviewed-by: Keith Seitz <keiths@redhat.com>
10 months agold: Add an LTO test for common symbol override
H.J. Lu [Wed, 14 Aug 2024 15:29:15 +0000 (08:29 -0700)] 
ld: Add an LTO test for common symbol override

Linker checks if a symbol in an archive member is a real definition, not
common, before including the archive member in the link output so that
only a real definition in archive will override the common symbol in
object file.  Add an LTO test to verify that a real definition in archive
overrides the common symbol in object file.

* testsuite/ld-plugin/common-1.c: New file.
* testsuite/ld-plugin/definition-1.c: Likewise.
* testsuite/ld-plugin/lto.exp: Run common tests.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
10 months agoRemove unnecessary default argument from initialize_block_iterator
Tom Tromey [Wed, 14 Aug 2024 12:52:19 +0000 (06:52 -0600)] 
Remove unnecessary default argument from initialize_block_iterator

I noticed that initialize_block_iterator has a default value for one
of its arguments, but this is not needed as this function has a single
caller that always passes all arguments.  This patch removes the
default.  Tested by rebuilding.

10 months agoLoongArch: Fix DT_RELR and relaxation interaction
Xi Ruoyao [Mon, 12 Aug 2024 10:23:47 +0000 (18:23 +0800)] 
LoongArch: Fix DT_RELR and relaxation interaction

Due to the way BFD implements DT_RELR as a part of relaxation, if in a
relax trip size_relative_relocs has changed the layout, when
relax_section runs only the vma of the section being relaxed is
guaranteed to be updated.  Then bad thing can happen.  For example, when
linking an auxilary program _freeze_module in the Python 3.12.4 building
system (with PGO + LTO), before sizing the .relr.dyn section, the vma of
.text is 30560 and the vma of .rodata is 2350944; in the final
executable the vma of .text is 36704 and the vma of .rodata is 2357024.
The vma increase is expected because .relr.dyn is squashed somewhere
before .text.  But size_relative_relocs may see the state in which .text
is at 36704 but .rodata "is" still at 2350944.  Thus the distance
between .text and .rodata can be under-estimated and overflowing
R_LARCH_PCREL20_S2 reloc can be created.

To avoid this issue, if size_relative_relocs is updating the size of
.relr.dyn, just supress the normal relaxation in this relax trip.  In
this situation size_relative_relocs should have been demending the next
relax trip, so the normal relaxation can happen in the next trip.

I tried to make a reduced test case but failed.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
10 months agoLoongArch: Fix assertion failure with DT_RELR
Xi Ruoyao [Mon, 12 Aug 2024 10:23:46 +0000 (18:23 +0800)] 
LoongArch: Fix assertion failure with DT_RELR

In the DT_RELR implementation I missed a code path emiting relative
reloc entries.  Then the already packed relative reloc entries will be
(unnecessarily) pushed into .rela.dyn but we've not allocated the space
for them, triggering an assertion failure.

Unfortunately I failed to notice the issue until profiled bootstrapping
GCC with LTO and -Wl,-z,pack-relative-relocs.  The failure can be easily
triggered by linking a "hello world" program with -fprofile-generate and
LTO:

    $ PATH=$HOME/ld-test:$PATH gcc hw.c -fprofile-generate -Wl,-z,pack-relative-relocs -flto
    /home/xry111/git-repos/binutils-build/TEST/ld: BFD (GNU Binutils) 2.43.50.20240802 assertion fail ../../binutils-gdb/bfd/elfnn-loongarch.c:2628
    /home/xry111/git-repos/binutils-build/TEST/ld: BFD (GNU Binutils) 2.43.50.20240802 assertion fail ../../binutils-gdb/bfd/elfnn-loongarch.c:2628
    collect2: error: ld returned 1 exit status

And the reduced test case is just incredibly simple (included in the
patch) so it seems I'm just stupid enough to fail to detect it before.
Let's fix it now anyway.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
10 months agogas: correct .irpc handling with empty string
Jan Beulich [Wed, 14 Aug 2024 09:25:34 +0000 (11:25 +0200)] 
gas: correct .irpc handling with empty string

Following 69cab370cf66 ("gas: adjust handling of quotes for .irpc") the
closing quote was mistakenly treated as the first quoted character.

10 months agox86: correct .insn with opcode extension and VEX/XOP/EVEX encoding
Jan Beulich [Wed, 14 Aug 2024 09:25:12 +0000 (11:25 +0200)] 
x86: correct .insn with opcode extension and VEX/XOP/EVEX encoding

When VexVVVV handling was re-worked, .insn broke: When an opcode
extension is in use, VexVVVV_DST needs using now, as ModR/M.reg is
already occupied, matching what c8866e3ec5e2 ("x86: Drop using
extension_opcode to encode vvvv register") did.

While adding (bad) POP2 forms, also slightly adjust existing ones:
No need to use XMM registers, and no need to specify %r8 when really
%rax is meant twice (EVEX.vvvv not really being the culprit there, or
else EVEX.V' would also have needed mentioning).

10 months agobtrace: Extend ptwrite event decoding.
Felix Willgerodt [Mon, 18 Feb 2019 14:50:49 +0000 (15:50 +0100)] 
btrace: Extend ptwrite event decoding.

Call the ptwrite filter function whenever a ptwrite event is decoded.
The returned string is written to the aux_data string table and a
corresponding auxiliary instruction is appended to the function segment.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
10 months agobtrace, python: Enable ptwrite filter registration.
Felix Willgerodt [Tue, 15 May 2018 13:42:24 +0000 (15:42 +0200)] 
btrace, python: Enable ptwrite filter registration.

By default GDB will be printing the hex payload of the ptwrite package as
auxiliary information.  To customize this, the user can register a ptwrite
filter function in python, that takes the payload and the PC as arguments and
returns a string which will be printed instead.  Registering the filter
function is done using a factory pattern to make per-thread filtering easier.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
10 months agobtrace, linux: Enable ptwrite packets.
Felix Willgerodt [Tue, 29 May 2018 06:44:45 +0000 (08:44 +0200)] 
btrace, linux: Enable ptwrite packets.

Enable ptwrite in the PT config, if it is supported by the kernel.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
10 months agobtrace, gdbserver: Add ptwrite to btrace_config_pt.
Felix Willgerodt [Tue, 21 Jul 2020 09:12:08 +0000 (11:12 +0200)] 
btrace, gdbserver: Add ptwrite to btrace_config_pt.

This enables gdb and gdbserver to communicate about ptwrite support.  If
ptwrite support would be enabled unconditionally, GDBs with older libipt
versions would break.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
10 months agopython: Add clear() to gdb.Record.
Felix Willgerodt [Mon, 25 Feb 2019 14:30:29 +0000 (15:30 +0100)] 
python: Add clear() to gdb.Record.

This function allows to clear the trace data from python, forcing to
re-decode the trace for successive commands.
This will be used in future ptwrite patches, to trigger re-decoding when
the ptwrite filter changes.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Markus Metzger <markus.t.metzger@intel.com>
10 months agopython: Introduce gdb.RecordAuxiliary class.
Felix Willgerodt [Thu, 21 Feb 2019 09:48:35 +0000 (10:48 +0100)] 
python: Introduce gdb.RecordAuxiliary class.

Auxiliary instructions are no real instructions and get their own object
class, similar to gaps. gdb.Record.instruction_history is now possibly a
list of gdb.RecordInstruction, gdb.RecordGap or gdb.RecordAuxiliary
objects.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
10 months agobtrace: Handle stepping and goto for auxiliary instructions.
Felix Willgerodt [Mon, 28 May 2018 12:30:46 +0000 (14:30 +0200)] 
btrace: Handle stepping and goto for auxiliary instructions.

Print the auxiliary data when stepping. Don't allow to goto an auxiliary
instruction.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
10 months agobtrace: Enable auxiliary instructions in record function-call-history.
Felix Willgerodt [Thu, 7 Jun 2018 08:38:10 +0000 (10:38 +0200)] 
btrace: Enable auxiliary instructions in record function-call-history.

Print the auxiliary data when a btrace_insn of type BTRACE_INSN_AUX
is encountered in the function-call-history.  Printing is
active by default, it can be silenced with the /a modifier.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
10 months agobtrace: Enable auxiliary instructions in record instruction-history.
Felix Willgerodt [Wed, 6 Jun 2018 12:27:21 +0000 (14:27 +0200)] 
btrace: Enable auxiliary instructions in record instruction-history.

Print the auxiliary data when a btrace_insn of type BTRACE_INSN_AUX
is encountered in the instruction-history.  Printing is active by default,
it can be silenced with the /a modifier.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
10 months agobtrace: Introduce auxiliary instructions.
Felix Willgerodt [Mon, 18 Feb 2019 12:49:25 +0000 (13:49 +0100)] 
btrace: Introduce auxiliary instructions.

Auxiliary instructions are pseudo instructions pointing to auxiliary data.
This auxiliary data can be printed in all commands displaying (record
function-call-history, record instruction-history) or stepping through
(stepi etc.) the execution history, which will be introduced in the next
commits.

This patch is in preparation for the new ptwrite feature, which is based on
auxiliary instructions.

Approved-By: Markus Metzger <markus.t.metzger@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
10 months agogdb: remove unnecessary code relating to limited-length arrays
Andrew Burgess [Tue, 6 Aug 2024 19:53:35 +0000 (20:53 +0100)] 
gdb: remove unnecessary code relating to limited-length arrays

While reviewing this commit:

  commit 8fdd2b2bcd8117cafcc6ef976e45f0d9f95fb528
  Date:   Tue Aug 6 19:34:18 2024 +0200

      Mark unavailable bytes of limited-length arrays when allocating contents

I spotted that there was some code in value::record_latest relating to
limited-length arrays which appeared redundant.  The code was added
with the first introduction on limited-length arrays in commit:

  commit a0c07915778486a950952139d27c01d4285b02b4
  Date:   Fri Feb 10 23:49:19 2023 +0000

      GDB: Introduce limited array lengths while printing values

The code in question is in value::record_latest.  When the value being
recorded is lazy we need to fetch its value before adding it to the
history list.  The code I spotted checks to see if the value is lazy,
if we currently have array limiting in effect, and if we do sets
m_limited_length to max_value_size before finally calling fetch_lazy.

The first thing fetch_lazy does is call allocate_contents to setup the
value's buffer, and in allocate_contents we perform the same set of
checks: if the value is an array, and array length limiting is in
effect then only allocate max_value_size buffer for the contents.

In ::allocate_contents the `if` condition check is spread out between
::allocate_contents and ::set_limited_array_length, but I'm certain
it's checking the same condition.

As such the checks and m_limited_length adjustment in ::record_latest
is redundant and can be removed.

Out of curiosity I went back to the original a0c07915778486a commit
and removed the same block of code from record_latest_value (as
value::record_latest was called back then) and non of the tests added
by commit a0c07915778486a failed.  I think this block of code was
never needed.

Anyway, I removed the unnecessary code and retested and there are no
regressions.

There should be no user visible changes after this commit.

Approved-By: John Baldwin <jhb@FreeBSD.org>
10 months agoAutomatic date update in version.in
GDB Administrator [Wed, 14 Aug 2024 00:00:42 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoelf: Never set non_ir_ref_regular for debug reference
H.J. Lu [Tue, 13 Aug 2024 00:01:05 +0000 (17:01 -0700)] 
elf: Never set non_ir_ref_regular for debug reference

Never set non_ir_ref_regular for debug reference since references in
debug sections shouldn't impact LTO output.

* elflink.c (elf_link_add_object_symbols): Don't check strip for
references in debug sections when setting non_ir_ref_regular.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
10 months agogdb/gdbarch: fix a dot-space-space in generated files
Gerlicher, Klaus [Wed, 7 Aug 2024 10:41:55 +0000 (10:41 +0000)] 
gdb/gdbarch: fix a dot-space-space in generated files

This is a very small patch to straighten out dot-space-space in these
comments in the gdbarch generated files:

-  /* Skip verify of short_bit, invalid_p == 0 */
+  /* Skip verify of short_bit, invalid_p == 0.  */

There is no functional change after this commit.

Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogas macro arg1 test
Alan Modra [Tue, 13 Aug 2024 02:53:03 +0000 (12:23 +0930)] 
gas macro arg1 test

A number of targets pad out the data section, and there are targets
that have 2 or 4 octets per byte.  And some even that don't have '#'
as a line comment char.  tic6x-elf fails the test with "Error: too
many positional arguments".

* testsuite/gas/macros/arg1.s: Pad out data section.  Use C style
comments.
* testsuite/gas/macros/arg1.d: Adjust to suit.  Don't run on
multi-octet per byte targes.  xfail tic6x.

10 months agoPR32072 dlltool.c initializer-string is too long
Alan Modra [Mon, 12 Aug 2024 22:25:04 +0000 (07:55 +0930)] 
PR32072 dlltool.c initializer-string is too long

PR 32072
* dlltool.c: Delete unneeded forward function declaraions.
Make buffers used by dlltmp static.
(prefix_encode): Avoid warning.  Use stpcpy.

10 months agoAutomatic date update in version.in
GDB Administrator [Tue, 13 Aug 2024 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agogprofng: specify the heap data collection range
Vladimir Mezentsev [Fri, 9 Aug 2024 04:30:08 +0000 (21:30 -0700)] 
gprofng: specify the heap data collection range

Extend the -H option:
 -H {off|on|N1[-N2]}  disable , or enable heap tracing, or
                      specify the heap data collection range.
                      The default is "-H off".

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

* libcollector/heaptrace.c: Read the range in the -H option.
Do not collect data if the allocated memory is out of range.
* src/collctrl.h (heaptrace_mode): Define as char * value.
* src/envsets.cc: Updated since heaptrace_mode is changed.
* src/collctrl.cc: Accept the extended -H option.
* src/gp-collect-app.cc: Accept the extended -H option.
Remove unused code.

10 months agosim: pru: Fix test case assembly with latest GAS
Dimitar Dimitrov [Mon, 12 Aug 2024 17:40:16 +0000 (20:40 +0300)] 
sim: pru: Fix test case assembly with latest GAS

After the recent change in GAS [1], macro arguments must be quoted or
grouped with parenthesis.  Add the necessary parenthesis in order to fix
assembly errors like:
    mul.s:31: Error: too many positional arguments

[1] https://sourceware.org/pipermail/binutils/2024-July/136053.html

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
10 months agoSimplify typename_concat
Tom Tromey [Mon, 29 Jul 2024 15:38:29 +0000 (09:38 -0600)] 
Simplify typename_concat

This patch simplifies typename_concat, changing the return type and
removing the obstack allocation code.  The latter is possible because
the only caller using this mode uses the name when creating a new
type, and 'new_type' copies the string to the appropriate obstack
anyway.  It also changes typename_concat to use 'concat'.  This change
lets us remove a mildly fragile macro as well.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
10 months agogas: Add macro tests for PR gas/32073
H.J. Lu [Mon, 12 Aug 2024 15:43:22 +0000 (08:43 -0700)] 
gas: Add macro tests for PR gas/32073

1. Add a macro test for expression argument with inner white spaces and
a white space before argument added by C preprocessor.
2. Add a x86-64 specific macro test.

PR gas/32073
* testsuite/gas/i386/x86-64-macro-1.d: New file.
* testsuite/gas/i386/x86-64-macro-1.s: Likewise.
* testsuite/gas/i386/x86-64.exp: Run x86-64-macro-1.
* testsuite/gas/macros/arg1.d: New file.
* testsuite/gas/macros/arg1.s: Likewise.
* testsuite/gas/macros/macros.exp: Run arg1.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
10 months agoRevert "gas: have scrubber retain more whitespace"
H.J. Lu [Mon, 12 Aug 2024 15:43:21 +0000 (08:43 -0700)] 
Revert "gas: have scrubber retain more whitespace"

This reverts commit 6ae8a30d44f016cafb46a75843b5109316eb1996.

This fixes PR gas/32073.

10 months agoRevert "gas: drop scrubber states 14 and 15"
H.J. Lu [Mon, 12 Aug 2024 15:43:20 +0000 (08:43 -0700)] 
Revert "gas: drop scrubber states 14 and 15"

This reverts commit 7dd0dfbde7ee31167a3b2e192a575493d26b7b0a.

This is a prerequisite for the PR gas/32073 fix.

10 months agopre-commit: autoupdate
Simon Marchi [Mon, 12 Aug 2024 17:03:09 +0000 (13:03 -0400)] 
pre-commit: autoupdate

Run `pre-commit autoupdate`.

Change-Id: I6623a61b7d1e827360854e825d84c5608a68e07b

10 months ago[gdb/testsuite] Fix gdb.tui/wrap-line.exp with wrapping disabled
Bernd Edlinger [Mon, 12 Aug 2024 15:32:44 +0000 (17:32 +0200)] 
[gdb/testsuite] Fix gdb.tui/wrap-line.exp with wrapping disabled

There are a couple of ways that readline wrapping can be disabled:
- using "set horizontal-scroll-mode on" in INPUTRC,
- using a TERM setting like TERM=dumb, and
- building gdb with stub-termcap.

Using a trigger patch in default_gdb_init that adds
"set horizontal-scroll-mode on" to INPUTRC:
...
-    setenv INPUTRC [cached_file inputrc "set enable-bracketed-paste off"]
+    setenv INPUTRC [cached_file inputrc "set enable-bracketed-paste off\nset horizontal-scroll-mode on"]
...
we can easily reproduce a failure in gdb.tui/wrap-line.exp mentioned in
PR testsuite/31201 (which was reported for the stub-termcap case):
...
WARNING: timeout in accept_gdb_output
Screen Dump (size 50 columns x 24 rows, cursor at column 34, row 1):
    0 Quit
    1 <89012345678901234567890123456789W
    2
    ...
    23
FAIL: gdb.tui/wrap-line.exp: width-hard-coded: cli: wrap
...

Fix this by accepting the horizontal-scroll-mode style output.  We do
this only when in CLI mode though, when in TUI wrapping works as before
because it doesn't rely on readline.

Tested on x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31201

10 months agogdb/amd-dbgapi-target: adjust to amd-dbgapi 0.75.0
Simon Marchi [Mon, 5 Aug 2024 14:39:15 +0000 (10:39 -0400)] 
gdb/amd-dbgapi-target: adjust to amd-dbgapi 0.75.0

amd-dbgapi 0.75 (from ROCm release 6.2.0) brings a few backwards
incompatible changes.  Adjust the amd-dbgapi target code accordingly.
Given that the AMD GPU port in upstream GDB today is of limited use
(it's still missing important  pieces), we don't really care about
supporting amd-dbgapi versions other than the latest stable one, so no
effort is made to keep compatibility with versions 6.1.2 and older.

The changes are:

 - AMD_DBGAPI_EXCEPTION_WAVE_APERTURE_VIOLATION was renamed to
   AMD_DBGAPI_EXCEPTION_WAVE_ADDRESS_ERROR (the old name still exists
   but is deprecated), use the latter.

 - In the callbacks structure, the get_os_pid callback was replaced with
   client_process_get_info, which is more general and extensible.
   Convert our get_os_pid to a new, equivalent, client_process_get_info
   callback.  Handle the new AMD_DBGAPI_CLIENT_PROCESS_INFO_CORE_STATE
   query, but just return "not available".

 - The xfer_global_memory callback was added to the callbacks structure,
   add that new callback.

 - Update configure.ac to check for amd-dbgapi >= 0.75.0.

Change-Id: If012398cf55ebf6146b007f6b4e8395dd48ef981
Approved-By: Lancelot Six <lancelot.six@amd.com>
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
10 months agogdb: pass inferior to gdbarch_update_p
Simon Marchi [Mon, 29 Jul 2024 03:25:58 +0000 (23:25 -0400)] 
gdb: pass inferior to gdbarch_update_p

Make the current inferior reference bubble up one level.  I think this
makes it clearer what gdbarch_update_p, which is update the passed
inferior's architecture (although the function name could probably be
better).

When gdbarch_find_by_info, it is possible for the new architecture's
init callback to be called.  I have not audited all of them (there are
just too many), it's possible that some of them do care about the
current inferior, for some reason (for instance, if one of them makes a
target call).  If so, they should be changed too.

Change-Id: I89f012188d7fdca395a830f4b013743565f26847

10 months agogdb: pass inferior to target_current_description
Simon Marchi [Mon, 29 Jul 2024 03:25:57 +0000 (23:25 -0400)] 
gdb: pass inferior to target_current_description

Make the current inferior reference bubble up one level.

Change-Id: I441f954877749dc5a861ab03e881b529dafc2efd

10 months agogdb: change names of enumerations in enum flags selftest
Simon Marchi [Thu, 30 May 2024 20:28:21 +0000 (16:28 -0400)] 
gdb: change names of enumerations in enum flags selftest

When reading this test (in the context of PR 31331), I had trouble
understanding the tests, because of the abbreviated names.  I would
prefer if the names were a bit more explicit, like this.

Change-Id: I85669b238a9d5dacf673a7bbfc1ca18f80d2b2cf

10 months agogdb, gdbsupport: use `using` in enum flags code
Simon Marchi [Thu, 30 May 2024 20:28:20 +0000 (16:28 -0400)] 
gdb, gdbsupport: use `using` in enum flags code

I think that `using` is easier to read than `typedef`, and it's the
modern C++ thing anyway.

Change-Id: Iccb62dc3869cddfb6a684ef3023dcd5b799f3ab2

10 months agogdbsupport: remove C enum flags fallback
Simon Marchi [Thu, 30 May 2024 20:28:19 +0000 (16:28 -0400)] 
gdbsupport: remove C enum flags fallback

This might have been useful during the C -> C++ conversion (not sure),
but it doesn't appear useful today.  I don't see when enum-flags.h would
be used in a C context.

Change-Id: I6c7ed655757248a62a1bf6615995f42e8aa2b4bd

10 months agogdb/NEWS: announce removal of QNX Neutrino support
Simon Marchi [Mon, 12 Aug 2024 14:29:36 +0000 (10:29 -0400)] 
gdb/NEWS: announce removal of QNX Neutrino support

QNX Neutrino support was removed here [1], but I forgot to mention in in
NEWS.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=36fb20fa93484b104d91e42e38930ee8629192ab

Change-Id: I8db7957acdd0be3c1e0b751c7c245870c4cd7101
Approved-By: Eli Zaretskii <eliz@gnu.org>
10 months agogdb: add program_space parameter to lookup_minimal_symbol_text
Simon Marchi [Wed, 17 Jul 2024 03:52:05 +0000 (23:52 -0400)] 
gdb: add program_space parameter to lookup_minimal_symbol_text

Make the current program space reference bubble up one level.  Use a
program space from the context whenever that makes sense.

Change-Id: Id3b0bf4490178d71a9aecdbf404b9287c22b30f5
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogdb: add program_space parameter to lookup_minimal_symbol_linkage
Simon Marchi [Wed, 17 Jul 2024 03:52:04 +0000 (23:52 -0400)] 
gdb: add program_space parameter to lookup_minimal_symbol_linkage

Make the current_program_space reference bubble up one level.

Change-Id: Ic349dc96b7d375ad7c66022d84657136f0de8c87
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogdb: add program_space parameter to get_symbol_leading_char
Simon Marchi [Wed, 17 Jul 2024 03:52:03 +0000 (23:52 -0400)] 
gdb: add program_space parameter to get_symbol_leading_char

Make the current_program_space references bubble up one level.  In this
case, I think it makes sense to use m_objfile's program space.

Change-Id: Ibecb89b5e8a0363328240f1675d0fb95ff99c99a
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogdb: add program_space parameter to lookup_minimal_symbol
Simon Marchi [Wed, 17 Jul 2024 03:52:02 +0000 (23:52 -0400)] 
gdb: add program_space parameter to lookup_minimal_symbol

>From what I can see, lookup_minimal_symbol doesn't have any dependencies
on the global current state other than the single reference to
current_program_space.  Add a program_space parameter and make that
current_program_space reference bubble up one level.

Change-Id: I759415e2f9c74c9627a2fe05bd44eb4147eee6fe
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogdb: remove lookup_bound_minimal_symbol
Simon Marchi [Wed, 17 Jul 2024 03:52:01 +0000 (23:52 -0400)] 
gdb: remove lookup_bound_minimal_symbol

Now that lookup_minimal_symbol has default values for sfile and objf,
calling lookup_bound_minimal_symbol is identical to calling
lookup_minimal_symbol without sfile and objf.  Remove
lookup_bound_minimal_symbol, replace call sites with
lookup_minimal_symbol.

Change-Id: I0a420fb56de1de8bee8a7303228c9e4546e3577b
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogdb: make lookup_minimal_symbol objf and sfile parameters optional
Simon Marchi [Wed, 17 Jul 2024 03:52:00 +0000 (23:52 -0400)] 
gdb: make lookup_minimal_symbol objf and sfile parameters optional

Most calls to lookup_minimal_symbol don't pass a value for sfile and
objf.  Make these parameters optional (have a default value of
nullptr).  And since passing a value to `objf` is much more common than
passing a value to `sfile`, swap the order so `objf` comes first, to
avoid having to pass a nullptr value to `sfile` when wanting to pass a
value to `objf`.

Change-Id: I8e9cc6b942e593bec640f9dfd30f62786b0f5a27
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogdb: drop struct keyword when using bound_minimal_symbol
Simon Marchi [Wed, 17 Jul 2024 03:51:59 +0000 (23:51 -0400)] 
gdb: drop struct keyword when using bound_minimal_symbol

This is a simple find / replace from "struct bound_minimal_symbol" to
"bound_minimal_symbol", to make things shorter and more consisten
througout.  In some cases, move variable declarations where first used.

Change-Id: Ica4af11c4ac528aa842bfa49a7afe8fe77a66849
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogdb: remove find_and_open_solib so_list method
Simon Marchi [Thu, 25 Jul 2024 17:41:37 +0000 (13:41 -0400)] 
gdb: remove find_and_open_solib so_list method

Now that the nto port is removed, this is unused.

Change-Id: I86565310cdbcde17a837eb10585cdd153f4f03d8
Approved-by: Kevin Buettner <kevinb@redhat.com>
10 months agogdbsupport: remove #ifndef REALTIME_LO in signals.cc
Simon Marchi [Thu, 25 Jul 2024 17:41:36 +0000 (13:41 -0400)] 
gdbsupport: remove #ifndef REALTIME_LO in signals.cc

REALTIME_LO was only possibly previously defined in config/nm-nto.h,
which is now removed.  So we can remove the #ifndef protecting against a
redefinition of REALTIME_LO in gdbsupport/signals.cc.

Change-Id: I021b9518ceaa6223bd480ff1e07e9a978b0b241e
Approved-by: Kevin Buettner <kevinb@redhat.com>
10 months agogdb: remove QNX Neutrino support
Simon Marchi [Thu, 25 Jul 2024 17:41:35 +0000 (13:41 -0400)] 
gdb: remove QNX Neutrino support

Remove the support for the QNX Neutrino OS (tdep and native bits).  This
has been unmaintained for years, and we don't have a way to see if it
works (or even builds, for the native parts).  Without somebody actively
maintaining it, this is just a burden for developers, especially that
this port does a few weird unique things that require reasoning about
when doing big change.

Support for GDBserver was removed in 2020, commit 613f149a90d6
("gdbserver: remove support for Neutrino").

Change-Id: I4e25ec26ab06636629adebd02ceb161ee31c232d
Approved-by: Kevin Buettner <kevinb@redhat.com>
10 months agogdb: rename target-delegates.c to target-delegates-gen.c
Simon Marchi [Mon, 5 Aug 2024 15:24:36 +0000 (11:24 -0400)] 
gdb: rename target-delegates.c to target-delegates-gen.c

Following this suggestion:

https://inbox.sourceware.org/gdb-patches/2a0520ec-ccfe-4fc3-b051-7b8c60294de5@efficios.com/T/#md537792a1871addf153f3e406224f9baf025414a

Change-Id: I30988c46505f130ca16155891958f92621cada97
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agoAutomatic date update in version.in
GDB Administrator [Mon, 12 Aug 2024 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoAutomatic date update in version.in
GDB Administrator [Sun, 11 Aug 2024 00:00:36 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agold: Add PR ld/32067 tests
H.J. Lu [Sat, 10 Aug 2024 14:23:53 +0000 (07:23 -0700)] 
ld: Add PR ld/32067 tests

Add PR ld/32067 tests with the compiler driver since the -plugin option
is needed to trigger this --oformat binary bug.

PR ld/32067
* testsuite/ld-i386/i386.exp: Run PR ld/32067 test.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/start.s: Add .note.GNU-stack section.
* testsuite/ld-x86-64/pr32067.s: New file.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
10 months agoPR32067, ld -Wl,--oformat,binary crash in _bfd_elf_link_keep_memory
Alan Modra [Fri, 9 Aug 2024 23:11:16 +0000 (08:41 +0930)] 
PR32067, ld -Wl,--oformat,binary crash in _bfd_elf_link_keep_memory

The direct fix for this segfault is to test for a non-NULL bed in
_bfd_elf_link_keep_memory, but also there isn't much point in running
code for LTO if the output is binary.

PR 32067
* elflink.c (_bfd_elf_link_keep_memory): Test for non-NULL bed.
(elf_link_add_object_symbols): Don't run the loop setting
non_ir_ref_regular if the output hash table is not ELF.

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

10 months agoFix test failure when TUI is not enabled
Bernd Edlinger [Fri, 9 Aug 2024 08:39:56 +0000 (10:39 +0200)] 
Fix test failure when TUI is not enabled

This adds a missing allow_tui_tests guard.

When tui is not enabled this test case does
typically fail:

FAIL: gdb.base/new-ui.exp: do_test_invalid_args: new-ui with tui

Approved-By: Tom de Vries <tdevries@suse.de>
10 months agogdb: adjust the default place of 'list' to main's prologue
Stephan Rohr [Sat, 3 Aug 2024 09:07:42 +0000 (02:07 -0700)] 
gdb: adjust the default place of 'list' to main's prologue

The 'list' command prints around the 'main' function if the current
source location is not set.  The prologue of 'main' is skipped and the
first real line of 'main' is offset by 'lines_to_print - 1'.  This is
incorrect, the location should be defaulted to main's prologue without
applying offsets (similar to 'list main').  Printing around the selected
line is then done in 'list_around_line'.

The patch also fixes an issue if the list command is used before the
program is started.  For example, with the following code:

26 static void attribute ((used)) ambiguous_fun (void) {}
27
28 static int attribute ((used)) ambiguous_var;
29
30
31
32
33
34
35
36
37
38 int
39 main (void)
40 {
41   return 0;
42 }

GDB offsets the relevant line by 'lines_to_print - 1' and then by another
'lines_to_print / 2' and prints:

(gdb) list
27
28 static int attribute ((used)) ambiguous_var;
29
30
31
32
33
34
35
36

With this patch, GDB correctly prints:

37
38      int
39      main (void)
40      {
41        return 0;
42      }

Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogas: drop scrubber states 14 and 15
Jan Beulich [Fri, 9 Aug 2024 10:00:26 +0000 (12:00 +0200)] 
gas: drop scrubber states 14 and 15

While sadly 5262831592fb doesn't say anything on why these would have
been needed, the latest with the removal of most of the opcode vs
operands distinction in the scrubber these shouldn't be needed anymore.
The implementation was a little questionable anyway, in moving back to
states expecting labels, when clearly labels shouldn't really be
following predicates (in practice, due to another bug, at least ia64
permits such).

10 months agogas: have scrubber retain more whitespace
Jan Beulich [Fri, 9 Aug 2024 09:59:31 +0000 (11:59 +0200)] 
gas: have scrubber retain more whitespace

According to the description of the state machine, the expectation
appears to be that (leaving aside labels) any insn mnemonic or
directive would be followed by a comma separated list of operands. That
may have been true very long ago, but the latest with the advent of more
elaborate macros this isn't rhe case anymore. Neither macro parameters
in macro definitions nor macro arguments in macro invocations are
required to be separated by commas. Hence whitespace serves a crucial
role there. Plus even without "real" macros issues exist, in e.g.

.irp n, ...
insn\n\(suffix) operand1, operand2
.endr

Whitespace following the closing parenthesis would have been removed
(ahead of even processing the .irp), as the "opcode" was deemed to have
ended earlier already.

Therefore, squash the distinction between "opcode" and operands, i.e.
fold state 10 back into state 3. Also drop most of the distinction
between "symbol chars" and "relatively normal" ones. Not entirely
unexpectedly this results in the need to skip whitespace in a few more
places in arch-specific code (and quite likely more changes are needed
for insn forms not covered by the testsuite).

As a result the D10V special case is no longer necessary.

In config/tc-sparc.c also move a comment to be next to the code being
commented.

In opcodes/cgen-asm.in some further cleanup is done, following the local
var adjustments.

10 months agoMIPS: relax gas testsuite whitespace expectations
Jan Beulich [Fri, 9 Aug 2024 09:52:42 +0000 (11:52 +0200)] 
MIPS: relax gas testsuite whitespace expectations

In a subsequent change the scrubber is going to be changed to retain
further whitespace.  Test case expectations generally would better not
depend on the specific whitespace treatment by the scrubber, unless of
course a test is specifically about it.  Adjust relevant test cases to
permit blanks where those will subsequently appear.

10 months agoaarch64: relax gas testsuite whitespace expectations
Jan Beulich [Fri, 9 Aug 2024 09:52:18 +0000 (11:52 +0200)] 
aarch64: relax gas testsuite whitespace expectations

In a subsequent change the scrubber is going to be changed to retain
further whitespace. Test case expectations generally would better not
depend on the specific whitespace treatment by the scrubber, unless of
course a test is specifically about it. Adjust relevant test cases to
permit blanks where those will subsequently appear.

10 months agoArm: relax gas testsuite whitespace expectations
Jan Beulich [Fri, 9 Aug 2024 09:51:47 +0000 (11:51 +0200)] 
Arm: relax gas testsuite whitespace expectations

In a subsequent change the scrubber is going to be changed to retain
further whitespace. Test case expectations generally would better not
depend on the specific whitespace treatment by the scrubber, unless of
course a test is specifically about it. Adjust relevant test cases to
permit blanks where those will subsequently appear.

10 months agom32r: move scrubber override to target header
Jan Beulich [Fri, 9 Aug 2024 09:49:36 +0000 (11:49 +0200)] 
m32r: move scrubber override to target header

Other than LEX_IS_* settings, such #define-s don't belong into the
common source file.

10 months agoArm: respect line separators for .symver scrubber special case
Jan Beulich [Fri, 9 Aug 2024 09:49:04 +0000 (11:49 +0200)] 
Arm: respect line separators for .symver scrubber special case

Directives end at "line" (really: statement) separators, not just at
new-line chars.

10 months agogas: respect CR_EOL also for scrubbing
Jan Beulich [Fri, 9 Aug 2024 09:48:32 +0000 (11:48 +0200)] 
gas: respect CR_EOL also for scrubbing

While apparently intended to be only externally controlled (e.g. via
specifying CFLAGS at make invocation), we should still keep scrubber and
lexer in sync in this regard. There's one place which imo was previously
wrong already, but would go further wrong and hence is being adjusted
right here: An .mri directive can be terminated by any kind of "line"
(really: statement) separators.

10 months agogas: have scrubber also respect quoted labels
Jan Beulich [Fri, 9 Aug 2024 09:48:05 +0000 (11:48 +0200)] 
gas: have scrubber also respect quoted labels

For the handling of ':' elsewhere in the scrubber to be correct with
regard to labels, the state after parsing a string found at the start of
a line must match that after finding a symbol character at the start of
a line. (Things are largely okay when there's whitespace ahead of the
label: Whitespace after the colon then is retained rather than dropped
for typical targets like x86, but read.c will know to deal with that.)

10 months agoRISC-V: PR32014, .option directives shuoldn't affect elf attribute.
Nelson Chu [Wed, 31 Jul 2024 05:00:11 +0000 (13:00 +0800)] 
RISC-V: PR32014, .option directives shuoldn't affect elf attribute.

The .option arch/rvc/norvc/push/pop directives can only take effect for a
small/large specific code region, so they are not file-level architecture
setting.  They should only affect the mapping symbols only rather than the
file-level elf architecture attribute.  Otherwise, the elf architecture
attribute will appear to missing some extensions when -flto merges files
with different .option architecture settings.

gas/
PR 32014
* config/tc-riscv.c (file_arch_str): New const char *, rather than the
arch_str in the riscv_rps_as.subset_list, it's file-level so only be
affected by .attribute arch directive.
(riscv_reset_subsets_list_arch_str): Renamed to riscv_set_arch_str, and
also can handle both file_arch_str and arch_str in subset_list, just
give the pointer address as the input.
(riscv_set_arch): Called by -march and .attribute arch, so set both
file_arch_str and arch_str in subset_list.
(s_riscv_option): Updated .option arch/rvc/norvc/push/pop that only
set the arch_str in subset_list.
(riscv_write_out_attrs): Output elf architecture attribute according to
file_arch_str.  Freed file_arch_str.
* doc/c-riscv.texi: Added destrbution that .option directives shouldn't
affect the elf attribute settings.
* testsuite/gas/riscv/option-arch.s: From option-arch-01/02/03 merged.
* testsuite/gas/riscv/option-arch-dis.d: Likewise, for dis-assembler.
* testsuite/gas/riscv/option-arch-attr.d: Likewise, to check readelf -A.

10 months agoAutomatic date update in version.in
GDB Administrator [Fri, 9 Aug 2024 00:00:28 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agogas: sparc: Fix faligndatai assembly and disassembly
Richard Henderson [Thu, 8 Aug 2024 22:32:54 +0000 (08:32 +1000)] 
gas: sparc: Fix faligndatai assembly and disassembly

The first operand is a general register, not an fp register;
the third operand is encoded into RS2, not RS3;
the second operand must match the destination operand.

10 months ago[gdb/python] Fix handling of ^C during disassembly
Tom de Vries [Thu, 8 Aug 2024 21:52:00 +0000 (23:52 +0200)] 
[gdb/python] Fix handling of ^C during disassembly

Inspired by the trigger patch I used here [1], I tried this in
gdbpy_print_insn:
...
   /* Call into the registered disassembler to (possibly) perform the
      disassembly.  */
+  set_quit_flag ();
   PyObject *insn_disas_obj = (PyObject *) disasm_info;
   gdbpy_ref<> result (PyObject_CallFunctionObjArgs (hook.get (),
                                                    insn_disas_obj,
...
and with test-case gdb.python/py-disasm-exec.exp ran into:
...
(gdb) disassemble test^M
Dump of assembler code for function test:^M
   0x00000000004101ac <+0>:     Python Exception <class 'KeyboardInterrupt'>: ^M
^M
unknown disassembler error (error = -1)^M
(gdb)
...

This is incorrect, the KeyboardInterrupt should propagate and interrupt the
command.

Fix this by using gdbpy_print_stack_or_quit instead of gdbpy_print_stack in
gdbpy_print_insn, giving us instead:
...
(gdb) disassemble test^M
Dump of assembler code for function test:^M
   0x00000000004101ac <+0>:     ^M
Quit^M
(gdb)
...

Tested on aarch64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
[1] https://sourceware.org/pipermail/gdb-patches/2024-July/210798.html

10 months ago[gdb] Handle ^C during disassembly
Tom de Vries [Thu, 8 Aug 2024 21:52:00 +0000 (23:52 +0200)] 
[gdb] Handle ^C during disassembly

In PR gdb/32025, a fatal error was reported when sending a SIGINT to gdb while
disassembling.

I managed to reproduce this on aarch64-linux in a Leap 15.5 container using
this trigger patch:
...
 gdb_disassembler_memory_reader::dis_asm_read_memory
   (bfd_vma memaddr, gdb_byte *myaddr, unsigned int len,
    struct disassemble_info *info) noexcept
 {
+  set_quit_flag ();
   return target_read_code (memaddr, myaddr, len);
 }
...
and a simple gdb command line calling the disassemble command:
...
$ gdb -q -batch a.out -ex "disassemble main"
...

The following scenario leads to the fatal error:
- the disassemble command is executed,
- set_quit_flag is called in
  gdb_disassembler_memory_reader::dis_asm_read_memory, pretending that a
  user pressed ^C,
- target_read_code calls QUIT, which throws a
  gdb_exception_quit,
- the exception propagation mechanism reaches c code in libopcodes and a fatal
  error triggers because the c code is not compiled with -fexception.

Fix this by:
- wrapping the body of gdb_disassembler_memory_reader::dis_asm_read_memory in
  catch_exceptions (which consequently needs moving to a header file), and
- reraising the caught exception in default_print_insn using QUIT.

Tested on aarch64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32025

10 months agoAutomatic date update in version.in
GDB Administrator [Thu, 8 Aug 2024 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoscore: drop TC_ALPHA code
Jan Beulich [Wed, 7 Aug 2024 14:32:43 +0000 (16:32 +0200)] 
score: drop TC_ALPHA code

I can't see how that could ever have come into play.

10 months agogas: drop dead VMS code from command line handling
Jan Beulich [Wed, 7 Aug 2024 14:32:15 +0000 (16:32 +0200)] 
gas: drop dead VMS code from command line handling

The only time 'v' was overridden, allowing for an optional value, was
when OBJ_VMS support still existed (until a little less than 20 years
ago). Drop the respective leftovers.

With that OPTION_VERBOSE also becomes redundant and hence is being
dropped.

10 months agoVAX: drop OBJ_VMS leftovers
Jan Beulich [Wed, 7 Aug 2024 14:31:54 +0000 (16:31 +0200)] 
VAX: drop OBJ_VMS leftovers

OBJ_VMS support was dropped almost 20 years ago (e330299ed5ee). Drop
respective code from tc-vax.c as well.

While there, make adjustments for OBJ_ELF as well: -K was dropped over
20 years ago (530556a951f5), yet left in md_shortopts. OPTION_PIC isn't
really necessary either; 'k' can be used instead. And then the ELF
options available weren't displayed by md_show_usage().

10 months agogas: improve unrecognized command line option diagnostic
Jan Beulich [Wed, 7 Aug 2024 14:31:00 +0000 (16:31 +0200)] 
gas: improve unrecognized command line option diagnostic

Printing optc with %c makes sense only when optc is actually a
character. Add logic to also deal with unrecognized long options,
rejected by md_parse_option() rather than get_opt_long_only(). Also
quote the reproduced strings, such that possible included whitespace
can be recognized.

10 months agogas/NEWS: Moved RISC-V Zimop/Zcmop changes into 2.43 section due to backport.
Nelson Chu [Wed, 7 Aug 2024 08:17:05 +0000 (16:17 +0800)] 
gas/NEWS: Moved RISC-V Zimop/Zcmop changes into 2.43 section due to backport.

10 months agoloongarch ld testsuite xpasses
Alan Modra [Tue, 6 Aug 2024 22:26:33 +0000 (07:56 +0930)] 
loongarch ld testsuite xpasses

Some tests started passing with commit 3a83f0342e54.  However,
supporting a changed ld output format is not so simple, and the change
to the loongarch_elf_hash_table macro needs further changes to the
rest of the code.  It is true that some uses of
loongarch_elf_hash_table do not need to check the type of the hash
table, but others like loongarch_elf_relax_section do need to check.
bfd_relax_section is called in lang_size_sections using the input bfd,
not the output bfd.  If the input bfd may be of different type to the
output, then the hash table type must be checked before accessing
elements of the hash table.  This patch corrects
loongarch_elf_relax_section.  I haven't checked all the uses of the
hash table throughout the loongarch backend.

bfd/
* elfnn-loongarch.c (loongarch_elf_relax_section): Don't relax
unless the hash table is loongarch_elf_link_hash_table.
Move variable declarations.  Formatting.
ld/
* testsuite/ld-elf/pr21884.d: Don't xfail loongarach.
* testsuite/ld-unique/pr21529.d: Likewise.

10 months agoAutomatic date update in version.in
GDB Administrator [Wed, 7 Aug 2024 00:00:28 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 months agoMark unavailable bytes of limited-length arrays when allocating contents
Hannes Domani [Tue, 6 Aug 2024 17:34:18 +0000 (19:34 +0200)] 
Mark unavailable bytes of limited-length arrays when allocating contents

Using 'output' to print arrays larger than max-value-size, with only
repeating elements, can cause gdb to crash:
```
$ cat a.c:
char a[1000000];

int main()
{
  return a[0];
}
$ gdb -q a
(gdb) print a
$1 = {0 '\000' <repeats 65536 times>, <unavailable> <repeats 934464 times>}
(gdb) output a

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
```

Using 'print' works, because value::record_latest sets the unavailable
bytes of the value when it's added to the value history.
But 'outout' doesn't do that, so the printing tries to access more bytes
than are available.

The original problem in PR32015 was about using 'print' of a dynamic
array in a D program.
Here the crash happens because for 'print' the value was a struct with
length/ptr fields, which is converted in d-valprint.c into an array.
So value::record_latest didn't have a chance to mark the unavailable
bytes in this case.

To make sure the unavailable bytes always match the contents, this fixes
it by marking the unavailable bytes immediately after the contents are
allocated.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32015
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
10 months agogas: scfi: replace verbose expressions with local vars
Indu Bhagat [Tue, 6 Aug 2024 16:46:06 +0000 (09:46 -0700)] 
gas: scfi: replace verbose expressions with local vars

Replace the scattered and repeated uses of verbose expressions with
variables.  E.g.,
  ginsn_get_src_reg (src1)  -> src1_reg
  ginsn_get_src_type (src1) -> src1_type
etc.

This hopefully makes the logic bit more maintainable.  While at it,
include minor adjustments to make few checks in gen_scfi_ops () more
precise:
  - When getting imm value from src operand, ensure the src type is
    GINSN_SRC_IMM,
  - When getting reg from src operand, ensure the src type is checked
    too (GINSN_SRC_REG or GINSN_SRC_INDIRECT as appropriate).

On the other hand, the changes in verify_heuristic_traceable_reg_fp ()
and verify_heuristic_traceable_stack_manipulation () are purely
mechanical.

gas/
        * scfi.c (verify_heuristic_traceable_reg_fp): Add new local
vars and reuse them.
        (verify_heuristic_traceable_stack_manipulation): Likewise.
        (gen_scfi_ops): Likewise.  Additionally, make some conditionals
more precise.

10 months agoRISC-V: map zext.h to pack/packw if Zbkb is enabled
Hau Hsu [Tue, 6 Aug 2024 03:56:18 +0000 (11:56 +0800)] 
RISC-V: map zext.h to pack/packw if Zbkb is enabled

The `zext.h` is zero-extend halfword instruction that belongs to Zbb.
Currently `zext.h` falls back to 2 shifts if Zbb is not enabled.  However, the
encoding and operation is a special case of `pack/packw rd, rs1, rs2`, which
belongs to Zbkb.  The instructions pack the low halves of rs1 and rs2 into rd.
When rs2 is zero (x0), they behave like zero-extend instruction, and the
encoding are exactly the same as zext.h.

Thus we can map `zext.h` to `pack` or `packw` (rv64) if Zbkb is enabled,
instead of 2 shifts. This reduces one instruction.

This patch does this by making `zext.h` also available for Zbkb.

opcodes/
* riscv-opc.c (riscv_opcodes): Update `zext.h` entries to use
`ZBB_OR_ZBKB` instruction class.

gas/
* testsuite/gas/riscv/zext-to-pack.s: Add test for mapping zext to
pack/packw encoding.
* testsuite/gas/riscv/zext-to-pack-encoding.d: Likewise.
* testsuite/gas/riscv/zext-to-packw-encoding.d: Likewise.

10 months agoRISC-V: Add support for XCvBitmanip extension in CV32E40P
Mary Bennett [Sun, 4 Aug 2024 17:12:26 +0000 (18:12 +0100)] 
RISC-V: Add support for XCvBitmanip extension in CV32E40P

Spec: https://docs.openhwgroup.org/projects/cv32e40p-user-manual/en/latest/instruction_set_extensions.html

Contributors:
  Mary Bennett <mary.bennett682@gmail.com>
  Nandni Jamnadas <nandni.jamnadas@embecosm.com>
  Pietra Ferreira <pietra.ferreira@embecosm.com>
  Charlie Keaney
  Jessica Mills
  Craig Blackmore <craig.blackmore@embecosm.com>
  Simon Cook <simon.cook@embecosm.com>
  Jeremy Bennett <jeremy.bennett@embecosm.com>
  Helene Chelin <helene.chelin@embecosm.com>

bfd/ChangeLog:
* elfxx-riscv.c (riscv_multi_subset_supports): Add `xcvbitmanip`
instruction class.
(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:
* config/tc-riscv.c (validate_riscv_insn): Add custom operands `Xc6` and `Xc7`.
(riscv_ip): Likewise.
* doc/c-riscv.texi: Note XCVbitmanip as an additional ISA extension
for CORE-V.
* testsuite/gas/riscv/march-help.l: Add xcvbitmanip.
* testsuite/gas/riscv/x-cv-bitmanip-fail.d: New Test.
* testsuite/gas/riscv/x-cv-bitmanip-fail.l: New Test.
* testsuite/gas/riscv/x-cv-bitmanip-fail.s: New Test.
* testsuite/gas/riscv/x-cv-bitmanip.d: New Test.
* testsuite/gas/riscv/x-cv-bitmanip.s: New Test.

include/opcode/ChangeLog:
* riscv-opc.h: Add corresponding MATCH and MASK macros for
XCVbitmanip.
* riscv.h: Add corresponding EXTRACT and ENCODE macros for
XCVbitmanip.
(enum riscv_insn_class): Add the XCVbitmanip instruction class.

opcodes/ChangeLog:
* riscv-dis.c (print_insn_args): Add custom operands `Xc6` and `Xc7`.
* riscv-opc.c: Add XCvBitmanip instructions.

10 months agoRISC-V: Add support for Zcmop extension
Xiao Zeng [Wed, 12 Jun 2024 01:28:18 +0000 (09:28 +0800)] 
RISC-V: Add support for Zcmop extension

This implements the Zcmop (Compressed Zimop) extension, as of version 1.0.

View detailed information in:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc>

The Zcmop extension requires the Zca extension.

bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): Handle Zcmop.
(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

* NEWS: Updated.
* testsuite/gas/riscv/march-help.l: Ditto.
* testsuite/gas/riscv/zcmop.d: New test.
* testsuite/gas/riscv/zcmop.s: New test.

include/ChangeLog:

* opcode/riscv-opc.h (DECLARE_INSN): New declarations for Zcmop.
(MATCH_C_MOP_1, MATCH_C_MOP_3, MATCH_C_MOP_5, MATCH_C_MOP_7,
MATCH_C_MOP_9, MATCH_C_MOP_11, MATCH_C_MOP_13, MATCH_C_MOP_15): Define.
(MASK_C_MOP_1, MASK_C_MOP_3, MASK_C_MOP_5, MASK_C_MOP_7,
MASK_C_MOP_9, MASK_C_MOP_11, MASK_C_MOP_13, MASK_C_MOP_15): Ditto.
* opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_ZCMOP.

opcodes/ChangeLog:

* riscv-opc.c: Add Zcmop instructions.

10 months agoRISC-V: Add support for Zimop extension
Xiao Zeng [Wed, 12 Jun 2024 01:28:17 +0000 (09:28 +0800)] 
RISC-V: Add support for Zimop extension

This implements the Zimop (May-Be-Operations) extension, as of version 1.0.

View detailed information in:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc>

bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): Handle Zimop
(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

* NEWS: Updated.
* testsuite/gas/riscv/march-help.l: Ditto.
* testsuite/gas/riscv/zimop.d: New test.
* testsuite/gas/riscv/zimop.s: New test.

include/ChangeLog:

* opcode/riscv-opc.h (DECLARE_INSN): New declarations for Zimop.
(MATCH_MOP_R_0, MATCH_MOP_R_1, MATCH_MOP_R_2, MATCH_MOP_R_3,
MATCH_MOP_R_4, MATCH_MOP_R_5, MATCH_MOP_R_6, MATCH_MOP_R_7,
MATCH_MOP_R_8, MATCH_MOP_R_9, MATCH_MOP_R_10, MATCH_MOP_R_11,
MATCH_MOP_R_12, MATCH_MOP_R_13, MATCH_MOP_R_14, MATCH_MOP_R_15,
MATCH_MOP_R_16, MATCH_MOP_R_17, MATCH_MOP_R_18, MATCH_MOP_R_19,
MATCH_MOP_R_20, MATCH_MOP_R_21, MATCH_MOP_R_22, MATCH_MOP_R_23,
MATCH_MOP_R_24, MATCH_MOP_R_25, MATCH_MOP_R_26, MATCH_MOP_R_27,
MATCH_MOP_R_28, MATCH_MOP_R_29, MATCH_MOP_R_30, MATCH_MOP_R_31,
MATCH_MOP_RR_0, MATCH_MOP_RR_1, MATCH_MOP_RR_2, MATCH_MOP_RR_3,
MATCH_MOP_RR_4, MATCH_MOP_RR_5, MATCH_MOP_RR_6, MATCH_MOP_RR_7): Define.
(MASK_MOP_R_0, MASK_MOP_R_1, MASK_MOP_R_2, MASK_MOP_R_3, MASK_MOP_R_4,
MASK_MOP_R_5, MASK_MOP_R_6, MASK_MOP_R_7, MASK_MOP_R_8, MASK_MOP_R_9,
MASK_MOP_R_10, MASK_MOP_R_11, MASK_MOP_R_12, MASK_MOP_R_13,
MASK_MOP_R_14, MASK_MOP_R_15, MASK_MOP_R_16, MASK_MOP_R_17,
MASK_MOP_R_18, MASK_MOP_R_19, MASK_MOP_R_20, MASK_MOP_R_21,
MASK_MOP_R_22, MASK_MOP_R_23, MASK_MOP_R_24, MASK_MOP_R_25,
MASK_MOP_R_26, MASK_MOP_R_27, MASK_MOP_R_28, MASK_MOP_R_29,
MASK_MOP_R_30, MASK_MOP_R_31, MASK_MOP_RR_0, MASK_MOP_RR_1,
MASK_MOP_RR_2, MASK_MOP_RR_3, MASK_MOP_RR_4, MASK_MOP_RR_5,
MASK_MOP_RR_6, MASK_MOP_RR_7): Ditto.
* opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_ZIMOP.

opcodes/ChangeLog:

* riscv-opc.c: Add Zimop instructions.

10 months agoAutomatic date update in version.in
GDB Administrator [Tue, 6 Aug 2024 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in