]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
8 months agogdb: avoid breakpoint::clear_locations calls in update_breakpoint_locations
Andrew Burgess [Mon, 23 Sep 2024 14:22:58 +0000 (15:22 +0100)] 
gdb: avoid breakpoint::clear_locations calls in update_breakpoint_locations

The commit:

  commit 6cce025114ccd0f53cc552fde12b6329596c6c65
  Date:   Fri Mar 3 19:03:15 2023 +0000

      gdb: only insert thread-specific breakpoints in the relevant inferior

added a couple of calls to breakpoint::clear_locations() inside
update_breakpoint_locations().

The intention of these calls was to avoid leaving redundant locations
around when a thread- or inferior-specific breakpoint was switched
from one thread or inferior to another.

Without the clear_locations() calls the tests gdb.multi/tids.exp and
gdb.multi/pending-bp.exp have some failures.  A b/p is changed such
that the program space it is associated with changes.  This triggers a
call to breakpoint_re_set_one() but the FILTER_PSPACE argument will be
the new program space.  As a result GDB correctly calculates the new
locations and adds these to the breakpoint, but the old locations, in
the old program space, are incorrectly retained.  The call to
clear_locations() solves this by deleting the old locations.

However, while working on another patch I realised that the approach
taken here is not correct.  The FILTER_PSPACE argument passed to
breakpoint_re_set_one() and then on to update_breakpoint_locations()
might not be the program space to which the breakpoint is associated.
Consider this example:

  (gdb) file /tmp/hello.x
  Reading symbols from /tmp/hello.x...
  (gdb) start
  Temporary breakpoint 1 at 0x401198: file hello.c, line 18.
  Starting program: /tmp/hello.x

  Temporary breakpoint 1, main () at hello.c:18
  18   printf ("Hello World\n");
  (gdb) break main thread 1
  Breakpoint 2 at 0x401198: file hello.c, line 18.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  2       breakpoint     keep y   0x0000000000401198 in main at hello.c:18
   stop only in thread 1
  (gdb) add-inferior -exec /tmp/hello.x
  [New inferior 2]
  Added inferior 2 on connection 1 (native)
  Reading symbols from /tmp/hello.x...
  (gdb) info breakpoints
  Num     Type           Disp Enb Address    What
  2       breakpoint     keep y   <PENDING>  main
   stop only in thread 1.1

Notice that after creating the second inferior and loading a file the
thread-specific breakpoint was incorrectly made pending.  Loading the
exec file in the second inferior triggered a call to
breakpoint_re_set() with the new, second, program space as the
current_program_space.

This program space ends up being passed to
update_breakpoint_locations().

In update_breakpoint_locations this condition is true:

  if (all_locations_are_pending (b, filter_pspace) && sals.empty ())

and so we end up discarding all of the locations for this breakpoint,
making the breakpoint pending.

What we really want to do in update_breakpoint_locations() is, for
thread- or inferior- specific breakpoints, delete any locations which
are associated with a program space that this breakpoint is NOT
associated with.

But then I realised the answer was easier than that.

The ONLY time that a b/p can have locations associated with the
"wrong" program space like this is at the moment we change the thread
or inferior the b/p is associated with by calling
breakpoint_set_thread() or breakpoint_set_inferior().

And so, I think the correct solution is to hoist the call to
clear_locations() out of update_breakpoint_locations() and place a
call in each of the breakpoint_set_{thread,inferior} functions.

I've done this, and added a couple of new tests.  All of which are
now passing.

Approved-By: Tom Tromey <tom@tromey.com>
8 months ago[gdb/testsuite] Fix gdb.ada/tagged-lookup.exp with read1+readnow
Tom de Vries [Tue, 8 Oct 2024 11:45:21 +0000 (13:45 +0200)] 
[gdb/testsuite] Fix gdb.ada/tagged-lookup.exp with read1+readnow

When running test-case gdb.ada/tagged-lookup.exp with target board readnow and
make target check-read1:
...
$ ( cd build/gdb; \
    make check-read1 \
      RUNTESTFLAGS="--target_board=readnow gdb.ada/tagged-lookup.exp" )
...
I run into:
...
(gdb) PASS: gdb.ada/tagged-lookup.exp: set debug symtab-create 1
print *the_local_var^M
$1 = (n => 2)^M
(gdb) FAIL: gdb.ada/tagged-lookup.exp: only one CU expanded
...

