]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
13 months agoX86: Remove "i.rex" to eliminate extra conditional branch
Cui, Lili [Wed, 22 May 2024 06:38:32 +0000 (14:38 +0800)] 
X86: Remove "i.rex" to eliminate extra conditional branch

Resulting code will do better without the extra conditional branch.
Remove "i.rex" to eliminate extra conditional branch.

gas/ChangeLog:

        * config/tc-i386.c (establish_rex): Remove i.rex.

13 months agogprofng: use StringBuilder to create long messages
Vladimir Mezentsev [Tue, 21 May 2024 02:08:39 +0000 (19:08 -0700)] 
gprofng: use StringBuilder to create long messages

ChangeLog
2024-05-20  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* src/collctrl.cc: Use StringBuilder to create messages.
Remove unused variables and arrays.
* src/collctrl.h: Remove unused variables.

13 months agogprofng: Remove hardware counter tables for unsupported hardware (Sparc)
Vladimir Mezentsev [Tue, 21 May 2024 02:06:05 +0000 (19:06 -0700)] 
gprofng: Remove hardware counter tables for unsupported hardware (Sparc)

ChangeLog
2024-05-20  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/31123
* common/hwctable.c: Remove hardware counter tables for Sparc machines.

13 months agogprofng: remove memset() in libcollector
Vladimir Mezentsev [Tue, 21 May 2024 01:48:07 +0000 (18:48 -0700)] 
gprofng: remove memset() in libcollector

ChangeLog
2024-05-20  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* libcollector/collector.c: Use static initialization instead of memset.
* libcollector/dispatcher.c: Likewise.
* libcollector/hwprofile.c: Likewise.
* libcollector/jprofile.c: Likewise.
* libcollector/profile.c: Likewise.
* libcollector/synctrace.c: Likewise.

13 months agoAdd check for 8-bit old registers in EVEX format
Cui, Lili [Wed, 22 May 2024 01:33:10 +0000 (09:33 +0800)] 
Add check for 8-bit old registers in EVEX format

Since APX supports EVEX from legacy instructions, we need to check
the 8-bit old registers in EVEX format. And add test cases for it.

gas/ChangeLog:

        * config/tc-i386.c (md_assemble): Add invalid check for old byte
        registers in EVEX format.
        * testsuite/gas/i386/x86-64-apx-inval.l: Add new test.
        * testsuite/gas/i386/x86-64-apx-inval.s: Ditto.

13 months agox86: Split REX/REX2 old registers judgment.
Cui, Lili [Wed, 22 May 2024 01:18:38 +0000 (09:18 +0800)] 
x86: Split REX/REX2 old registers judgment.

Split "REX/REX2 old register checking" and "add empty rex prefix"
into two separate branches.

gas/ChangeLog:

        * config/tc-i386.c (establish_rex): Split the judgments.

