]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
12 months agoaarch64: Add DT_RELR support
Szabolcs Nagy [Wed, 27 Mar 2024 15:38:06 +0000 (15:38 +0000)] 
aarch64: Add DT_RELR support

The logic to decide if an input relocation for a symbol becomes a
particular kind of output relocation is one of the hard to maintain
parts of the bfd ld backend, since it is partially repeated across

 elfNN_aarch64_check_relocs (where dynamic relocations are counted per
 symbol and input section),

 elfNN_aarch64_late_size_sections (where relocation sections are sized
 and GOT offsets assigned),

 elfNN_aarch64_relocate_section (where most relocations are applied and
 output to a relocation section),

 elfNN_aarch64_finish_dynamic_symbol (where some of the GOT
 relocations are applied and output).

The DT_RELR support adds another layer to this complexity: after the
output relocation sections are sized, so all dynamic relocations are
accounted (in elfNN_aarch64_late_size_sections), we scan the symbols
and input relocations again to decide which ones become relative
relocations that can be packed. The sizes of the relocation sections
are updated accordingly. This logic must be consistent with the code
that applies the relocs later so each relative relocation is emitted
exactly once: either in .rela.* or packed in .relr.dyn.

Sizing of .relr.dyn is done via elfNN_aarch64_size_relative_relocs that
may be called repeatedly whenever the layout changes since an address
change can affect the size of the packed format. Then the final content
is emitted in elfNN_aarch64_finish_relative_relocs, that is called
after the layout is final and before relocations are applied and
emitted. These hooks are only called if DT_RELR is enabled.

We only pack relative relocs that are known to be aligned in the output
during .relr.dyn sizing, the potentially unaligned relative relocs are
emitted normally (in .rela.*, not packed), because the format requires
aligned addresses.

12 months agox86: reduce check_{byte,word,long,qword}_reg() overhead
Jan Beulich [Fri, 31 May 2024 08:22:50 +0000 (10:22 +0200)] 
x86: reduce check_{byte,word,long,qword}_reg() overhead

These run after template matching. Therefore it is quite pointless for
them to check all operands, when operand sizes matching across operands
is already known. Exit the loops early in such cases.

In check_byte_reg() also drop a long-stale part of a comment.

12 months agogdb, amd64: remove unused forward declarations
Felix Willgerodt [Thu, 14 Jul 2022 14:46:37 +0000 (16:46 +0200)] 
gdb, amd64: remove unused forward declarations

These structs are not referenced anywhere anymore and seemed to have been
missed at some point when their usage was removed.

Co-authored-by: Nils-Christian Kempke <nils-christian.kempke@intel.com>
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb, doc: Fix AVX-512 documentation.
Felix Willgerodt [Tue, 21 May 2024 12:54:05 +0000 (14:54 +0200)] 
gdb, doc: Fix AVX-512 documentation.

org.gnu.gdb.i386.avx512 adds k registers, but these aren't mentioned in the
docs yet.  Fix that.

In addition the documentation describes xmm registers with an `h`
(e.g. xmm16h).  I am assuming that we follow the register xml files here,
which don't have the h suffix.  So this removes that as well.

Approved-By: Eli Zaretskii <eliz@gnu.org>
12 months agogdb: remove unused includes in utils.h
Simon Marchi [Mon, 29 Apr 2024 15:07:22 +0000 (11:07 -0400)] 
gdb: remove unused includes in utils.h

Remove some includes reported as unused by clangd.  Add some includes in
other files that were previously relying on the transitive include.

Change-Id: Ibdd0a998b04d21362a20d0ca8e5267e21e2e133e