The problem is that the corresponding gdb_test_multiple uses line-by-line
matching (using -lbl) which doesn't work well with the multiline pattern
matching both the prompt and the line before it:
...
    -re -wrap ".* = \\\(n => $decimal\\\)" {
...

Fix this by making it a one-line pattern:
...
    -re -wrap "" {
...

While we're at it, replace an if-then-pass-else-fail with a gdb_assert.

Tested on aarch64-linux.

8 months ago[gdb/symtab] Fix gdb.dwarf2/enum-type-c++.exp with cc-with-debug-types
Tom de Vries [Tue, 8 Oct 2024 10:27:20 +0000 (12:27 +0200)] 
[gdb/symtab] Fix gdb.dwarf2/enum-type-c++.exp with cc-with-debug-types

When running test-case gdb.dwarf2/enum-type-c++.exp with target board
cc-with-debug-types, we run into:
...
(gdb) FAIL: gdb.dwarf2/enum-type-c++.exp: val1 has a parent
...
because val1 has no parent:
...
    [31] ((cooked_index_entry *) 0x7efedc002e90)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0xef
    parent:     ((cooked_index_entry *) 0)

  ...

    [37] ((cooked_index_entry *) 0x38ffd280)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0xef
    parent:     ((cooked_index_entry *) 0)
...

There are two entries, which seems to be an inefficiency, but for now let's
focus on the correctness issue.

The debug info for val1 looks like this:
...
 <1><cb>: Abbrev Number: 2 (DW_TAG_namespace)
    <cc>   DW_AT_name        : ns
    <cf>   DW_AT_declaration : 1
 <2><d3>: Abbrev Number: 12 (DW_TAG_class_type)
    <d4>   DW_AT_name        : A
    <d6>   DW_AT_declaration : 1
 <3><d6>: Abbrev Number: 13 (DW_TAG_enumeration_type)
    <db>   DW_AT_declaration : 1
 <1><dd>: Abbrev Number: 14 (DW_TAG_enumeration_type)
    <e7>   DW_AT_specification: <0xd6>
 <2><ef>: Abbrev Number: 5 (DW_TAG_enumerator)
    <f0>   DW_AT_name        : val1
    <f4>   DW_AT_const_value : 1
...

Fix this by:
- adding a cooked index entry for DIE 0xcb (and consequently for child DIE
  0xd3), by marking it interesting,
- making sure that the entry for DIE 0xcb has a name, and
- using the entry for DIE 0xd3 as parent entry for DIE 0xdd.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
8 months ago[gdb/symtab] Fix parent of enumerator
Tom de Vries [Tue, 8 Oct 2024 10:27:20 +0000 (12:27 +0200)] 
[gdb/symtab] Fix parent of enumerator

As mentioned in commit 489b82720f5 ('[gdb/symtab] Revert "Change handling of
DW_TAG_enumeration_type in DWARF scanner"'), when doing "maint print objfiles" in
test-case gdb.dwarf2/enum-type.exp, for val1 we get an entry without parent:
...
    [27] ((cooked_index_entry *) 0x7fbbb4002ef0)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0x124
    parent:     ((cooked_index_entry *) 0)
...

This happens here in cooked_indexer::index_dies:
...
      info_ptr = recurse (reader, info_ptr,
  is_enum_class ? this_entry : parent_entry,
  fully);
...
when we're passing down a nullptr parent_entry, while the parent of this_entry
is deferred.

Fix this in cooked_indexer::index_dies by passing down a deffered parent
instead, such that we get:
...
    [27] ((cooked_index_entry *) 0x7ff0e4002ef0)^M
    name:       val1^M
    canonical:  val1^M
    qualified:  ns::val1^M
    DWARF tag:  DW_TAG_enumerator^M
    flags:      0x0 []^M
    DIE offset: 0x124^M
    parent:     ((cooked_index_entry *) 0x7ff0e4002f20) [ns]^M
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
8 months ago[gdb/contrib] Fix "sofar->so far" misspelling
Tom de Vries [Tue, 8 Oct 2024 06:24:13 +0000 (08:24 +0200)] 
[gdb/contrib] Fix "sofar->so far" misspelling

I forgot to follow up on a review comment and fix the "sofar->so far"
misspelling [1].

Fix this by adding it to gdb/contrib/common-misspellings.txt.

Tested on x86_64-linux.

[1] https://sourceware.org/pipermail/gdb-patches/2024-September/211894.html

8 months ago[gdb/contrib] Add more separators in spellcheck.sh
Tom de Vries [Tue, 8 Oct 2024 06:24:13 +0000 (08:24 +0200)] 
[gdb/contrib] Add more separators in spellcheck.sh

Add two more separators in spellcheck.sh: colon and comma.

Doing so triggers the "inbetween->between" rule, which gives an incorrect
result.  Override this with "inbetween->between, in between, in-between" [1],
in a new file gdb/contrib/common-misspellings.txt.

Fix the following common misspellings:
...
everytime -> every time
sucess -> success
thru -> through
transfered -> transferred
inbetween -> between, in between, in-between
...

Verified with spellcheck.sh.  Tested on x86_64-linux.

[1] https://www.grammarly.com/blog/commonly-confused-words/in-between-or-inbetween/

8 months ago[gdb/contrib] Factor out grep_or and sed_or in spellcheck.sh
Tom de Vries [Tue, 8 Oct 2024 06:24:13 +0000 (08:24 +0200)] 
[gdb/contrib] Factor out grep_or and sed_or in spellcheck.sh

While trying to add more separators here:
...
 # Separators: space, slash, tab.
 grep_separator=" |/| "
 sed_separator=" \|/\|\t"
...
I mistakingly used "|" instead of "\|" in sed_separator.

Factor out new variables grep_or and sed_or, and construct the grep_separator
and sed_separator variables by joining the elements of a list using grep_or
and sed_or.

Verified with shellcheck, and tested by rerunning on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
8 months agoRevised "Don't return (null) from bfd_elf_sym_name"
Alan Modra [Mon, 7 Oct 2024 23:35:39 +0000 (10:05 +1030)] 
Revised "Don't return (null) from bfd_elf_sym_name"

Commit 68bbe1183379 results in a lot of follow up work, much of which
likely is still to be done. (And yes, since this is all for corrupted
or fuzzed object files, a whole lot of work doesn't much benefit
anyone.  It was a bad idea to put NULL in asymbol->name.)  So I'm
changing the approach to instead put a unique empty string for symbols
with a corrupted st_name.  An empty string won't require much work to
ensure nm, objcopy, objdump etc. won't crash, since these tools
already must work with unnamed local symbols.

The unique empty string is called bfd_symbol_error_name.  This patch
uses that name string for corrupted symbols in the ELF and COFF
backends.  Such symbols are displayed by nm and objdump as the
translated string "<corrupt>", which is what the COFF backend used to
put directly into corrupted symbols.

ie. it's the way I should have written the original patch, plus a few
tides and cleanups I retained from the reverted patches.

8 months agoRevert "Don't return "(null)" from bfd_elf_sym_name"
Alan Modra [Mon, 7 Oct 2024 23:21:37 +0000 (09:51 +1030)] 
Revert "Don't return "(null)" from bfd_elf_sym_name"

This reverts commit 68bbe118337939aa0b52e007a7415c8a157579a1.

8 months agoRevert "bfd_elf_sym_name_raw"
Alan Modra [Mon, 7 Oct 2024 23:21:01 +0000 (09:51 +1030)] 
Revert "bfd_elf_sym_name_raw"

This reverts commit 265757dc6e4d011a1b33ef1b3bfcd7f100f12f64.

8 months agoRevert "get_synthetic_symtab fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:19:26 +0000 (09:49 +1030)] 
Revert "get_synthetic_symtab fixes for commit 68bbe1183379"

This reverts commit 0c13ac533e59589793ee6c8045cff98663f3ea85.

8 months agoRevert "is_target_special_symbol fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:19:14 +0000 (09:49 +1030)] 
Revert "is_target_special_symbol fixes for commit 68bbe1183379"

This reverts commit 6e40f9bb31be2f3656df97a1fcba4d6a30081e24.

8 months agoRevert "dlltool fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:18:27 +0000 (09:48 +1030)] 
Revert "dlltool fixes for commit 68bbe1183379"

This reverts commit 06116013f80e474800cfb122924bc2a6f060606a.

8 months agoRevert "elf.c and elflink.c fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:18:08 +0000 (09:48 +1030)] 
Revert "elf.c and elflink.c fixes for commit 68bbe1183379"

This reverts commit 389fdfbe0d2aca0af1431ddf34704534dacc48c8.

8 months agoRevert "objcopy fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:17:47 +0000 (09:47 +1030)] 
Revert "objcopy fixes for commit 68bbe1183379"

This reverts commit ef166f451fbc2c7b251a251ab23cd35b36c5ee23.

8 months agoRISC-V: Fix implicit dependency of Zabha and Zacas
Xiao Zeng [Tue, 8 Oct 2024 01:10:35 +0000 (09:10 +0800)] 
RISC-V: Fix implicit dependency of Zabha and Zacas

1 Zabha depends on Zaamo:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zabha.adoc>

2 Zacas depends on Zaamo:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zacas.adoc>

bfd/ChangeLog:

* elfxx-riscv.c: Zabha and Zacas implicitly depend on Zaamo.

gas/ChangeLog:

* testsuite/gas/riscv/imply.d: Updated.

Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
8 months agogprofng: add hardware counters for Neoverse-N1 and Ampere-1 processors
Vladimir Mezentsev [Fri, 4 Oct 2024 02:18:08 +0000 (19:18 -0700)] 
gprofng: add hardware counters for Neoverse-N1 and Ampere-1 processors

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

* common/hwc_cpus.h: New constant for Neoverse-N1 and Ampere-1.
* common/hwctable.c: Add the hwc table for Neoverse-N1 and Ampere-1.
* src/hwc_arm_ampere_1.h: New file with hwc table for Ampere-1.
* src/hwc_arm_neoverse_n1.h: New file with hwc table for Neoverse-N1.

8 months agoAutomatic date update in version.in
GDB Administrator [Tue, 8 Oct 2024 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agom68k: Support for jump visualization in disassembly
Andreas Schwab [Thu, 13 Jun 2024 17:41:13 +0000 (19:41 +0200)] 
m68k: Support for jump visualization in disassembly

opcodes/
* m68k-dis.c (m68k_opcode_to_insn_type): Define.
(match_insn_m68k): Call it to set insn_type.
(print_insn_arg) [case 'B']: Set branch target address.
(print_insn_m68k): Set insn_info_valid.

8 months ago[gdb/testsuite] Fix gdb.python/py-inferior.exp with -fsanitize=thread
Tom de Vries [Mon, 7 Oct 2024 08:44:45 +0000 (10:44 +0200)] 
[gdb/testsuite] Fix gdb.python/py-inferior.exp with -fsanitize=thread

With a gdb build with -fsanitize=thread, and test-case
gdb.python/py-inferior.exp I run into:
...
(gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff)^M
ERROR: ThreadSanitizer: requested allocation size 0xffffffffffffffff exceeds \
  maximum supported size of 0x10000000000^M
...

There's already a workaround for this using ASAN_OPTIONS, and apparently the
same is needed for TSAN_OPTIONS.

Add the allocator_may_return_null=1 workaround also in TSAN_OPTIONS.

Likewise in gdb.dap/memory.exp.

Tested on x86_64-linux.

8 months agoAutomatic date update in version.in
GDB Administrator [Mon, 7 Oct 2024 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogdb/m2: add builtin procedure function ADR
Gaius Mulley [Sun, 6 Oct 2024 19:40:59 +0000 (20:40 +0100)] 
gdb/m2: add builtin procedure function ADR

This patch introduces ADR to the Modula-2 language interface.
It return the address of the parameter supplied.
The patch also contains a dejagnu test for ADR.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
8 months agogdb/MAINTAINERS: update my email address
Gaius Mulley [Sun, 6 Oct 2024 19:08:04 +0000 (20:08 +0100)] 
gdb/MAINTAINERS: update my email address

Sync the maintainers file with my new email address.

8 months ago[gdb] Rerun spellcheck.sh
Tom de Vries [Sun, 6 Oct 2024 06:07:31 +0000 (08:07 +0200)] 
[gdb] Rerun spellcheck.sh

Fix the following common misspellings:
...
completetion -> completion
inital -> initial
...

8 months ago[gdb] Fix more common misspellings
Tom de Vries [Sun, 6 Oct 2024 05:59:48 +0000 (07:59 +0200)] 
[gdb] Fix more common misspellings

Fix the following common misspellings:
...
addres -> address, adders
behavour -> behavior, behaviour
intented -> intended, indented
ther -> there, their, the
throught -> thought, through, throughout
...

Tested on x86_64-linux.

8 months ago[gdb] Fix common misspellings
Tom de Vries [Sun, 6 Oct 2024 05:59:48 +0000 (07:59 +0200)] 
[gdb] Fix common misspellings

Fix the following common misspellings:
...
accidently -> accidentally
additonal -> additional
addresing -> addressing
adress -> address
agaisnt -> against
albiet -> albeit
arbitary -> arbitrary
artifical -> artificial
auxillary -> auxiliary
auxilliary -> auxiliary
bcak -> back
begining -> beginning
cannonical -> canonical
compatiblity -> compatibility
completetion -> completion
diferent -> different
emited -> emitted
emiting -> emitting
emmitted -> emitted
everytime -> every time
excercise -> exercise
existance -> existence
fucntion -> function
funtion -> function
guarentee -> guarantee
htis -> this
immediatly -> immediately
layed -> laid
noone -> no one
occurances -> occurrences
occured -> occurred
originaly -> originally
preceeded -> preceded
preceeds -> precedes
propogate -> propagate
publically -> publicly
refering -> referring
substract -> subtract
substracting -> subtracting
substraction -> subtraction
taht -> that
targetting -> targeting
teh -> the
thier -> their
thru -> through
transfered -> transferred
transfering -> transferring
upto -> up to
vincinity -> vicinity
whcih -> which
whereever -> wherever
wierd -> weird
withing -> within
writen -> written
wtih -> with
doesnt -> doesn't
...

Tested on x86_64-linux.

8 months ago[gdb/contrib] Add spellcheck.sh
Tom de Vries [Sun, 6 Oct 2024 05:59:48 +0000 (07:59 +0200)] 
[gdb/contrib] Add spellcheck.sh

I came across a table containing common misspellings [1], and wrote a script to
detect and correct these misspellings.

The table also contains entries that have alternatives, like this:
...
addres->address, adders
...
and for those the script prints a TODO instead.

The script downloads the webpage containing the table, extracts the table and
caches it in .git/wikipedia-common-misspellings.txt to prevent downloading it
over and over again.

Example usage:
...
$ gdb/contrib/spellcheck.sh gdb*
...

ChangeLog files are silently skipped.

Checked with shellcheck.

Tested on x86_64-linux, by running it on the gdb* dirs on doing a build and
test run.

The results of running it are in the two following patches.

Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
[1] https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines

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

8 months agoobjcopy fixes for commit 68bbe1183379
Alan Modra [Sat, 5 Oct 2024 01:26:20 +0000 (10:56 +0930)] 
objcopy fixes for commit 68bbe1183379

* objcopy.c (is_specified_symbol): Handle NULL name.
(filter_symbols): Drop syms with a NULL name.

8 months agoelf.c and elflink.c fixes for commit 68bbe1183379
Alan Modra [Sat, 5 Oct 2024 01:09:17 +0000 (10:39 +0930)] 
elf.c and elflink.c fixes for commit 68bbe1183379

Plus some tidies to swap_out_syms.

* elf.c (swap_out_syms): Handle NULL sym name.  Use correct type
for return of _bfd_elf_strtab_add.  Simplify.
* elflink.c (bfd_elf_match_symbols_in_sections): Handle NULL
sym name.

8 months agoAutomatic date update in version.in
GDB Administrator [Sat, 5 Oct 2024 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogdb segv in elfread.c:elf_rel_plt_read
Alan Modra [Thu, 3 Oct 2024 22:17:05 +0000 (07:47 +0930)] 
gdb segv in elfread.c:elf_rel_plt_read

After commit 68bbe1183379, ELF symbols read via bfd_canonicalize_symtab
and similar functions which have bad st_name fields will have NULL in
the name rather than "(null)".  gdb.base/bfd-errors.exp deliberately
creates a faulty shared library with st_name pointing outside of
.dynsym for some symbols, and thus now results in NULL symbol names.
This triggers a segv on string_buffer.assign(name).  Fix that.

8 months agodlltool fixes for commit 68bbe1183379
Alan Modra [Fri, 4 Oct 2024 12:22:53 +0000 (21:52 +0930)] 
dlltool fixes for commit 68bbe1183379

For some reason, dlltool supports mcore-elf input files.

* dlltool.c (filter_symbols): Drop symbols with NULL names.
(identify_member_contains_symname): Don't consider symbols
with NULL names.

8 months agois_target_special_symbol fixes for commit 68bbe1183379
Alan Modra [Fri, 4 Oct 2024 07:34:59 +0000 (17:04 +0930)] 
is_target_special_symbol fixes for commit 68bbe1183379

* elf.c (_bfd_elf_is_local_label_name): Don't segv on NULL name.
* elf32-v850.c (v850_elf_is_local_label_name): Likewise.
* elfnn-riscv.c (riscv_elf_is_target_special_symbol): Likewise.

8 months agoget_synthetic_symtab fixes for commit 68bbe1183379
Alan Modra [Fri, 4 Oct 2024 04:00:09 +0000 (13:30 +0930)] 
get_synthetic_symtab fixes for commit 68bbe1183379

Given that relocation symbol name can now be NULL for ELF, adjust
various get_synthetic_symtab routines so they don't segfault.

* elf.c (_bfd_elf_get_synthetic_symtab): Cope with sym->name
possibly being NULL.
* elf32-arm.c (elf32_arm_get_synthetic_symtab): Likewise.
* elf32-ppc.c (ppc_elf_get_synthetic_symtab): Likewise.
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise.
* elfxx-mips.c (_bfd_mips_elf_get_synthetic_symtab): Likewise.
* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Likewise.

8 months agobfd_elf_sym_name_raw
Alan Modra [Fri, 4 Oct 2024 07:07:35 +0000 (16:37 +0930)] 
bfd_elf_sym_name_raw

Many uses of bfd_elf_sym_name report errors.  They ought to not return
a NULL, as was the case prior to commit 68bbe1183379.  Introduce a new
function for cases where we'd like to know there is a problem with a
symbol st_name.

* elf-bfd.h  (bfd_elf_sym_name_raw): Declare.
* elf.c (bfd_elf_sym_name_raw): New function.
(bfd_elf_sym_name): Revert to behaviour prior to 68bbe1183379,
but returning "<null>" rather than "(null)" for st_name errors.
(group_signature): Use bfd_elf_sym_name_raw.
* elfcode.h (elf_slurp_symbol_table): Likewise.
* elf32-i386.c (elf_i386_scan_relocs): Whitespace.

8 months agogas: hide emulation struct format_ops instances when not needed
Jan Beulich [Fri, 4 Oct 2024 07:42:45 +0000 (09:42 +0200)] 
gas: hide emulation struct format_ops instances when not needed

Most targets don't even support emulations, so this data (and certain
functions) are entirely dead code for them.

8 months agox86: prune OBJ_MAYBE_... uses
Jan Beulich [Fri, 4 Oct 2024 07:42:13 +0000 (09:42 +0200)] 
x86: prune OBJ_MAYBE_... uses

With the removal of emulations, OBJ_MAYBE_... can no longer be defined.
Tidy code wherever they're used, which also includes the dropping of
most IS_ELF and uses and checks of OUTPUT_FLAVOR.

Where touching such constructs anyway, also drop TE_PEP checks when used
together with TE_PE ones (the former implies the latter).

8 months agox86: drop largely defunct gas emulations
Jan Beulich [Fri, 4 Oct 2024 07:41:38 +0000 (09:41 +0200)] 
x86: drop largely defunct gas emulations

Both ELF and COFF have various sub-flavors, each of which would then
require its own emulation: Right now when configuring a COFF/PE
secondary target (with perhaps an ELF primary one), one gets plain COFF
emulation rather than COFF/PE one.

As such a multitude of emulations would be unwieldy (and likely fragile)
drop gas emulations altogether instead.

8 months agoinclude: de-duplicate i386.h and x86_64.h
Jan Beulich [Fri, 4 Oct 2024 07:39:36 +0000 (09:39 +0200)] 
include: de-duplicate i386.h and x86_64.h

Move common definitions to a new x86.h, thus allowing gas'es obj-coff.h
to include just that, getting rid of a TE_PEP compile-time dependency.

8 months agogas: drop generate_asm_lineno emulation hook
Jan Beulich [Fri, 4 Oct 2024 07:38:05 +0000 (09:38 +0200)] 
gas: drop generate_asm_lineno emulation hook

It's not wired up, so can't be used.

8 months agogas: don't use COFF-specific SF_SET_LOCAL() directly from read.c
Jan Beulich [Fri, 4 Oct 2024 07:37:37 +0000 (09:37 +0200)] 
gas: don't use COFF-specific SF_SET_LOCAL() directly from read.c

Make this a proper obj-format hook instead.

8 months agogas/dw2gencfi: correct .sframe section conditional
Jan Beulich [Fri, 4 Oct 2024 07:36:56 +0000 (09:36 +0200)] 
gas/dw2gencfi: correct .sframe section conditional

While originally this was in preparation of a subsequent change making
SUPPORT_FRAME_LINKONCE potentially dependent on a global variable, the
construct appears unlikely to have been correct in the first place: The
variable would have been passed reliably uninitialized when
SUPPORT_FRAME_LINKONCE is build-time true.

While there correct indentation of the parameters passed to
get_cfi_seg().

8 months agogas: put emul decls in emul.h
Jan Beulich [Fri, 4 Oct 2024 07:36:24 +0000 (09:36 +0200)] 
gas: put emul decls in emul.h

The individual struct emulation instances shouldn't be declared in a .c
file; it and the producers of the symbols want to both see the
declarations, so declarations and definitions don't go out of sync. Move
these declarations to emul.h.

While there also adjust the conditional around this_format: That symbol
is never #define-d anywhere, and it's needed only when USE_EMULATIONS is
defined. (Really, when obj-multi isn't in use, it also is effectively
only ever written to.)

8 months agogas: drop unused fields from struct emulation
Jan Beulich [Fri, 4 Oct 2024 07:35:56 +0000 (09:35 +0200)] 
gas: drop unused fields from struct emulation

Neither .match not .bfd_name appear to ever have been used in the last
about 25 years. Purge them.

8 months agoMAINTAINERS: move M R Swami Reddy to Past Maintainers
Jan Beulich [Fri, 4 Oct 2024 07:34:11 +0000 (09:34 +0200)] 
MAINTAINERS: move M R Swami Reddy to Past Maintainers

He/she cannot be reached at the given address anymore, and the name is
apparently too common to identify the person to attempt to establish
another contact. Sadly this orphans the CR16 and CRx ports.

8 months agoMAINTAINERS: move Matt Thomas to Past Maintainers
Jan Beulich [Fri, 4 Oct 2024 07:33:49 +0000 (09:33 +0200)] 
MAINTAINERS: move Matt Thomas to Past Maintainers

Matt cannot be reached at the @netbsd.org address anymore, and I was
unable to find another one, even with the help of the NetBSD community
(where his resigning was announced over 4 years ago [1]).

[1] http://mail-index.netbsd.org/netbsd-announce/2020/05/07/msg000314.html

8 months agoAutomatic date update in version.in
GDB Administrator [Fri, 4 Oct 2024 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogdb-dap: disable events when deleting breakpoints
oltolm [Sat, 28 Sep 2024 09:35:04 +0000 (11:35 +0200)] 
gdb-dap: disable events when deleting breakpoints

when I disable a breakpoint in VS Code the breakpoint is removed
instead. I compared the behavior to lldb-dap and disabled events when
removing a breakpoint. Now it is possible to disable and enable
breakpoints in VS Code.

8 months agobfd: fix unnecessary bfd.info regen
Alexey Izbyshev [Wed, 2 Oct 2024 19:58:08 +0000 (22:58 +0300)] 
bfd: fix unnecessary bfd.info regen

When building from an unmodified release tarball, a REGEN_TEXI
invocation is supposed to create a symlink to the .texi file
in the source directory and discard the newly generated .tmp file.
However, after commit bd32be01c997 ("bfd: merge doc subdir up a level")
it creates the symlink at the wrong level, and then a .texi with
a fresh timestamp, which in turn forces bfd.info regeneration.
This breaks builds in environments without makeinfo program.

Fix this by creating the symlink at the level of the target stamp.

Fixes: bd32be01c997 ("bfd: merge doc subdir up a level")
Signed-off-by: Alexey Izbyshev <izbyshev@ispras.ru>
8 months agopeicode.h formatting
Alan Modra [Wed, 2 Oct 2024 21:36:32 +0000 (07:06 +0930)] 
peicode.h formatting

Fix some overlong line, comment block style, whitespace issues.

8 months agoEnable dlltool --leading-underscore for targets other than x86
Alan Modra [Wed, 2 Oct 2024 05:09:02 +0000 (14:39 +0930)] 
Enable dlltool --leading-underscore for targets other than x86

This also makes the dlltool tests run more PE targets, finding that
sh-pe dlltool reports "Machine 'sh' not supported".  I guess no one
cares about that.

PR19459
* dlltool.c (asm_prefix): Remove "mach" parameter.  Return
leading_underscore independent of machine.
(ASM_PREFIX): Adjust.
* testsuite/binutils-all/dlltool.exp: Run on any target
satisfying is_pecoff_format for which dlltool is built.
Revert commit 0398b8d6c86a.  Remove target_xfail.

8 months agodlltool leading_underscore
Alan Modra [Wed, 2 Oct 2024 05:04:35 +0000 (14:34 +0930)] 
dlltool leading_underscore

This patch tidies dlltool code dealing with adding a leading
underscore to generated symbol names.  There should be no functional
change here, but there could be if we ever have a bfd target with
symbol_leading_char something other than '_' or 0.

* dlltool.c (leading_underscore): Change from an int to a
        char*.  Update all uses.  If neither --leading-underscore or
        --no=leading-underscore is given, set leading_underscore to a
        string with first char returned by bfd_get_target_info as the
        target's symbol underscoring.

8 months agonm: don't try to print line numbers for symbols without names
Alan Modra [Tue, 1 Oct 2024 23:32:16 +0000 (09:02 +0930)] 
nm: don't try to print line numbers for symbols without names

It doesn't make much sense trying to print line numbers for what are
usually broken symbols, and there is a possibility of a segfault if
we pass strcmp a NULL.

8 months agoDon't return "(null)" from bfd_elf_sym_name
Alan Modra [Tue, 1 Oct 2024 04:38:08 +0000 (14:08 +0930)] 
Don't return "(null)" from bfd_elf_sym_name

A NULL return from bfd_elf_string_from_elf_section indicates an error.
That shouldn't be masked by bfd_elf_sym_name but rather passed up to
callers such as group_signature.  If we want to print "(null)" then
that should be done at a higher level.  That's what this patch does,
except that I chose to print "<null>" instead, like readelf.  If we
see "(null)" we're probably passing a NULL to printf.  I haven't
changed aoutx.h or pdp11.c print_symbol functions because they already
handle NULL names by omitting the name.  I also haven't changed
mach-o.c, mmo.c, som.c, srec.c, tekhex.c, vms-alpha.c and
wasm-module.c print_symbol function because it looks like they will
never have NULL symbol names.

bfd/
* elf.c (bfd_elf_sym_name): Don't turn a NULL name into a
pointer to "(null)".
(bfd_elf_print_symbol): Print "<null>" for NULL symbol names.
* coffgen.c (coff_print_symbol): Likewise.
* ecoff.c (_bfd_ecoff_print_symbol): Likewise.
* pef.c (bfd_pef_print_symbol): Likewise.
* syms.c (bfd_symbol_info): Return "<null>" in symbol_info.name
if symbol name is NULL.
ld/
* ldlang.c (ld_is_local_symbol): Don't check for "(null)"
symbol name.

8 months agoAutomatic date update in version.in
GDB Administrator [Thu, 3 Oct 2024 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogprofng: fix a problem with hardware event counters
Ruud van der Pas [Tue, 24 Sep 2024 19:54:54 +0000 (19:54 +0000)] 
gprofng: fix a problem with hardware event counters

Fix a bug where an experiment with hardware event counter data
causes the source and disassembly files not to be generated.
No longer suppress zero valued metrics and change the name
of the man page in a warning message. Adapt line lengths to
not exceed 79.

gprofng/ChangeLog
2024-09-24  Ruud van der Pas  <ruud.vanderpas@oracle.com>

PR 32193
PR 32199
PR 32201
* gp-display-html/gp-display-html.in: Implement all
the above changes.

8 months agogdb: more file name styling
Andrew Burgess [Tue, 1 Oct 2024 15:55:28 +0000 (16:55 +0100)] 
gdb: more file name styling

While looking at the recent line number styling commit I noticed a few
places where we could add more file name styling.  So lets do that.

Approved-By: Tom Tromey <tom@tromey.com>
8 months agoAdd support for IMPORT_NAME_EXPORTAS in ILF (MSVC style) import libraries
Martin Storsjö [Fri, 20 Sep 2024 21:47:21 +0000 (00:47 +0300)] 
Add support for IMPORT_NAME_EXPORTAS in ILF (MSVC style) import libraries

This import name type is formally yet undocumented, but MSVC
produces/supports it, primarily for ARM64EC import libraries.

LLVM/LLD also supports this import name type. Since recently,
llvm-dlltool also uses this type for certain kinds of renamed imports
(that are easy to do in the long style import libraries produced by
GNU dlltool, but require this name type in short import libraries).

This name type contains a third string, in addition to the symbol
name and the DLL name, indicating the actual imported name to
reference in the import tables - which now can be distinct different
from the symbol name on the object file level.

https://github.com/llvm/llvm-project/commit/8f23464a5d957242c89ca6f33d4379c42519cd81
and
https://github.com/llvm/llvm-project/commit/7b275aa2438c22604505d618dd37ee60052f2800
show how this import name type was added in LLVM.

Signed-off-by: Martin Storsjö <martin@martin.st>
8 months agoAutomatic date update in version.in
GDB Administrator [Wed, 2 Oct 2024 00:00:14 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agoIntroduce and use operation::type_p
Tom Tromey [Wed, 18 Sep 2024 16:25:13 +0000 (10:25 -0600)] 
Introduce and use operation::type_p

There's currently code in gdb that checks if an expression evaluates
to a type.  In some spots this is done by comparing the opcode against
OP_TYPE, but other spots more correctly also compare with OP_TYPEOF
and OP_DECLTYPE.

This patch cleans up this area, replacing opcode-checking with a new
method on 'operation'.

Generally, checking the opcode should be considered deprecated,
although it's unfortunately difficult to get rid of opcodes entirely.

I also took advantage of this change to turn eval_op_type into a
method, removing a bit of indirection.

Reviewed-by: Keith Seitz <keiths@redhat.com>
8 months agoAutomatic date update in version.in
GDB Administrator [Tue, 1 Oct 2024 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agoRe: dlltool: file name too long
Alan Modra [Wed, 25 Sep 2024 01:12:36 +0000 (10:42 +0930)] 
Re: dlltool: file name too long

Allow for "snnnnn.o" suffix when testing against NAME_MAX, and tidy
TMP_STUB handling by overwriting a prior nnnnn.o string rather than
copying the entire name.

* dlltool.c (TMP_STUB): Add "nnnnn.o" to format.
(make_one_lib_file): Localise variables.  Don't copy TMP_STUB,
overwrite suffix instead.
(gen_lib_file): Similarly.
(main): Allow for max suffix when testing against NAME_MAX.

8 months agosegv in read_a_source_file
Alan Modra [Mon, 30 Sep 2024 22:30:32 +0000 (08:00 +0930)] 
segv in read_a_source_file

On some paths through read_a_source file, "s" may not be set.

* read.c (read_a_source_file): Correct code ignoring comment.

8 months agosegv in bfd_elf_get_str_section
Alan Modra [Mon, 30 Sep 2024 22:23:55 +0000 (07:53 +0930)] 
segv in bfd_elf_get_str_section

Attempting to write a termination NUL to PROT_READ mmap'd memory was
a silly idea.

PR 32109
* elf.c (bfd_elf_get_str_section): Don't write terminating NUL
if missing.
* libbfd.c (_bfd_munmap_readonly_temporary): Correct comment.

8 months agoAdd line-number styling
Tom Tromey [Sat, 14 Sep 2024 21:07:17 +0000 (15:07 -0600)] 
Add line-number styling

This patch adds separate styling for line numbers.  That is, whenever
gdb prints a source line number, it uses this style.

v2 includes a change to ensure that %ps works in query.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Keith Seitz <keiths@redhat.com>
8 months agoImprove the placement of orphan note sections.
Nick Clifton [Mon, 30 Sep 2024 13:41:11 +0000 (14:41 +0100)] 
Improve the placement of orphan note sections.

PR 32219

8 months agogdb: fix filename completion in the middle of a line
Andrew Burgess [Thu, 12 Sep 2024 09:56:54 +0000 (10:56 +0100)] 
gdb: fix filename completion in the middle of a line

I noticed that filename completion in the middle of a line doesn't
work as I would expect it too.  For example, assuming '/tmp/filename'
exists, and is the only file in '/tmp/' then when I do the following:

  (gdb) file "/tmp/filen<TAB>

GDB completes to:

  (gdb) file "/tmp/filename"

But, if I type this:

  (gdb) file "/tmp/filen "xxx"

Then move the cursor to the end of '/tmp/filen' and press <TAB>, GDB
will complete the line to:

  (gdb) file "/tmp/filename "xxx"

But GDB will not insert the trailing double quote character.

The reason for this is found in readline/readline/complete.c in the
function append_to_match.  This is the function that appends the
trailing closing quote character, however, the closing quote is only
inserted if the cursor (rl_point) is at the end (rl_end) of the line
being completed.

In this patch, what I do instead is add the closing quote in the
function gdb_completer_file_name_quote, which is called from readline
through the rl_filename_quoting_function hook.  The docs for
rl_filename_quoting_function say (see 'info readline'):

  "... The MATCH_TYPE is either 'SINGLE_MATCH', if there is only one
  completion match, or 'MULT_MATCH'.  Some functions use this to
  decide whether or not to insert a closing quote character. ..."

This is exactly what I'm doing in this patch, and clearly this is not
an unusual choice.  Now after completing a filename that is not at the
end of the line GDB will add the closing quote character if
appropriate.

I have managed to write some tests for this.  I send a line of text to
GDB which includes a partial filename followed by a trailing string, I
then send the escape sequence to move the cursor left, and finally I
send the tab character.

Obviously, expect doesn't actually see the complete output with the
extra text "in place", instead expect sees the original line followed
by some escape sequences to reflect the cursor movement, then an
escape sequence to indicate that text is being inserted in the middle
of a line, followed by the new characters ... it's a bit messy, but I
think it holds together.

Reviewed-By: Tom Tromey <tom@tromey.com>
8 months agogdb: fix for completing a second filename for a command
Andrew Burgess [Fri, 13 Sep 2024 10:16:51 +0000 (11:16 +0100)] 
gdb: fix for completing a second filename for a command

After the recent filename completion changes I noticed that the
following didn't work as expected:

  (gdb) file "/path/to/some/file" /path/to/so<TAB>

Now, I know that the 'file' command doesn't actually take multiple
filenames, but currently (and this was true before the recent filename
completion changes too) the completion function doesn't know that the
command only expects a single filename, and should complete any number
of filenames.  And indeed, this works:

  (gdb) file "/path/to/some/file" "/path/to/so<TAB>

In this case I quoted the second path, and now GDB is happy to offer
completions.

It turns out that the problem in the first case is an off-by-one bug
in gdb_completer_file_name_char_is_quoted.  This function tells GDB if
a character within the line being completed is escaped or not.  An
escaped character cannot be a word separator.

The algorithm in gdb_completer_file_name_char_is_quoted is to scan
forward through the line keeping track of whether we are inside double
or single quotes, or if a character follows a backslash.  When we find
an opening quote we skip forward to the closing quote and then check
to see if we skipped over the character we are looking for, if we did
then the character is within the quoted string.

The problem is that this "is character inside quoted string" check
used '>=' instead if '>'.  As a consequence a character immediately
after a quoted string would be thought of as inside the quoted string.

In our first example this means that the single white space character
after the quoted string was thought to be quoted, and was not
considered a word breaking character.  As such, GDB would not try to
complete the second path.  And indeed, if we tried this:

  (gdb) file "/path/to/some/file"    /path/to/so<TAB>

That is, place multiple spaces after the first path, then GDB would
consider the first space as quoted, but the second space is NOT
quoted, and would be a word break.  Now GDB does complete the second
path.

By changing '>=' to '>' in gdb_completer_file_name_char_is_quoted this
bug is resolved, now the original example works and GDB will correctly
complete the second path.

For testing I've factored out the core of one testing proc, and I now
run those tests multiple times, once with no initial path, once with
an initial path in double quotes, once with an initial path in
single quotes, and finally, with an unquoted initial path.

Reviewed-By: Tom Tromey <tom@tromey.com>
8 months agogdb/MAINTAINERS: add myself to maintainers
Gerlicher, Klaus [Mon, 30 Sep 2024 09:03:57 +0000 (09:03 +0000)] 
gdb/MAINTAINERS: add myself to maintainers

8 months agogdb: Remove myself as x86 maintainer and update my email
Felix Willgerodt [Wed, 25 Sep 2024 13:28:18 +0000 (15:28 +0200)] 
gdb: Remove myself as x86 maintainer and update my email

8 months agogdb, testsuite: clean duplicate header includes
Gerlicher, Klaus [Fri, 13 Sep 2024 07:55:33 +0000 (07:55 +0000)] 
gdb, testsuite: clean duplicate header includes

Some of the gdb and testsuite files double include some headers. While
all headers use include guards, it helps a bit keeping the code base
tidy.

No functional change.

Approved-by: Kevin Buettner <kevinb@redhat.com>
8 months agoAutomatic date update in version.in
GDB Administrator [Mon, 30 Sep 2024 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agoAutomatic date update in version.in
GDB Administrator [Sun, 29 Sep 2024 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months ago[gdb/symtab] Dump m_all_parents_map for verbose debug dwarf-read
Tom de Vries [Sat, 28 Sep 2024 06:35:02 +0000 (08:35 +0200)] 
[gdb/symtab] Dump m_all_parents_map for verbose debug dwarf-read

[ This is based on "[gdb/symtab] Add parent_map::dump" [1]. ]

When building the cooked index, gdb builds up a parent map.

This map is currently only visible at user level through the effect of using
it, but it's useful to be able to inspect it as well.

Add dumping of this parent map for "set debug dwarf-read 2".

As example, take test-case gdb.dwarf2/enum-type-c++.exp with target board
debug-types.

The parent map looks like:
...
$ gdb -q -batch \
    -iex "maint set worker-threads 0" \
    -iex "set debug dwarf-read 2" \
    outputs/gdb.dwarf2/enum-type-c++/enum-type-c++
  ...
[dwarf-read] print_stats: Final m_all_parents_map:
map start:
  0x0000000000000000 0x0
  0x0000000000000037 0x20f27d30 (0x36: ec)
  0x0000000000000051 0x0
  0x000000000000008b 0x20f27dc0 (0x8a: A)
  0x00000000000000a6 0x0
...

There's no parent entry at address 0xd6, which is part of what causes this:
...
(gdb) FAIL: gdb.dwarf2/enum-type-c++.exp: val1 has a parent
...

With the series containing the proposed fix applied [2], we get instead:
...
[dwarf-read] print_stats: Final m_all_parents_map:
map start:
  0x0000000000000000 0x0
  0x0000000000000026 0x7e0bdc0 (0x25: ns)
  0x0000000000000036 0x0
  0x0000000000000037 0x7e0bdf0 (0x36: ns::ec)
  0x0000000000000051 0x0
  0x000000000000007f 0x7e0be80 (0x7e: ns)
  0x000000000000008a 0x0
  0x000000000000008b 0x7e0beb0 (0x8a: ns::A)
  0x00000000000000a6 0x0
  0x00000000000000cc 0x7e0bf10 (0xcb: ns)
  0x00000000000000d4 0x7e0bf40 (0xd3: ns::A)
  0x00000000000000dc 0x7e0bf10 (0xcb: ns)
  0x00000000000000dd 0x7e0bf40 (0xd3: ns::A)
  0x00000000000000f6 0x0
...
and find at 0xd6 parent ns::A.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
[1] https://sourceware.org/pipermail/gdb-patches/2023-October/202883.html
[2] https://sourceware.org/pipermail/gdb-patches/2024-September/211958.html

8 months agogas buffer overflow with --listing-rhs-width
Alan Modra [Fri, 27 Sep 2024 22:33:36 +0000 (08:03 +0930)] 
gas buffer overflow with --listing-rhs-width

With listings enabled, gas keeps a small cache of source lines.  They
are stored in buffers of size LISTING_RHS_WIDTH, ie. 100.  Given
listing-rhs-width larger than 100 it is of course possible to overflow
the buffer.  Fix that by allocating as needed.  We could allocate all
buffers on the first call to print_source using listing_rhs_width, but
I chose not to do that in case some future assembly directive allows
changes to listing_rhs_width similarly to the way paper_width can
change during assembly.

8 months agoMove uses_elf_em to ld-lib.exp
Alan Modra [Fri, 27 Sep 2024 00:22:07 +0000 (09:52 +0930)] 
Move uses_elf_em to ld-lib.exp

and add a missing entry from uses_genelf.

binutils/
* testsuite/lib/binutils-common.exp (uses_elf_em): Delete.
ld/
* testsuite/lib/ld-lib.exp (uses_genelf): Add moxie-*-moxiebox.
(uses_elf_em): New.

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

8 months agoRe-run 'isort' on gdb tests
Tom Tromey [Fri, 27 Sep 2024 19:45:11 +0000 (13:45 -0600)] 
Re-run 'isort' on gdb tests

Re-running 'isort' (via pre-commit) showed that the file
py-read-memory-leak.py (from the gdb test suite) needed a small patch.

8 months agogdb/symtab: pass program space to lookup_symtab and iterate_over_symtabs
Simon Marchi [Mon, 12 Aug 2024 17:46:06 +0000 (13:46 -0400)] 
gdb/symtab: pass program space to lookup_symtab and iterate_over_symtabs

Make the current program space references bubble up.

In collect_symtabs_from_filename, remove the calls to
set_current_program_space and just pass the relevant pspaces.
This appears safe to do, because nothing in the `collector` callback
cares about the current pspace.

Change-Id: I00a7ed484bfbe5264f01a6abf0d33b51de373cbb
Reviewed-by: Keith Seitz <keiths@redhat.com>
8 months agox86: fix Solaris gas testsuite run
Jan Beulich [Fri, 27 Sep 2024 09:41:27 +0000 (11:41 +0200)] 
x86: fix Solaris gas testsuite run

Commits 8015b1b0c1a1 ("x86-64: Never make R_X86_64_GOT64 section
relative"), d774bf9b3623 ("x86: Add tls check in gas"), and
1b714c14e40f ("x86: Turn PLT32 to PC32 only for PC-relative
relocations") all should have adjusted the Solaris counterpart of the
reloc64 test as well.

8 months agoRISC-V: odd data padding vs mapping symbols
Jan Beulich [Fri, 27 Sep 2024 09:41:00 +0000 (11:41 +0200)] 
RISC-V: odd data padding vs mapping symbols

Odd data padding has a $d label inserted at its beginning. When a $x...
label is removed instead, a replacement is inserted after the padding.
The same, however, needs to also happen when there's no $x to replace.

8 months agoRISC-V: correct alignment directive handling for text sections
Jan Beulich [Fri, 27 Sep 2024 09:40:22 +0000 (11:40 +0200)] 
RISC-V: correct alignment directive handling for text sections

.insn or data emitted inside text sections can lead to positions not
being at insn granularity. In such situations using alignment
directives should reliably enforce the requested alignment.
Specifically requests to align back to insn granularity may not be
ignored (where, as a subcase thereof, the ordering of ".option norvc"
and e.g. ".p2align 2" should not matter; so far the alignment directive
needs to come first to have any effect). Similarly ahead of emitting
NOPs alignment first needs to be forced back to insn granularity.

The new testcases actually point out a corner case issue in the
disassembler as well, which is being corrected at the same time: We
don't want to print "0x" without any subsequent digits.

8 months agox86: optimize {,V}INSERTPS with certain immediates
Jan Beulich [Fri, 27 Sep 2024 09:23:12 +0000 (11:23 +0200)] 
x86: optimize {,V}INSERTPS with certain immediates

They are equivalent to simple moves or xors, which are up to 3 bytes
shorter to encode (and maybe/likely also cheaper to execute).

8 months agox86: optimize {,V}EXTRACT{F,I}{128,32x{4,8},64x{2,4}} with immediate 0
Jan Beulich [Fri, 27 Sep 2024 09:22:34 +0000 (11:22 +0200)] 
x86: optimize {,V}EXTRACT{F,I}{128,32x{4,8},64x{2,4}} with immediate 0

They, too, are equivalent to simple moves, which are up to 3 bytes
shorter to encode (and maybe also cheaper to execute).

8 months agox86: optimize {,V}EXTRACTPS with immediate 0
Jan Beulich [Fri, 27 Sep 2024 09:21:51 +0000 (11:21 +0200)] 
x86: optimize {,V}EXTRACTPS with immediate 0

They are equivalent to simple moves, which are up to 2 bytes shorter to
encode (and maybe also cheaper to execute).

8 months agox86: correct {,V}PEXTR{D,Q} optimization
Jan Beulich [Fri, 27 Sep 2024 09:20:37 +0000 (11:20 +0200)] 
x86: correct {,V}PEXTR{D,Q} optimization

A possible relocation associated with a memory operand also needs
moving.

8 months agoEnable -z separate-code, -z common and -z text for more targets
Alan Modra [Fri, 27 Sep 2024 00:23:10 +0000 (09:53 +0930)] 
Enable -z separate-code, -z common and -z text for more targets

Fix a mis-placed "fi".

8 months agoAutomatic date update in version.in
GDB Administrator [Fri, 27 Sep 2024 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agoAdd 'const' to symmisc.c
Tom Tromey [Thu, 26 Sep 2024 23:06:50 +0000 (17:06 -0600)] 
Add 'const' to symmisc.c

I noticed a few spots in symmisc.c that could use a 'const'.

8 months agoFix 32207 [gprofng collect app] Error in parsing the -O option
Vladimir Mezentsev [Wed, 25 Sep 2024 22:31:34 +0000 (15:31 -0700)] 
Fix 32207 [gprofng collect app] Error in parsing the -O option

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

PR 32207
* src/collctrl.cc (preprocess_names): Fix the size in strndup.

8 months agoUpdated Brazilian Portuguese translation for the gprof directory.
Nick Clifton [Thu, 26 Sep 2024 15:11:28 +0000 (16:11 +0100)] 
Updated Brazilian Portuguese translation for the gprof directory.

8 months agoFix -Wstringop-overflow warning in ecoff_link_hash_newfunc
Andreas Schwab [Thu, 26 Sep 2024 11:06:25 +0000 (13:06 +0200)] 
Fix -Wstringop-overflow warning in ecoff_link_hash_newfunc

* ecoff.c (ecoff_link_hash_newfunc): Don't call memset if ret is
NULL.

8 months agold: Ignore .note.gnu.build-id when placing orphaned notes
H.J. Lu [Fri, 20 Sep 2024 03:32:26 +0000 (11:32 +0800)] 
ld: Ignore .note.gnu.build-id when placing orphaned notes

The commits:

e8e10743f7b Add --rosegment option to BFD linker to stop the '-z separate-code' from generating two read-only segments.
bf6d7087de0 ld: Move the .note.build-id section to near the start of the memory map

place .note.gnu.build-id before text sections when --rosegment is used.
Ignore .note.gnu.build-id when placing orphaned notes if --rosegment and
-z separate-code are used together to avoid putting any note sections
between .note.gnu.build-id and text sections in the same PT_LOAD segment.

PR ld/32191
* ldlang.c (lang_insert_orphan): Ignore .note.gnu.build-id when
placing orphaned notes.
* testsuite/ld-elf/pr23658-1a.d: Pass --no-rosegment to ld.
* testsuite/ld-elf/pr23658-1c.d: Likewise.
* testsuite/ld-elf/pr23658-1e.d: New file.
* testsuite/ld-elf/pr23658-1f.d: Likewise.
* testsuite/ld-i386/i386.exp: Run PR ld/32191 test.
* testsuite/ld-i386/pr32191.d: New file.
* testsuite/ld-x86-64/lam-u48.rd: Updated.
* testsuite/ld-x86-64/lam-u57.rd: Likewise.
* testsuite/ld-x86-64/pr32191-x32.d: New file.
* testsuite/ld-x86-64/pr32191.d: Likewise.
* testsuite/ld-x86-64/pr32191.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/32191 tests.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
8 months agox86: templatize SIMD narrowing-move templates
Jan Beulich [Thu, 26 Sep 2024 10:27:14 +0000 (12:27 +0200)] 
x86: templatize SIMD narrowing-move templates

Once again to reduce redundancy.

8 months agox86: templatize SIMD sign-/zero-extension templates
Jan Beulich [Thu, 26 Sep 2024 10:27:01 +0000 (12:27 +0200)] 
x86: templatize SIMD sign-/zero-extension templates

Yet again to reduce redundancy.

8 months agox86: templatize SIMD FP binary-logic templates
Jan Beulich [Thu, 26 Sep 2024 10:26:34 +0000 (12:26 +0200)] 
x86: templatize SIMD FP binary-logic templates

Once more to reduce redundancy.

8 months agox86: further templatize FMA templates
Jan Beulich [Thu, 26 Sep 2024 10:26:15 +0000 (12:26 +0200)] 
x86: further templatize FMA templates

Further reduce redundancy, in preparation of the addition of
counterparts for AVX10.2.

8 months agox86: templatize SIMD FP arithmetic templates
Jan Beulich [Thu, 26 Sep 2024 10:25:45 +0000 (12:25 +0200)] 
x86: templatize SIMD FP arithmetic templates

Reduce redundancy, in preparation of the addition of further counterparts
for AVX10.2. Provide the "ne" parameter needed there right away, even if
unused for now.

8 months agogdb/testsuite: test for memory leaks in gdb.Inferior.read_memory()
Andrew Burgess [Wed, 25 Sep 2024 14:44:56 +0000 (15:44 +0100)] 
gdb/testsuite: test for memory leaks in gdb.Inferior.read_memory()

For a long time Fedora GDB has carried an out of tree patch which
checks for memory leaks in gdb.Inferior.read_memory().  At one point
in the distant past GDB did have a memory leak in this code, but this
was first fixed in commit:

  commit 655e820cf9a039ee55325d9e1f8423796d592b4b
  Date:   Wed Mar 28 17:38:07 2012 +0000

        * python/py-inferior.c (infpy_read_memory): Remove cleanups and
          explicitly free 'buffer' on exit paths.  Decref 'membuf_object'
          before returning.

And the code has changed a lot since then, but the leak is still
fixed.  Unfortunately, this commit didn't have any associated tests.

The original Fedora test wasn't really suitable for upstream, it was
reading /proc/PID/... to figure out if there was a leak or not.

However, we already have gdb.python/py-inferior-leak.exp in upstream
GDB, which makes use of the Python tracemalloc module to check for
memory leaks in a corner of the Python API, so I figured it wouldn't
hurt to rewrite the test in the same style.

And so here is a test for a bug which was closed 12 years ago.  This
detects if the gdb.Inferior.read_memory() call leaks any memory.

I've tested this by hacking gdbpy_buffer_to_membuf, replacing the last
line which currently looks like this:

  return PyMemoryView_FromObject ((PyObject *) membuf_obj.get ());

and instead doing:

  return PyMemoryView_FromObject ((PyObject *) membuf_obj.release ());

The use of "release" here will mean we no longer decrement the
reference count on membuf_obj before returning from the function.  As
a consequence the membuf_obj will not be garbage collected.  With this
hack in place the new test will fail.

The Python script in the new test is mostly a copy&paste from
py-inferior-leak.py with the core changed to do a memory read instead
of inferior creation.  I did consider rewriting both tests into a
single file, maybe, py-memory-leak.py, which would make it easier to
add additional similar tests in the future.  For now I've held off
doing that, but if this gets merged then I _might_ revisit this idea.

If folk feel that this new test should only be accepted if I do this
rewrite then let me know and I can get that done.

On copyright date ranges: The .exp and .py scripts are new enough for
this commit that I've dated them 2024.  The .c source script is lifted
directly from the old Fedora patch, so I've retained the original 2014
start date for that file only.

Approved-By: Tom Tromey <tom@tromey.com>