13 months agoAutomatic date update in version.in
GDB Administrator [Wed, 22 May 2024 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agogas: ginsn: remove unnecessary buffer allocation and free
Indu Bhagat [Tue, 21 May 2024 19:59:55 +0000 (12:59 -0700)] 
gas: ginsn: remove unnecessary buffer allocation and free

A previous commit 80ec235 fixed the memory leaks, but brought to light
that the code should ideally make consistent use of snprintf and not
allocate/free more buffers than necessary.

gas/
* ginsn.c (ginsn_dst_print): Use snprintf consistently.

13 months agoaarch64: Fix the hyphenated disassembly comment.
Srinath Parvathaneni [Tue, 21 May 2024 13:59:03 +0000 (14:59 +0100)] 
aarch64: Fix the hyphenated disassembly comment.

This patch fixes the following comment.

-  /* The hyphenated form is preferred for disassembly if there are
-     more than two registers in the list, and the register numbers
      are monotonically increasing in increments of one.  */

+  /* The hyphenated form is preferred for disassembly if there is
+     more than one register in the list, and the register numbers
      are monotonically increasing in increments of one.  */

13 months agoClarify documentation for pretty_printer.child
Tom Tromey [Tue, 21 May 2024 11:13:18 +0000 (05:13 -0600)] 
Clarify documentation for pretty_printer.child

An Ada pretty-printer had a bug where its 'child' method returned a
gdb.Value rather than a tuple.  Kévin suggested that the documentation
for this method could be improved to clarify this.

Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com>
Approved-By: Eli Zaretskii <eliz@gnu.org>
13 months agogas: drop remnants of ia64-*-aix*
Jan Beulich [Tue, 21 May 2024 11:43:08 +0000 (13:43 +0200)] 
gas: drop remnants of ia64-*-aix*

With BFD not supporting that target anymore, GAS can't possibly support
it either.

13 months agold: silence makeinfo warnings
Jan Beulich [Tue, 21 May 2024 11:42:25 +0000 (13:42 +0200)] 
ld: silence makeinfo warnings

Older tool versions (4.12 in my case) demand . or , after @xref{};
arrange for this to be the case.

13 months agoinclude, libctf: improve documentation
Nick Alcock [Mon, 20 May 2024 13:31:03 +0000 (14:31 +0100)] 
include, libctf: improve documentation

Some review comments came in after I pushed the last lot of ctf-api.h
comment improvements.  They were good, so I've incorporated them.
Mostly: better _next iterator usage info, better info on ctf_*open
functions, and better info on ctf_type_aname and ctf_type_name_raw.

include/
* ctf-api.h: improve documentation.

13 months agoAutomatic date update in version.in
GDB Administrator [Tue, 21 May 2024 00:00:25 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agogdb: Fix Windows build after #include shuffle
Kévin Le Gouguec [Mon, 20 May 2024 15:22:50 +0000 (17:22 +0200)] 
gdb: Fix Windows build after #include shuffle

Without this patch, the build chokes on:

    ../../src/gdb/windows-nat.c:384:21: error: field 'm_debug_event_pending' has incomplete type 'std::atomic<bool>'
      384 |   std::atomic<bool> m_debug_event_pending { false };
          |                     ^~~~~~~~~~~~~~~~~~~~~
    In file included from […gcc tree…]/include/c++/13.2.1/bits/shared_ptr_atomic.h:33,
                     from […gcc tree…]/include/c++/13.2.1/memory:81,
                     from ../../src/gdb/../gdbsupport/gdb_unique_ptr.h:23,
                     from ../../src/gdb/../gdbsupport/common-utils.h:26,
                     from ../../src/gdb/../gdbsupport/common-defs.h:199,
                     from ./../../src/gdb/defs.h:26,
                     from <command-line>:
    […gcc tree…]/include/c++/13.2.1/bits/atomic_base.h:174:12: note: declaration of 'struct std::atomic<bool>'
      174 |     struct atomic;
          |            ^~~~~~
    make.exe[2]: *** [Makefile:1947: windows-nat.o] Error 1

Presumably windows-nat.c relied on objfiles.h including <atomic>,
which was undone in 2024-05-16 "gdb: remove unused includes in
objfiles.{c,h}" (f617661c110).

13 months agoreadelf: add pretty printing for FDO Dlopen Metadata note
Luca Boccassi [Mon, 20 May 2024 15:47:00 +0000 (16:47 +0100)] 
readelf: add pretty printing for FDO Dlopen Metadata note

13 months agoAdd extra files found in etc/ sub-directory to ETC_SUPPORT in src-release.sh
Nick Clifton [Mon, 20 May 2024 15:12:53 +0000 (16:12 +0100)] 
Add extra files found in etc/ sub-directory to ETC_SUPPORT in src-release.sh

  PR 31726

13 months ago[gdb/testsuite] Fix can_spawn_for_attach_1 consistency check
Tom de Vries [Mon, 20 May 2024 14:42:08 +0000 (16:42 +0200)] 
[gdb/testsuite] Fix can_spawn_for_attach_1 consistency check

When running test-case gdb.testsuite/gdb-caching-proc-consistency.exp with
target board native-gdbserver, we run into:
...
(gdb) ERROR: tcl error sourcing gdb.testsuite/gdb-caching-proc-consistency.exp.
ERROR: gdbserver does not support attach 4827 without extended-remote
    while executing
"error "gdbserver does not support $command without extended-remote""
    (procedure "gdb_test_multiple" line 51)
    invoked from within
"gdb_test_multiple "attach $test_pid" "can spawn for attach" {
        -re -wrap "$attaching_re\r\n.*ptrace: Operation not permitted\\." {
            # Not permitte..."
    (procedure "gdb_real__can_spawn_for_attach_1" line 27)
    invoked from within
"gdb_real__can_spawn_for_attach_1"
...

The problem is that:
- can_spawn_for_attach_1 is a helper function for can_spawn_for_attach,
  designed to be called only from that function, and
- can_spawn_for_attach_1 is a gdb_caching_proc, and consequently
  test-case gdb.testsuite/gdb-caching-proc-consistency.exp calls
  can_spawn_for_attach_1 directly.

Fix this by copying the early-outs from can_spawn_for_attach to
can_spawn_for_attach_1.

Tested on x86_64-linux.

Reported-By: Simon Marchi <simark@simark.ca>
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
13 months agoaarch64: Add support for the fpmr system register
Claudio Bantaloukas [Mon, 20 May 2024 14:18:10 +0000 (15:18 +0100)] 
aarch64: Add support for the fpmr system register

13 months agoInclude .rodata size in avr-objdump -P mem-usage.
Georg-Johann Lay [Mon, 20 May 2024 12:33:55 +0000 (13:33 +0100)] 
Include .rodata size in avr-objdump -P mem-usage.

  PR 31687

13 months agoLet avr-objdump show .note.gnu.avr.deviceinfo
Georg-Johann Lay [Mon, 20 May 2024 11:12:10 +0000 (12:12 +0100)] 
Let avr-objdump show .note.gnu.avr.deviceinfo

  PR 31704

13 months agoRISC-V: PR31733, Change initial CFI operation from DW_CFA_def_cfa_register to DW_CFA_...
Sung-hun Kim [Mon, 13 May 2024 08:11:49 +0000 (17:11 +0900)] 
RISC-V: PR31733, Change initial CFI operation from DW_CFA_def_cfa_register to DW_CFA_def_cfa

The DWARF specification (especially, DWARF4 and 5 [1,2]) states that
DW_CFA_def_cfa_register cannot be used as the first CFI operation.
It said DW_CFA_def_cfa_register as follows:

  ... This operation is valid only if the current CFA rule is defined
  to use a register and offset.

So, DW_CFA_def_cfa_register can be used after that other definition
operation such as DW_CFA_def_cfa is called. However, the current gas
code emits DW_CFA_def_cfa_register as an initial CFI operation for RISCV.

In the libgcc, the unwinding function does not care about it, so it can
unwind the call stack. However, on the third party library such as
libunwindstack in Android, it causes a fatal error.

This patch changes the initial CFI operation to DW_CFA_def_cfa with
offset 0. It works as same as the previous one, but it does not have
any limitation so it satisfies the DWARF spec. This change resolves
the compatibility issue while preserving the original behaviour.

[1] DWARF4 specification, https://dwarfstd.org/doc/DWARF4.pdf
[2] DWARF5 specification, https://dwarfstd.org/doc/DWARF5.pdf

Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Nelson Chu <nelson@rivosinc.com>
gas/
PR 31733
config/tc-riscv.c (riscv_cfi_frame_initial_instructions): Use
DW_CFA_def_cfa rather than DW_CFA_def_cfa_register.

13 months agoAutomatic date update in version.in
GDB Administrator [Mon, 20 May 2024 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agoAutomatic date update in version.in
GDB Administrator [Sun, 19 May 2024 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agoRemove unnecessary block from execute_fn_to_ui_file
Tom Tromey [Sat, 18 May 2024 16:51:35 +0000 (10:51 -0600)] 
Remove unnecessary block from execute_fn_to_ui_file

I noticed that execute_fn_to_ui_file has an extra, unnecessary block.
This patch removes it.

13 months agogprofng: add hardware counters for AMD Zen3
Vladimir Mezentsev [Fri, 17 May 2024 04:00:51 +0000 (21:00 -0700)] 
gprofng: add hardware counters for AMD Zen3

Historically, we have used several APIs (perfctr, libcpc, perf_event_open) for profiling.
For each hardware we have several tables of hardware counters.
Some information is duplicated in these tables.
Some of the information is no longer used.
I did not touch the existing hwc tables.
I added a new hwc table for an AMD Zen3 machine.

ChangeLog
2024-05-16  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/31123
* common/core_pcbe.c (core_pcbe_get_events): Add new argument.
* common/hwc_cpus.h: New constants for AMD hardware.
* common/hwcdrv.c: Add new argument to hwcdrv_get_descriptions.
Clean up the code.
* common/hwcdrv.h: Likewise.
* common/hwcfuncs.c (hwcdrv_get_descriptions): Add new argument.
* common/hwctable.c: Add the hwc table for AMD Zen3.
* src/hwc_amd_zen3.h: New file.
* common/opteron_pcbe.c: Add new argument to opt_pcbe_get_events.
* src/collctrl.cc: Remove unused variable.
* src/collctrl.h: Likewise.

13 months agogprofng: remove old interface with libcpc
Vladimir Mezentsev [Tue, 30 Apr 2024 03:21:50 +0000 (20:21 -0700)] 
gprofng: remove old interface with libcpc

interface with libcpc was used on Solaris.
gprofng doesn't support profiling on Solaris.
I removed this old code and other unused macros and variables.

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

PR gprofng/31123
* common/hwcdrv.c: remove old interface with libcpc.
* common/hwcdrv.h: Likewise.
* common/hwcentry.h: Likewise.
* common/hwcfuncs.c: Likewise.
* common/hwcfuncs.h: Likewise.
* common/hwctable.c: Likewise.
* src/Dbe.cc: Likewise.
* src/collctrl.cc: Likewise.

13 months agoAutomatic date update in version.in
GDB Administrator [Sat, 18 May 2024 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agobfd: sframe: minor code adjustments and fix typos
Indu Bhagat [Fri, 17 May 2024 18:24:28 +0000 (11:24 -0700)] 
bfd: sframe: minor code adjustments and fix typos

bfd/
* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Use local
variable.
(_bfd_x86_elf_size_dynamic_sections): Fix typos.

13 months agoRemove gdb_stdtargerr
Tom Tromey [Tue, 16 Aug 2022 17:40:15 +0000 (11:40 -0600)] 
Remove gdb_stdtargerr

This patch removes gdb_stdtargerr.  There doesn't seem to be a need
for this -- it is always the same as stdtarg, and (I believe) has been
for many years.

Approved-By: Andrew Burgess <aburgess@redhat.com>
13 months agoDon't allow new-ui to start the TUI
Tom Tromey [Tue, 16 Aug 2022 15:31:33 +0000 (09:31 -0600)] 
Don't allow new-ui to start the TUI

The TUI can't really work properly with new-ui, at least not as
currently written.  This patch changes new-ui to reject an attempt.
Attempting to make a DAP ui this way is also now rejected.

Regression tested on x86-64 Fedora 38.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29273
Approved-By: Andrew Burgess <aburgess@redhat.com>
13 months agoInline some ui_out methods
Tom Tromey [Fri, 10 May 2024 19:13:03 +0000 (13:13 -0600)] 
Inline some ui_out methods

I noticed a few ui_out methods that are just trivial wrappers.  This
patch moves these to ui-out.h, as it seems like they should be
inlineable.

Approved-By: Andrew Burgess <aburgess@redhat.com>
13 months agogdb/symtab: use symbol name matcher for all segments in a qualified name
Dmitry Neverov [Mon, 6 May 2024 15:09:20 +0000 (17:09 +0200)] 
gdb/symtab: use symbol name matcher for all segments in a qualified name

13 months agogdb/symtab: compute match_type outside the loop
Dmitry Neverov [Mon, 6 May 2024 15:09:19 +0000 (17:09 +0200)] 
gdb/symtab: compute match_type outside the loop

It will be used for all segments in a qualified name,
not only the last one.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agogdb/symtab: reuse last segment lookup name info by creating it outside the loop
Dmitry Neverov [Mon, 6 May 2024 15:09:18 +0000 (17:09 +0200)] 
gdb/symtab: reuse last segment lookup name info by creating it outside the loop

13 months agogdb/symtab: check name matches before expanding a CU
Dmitry.Neverov [Mon, 6 May 2024 15:09:17 +0000 (17:09 +0200)] 
gdb/symtab: check name matches before expanding a CU

The added check fixes the case when an unqualified lookup
name without template arguments causes expansion of many CUs
which contain the name with template arguments.

This is similar to what dw2_expand_symtabs_matching_symbol does
before expanding the CU.

In the referenced issue the lookup name was wxObjectDataPtr and many
CUs had names like wxObjectDataPtr<wxBitmapBundleImpl>. This caused
their expansion and the lookup took around a minute. The added check
helps to avoid the expansion and makes the symbol lookup to return in
a second or so.

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

13 months agoinclude, libctf: add a bunch of documentation to ctf-api.h
Nick Alcock [Tue, 7 May 2024 15:23:33 +0000 (16:23 +0100)] 
include, libctf: add a bunch of documentation to ctf-api.h

Hopefully this library is no longer quite so much a "you have to look
in the source to understand anything" library.

No semantic changes, though some functions have been moved around for
clarity.

include/
ctf-api.h: Add comments.

13 months agolibctf: fix leak of entire dict when dict opening fails
Nick Alcock [Fri, 26 Apr 2024 17:19:15 +0000 (18:19 +0100)] 
libctf: fix leak of entire dict when dict opening fails

Ever since commit 1fa7a0c24e78e7f ("libctf: sort out potential refcount
loops") ctf_dict_close has only freed anything if the refcount on entry
to the function is precisely 1.  >1 obviously just decrements the
refcount, but the linker machinery can sometimes cause freeing to recurse
from a dict to another dict and then back to the first dict again, so
we interpret a refcount of 0 as an indication that this is a recursive call
and we should just return, because a caller is already freeing this dict.

Unfortunately there is one situation in which this is not true: the bad:
codepath in ctf_bufopen entered when opening fails.  Because the refcount is
bumped only at the very end of ctf_bufopen, any failure causes
ctf_dict_close to be entered with a refcount of zero, and it frees nothing
and we leak the entire dict.

The solution is to bump the refcount to 1 right before freeing... but this
codepath is clearly delicate enough that we need to properly validate it,
so we add a test that uses malloc interposition to count allocations and
frees, creates a dict, writes it out, intentionally corrupts it (by setting
a bunch of bytes after the header to a value high enough that it is
definitely not a valid CTF type kind), then tries to open it again and
counts the malloc/free pairs to make sure they're matched.  (Test run only
on *-linux-gnu, because malloc interposition is not a thing you can rely
upon working everywhere, and this test is not arch-dependent so if it
passes on one arch it can be assumed to pass on all of them.)

libctf/
* ctf-open.c (ctf_bufopen): Bump the refcount on failure.
* testsuite/libctf-regression/open-error-free.*: New test.

13 months agolibctf: test: add wrapper
Nick Alcock [Fri, 26 Apr 2024 17:16:49 +0000 (18:16 +0100)] 
libctf: test: add wrapper

This .lk option lets you run the lookup program via a wrapper executable.
For example, to run under valgrind and check for leaks (albeit noisily
because of the libtool shell script wrapper):

libctf/
* testsuite/lib/ctf-lib.exp (run_lookup_test): Add wrapper.

13 months agolibctf: test: add host
Nick Alcock [Fri, 26 Apr 2024 17:15:24 +0000 (18:15 +0100)] 
libctf: test: add host

This .lk option lets you execute particular tests only on specific host
architectures.

libctf/
* testsuite/lib/ctf-lib.exp (run_lookup_test): Add host.

13 months agolibctf: test: add lookup_link
Nick Alcock [Fri, 26 Apr 2024 17:13:23 +0000 (18:13 +0100)] 
libctf: test: add lookup_link

This .lk option lets you link the lookup program with extra libraries
in addition to -lctf.

libctf/
* testsuite/lib/ctf-lib.exp (run_lookup_test): Add lookup_link.

13 months agolibctf: ctf_archive_iter: fix tiny leak
Nick Alcock [Fri, 26 Apr 2024 17:10:00 +0000 (18:10 +0100)] 
libctf: ctf_archive_iter: fix tiny leak

If iteration fails because opening a dict has failed, ctf_archive_next does
not destroy the iterator, so the caller can keep going and try to open other
dicts further into the archive.  ctf_archive_iter just returns, though, so
it should free the iterator rather than leaking it.

libctf/
* ctf-archive.c (ctf_archive_iter): Don't leak the iterator on
failure.

13 months agolibctf: failure to open parent dicts that exist should be an error
Nick Alcock [Fri, 26 Apr 2024 17:09:38 +0000 (18:09 +0100)] 
libctf: failure to open parent dicts that exist should be an error

CTF archive member opening (via ctf_arc_open_by_name, ctf_archive_iter, et
al) attempts to be helpful and auto-open and import any needed parent dict
in the same archive.  But if this fails, the error is not reported but
simply discarded, and you silently get back a dict with no parent, that
*you* suddenly have to remember to import.

This is not helpful behaviour: if the parent is corrupted or we run out of
memory or something, the caller is going to want to know!  Split it in two:
if the dict cites a parent that doesn't exist at all (a lot of historic
dicts name "PARENT" as their parent, even when they're not even children, or
perhaps the parent dict is stored separately and you plan to manually
associate it), we skip it as now, but if the import fails with an actual
error other than ECTF_ARNNAME, return the error and fail the open.

libctf/
* ctf-archive.c (ctf_arc_import_parent):  Return failure if
        parent opening fails for reasons other thnn nonexistence.
(ctf_dict_open_sections): Adjust.

13 months agolibctf: typos
Nick Alcock [Fri, 26 Apr 2024 16:50:20 +0000 (17:50 +0100)] 
libctf: typos

Some functions were renamed without the comments catching up.

libctf/
* ctf-open.c (upgrade_types_v1): Fix comment typos.

13 months agoaarch64: correct SVE2.1 ld2q (scalar plus scalar)
Jan Beulich [Fri, 17 May 2024 08:52:53 +0000 (10:52 +0200)] 
aarch64: correct SVE2.1 ld2q (scalar plus scalar)

It's opcode was wrong, as was e.g. easily visible from the inappropriate
testcase expectation.

13 months agoaarch64: correct SVE2.1 ld{3,4}q / st{3,4}q (scalar plus immediate)
Jan Beulich [Fri, 17 May 2024 08:52:36 +0000 (10:52 +0200)] 
aarch64: correct SVE2.1 ld{3,4}q / st{3,4}q (scalar plus immediate)

Like their byte, half, word, and doubleword counterparts their
immediates are multiples of 3 / 4 respectively.

13 months agoLoongArch: gas: Adjust DWARF CIE alignment factors
mengqinggang [Mon, 29 Apr 2024 07:11:31 +0000 (15:11 +0800)] 
LoongArch: gas: Adjust DWARF CIE alignment factors

Set DWARF2_CIE_DATA_ALIGNMENT (data alignment factors) to -8.
It helps to save space.

Data Alignment Factor
A signed LEB128 encoded value that is factored out of all offset
instructions that are associated with this CIE or its FDEs. This value
shall be multiplied by the register offset argument of an offset
instruction to obtain the new offset value.

13 months agoAutomatic date update in version.in
GDB Administrator [Fri, 17 May 2024 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agogas: sframe: fix typo to use FP instead of BP
Indu Bhagat [Thu, 16 May 2024 21:59:23 +0000 (14:59 -0700)] 
gas: sframe: fix typo to use FP instead of BP

gas/
* gen-sframe.c (output_sframe_internal): Use BP instead of FP.

13 months ago[gdb/testsuite] Add missing terminator in Dwarf::_macro_unit
Tom de Vries [Thu, 16 May 2024 20:28:07 +0000 (22:28 +0200)] 
[gdb/testsuite] Add missing terminator in Dwarf::_macro_unit

When printing complaints with one of the execs from test-case
gdb.dwarf2/macro-source-path.exp, we run into:
...
$ gdb -q -batch \
    -iex "set complaints 100" \
    macro-source-path-clang14-dw4-absolute-cwd-32 \
    -ex "p main"
During symbol reading: debug info runs off end of .debug_macro section \
  [in module macro-source-path-clang14-dw4-absolute-cwd-32]
$1 = {int ()} 0x4004b7 <main>
...
and readelf complains more specifically:
...
Contents of the .debug_macro section:

  Offset:                      0
  Version:                     5
  Offset size:                 4
  Offset into .debug_line:     0xe3

 DW_MACRO_define - lineno : 0 macro : ONE 1
 DW_MACRO_define_strp - lineno : 0 macro : THREE 3
 DW_MACRO_start_file - lineno: 0 filenum: 1 filename: test.c
 DW_MACRO_define - lineno : 1 macro : TWO 2
 DW_MACRO_end_file
readelf: Error: .debug_macro section not zero terminated
...

Fix this by adding the missing terminator in Dwarf::_macro_unit.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agogdb: remove unused includes in objfiles.{c,h}
Simon Marchi [Thu, 16 May 2024 19:54:37 +0000 (15:54 -0400)] 
gdb: remove unused includes in objfiles.{c,h}

Remove some includes reported as unused by clangd.

Change-Id: I7768232c28b9b86b0a03628a1d15dede2b30c76a

13 months agogdb, testsuite: Handle unused compiler option fdiagnostics-color=never.
Ijaz, Abdul B [Tue, 19 Mar 2024 10:50:51 +0000 (11:50 +0100)] 
gdb, testsuite: Handle unused compiler option fdiagnostics-color=never.

The 'univeral_compile_options' in gdb.exp file only verifies the support
of '-fdiagnostics-color=never' for the "C" source file.  So while running
tests with assembly source file (.s), many of them are not able to run
on icx/clang compilers because '-fdiagnostics-color=never' option is not
supported.  This problem is not seen for the ".S" assembly source files so
these files are not handled separately.  After this change, this function
is split into multiple functions to check the support for different type
of sources individually.

Before this change, in the case of clang and ICX compiler, this error is
shown for assembly source files (.s):

'''
icx -fdiagnostics-color=never -Wno-unknown-warning-option -fno-pie -c -O0 -o
amd64-entry-value0.o gdb/testsuite/gdb.arch/amd64-entry-value.s (timeout = 300)

icx: warning: argument unused during compilation: '-fdiagnostics-color=never'
[-Wunused-command-line-argument]

gdb compile failed, icx: warning: argument unused during compilation:
'-fdiagnostics-color=never' [-Wunused-command-line-argument]

UNTESTED: gdb.arch/amd64-entry-value.exp: failed to prepare
'''

Similarly this error is shown for the clang compiler:

'''
clang  -fdiagnostics-color=never -Wno-unknown-warning-option -fno-pie -c -O0
-o amd64-entry-value0.o gdb/testsuite/gdb.arch/amd64-entry-value.s

clang: warning: argument unused during compilation:
 '-fdiagnostics-color=never' [-Wunused-command-line-argument]
'''

Approved-By: Tom Tromey <tom@tromey.com>
13 months agogdb: define type aliases for `fork_inferior()` callbacks
Simon Marchi [Thu, 16 May 2024 16:55:01 +0000 (12:55 -0400)] 
gdb: define type aliases for `fork_inferior()` callbacks

The `fork_inferior()` function accepts multiple callbacks, making its
signature a bit hard to read.  Define some type aliases to make it a bit
clearer.  Use function view for all, while at it.

Change-Id: Ide8d1fa533d0c5eaf3249860f8c0d339baa09bce
Approved-By: Tom Tromey <tom@tromey.com>
13 months agogdb: initialize packet_result::m_textual_err_msg
Simon Marchi [Thu, 16 May 2024 16:35:53 +0000 (12:35 -0400)] 
gdb: initialize packet_result::m_textual_err_msg

When building GDB with -O2 and --enable-ubsan, I get some random errors
in the packet_result self test:

  /home/smarchi/src/binutils-gdb/gdb/remote.c:161:7: runtime error: load of value 92, which is not a valid value for type 'bool'

This happens because packet_result::m_textual_err_msg is uninitialized
when using the second constructor.  When such a packet_result object
gets copied, an invalid value for m_textual_err_msg (a bool field) is
loaded, which triggers ubsan.

Avoid this by initializing m_textual_err_msg.

Change-Id: I3ce44816bb0bfc6e442067292f993e5c17301b85
Approved-By: Tom Tromey <tom@tromey.com>
13 months agogdb: remove unused include in infcmd.c
Simon Marchi [Thu, 16 May 2024 04:58:08 +0000 (00:58 -0400)] 
gdb: remove unused include in infcmd.c

clangd reports this header as unused.

Change-Id: I7bf413f57b2840a52d83bd4f8b9415728bc0917b

13 months agogdb: remove unused includes from progspace.{c,h}
Simon Marchi [Wed, 15 May 2024 20:00:38 +0000 (16:00 -0400)] 
gdb: remove unused includes from progspace.{c,h}

Remove some include files reported as unused by clangd.

Change-Id: I39f9d40b9d5bbf040250b41ef258fb8f32dd5c0a

13 months agogdb: bump black version to 24.4.2
Simon Marchi [Tue, 23 Apr 2024 01:43:02 +0000 (21:43 -0400)] 
gdb: bump black version to 24.4.2

Run `pre-commit autoupdate`, this is the outcome.  There is no change in
formatting of Python files.

Change-Id: I79c221af1b2192f866a344ab17d6199b137371cb

13 months agogdb: move lm_info to solib in dsbt_current_sos
Simon Marchi [Wed, 15 May 2024 17:13:27 +0000 (13:13 -0400)] 
gdb: move lm_info to solib in dsbt_current_sos

Commit 8971d2788e79 ("gdb: link so_list using intrusive_list")
mistakenly removed the line that moves the lm_info unique pointer to
sop->lm_info, probably due to a bad conflict resolution.  Restore that
line.

Unfortunately, this code is only used for TI C66, which is not widely
tested (if used at all).

Change-Id: I9f64eb4430c324bc93ddb4bd00d820dee34adfbb
Approved-By: Tom Tromey <tom@tromey.com>
13 months agoaarch64: fp8 convert and scale - add sme2 insn variants
Victor Do Nascimento [Tue, 27 Feb 2024 16:17:25 +0000 (16:17 +0000)] 
aarch64: fp8 convert and scale - add sme2 insn variants

Add the SME2 variant of the FP8 convert and scale
instructions, enabled at assembly-time using the `+sme2+fp8'
architectural extension flag.  More specifically, support is
added for the following instructions:

Multi-vector floating-point convert from FP8 to
BFloat16 (in-order):
-----------------------------------------------

  - bf1cvt { <Zd1>.H-<Zd2>.H }, <Zn>.B
  - bf2cvt { <Zd1>.H-<Zd2>.H }, <Zn>.B

Multi-vector floating-point convert from FP8 to
deinterleaved BFloat16:
-----------------------------------------------

  - bf1cvtl { <Zd1>.H-<Zd2>.H }, <Zn>.B
  - bf2cvtl { <Zd1>.H-<Zd2>.H }, <Zn>.B

Multi-vector floating-point convert from BFloat16
to packed FP8 format:
-------------------------------------------------

  - bfcvt <Zd>.B, { <Zn1>.H-<Zn2>.H }

Multi-vector floating-point convert from FP8 to
half-precision (in-order):
-----------------------------------------------

  - f1cvt { <Zd1>.H-<Zd2>.H }, <Zn>.B
  - f2cvt { <Zd1>.H-<Zd2>.H }, <Zn>.B

Multi-vector floating-point convert from FP8 to
deinterleaved half-precision:
-----------------------------------------------

  - f1cvtl { <Zd1>.H-<Zd2>.H }, <Zn>.B
  - f2cvtl { <Zd1>.H-<Zd2>.H }, <Zn>.B

Multi-vector floating-point convert from half-precision
to packed FP8 format:
-------------------------------------------------------

fcvt_2h

Multi-vector floating-point convert from single-precision
to packed FP8 format:
---------------------------------------------------------
fcvt_4s

Multi-vector floating-point convert from single-precision
to interleaved FP8 format:
---------------------------------------------------------

  - fcvtn <Zd>.B, { <Zn1>.S-<Zn4>.S }

Multi-vector floating-point adjust exponent by vector:
------------------------------------------------------

  - fscale { <Zdn1>.H-<Zdn2>.H }, { <Zdn1>.H-<Zdn2>.H },
   <Zm>.H
  - fscale { <Zdn1>.S-<Zdn2>.S }, { <Zdn1>.S-<Zdn2>.S },
   <Zm>.S
  - fscale { <Zdn1>.D-<Zdn2>.D }, { <Zdn1>.D-<Zdn2>.D },
   <Zm>.D

Multi-vector floating-point adjust exponent:
--------------------------------------------

  - fscale { <Zdn1>.H-<Zdn2>.H }, { <Zdn1>.H-<Zdn2>.H },
   { <Zm1>.H - <Zm2>.H }
  - fscale { <Zdn1>.S-<Zdn2>.S }, { <Zdn1>.S-<Zdn2>.S },
   { <Zm1>.S - <Zm2>.S }
  - fscale { <Zdn1>.D-<Zdn2>.D }, { <Zdn1>.D-<Zdn2>.D },
   { <Zm1>.D - <Zm2>.D }

13 months agoaarch64: fp8 convert and scale - add sve2 insn variants
Victor Do Nascimento [Tue, 27 Feb 2024 01:32:52 +0000 (01:32 +0000)] 
aarch64: fp8 convert and scale - add sve2 insn variants

Add the SVE2 variant of the FP8 convert and scale instructions,
enabled at assembly-time using the `+sve2+fp8' architectural
extension flag.  More specifically, support is added for the
following instructions:

FP8 convert to BFloat16 (bottom/top):
-------------------------------------

  - bf1cvt Z<d>.H, Z<n>.B
  - bf2cvt Z<d>.H, Z<n>.B
  - bf1cvtlt Z<d>.H, Z<n>.B
  - bf2cvtlt Z<d>.H, Z<n>.B

FP8 convert to half-precision (bottom/top):
-------------------------------------------

  - f1cvt Z<d>.H, Z<n>.B
  - f2cvt Z<d>.H, Z<n>.B
  - f1cvtlt Z<d>.H, Z<n>.B
  - f2cvtlt Z<d>.H, Z<n>.B

BFloat16/half-precision convert, narrow and
interleave to FP8:
-------------------------------------------

  - bfcvtn Z<d>.B, { Z<n>1.H - Z<n>2.H }
  - fcvtn Z<d>.B, { Z<n>1.H - Z<n>2.H }

Single-precision convert, narrow and interleave
to FP8 (bottom/top):
-----------------------------------------------

  - fcvtnb Z<d>.B, { Z<n>1.S - Z<n>2.S }
  - fcvtnt Z<d>.B, { Z<n>1.S - Z<n>2.S }

13 months agoaarch64: fp8 convert and scale - Add advsimd insn variants
Victor Do Nascimento [Tue, 6 Feb 2024 14:59:02 +0000 (14:59 +0000)] 
aarch64: fp8 convert and scale - Add advsimd insn variants

Add the advanced SIMD variant of the FP8 convert and scale
instructions, enabled at assembly-time using the `+fp8'
architectural extension flag.  More specifically, support is
added for the following instructions:

FP8 convert to BFloat16 (vector):
---------------------------------

  - bf1cvtl V<d>.8H, V<n>.8B
  - bf2cvtl V<d>.8H, V<n>.8B
  - bf1cvtl2 V<d>.8H, V<n>.16B
  - bf2cvtl2 V<d>.8H, V<n>.16B

FP8 convert to half-precision (vector):
---------------------------------------

  - f1cvtl V<d>.8H, V<n>.8B
  - f2cvtl V<d>.8H, V<n>.8B
  - f1cvtl2 V<d>.8H, V<n>.16B
  - f2cvtl2 V<d>.8H, V<n>.16B

Single-precision to FP8 convert and narrow (vector):
----------------------------------------------------

  - fcvtn V<d>.8B, V<n>.4S, V<m>.4S
  - fcvtn2 V<d>.16B, V<n>.4S, V<m>.4S

Half-precision to FP8 convert and narrow (vector):
--------------------------------------------------

  - fcvtn V<d>.8B, V<n>.4H, V<m>.4H
  - fcvtn V<d>.16B, V<n>.8H, V<m>.8H

Floating-point adjust exponent by vector:
-----------------------------------------

  - fscale V<d>.4H, V<n>.4H, V<m>.4H
  - fscale V<d>.8H, V<n>.8H, V<m>.8H
  - fscale V<d>.2S, V<n>.2S, V<m>.2S
  - fscale V<d>.4S, V<n>.4S, V<m>.4S
  - fscale V<d>.2d, V<n>.2d, V<m>.2d

13 months agoaarch64: fp8 convert and scale - add feature flags and related structures
Victor Do Nascimento [Thu, 29 Feb 2024 13:35:26 +0000 (13:35 +0000)] 
aarch64: fp8 convert and scale - add feature flags and related structures

13 months agoStop 'configure --enable-threading' if std::thread doesn't work
Pedro Alves [Tue, 14 May 2024 14:43:41 +0000 (15:43 +0100)] 
Stop 'configure --enable-threading' if std::thread doesn't work

Currently, if you configure gdb with explicit --enable-threading, but
then configure detects std::thread does not work, configure silently
disables threading support and continues configuring.

This patch makes that scenario cause a configuration error, like so:

 $ /home/pedro/gdb/src/configure --enable-threading && make
 ...
 configure: error: std::thread does not work; disable threading
 make[1]: *** [Makefile:11225: configure-gdbsupport] Error 1
 make[1]: Leaving directory '/home/pedro/gdb/build-windows-threads'
 make: *** [Makefile:1041: all] Error 2
 $

Additionally, if you don't explicitly pass --enable-threading, and
std::thread does not work, we will now get a warning (and the build
continues):

 $ /home/pedro/gdb/src/configure && make
 ...
 configure: WARNING: std::thread does not work; disabling threading
 ...

This is similar to how we handle --enable-tui and missing curses.  The
code and error/warning messages were borrowed from there.

Change-Id: I73a8b580d1e2a796b23136920c0e181408ae1b22
Approved-By: Tom Tromey <tom@tromey.com>
13 months agoaarch64: add SPMU feature and its associated registers
Matthieu Longo [Thu, 16 May 2024 11:36:14 +0000 (12:36 +0100)] 
aarch64: add SPMU feature and its associated registers

13 months agoMove assembler "IRP \+" test into a separate file. Add XFAILs for targets that do...
Nick Clifton [Thu, 16 May 2024 10:43:29 +0000 (11:43 +0100)] 
Move assembler "IRP \+" test into a separate file.  Add XFAILs for targets that do not support it.

13 months agoarm: remove incorrect handling of FP bignums in move_or_literal_pool
Richard Earnshaw [Wed, 15 May 2024 15:06:28 +0000 (16:06 +0100)] 
arm: remove incorrect handling of FP bignums in move_or_literal_pool

This hunk of code in move_or_literal_pool just looks wrong, but I
can't find a testcase that will tickle it to prove it.  It looks a bit
like it was intended to catch cases where a bignum contained a
floating-point value, but there were a number of problems with it.

- It tested X_add_number == -1, but an FP bignum is indicated by any
  value <= 0.
- It converted the floating-point value to extended precision, but
  that's not used on Arm beyond the legacy FPA code.  No attempt was
  made to match the FP value to the intended memory/mov operation.

Since I can't construct a viable testcase, I've just removed the existing
code and made the function error out in this case: this seems more sensible
than generating wrong code or trying to write something more complex that
can't be tested anyway.

13 months ago[gdb/testsuite] Generate DW_MACRO_define_strp in dwarf assembly
Tom de Vries [Thu, 16 May 2024 07:38:15 +0000 (09:38 +0200)] 
[gdb/testsuite] Generate DW_MACRO_define_strp in dwarf assembly

Add support for DW_MACRO_define_strp in dwarf assembly, and use it in
test-case gdb.dwarf2/macro-source-path.exp.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agoFix FAIL: macros altmacro
Alan Modra [Wed, 15 May 2024 23:27:37 +0000 (08:57 +0930)] 
Fix FAIL: macros altmacro

spu-elf and z80-coff fail this test due to "def" being a pseudo-op.
tic30-unknown-coff fails it due to '#' not starting comments.

* testsuite/gas/macros/altmacro.s: Use /* */ comments.  Rename
DEF to EDF.

13 months agoAutomatic date update in version.in
GDB Administrator [Thu, 16 May 2024 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agogas: Fix \+ expansion for .irp and .irpc
Fangrui Song [Wed, 15 May 2024 22:05:30 +0000 (15:05 -0700)] 
gas: Fix \+ expansion for .irp and .irpc

.irp and .irpc receive a null macro_entry.  \+ causes a crash after the
recent \+ support.  Restore the previous behavior.

Signed-off-by: Fangrui Song <maskray@gcc.gnu.org>
13 months agoaarch64: Add sysreg features to +d128 dependencies
Andrew Carlotti [Mon, 15 Jan 2024 11:16:53 +0000 (11:16 +0000)] 
aarch64: Add sysreg features to +d128 dependencies

We should revisit sysreg feature enablement and dependencies in future, but
this change should help until then.

OK for master?

13 months agoaarch64: Add simd dependency to +sha2
Andrew Carlotti [Mon, 15 Jan 2024 11:17:38 +0000 (11:17 +0000)] 
aarch64: Add simd dependency to +sha2

This matches the existing behaviour in GCC and LLVM, and also the current
documentation.

OK for master?

13 months agoaarch64: testsuite: share test utils macros and use them
Matthieu Longo [Tue, 27 Feb 2024 10:59:17 +0000 (10:59 +0000)] 
aarch64: testsuite: share test utils macros and use them

This patch rewrites assembly tests to use utils macros declared in
sysreg-test-utils.inc. Some tests were adapted to use the new macro
rw_sys_reg.

13 months agoaarch64: testsuite: reorder write and read to match macro order
Matthieu Longo [Tue, 27 Feb 2024 10:59:16 +0000 (10:59 +0000)] 
aarch64: testsuite: reorder write and read to match macro order

This patch aims at grouping write and read for a same system register
one after another so that the diff for the macro replacement does not
generate too much noise.

13 months agoaarch64: testsuite: use same regs for read and write tests
Matthieu Longo [Tue, 27 Feb 2024 10:59:15 +0000 (10:59 +0000)] 
aarch64: testsuite: use same regs for read and write tests

This patch aims at making easier to replacement of read and write
instructions to system registers by a macro that will use the same
registers for read and write.

13 months agoaarch64: testsuite: replace instruction addresses by regex
Matthieu Longo [Tue, 27 Feb 2024 10:59:14 +0000 (10:59 +0000)] 
aarch64: testsuite: replace instruction addresses by regex

This patch removes the instruction addresses from the objdump's expected
output (.d files). The intended benefit from this clean-up is to allow to
swap lines around more easilly, and removes the noise of patches that add,
remove or reorder instructions.

13 months ago[binutils/readelf] Fix handling of DW_MACRO_define_strx in dwo file
Tom de Vries [Wed, 15 May 2024 07:45:55 +0000 (09:45 +0200)] 
[binutils/readelf] Fix handling of DW_MACRO_define_strx in dwo file

When printing a DW_MACRO_define_strx entry in a .debug_macro.dwo section, we
run into:
...
 DW_MACRO_define_strx lineno : 0 macro : <no .debug_str_offsets section>
...

Fix this in display_debug_macro by passing the correct dwo argument to a
fetch_indexed_string call.

That works fine for readelf -w, with with readelf -wm we have:
...
 DW_MACRO_define_strx lineno : 0 macro : <no .debug_str_offsets.dwo section>
...

Fix this in display_debug_macro by doing load_debug_section_with_follow for
str_dwo / str_index_dwo sections instead of str / str_index sections when
handling .debug_macro.dwo.

PR 31735

13 months ago[binutils/readelf] Fix printing of dwarf4 .debug_str_offsets.dwo
Tom de Vries [Wed, 15 May 2024 07:45:55 +0000 (09:45 +0200)] 
[binutils/readelf] Fix printing of dwarf4 .debug_str_offsets.dwo

When compiling a hello world with dwarf4 split dwarf:
...
$ gcc -gdwarf-4 -gsplit-dwarf hello.c -save-temps -dA
...
we have in a-hello.s these three initial entries in .debug_str_offsets:
...
.section        .debug_str_offsets.dwo,"e",@progbits
.4byte  0       // indexed string 0x0: short int
.4byte  0xa     // indexed string 0x1: /home/vries/binutils
.4byte  0x1f    // indexed string 0x2: main
...
but "readelf -ws a.out" starts at the third entry:
...
Contents of the .debug_str_offsets.dwo section (loaded from a-hello.dwo):

    Length: 0x30
       Index   Offset [String]
           0 00000000  main
...

This is a regression since commit 407115429b3 ("Modified changes for
split-dwarf and dwarf-5."), which introduced a variable
debug_str_offsets_hdr_len in display_debug_str_offsets.

Fix this by setting display_debug_str_offsets to 0 for the dwarf4 case.

PR 31734

13 months agoAutomatic date update in version.in
GDB Administrator [Wed, 15 May 2024 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agoRISC-V: Search for mapping symbols from the last one found
Joseph Faulls [Tue, 14 May 2024 22:59:58 +0000 (06:59 +0800)] 
RISC-V: Search for mapping symbols from the last one found

With previous behaviour, multiple mapping symbols within the same
function would result in all the mapping symbols being searched.
This could slow down disassembly dramatically.

Multiple mapping symbols within a function can be a result of encoding
instructions as data, like sometimes seen in random instruction
generators.

opcodes/ChangeLog:

* riscv-dis.c (riscv_search_mapping_symbol): Use last mapping
symbol if it exists.

13 months agoAdd spaceship operator to cp-name-parser.y
Tom Tromey [Sat, 20 Apr 2024 22:33:37 +0000 (16:33 -0600)] 
Add spaceship operator to cp-name-parser.y

While debugging gdb, I saw this:

During symbol reading: unexpected demangled name 'operator<=><std::chrono::_V2::system_clock, std::chrono::duration<long int>, std::chrono::duration<long int> >'

This happens because cp-name-parser.y does not handle the spaceship
operator.  This patch implements this.

Approved-By: John Baldwin <jhb@FreeBSD.org>
13 months agoAllow function types as template parameters in name canonicalizer
Tom Tromey [Sat, 20 Apr 2024 16:44:13 +0000 (10:44 -0600)] 
Allow function types as template parameters in name canonicalizer

This adds function types as template parameters in the C++ name
canonicalizer.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11907
Approved-By: John Baldwin <jhb@FreeBSD.org>
13 months agoImplement C++14 numeric separators
Tom Tromey [Sat, 20 Apr 2024 02:22:11 +0000 (20:22 -0600)] 
Implement C++14 numeric separators

C++14 allows the use of the apostrophe as a numeric separator; that
is, "23000" and "23'000" represent the same number.  This patch
implements this for gdb's C++ parser and the C++ name canonicalizer.

I did this unconditionally for all C variants because I think it's
unambiguous.

For the name canonicalizer, there's at least one compiler that can
emit constants with this form, see bug 30845.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23457
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30845
Approved-By: John Baldwin <jhb@FreeBSD.org>
13 months agoFix C++ canonicalization of hex literals
Tom Tromey [Thu, 11 Apr 2024 18:43:06 +0000 (12:43 -0600)] 
Fix C++ canonicalization of hex literals

Currently names like "x::y::z<1>" and "x::y::z<0x01>" canonicalize to
different things.  I think it's nicer for them to be the same.
Differences between types can be done using suffixes like "ll" and "u"
-- it's not really possible to implement C++ rules in the
canoncalizer, because no gdbarch is available.  Possibly gdb should
even drop the type here and just represent all integers the same way
in names.

Approved-By: John Baldwin <jhb@FreeBSD.org>
13 months agoRemove some unnecessary allocations from cpname_state::parse_number
Tom Tromey [Fri, 12 Apr 2024 02:00:09 +0000 (20:00 -0600)] 
Remove some unnecessary allocations from cpname_state::parse_number

cpname_state::parse_number allocates nodes for various types and then
only uses one of them.  This patch reduces the number of allocations
by not performing the unnecessary ones.

Approved-By: John Baldwin <jhb@FreeBSD.org>
13 months agoFix C++ name canonicalizations of character literals
Tom Tromey [Wed, 10 Apr 2024 22:49:51 +0000 (16:49 -0600)] 
Fix C++ name canonicalizations of character literals

The names "void C<(char)1>::m()" and "void C<'\001'>::m()" should
canonicalize to the same string, but currently they do not -- the
former remains unchanged and the latter is transformed to
"void C<(char)'\001'>::m()".

This patch fixes the bug and also adds some unit tests.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16843
Approved-By: John Baldwin <jhb@FreeBSD.org>
13 months agoChange storage of demangle_component
Tom Tromey [Thu, 11 Apr 2024 16:35:09 +0000 (10:35 -0600)] 
Change storage of demangle_component

This changes demangle_component objects to be stored on the obstack
that is part of demangle_info.  It also arranges for a demangle_info
object to be kept alive by cp_merge_demangle_parse_infos.  This way,
other data on the obstack can be kept while an "outer" demangle_info
needs it.

Acked-By: John Baldwin <jhb@FreeBSD.org>
13 months agoClean up demangle_parse_info
Tom Tromey [Wed, 10 Apr 2024 23:01:13 +0000 (17:01 -0600)] 
Clean up demangle_parse_info

This changes demangle_parse_info to use inline initializers and to
remove some manual memory management.

Approved-By: John Baldwin <jhb@FreeBSD.org>
13 months agoAllow initialization functions in .y files
Tom Tromey [Wed, 10 Apr 2024 20:54:17 +0000 (14:54 -0600)] 
Allow initialization functions in .y files

If you add an initialization function to a .y file, it will not show
up in init.c, because if the yacc output is in the build tree, it
won't be found.

This patch changes the Makefile to be more robust in this situation.

13 months agoRemove test code from cp-name-parser.y
Tom Tromey [Wed, 10 Apr 2024 20:34:42 +0000 (14:34 -0600)] 
Remove test code from cp-name-parser.y

This removes the current test 'main' from cp-name-parser.y.  There
aren't any tests using this, and nowadays it would be better as a unit
test.

Approved-By: John Baldwin <jhb@FreeBSD.org>
13 months agoDisallow trailing whitespace in docstrings
Tom Tromey [Wed, 17 Apr 2024 14:04:59 +0000 (08:04 -0600)] 
Disallow trailing whitespace in docstrings

This patch changes the docstring self-test to verify that there is no
trailing whitespace at the end of lines.  A few existing docstrings
had to be updated.

13 months agoRemove fflush call from tui_refresh_cmd_win
Tom Tromey [Fri, 26 Apr 2024 16:32:07 +0000 (10:32 -0600)] 
Remove fflush call from tui_refresh_cmd_win

tui_refresh_cmd_win calls fflush, but there's a comment explaining
that the reason for the call is unknown.  This patch removes the call.
I don't think it can be useful, since gdb doesn't generally use stdout
in this way -- only through ui_file.

13 months agogdb/doc: don't delete *.pod files too early
Andrew Burgess [Sat, 11 May 2024 08:44:07 +0000 (09:44 +0100)] 
gdb/doc: don't delete *.pod files too early

When doing 'make -C gdb/doc man' to build the man pages, I noticed
that the outputs were being rebuilt each time the make command was
rerun, even when the input files hadn't changed.

This was caused by this commit:

  commit 824083f34c222aa7419e2ea58e82d6f230d5f531
  Date:   Fri Apr 12 17:47:20 2024 +0100

      gdb/doc: use silent-rules.mk in the Makefile

Which split the generation of the .pod file from the actual creation
of the man page file.  Prior to this split it was OK to delete the
.pod file at the end of the recipe, the rule depending on the .texi
input file, and output was the .1 or .5 man page file.

Now however, with the split, the man page creation depends on the .pod
file, if we delete this after creating the .1 or .5 man page file then
the next time we run 'make' the .pod file is missing and is
regenerated, which in turn triggers the regeneration of the man page
file.

Fix this by leaving the .pod file around, and only cleaning up these
files in the 'mostlyclean' target.

Which leads to a second problem, the POD_FILE_TMPS is not created
correctly, so we don't actually clean up the .pod files!  This too is
fixed in this commit.

After this commit running 'make -C gdb/doc man' will build the manual
pages the first time, and each subsequent run will do nothing.

Running 'make -C gdb/doc mostlyclean' will now delete the .pod files.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agogdb/testsuite: remove unnecessary -Wl,-soname,NAME build flags
Andrew Burgess [Tue, 14 May 2024 10:29:49 +0000 (11:29 +0100)] 
gdb/testsuite: remove unnecessary -Wl,-soname,NAME build flags

While working on another patch I needed to pass -Wl,-soname,NAME as a
compiler flag.  I initially looked for other tests that did this, and
found a few examples, so I copied what they did.

But when I checked the gdb.log file I noticed that we were actually
getting -Wl,-soname passed twice.

I tracked the repeated option to 'proc gdb_compile_shlib_1' in
lib/gdb.exp.  It turns out that we always add -Wl,-soname when
compiling a shared library.

Here's an example of a build command from gdb.base/prelink.exp:

  builtin_spawn -ignore SIGHUP gcc -fno-stack-protector \
    /tmp/build/gdb/testsuite/outputs/gdb.base/prelink/prelink-lib.c.o \
    -fdiagnostics-color=never -shared -g \
    -Wl,-soname,prelink.so -Wl,-soname,prelink.so -lm \
    -o /tmp/build/gdb/testsuite/outputs/gdb.base/prelink/prelink.so

Notice that '-Wl,-soname,prelink.so' is repeated.

I believe that all of the places where tests add '-Wl,-soname,NAME' as
a build option, are unnecessary.

In this commit I propose we remove them all.

As part of this change I've switched from calling gdb_compile_shlib
directly, to instead call build_executable and adding the 'shlib'
flag.

I've tested with gcc and clang and see no changes in the test results
after this commit.  All the compile commands still have -Wl,-soname
added, but now it's only added once, from within lib/gdb.exp.

There should be no change in what is tested after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agoImprove objdump -p output of PE Import and Export Tables
Pali Roh?r [Tue, 14 May 2024 15:50:32 +0000 (16:50 +0100)] 
Improve objdump -p output of PE Import and Export Tables

  PR 31738

13 months agoAdjust C++ destructor type tests
Jason Merrill [Fri, 10 May 2024 20:33:20 +0000 (16:33 -0400)] 
Adjust C++ destructor type tests

In gcc-15-95-ga12cae97390 I dropped the unnecessary artificial "in-charge"
parameter from destructors of classes with no virtual bases; Linaro's CI
informed me that the gdb testsuite needs to be adjusted to match.

Teested against GCC 13.2 and GCC 15 trunk.

Approved-by: Kevin Buettner <kevinb@redhat.com>
13 months agoFix gas's 'macro count' test for various targets
Nick Clifton [Tue, 14 May 2024 14:30:52 +0000 (15:30 +0100)] 
Fix gas's 'macro count' test for various targets

13 months agoFix Segmentation Fault in AIX during multi process debugging.
Aditya Vidyadhar Kamath [Tue, 14 May 2024 09:51:41 +0000 (15:21 +0530)] 
Fix Segmentation Fault in AIX during multi process debugging.

Due to the recent commit in aix-thread.c, we see a segmentation fault
in AIX while debugging multiple process involving multiple threads.

One example is a thread that can fork. The GDB output in AIX for the same is

Reading symbols from //gdb_tests/multi-thread-fork...
(gdb) set detach-on-fork off
(gdb) r
Starting program: /gdb_tests/multi-thread-fork
[New Thread 258 (tid 67110997)]
[New Thread 515 (tid 127404289)]
[New inferior 2 (process 16580940)]
Hello from Parent!
[process 16580940 exited]
[New inferior 3 (process 14549318)]
Hello from Parent!
[process 14549318 exited]
Fatal signal: Segmentation fault
----- Backtrace -----

This is because in sync_threadlists () in aix-thread.c there when we
delete threads in unknown state we iterate through all the threads.

When we have one or more threads with the same user thread ID but of different
process then we delete a wrong thread. Since we just check only the pdtid
in in_queue_threads.count (priv->pdtid) == 0 this happened.

This patch is a fix for the same.

The output after we apply this patch is:
Reading symbols from //gdb_tests/multi-thread-fork...
(gdb) set detach-on-fork off
(gdb) r
Starting program: /gdb_tests/multi-thread-fork
[New Thread 258 (tid 75565441)]
[New Thread 515 (tid 63244397)]
[New inferior 2 (process 10813892)]
Hello from Parent!
[New inferior 3 (process 19005888)]
Hello from Parent!

Thread 1.1 received signal SIGINT, Interrupt.
0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) info threads
  Id   Target Id                             Frame
* 1.1  Thread 1 (tid 66062355) ([running])   0xd0611d70 in _p_nsleep () from /usr/lib/libpthread.a(_shr_xpg5.o)
  1.2  Thread 258 (tid 75565441) ([running]) thread_function (arg=0x0) at //gdb_tests/multi-thread-fork.c:50
  1.3  Thread 515 (tid 63244397) ([running]) thread_function (arg=0x0) at //gdb_tests/multi-thread-fork.c:50
2.1  Thread 515 (tid 32113089) ([running]) 0xd0610df0 in _sigsetmask () from /usr/lib/libpthread.a(_shr_xpg5.o)
  3.1  Thread 258 (tid 64489699) ([running]) 0xd0610df0 in _sigsetmask () from /usr/lib/libpthread.a(_shr_xpg5.o)
(gdb) q
A debugging session is active.

13 months agoarm: update documentation for removal of the Maverick extension
Richard Earnshaw [Mon, 29 Apr 2024 14:09:06 +0000 (15:09 +0100)] 
arm: update documentation for removal of the Maverick extension

Finally, update the documentation and add a NEWS item.

13 months agoarm: remove Maverick support from BFD.
Richard Earnshaw [Mon, 29 Apr 2024 13:45:11 +0000 (14:45 +0100)] 
arm: remove Maverick support from BFD.

Remove the handling of Maverick from BFD.  Where appropriate we handle
legacy code by mapping ep9312 onto Armv4t.