12 months agoAutomatic date update in version.in
GDB Administrator [Fri, 31 May 2024 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogdb: remove unused includes in symfile.c
Simon Marchi [Tue, 23 Apr 2024 02:34:13 +0000 (22:34 -0400)] 
gdb: remove unused includes in symfile.c

Remove some includes reported as unused by clangd.

Change-Id: Iebd986eaf42409f1e526f09df0fcb0ce45c2fad6

12 months agogdb: remove unused includes in breakpoint.{c,h}
Simon Marchi [Tue, 23 Apr 2024 02:26:41 +0000 (22:26 -0400)] 
gdb: remove unused includes in breakpoint.{c,h}

Remove some includes reported as unused by clangd.

Change-Id: I36d388bcff166f6baafa212f0bcbe8af64b2946d

12 months agoUpdate binutils release documentation to include using the -z option when invoking...
Nick Clifton [Thu, 30 May 2024 11:52:37 +0000 (12:52 +0100)] 
Update binutils release documentation to include using the -z option when invoking src-release.sh

12 months agosrc-release.sh: Support zstd compression
Mark Wielaard [Thu, 30 May 2024 11:50:11 +0000 (12:50 +0100)] 
src-release.sh: Support zstd compression

12 months ago.gitignore: ignore .vscode
Simon Marchi [Thu, 30 May 2024 11:09:35 +0000 (12:09 +0100)] 
.gitignore: ignore .vscode

12 months agoAutomatic date update in version.in
GDB Administrator [Thu, 30 May 2024 00:00:14 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogdb/doc: don't have .pod targets separate to man page targets
Andrew Burgess [Sun, 26 May 2024 22:30:37 +0000 (23:30 +0100)] 
gdb/doc: don't have .pod targets separate to man page targets

While preparing the new release it was discovered that commit:

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

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

was causing problems.  Given a release tar file, an attempt to build
and install GDB would give an error like this:

  [...]
    TEXI2POD gdb.pod
  cannot find GDBvn.texi at ../../../gdb-15.0.50.20240508/gdb/doc/../../etc/texi2pod.pl line 251, <GEN0> line 16.
  make[5]: *** [Makefile:663: gdb.pod] Error 2

The problem here is how the man pages are built, and how they are
distributed within a release.

Within the development (git) tree, the man page files are not part of
the source tree, these files are built as needed.  Within a release
tar file though, the man pages are included.  The idea being that a
user can build and install GDB, including getting the man pages,
without having to install the tools needed to generate the man pages.

The man pages are generated in a two step process.  First the .texi
file is processed with texi2pod to create a .pod file, then this .pod
file is processed to create the .1 or .5 man file.

Prior to the above commit these two steps were combined into a single
recipe, this meant that when a user performed a build/install from a
release tree all of the dependencies, as well as the final result,
were all present in the source tree, and so nothing needed to be
rebuilt.

However, the above commit split the two steps apart.  Now we had a
separate rule for building the .pod files, and the .1/.5 man page
files depended on the relevant .pod file.

As the .pod files are not shipped in a GDB release, this meant that
one of the dependencies of the man page files was now missing.  As a
result if a user tried to install from a release tree a rebuild of the
.pod files would be attempted, and if that succeeded then building the
man pages would follow that.

Unfortunately, building the .pod files would fail as the GDBvn.texi
file, though present in the source tree, was not present in the build
tree, which is where it is needed for the .pod file generation to
work.

To fix this, I propose merging the .pod creation and the .1/.5 man
page creation back into a single recipe.  Having these two steps split
is probably the "cleaner" solution, but makes it harder for us to
achieve our goal of shipping the prebuilt man page files.  I've added
a comment explaining what's going on (such a comment would have
prevented this mistake having been made in the first place).

One possibly weird thing here is that I have left both an
ECHO_TEXI2POD and a ECHO_TEXI2MAN in the rule $(MAN1S) and $(MAN5S)
recipes.  This is 100% not going to break anything, these just print
two different progress messages while executing the recipes, but I'm
not sure if this is considered poor style or not.  Maybe we're only
supposed to have a single ECHO_* per recipe?

Anyway, even if this is poor style, I figure it really is just a style
thing.  We can tweak this later as needed.  Otherwise, this commit
should fix the current issue blocking the next GDB release.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoreadelf: Use section names for displaying RELR relocs
Szabolcs Nagy [Tue, 28 May 2024 16:23:41 +0000 (17:23 +0100)] 
readelf: Use section names for displaying RELR relocs

In some cases using section names instead of symbol names for
displaying an address is more useful.

If the symbol falls outside the section where the address is
then likely it is not useful to display the address relative to.

And if symbols are stripped from a binary then printing the
section that contains the address is more useful than printing
<no sym>.

12 months agoreadelf: Fix symbol display for RELR relocs
Szabolcs Nagy [Thu, 23 May 2024 17:16:57 +0000 (18:16 +0100)] 
readelf: Fix symbol display for RELR relocs

Filter symbols before binary searching for the right symbol to display
for a given address, such that only displayable symbols are present and
at most one per address.

The current logic does not handle multiple symbols for the same address
well if some of them are empty, the selected symbol is not stable with
respect to an unrelated symbol table change and on aarch64 often mapping
symbols are displayed which is not useful.

Filtering solves these problems at the cost of a linear scan of the
sorted symbol table.

The heuristic to select the best symbol likely could be improved, this
patch aims to improve symbol display for RELR without complex logic
such that the output is useful and stable for ld tests.

12 months agox86/Intel: warn about undue mnemonic suffixes
Jan Beulich [Wed, 29 May 2024 08:03:00 +0000 (10:03 +0200)] 
x86/Intel: warn about undue mnemonic suffixes

Except for very few insns mnemonic suffixes aren't permitted in Intel
syntax. Warn about such for now, indicating that they will be outright
refused down the road.

While fiddling with testcases to address fallout, drop a few things
which should never have been tested as valid Intel syntax.

Also add a previously missing line to simd-suffix.d.

12 months agox86/Intel: SHLD/SHRD have dual meaning
Jan Beulich [Wed, 29 May 2024 08:02:01 +0000 (10:02 +0200)] 
x86/Intel: SHLD/SHRD have dual meaning

Since we uniformly permit D suffixes in Intel mode whenever in AT&T mode
an L suffix may be used, we need to be consistent with this.

Take the easy route, despite that still leading to an anomaly which is
also visible from the new testcase:

shld eax, ecx, 1
shld eax, ecx, cl

can mean two things with APX: SHL with a D suffix in NDD EVEX encoding,
or the traditional SHLD in legacy encoding.

12 months agoPR31796, Internal error in write_function_pdata at obj-coff-seh
Alan Modra [Tue, 28 May 2024 04:10:50 +0000 (13:40 +0930)] 
PR31796, Internal error in write_function_pdata at obj-coff-seh

PR31796 is the result of lack of aarch64 support in obj-coff-seh.c.
Nick fixed this with commit 73c8603c3f.  Make the seh support
consistently warn in future if some archictecture is missing, rather
than giving internal errors.

PR 31796
* config/obj-coff-seh.c (verify_target): New function.
(obj_coff_seh_handler, obj_coff_seh_endproc, obj_coff_seh_proc),
(obj_coff_seh_endprologue): Use it.

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

12 months agold: pru: Increase the default memory region sizes
Dimitar Dimitrov [Tue, 21 May 2024 15:05:54 +0000 (18:05 +0300)] 
ld: pru: Increase the default memory region sizes

The default memory region sizes for PRU were set somewhat arbitrarily to
the sizes of the most popular BeagleBone board with AM33x SoC.  But the
PRU toolchain documentation has always instructed to use SoC-specific
spec files to override the defaults and set the correct memory sizes [1].

The small default memory sizes can cause IMEM memory region overflow
even for simple printf("Hello world") programs, as usually done by
Autotools checks.  The stdio is simply too big to fit in 8K
instruction memory.  This can confuse the check and lead to wrong
feature selection during configure [2].

Fix by bumping the default DMEM and IMEM memory sizes.

There is no need to backport this patch.  Issue was caught with a
feature-rich newlib build used for daily CI.  The release builds of the
PRU toolchain use stripped newlib configuration, which does not overflow
the IMEM region, even for 8K.

[1] https://github.com/dinuxbg/gnuprumcu
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115158

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
12 months agoMake tui_win_info::make_window non-virtual
Tom Tromey [Sat, 27 Apr 2024 15:30:09 +0000 (09:30 -0600)] 
Make tui_win_info::make_window non-virtual

Nothing overrides tui_win_info::make_window, so remove the "virtual".
Tested by rebuilding.

12 months agogas, aarch64: Add SVE2 lut extension
saurabh.jha@arm.com [Tue, 28 May 2024 14:45:52 +0000 (15:45 +0100)] 
gas, aarch64: Add SVE2 lut extension

Introduces instructions for the SVE2 lut extension for AArch64. They are documented in the following links:
* luti2: https://developer.arm.com/documentation/ddi0602/2024-03/SVE-Instructions/LUTI2--Lookup-table-read-with-2-bit-indices-?lang=en
* luti4: https://developer.arm.com/documentation/ddi0602/2024-03/SVE-Instructions/LUTI4--Lookup-table-read-with-4-bit-indices-?lang=en

These instructions use new SVE2 vector operands. They are called
SVE_Zm1_23_INDEX, SVE_Zm2_22_INDEX, and Zm3_12_INDEX and they have
1 bit, 2 bit, and 3 bit indices respectively.

The lsb and width of these new operands are the same as many existing
operands but the convention is to give different names to fields that
serve different purpose so we introduced new fields in aarch64-opc.c
and aarch64-opc.h.

We made a design choice for the second operand of the halfword variant of
luti4 with two register tables. We could have either defined a new operand,
like SVE_Znx2, or we could have use the existing operand SVE_ZnxN. With
the new operand, we would need to implement constraints on register
lists based on either operand or opcode flag. With existing operand, we
could just existing constraint checks using opcode flag. We chose
the second approach and went with SVE_ZnxN and added opcode flag to
enforce lengths of vector register list operands. This way, we can reuse
the existing constraint check logic.

12 months agogas, aarch64: Add AdvSIMD lut extension
saurabh.jha@arm.com [Tue, 28 May 2024 14:45:50 +0000 (15:45 +0100)] 
gas, aarch64: Add AdvSIMD lut extension

Introduces instructions for the Advanced SIMD lut extension for AArch64. They are documented in the following links:
* luti2: https://developer.arm.com/documentation/ddi0602/2024-03/SIMD-FP-Instructions/LUTI2--Lookup-table-read-with-2-bit-indices-?lang=en
* luti4: https://developer.arm.com/documentation/ddi0602/2024-03/SIMD-FP-Instructions/LUTI4--Lookup-table-read-with-4-bit-indices-?lang=en

These instructions needed definition of some new operands. We will first
discuss operands for the third operand of the instructions and then
discuss a vector register list operand needed for the second operand.

The third operands are vectors with bit indices and without type
qualifiers. They are called Em_INDEX1_14, Em_INDEX2_13, and Em_INDEX3_12
and they have 1 bit, 2 bit, and 3 bit indices respectively. For these
new operands, we defined new parsing case branch. The lsb and width of
these operands are the same as many existing but the convention is to
give different names to fields that serve different purpose so we
introduced new fields in aarch64-opc.c and aarch64-opc.h for these new
operands.

For the second operand of these instructions, we introduced a new
operand called LVn_LUT. This represents a vector register list with
stride 1. We defined new inserter and extractor for this new operand and
it is encoded in FLD_Rn. We are enforcing the number of registers in the
reglist using opcode flag rather than operand flag as this is what other
SIMD vector register list operands are doing. The disassembly also uses
opcode flag to print the correct number of registers.

12 months agoUse bool in thread_events
Tom Tromey [Mon, 27 May 2024 20:12:33 +0000 (14:12 -0600)] 
Use bool in thread_events

This changes target_ops::thread_events and target_thread_events to use
'bool'.  The callers were already doing this.

Tested by rebuilding.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
12 months agoFix typo in assembler documentation
Nick Clifton [Tue, 28 May 2024 15:34:52 +0000 (16:34 +0100)] 
Fix typo in assembler documentation

12 months agoFix: internal error in write_function_pdata at obj-coff-seh
Nick Clifton [Tue, 28 May 2024 15:30:14 +0000 (16:30 +0100)] 
Fix: internal error in write_function_pdata at obj-coff-seh

  PR 31796

12 months agoUpdated Spanish translation for the BFD sub-directory.
Nick Clifton [Tue, 28 May 2024 13:48:08 +0000 (14:48 +0100)] 
Updated Spanish translation for the BFD sub-directory.

12 months agoopcodes: add a .gitattributes file for aarch64 autogenerated file exceptions
Richard Earnshaw [Thu, 23 May 2024 15:25:51 +0000 (16:25 +0100)] 
opcodes: add a .gitattributes file for aarch64 autogenerated file exceptions

The autogenerated files in opcodes use spaces for indentation.
Changing that would be a lot of work to little benefit, so add a local
override to the white-space rules, so patches apply cleanly.

12 months agoAdd new ELF section and segment types to readelf.
Nick Clifton [Tue, 28 May 2024 09:12:28 +0000 (10:12 +0100)] 
Add new ELF section and segment types to readelf.

12 months agoRISC-V: Fix U insn; replace opcode6 with opcode7 in gas/doc/c-riscv.texi
Javier Mora [Fri, 24 May 2024 18:10:05 +0000 (20:10 +0200)] 
RISC-V: Fix U insn; replace opcode6 with opcode7 in gas/doc/c-riscv.texi

The type U RISC-V instruction format in gas/doc/c-riscv.texi shows the
bit arrangement of the simm20 immediate that belongs to the J type;
It should be just `simm20[19:0]`.  The current behavior of `gas` matches
the proposed documentation change.

Additionally, the opcode is called `opcode6` despite of having 7 bits.
Rename it to `opcode7`.

gas/
* doc/c-riscv.texi: Fix U type, and replace opcode6 with opcode7.

12 months agoAutomatic date update in version.in
GDB Administrator [Tue, 28 May 2024 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoRe-run make-target-delegates.py
Tom Tromey [Mon, 27 May 2024 21:17:51 +0000 (15:17 -0600)] 
Re-run make-target-delegates.py

I re-ran make-target-delegates.py and discovered that the tree was out
of sync.  This patch corrects the problem.

12 months agoRISC-V: Fixed overwritten IRELATIVE relocs in the .rel.iplt for data reloc.
Nelson Chu [Mon, 27 May 2024 17:22:13 +0000 (01:22 +0800)] 
RISC-V: Fixed overwritten IRELATIVE relocs in the .rel.iplt for data reloc.

This was originally reported by Hau Hsu <hau.hsu@sifive.com>.

Similar to commit 51a8a7c2e3cc0730831963651a55d23d1fae624d

We shouldn't use riscv_elf_append_rela to add dynamic relocs into .rela.iplt
in the riscv_elf_relocate_section when handling ifunc data reloc R_RISCV_32/64.
This just like what did in the riscv_elf_finish_dynamic_symbol.

bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): We shouldn't use
riscv_elf_append_rela to add dynamic relocs into .rela.iplt in the
riscv_elf_relocate_section when handling ifunc data reloc.
ld/
* testsuite/ld-riscv-elf/ifunc-overwrite.s: Updated and renamed.
* testsuite/ld-riscv-elf/ifunc-overwrite-exe.rd: Likewise.
* testsuite/ld-riscv-elf/ifunc-overwrite-pic.rd: Likewise.
* testsuite/ld-riscv-elf/ifunc-overwrite-pie.rd: Likewise.
* testsuite/ld-riscv-elf/ifunc-overwrite.d: Renamed.

12 months agoRISC-V: Segment fault for kernel purgatory when linking.
Nelson Chu [Mon, 29 Apr 2024 09:44:51 +0000 (17:44 +0800)] 
RISC-V: Segment fault for kernel purgatory when linking.

This was originally reported by Ard Biesheuvel <ardb@kernel.org>.

The followings are reproduce steps,
https://lore.kernel.org/all/202404260640.9GQVTmrw-lkp@intel.com/T/#u

The segment fault happens in the riscv_elf_finish_dynamic_sections when the
output got section is an ABS.  Refer to MIPS code, they added an extra
bfd_is_abs_section check to avoid ABS got, so this seems the right and easier
way to go in the short-term.

bfd/
* elfnn-riscv.c (riscv_elf_finish_dynamic_sections): Set sh_entsize
and fill the got entries only when the got isn't an ABS section, and
the size of got is larger than zero.  The similar goes for gotplt,
except we already reported error when the gotplt is an ABS.

12 months agoLoongArch: Fix relaxation overflow caused by ld -z separate-code
mengqinggang [Wed, 22 May 2024 06:27:08 +0000 (14:27 +0800)] 
LoongArch: Fix relaxation overflow caused by ld -z separate-code

ld -z separate-code let .text and .rodata in two different but read only
segment. If the symbol and pc in two segment, the offset from pc to
symbol need to consider segment alignment.

Add a function 'loongarch_two_sections_in_same_segment' to determine
whether two sections are in the same segment.

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

13 months agoUpdate gdb/NEWS after GDB 15 branch creation.
Joel Brobecker [Sun, 26 May 2024 16:02:38 +0000 (09:02 -0700)] 
Update gdb/NEWS after GDB 15 branch creation.

This commit a new section for the next release branch, and renames
the section of the current branch, now that it has been cut.

13 months agoBump version to 16.0.50.DATE-git.
Joel Brobecker [Sun, 26 May 2024 15:57:27 +0000 (08:57 -0700)] 
Bump version to 16.0.50.DATE-git.

Now that the GDB 15 branch has been created,
this commit bumps the version number in gdb/version.in to
16.0.50.DATE-git

For the record, the GDB 15 branch was created
from commit 3a624d9f1c5ccd8cefdd5b7ef12b41513f9006cd.

Also, as a result of the version bump, the following changes
have been made in gdb/testsuite:

* gdb.base/default.exp: Change $_gdb_major to 16.

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

13 months agold: Document -pie -Ttext-segment=ORG generates ET_EXEC
H.J. Lu [Sat, 25 May 2024 14:44:59 +0000 (07:44 -0700)] 
ld: Document -pie -Ttext-segment=ORG generates ET_EXEC

This is the v2 patch I am checking in.

H.J.

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

13 months agoRe: LoongArch: gas: Adjust DWARF CIE alignment factors
Alan Modra [Thu, 23 May 2024 05:21:31 +0000 (14:51 +0930)] 
Re: LoongArch: gas: Adjust DWARF CIE alignment factors

Adjust the gas testsuite to suit commit de203ed568f6.

* testsuite/gas/loongarch/relax-cfi-fde-DW_CFA_advance_loc.d:
Expect data alignment of -8.  Tidy.

13 months agogas: extend \+ support to .irp / .irpc
Jan Beulich [Fri, 24 May 2024 10:23:22 +0000 (12:23 +0200)] 
gas: extend \+ support to .irp / .irpc

PR gas/31752

These are effectively macro-like, without any separate macro definition.
They already support \@, so they would better also support \+. This
allows, where desired, to get away without maintaining an explicit count
variable in source code.

With this the recently introduced testcase doesn't need any xfails
anymore.

13 months agogas: adjust handling of quotes for .irpc
Jan Beulich [Fri, 24 May 2024 10:22:54 +0000 (12:22 +0200)] 
gas: adjust handling of quotes for .irpc

The present handling of inner double quotes can lead to very strange
diagnostics. Follow one of the two possible interpretations of the doc:
@dots{} referring to possibly multiple white space separated
@var{values}, each of which may be quoted. The original implementation,
prior to 465e5617233f ("PR gas/3856"), hints at the other possible
interpretation: When quoted there's only a single @var{values}, with
inner quotes taken as ordinary characters. That, however, seems overall
less useful to me.

While touching the documentation, mirror the (inverse) spelling
correction (@section line inconsistent with actual description) to .irp
as well.

13 months agox86: simplify VexVVVV_SRC2 handling for the XOP case
Jan Beulich [Fri, 24 May 2024 10:21:57 +0000 (12:21 +0200)] 
x86: simplify VexVVVV_SRC2 handling for the XOP case

As already suggested during review, rather than having an extra
conditional in build_modrm_byte() (a code path used for quite a few
more insns, including even certain GPR ones), adjust the attribute in
the installed template to properly describe things with operands
swapped.

13 months agox86: simplify / consolidate check_{word,long,qword}_reg()
Jan Beulich [Fri, 24 May 2024 09:51:21 +0000 (11:51 +0200)] 
x86: simplify / consolidate check_{word,long,qword}_reg()

These run after template matching. Therefore operands are already known
to match the template in use. With the loop bodies skipping anything not
a GPR in the actual operands, there's therefore no need to check the
template's operand type for permitting Reg or Accum.

At the same time bring the three functions in sync for the "byte" part
of the logic, as far as checking the template for other sizes (qword
specifically) goes. Plus drop a stale comment from check_qword_reg(),
when all three are now behaving the same in this regard.

13 months agox86: correct VCVT{,U}SI2SD
Jan Beulich [Fri, 24 May 2024 09:50:38 +0000 (11:50 +0200)] 
x86: correct VCVT{,U}SI2SD

Properly reject inappropriate suffixes (No_lSuf / No_qSuf mistakenly
omitted by cf665fee1d6c ["x86: re-work AVX512 embedded rounding / SAE"]),
to avoid emitting bad or arbitrarily guessed instructions. Interestingly
check_{long,qword}_suffix() don't help here, which perhaps is another
indication that the way they work right now isn't quite appropriate.

Sadly correcting just the templates breaks operand ambiguity detection,
since so far that worked from a single template permitting more than one
suffix. Here we have ambiguity though which can now be noticed only when
taking all (matching) templates together. Therefore we need to determine
further matching templates (see code comments for constraints), to then
accumulate permitted suffixes across all of them.

13 months ago[gdb/testsuite] Add PR26286 kfail in gdb.threads/attach-many-short-lived-threads.exp
Tom de Vries [Fri, 24 May 2024 07:36:52 +0000 (09:36 +0200)] 
[gdb/testsuite] Add PR26286 kfail in gdb.threads/attach-many-short-lived-threads.exp

When running test-case gdb.threads/attach-many-short-lived-threads.exp, I run
regularly into PR26286:
...
(gdb) continue^M
Continuing.^M
[LWP ... exited]^M
  ...
[LWP ... exited]^M
^M
Program terminated with signal SIGTRAP, Trace/breakpoint trap.^M
The program no longer exists.^M
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 9: \
  break at break_fn: 1
...

Add a kfail for this, such that we have:
...
(gdb) KFAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 9: \
  break at break_fn: 1 (PRMS: threads/26286)
...

Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Tested on x86_64-linux.

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

13 months agogdb, testsuite: Fix return value in gdb.base/foll-fork.exp
Felix Willgerodt [Tue, 21 May 2024 07:20:39 +0000 (09:20 +0200)] 
gdb, testsuite: Fix return value in gdb.base/foll-fork.exp

In a remote testing setup, I saw this error:

~~~
(gdb) FAIL: gdb.base/foll-fork.exp: check_fork_catchpoints: runto: run to main
ERROR: tcl error sourcing gdb/gdb/testsuite/gdb.base/foll-fork.exp.
ERROR: expected boolean value but got ""
    while executing
"if { ![check_fork_catchpoints] } {
    untested "follow-fork not supported"
    return
}"
    (file "gdb/gdb/testsuite/gdb.base/foll-fork.exp" line 434)
    invoked from within
"source gdb/gdb/testsuite/gdb.base/foll-fork.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source gdb/gdb/testsuite/gdb.base/foll-fork.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""
Remote debugging from host 172.0.1.3, port 37766
Killing process(es): 1171
Quit
~~~

The actual reason for this were some connection problems. Though the
function check_fork_catchpoints shouldn't return an empty string, especially
as it promises to always return 0 or 1. Fix that.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agogdb/testsuite: Restore libc_has_debug_info's less strict behaviour
Thiago Jung Bauermann [Tue, 30 Apr 2024 01:53:25 +0000 (22:53 -0300)] 
gdb/testsuite: Restore libc_has_debug_info's less strict behaviour

The code that was factored out from gdb.base/relativedebug.exp assumed that
libc has debug info and only determined that it doesn't if it saw a specific
message from GDB to that effect.  In the process of factoring it into a
require predicate, I made it stricter by trying to make a specific
determination of whether or not debug info is available.

Pedro noticed that "It'll disable the testcase on systems that link with
their libc statically (even if has debug info), or systems that name their
libc something else."  Which is something I hadn't considered.

This patch returns libc_has_debug_info to the original behaviour.

Also, remove a verbose message that is redundant with the $message
variable.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31700
Approved-By: Tom Tromey <tom@tromey.com>
13 months agoAutomatic date update in version.in
GDB Administrator [Thu, 23 May 2024 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 months agolibctf testsuite compilation failure
Alan Modra [Tue, 21 May 2024 23:16:17 +0000 (08:46 +0930)] 
libctf testsuite compilation failure

* testsuite/libctf-regression/open-error-free.c (main): Correct
format length modifier.

13 months agoDefault dwarf_synchronous to true
Tom Tromey [Fri, 17 May 2024 14:55:46 +0000 (08:55 -0600)] 
Default dwarf_synchronous to true

Unfortunately the background DWARF reading series introduced a number
of races, as repored by thread sanitizer.  This patch changes gdb to
disable this feature for the time being -- in particular for the gdb
15 release.

I've filed a bug and linked all the known races to it.  Once those are
fixed we can re-enable this feature by default.

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

13 months agorestore build with --enable-maintainer-mode
Indu Bhagat [Wed, 22 May 2024 15:38:34 +0000 (08:38 -0700)] 
restore build with --enable-maintainer-mode

A build with --enable-maintainer-mode is currently failing with:

make[4]: *** No rule to make target '<SRC>/gas/config/te-ia64aix.h',
 needed by '<SRC>/gas/po/gas.pot'.  Stop.
make[4]: Leaving directory '<$OBJ>/gas/po'
make[3]: *** [Makefile:1695: all-recursive] Error 1
...

As config/te-ia64aix.h is now removed, remove the corresponding fragment
from the makefile.

gas/
        * Makefile.am: Remove config/te-ia64aix.h.
        * Makefile.in: Regenerate.
        * po/POTFILES.in: Regenerate.

13 months agoaarch64: fix incorrect encoding for system register pmsdsfr_el1
Matthieu Longo [Fri, 17 May 2024 11:04:25 +0000 (12:04 +0100)] 
aarch64: fix incorrect encoding for system register pmsdsfr_el1

This patch fixes a mistake in the encoding of the system register
pmsdsfr_el1.

Reference:
https://developer.arm.com/documentation/ddi0601/2022-09/AArch64-Registers/PMSDSFR-EL1--Sampling-Data-Source-Filter-Register?lang=en

13 months agoSupport APX zero-upper
Cui, Lili [Wed, 22 May 2024 08:15:47 +0000 (16:15 +0800)] 
Support APX zero-upper

This patch is to enable ZU for IMUL (opcodes 0x69 and 0x6B) and SETcc.
Since the spec only recommends one form of setzu, I won't be adding
set<cc>reg32/reg64 support in this patch.

gas/ChangeLog:

        * config/tc-i386.c (build_apx_evex_prefix): Handle ZU.
        * testsuite/gas/i386/x86-64.exp: Added new tests for ZU.
        * testsuite/gas/i386/x86-64.exp: Added new tests for ZU.
        * testsuite/gas/i386/x86-64-apx-zu-intel.d: New test.
        * testsuite/gas/i386/x86-64-apx-zu-inval.l: Ditto.
        * testsuite/gas/i386/x86-64-apx-zu-inval.s: Ditto.
        * testsuite/gas/i386/x86-64-apx-zu.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-zu.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex-prefix.h: Handle PREFIX_EVEX_MAP4_40 ~
        PREFIX_EVEX_MAP4_4F.
        * i386-dis-evex.h: Ditto.
        * i386-dis.c (struct dis386): Add new micro 'ZU'.
        (putop): Handle %ZU.
        * i386-gen.c: Added ZU.
        * i386-opc.h: Ditto.
        * i386-opc.tbl: Added new templates to support ZU.

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.