]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
3 weeks agogdb/dwarf: add more context to complaints in mapped_debug_names_reader::scan_one_entry
Simon Marchi [Mon, 11 May 2026 15:40:32 +0000 (11:40 -0400)] 
gdb/dwarf: add more context to complaints in mapped_debug_names_reader::scan_one_entry

I realize that complaints are not often enabled and shown, but if we
emit them, I think they should include enough context to help a user who
wishes to dig in the problem to pinpoint where the problem happened
exactly.  For this reason, change the complaints in
mapped_debug_names_reader::scan_one_entry to include precisions
regarding which index entry is problematic exactly.

I am not attached to the particular format.  I thought that because this
is extra contextual information, I would put it in the square brackets
at the end (which only shows the module name currently).  However, it
would be nice to converge towards a format that we could replicate
elsewhere in the DWARF reader, so feel free to chime in.

I factored out the formatting to a separate function, because I will be
adding more of these in a subsequent patch, and it's easier to have the
formatting centralized.

I have not touched the "Unsupported .debug_names form" warning.  If that
comes up, we probably don't care about the specific index entry, we just
need to implement support for that form.

Change-Id: Id68a0ae406a3ca620408576b81f893f05c7e3df2
Approved-By: Tom Tromey <tom@tromey.com>
3 weeks agogdb/dwarf: add debug output in read-debug-names.c
Simon Marchi [Mon, 11 May 2026 15:40:31 +0000 (11:40 -0400)] 
gdb/dwarf: add debug output in read-debug-names.c

Add a bunch of debug prints in read-debug-names.c to dump what we are
reading.  Some of if was helpful to me when debugging my changes to the
.debug_names reader and writer.

The debug prints are activated by "set debug dwarf-read" (I didn't feel
like we needed a separate knob for that).  There are two levels of
verbosity.  At level 1, we print everything that happens once, like the
header, counts, offsets of important parts of the index, etc.  At
levels > 1, we print information about each abbrev, CU/TU and index
entry.

The output is made such that it is easy look at the output of readelf of
llvm-dwarfdump on the side and confirm that GDB is reading the index
right.

Here are some examples of the output.

Header and some abbrevs:

    [dwarf-read] read_debug_names_from_section: start: reading .debug_names from /home/simark/build/babeltrace/src/lib/.libs/libbabeltrace2.so.0.0.0
      [dwarf-read] read_debug_names_from_section: section size: 0x19d4e, initial length: 0x19d4a, dwarf64: 0, offset_size: 4
      [dwarf-read] read_debug_names_from_section: version: 5
      [dwarf-read] read_debug_names_from_section: cu_count: 56, tu_count: 0, foreign_tu_count: 0
      [dwarf-read] read_debug_names_from_section: bucket_count: 0, name_count: 3418, abbrev_table_size: 374, augmentation_string_size: 8
      [dwarf-read] read_debug_names_from_section: augmentation string: "GDB3\x00\x00\x00\x00"
      [dwarf-read] read_debug_names_from_section:   abbrev 1: tag DW_TAG_namespace, 4 attributes
      [dwarf-read] read_debug_names_from_section:     DW_IDX_compile_unit DW_FORM_udata
      [dwarf-read] read_debug_names_from_section:     DW_IDX_die_offset DW_FORM_ref_addr
      [dwarf-read] read_debug_names_from_section:     DW_IDX_GNU_language DW_FORM_udata
      [dwarf-read] read_debug_names_from_section:     DW_IDX_parent DW_FORM_data4
      [dwarf-read] read_debug_names_from_section:   abbrev 2: tag DW_TAG_enumerator, 4 attributes
      [dwarf-read] read_debug_names_from_section:     DW_IDX_compile_unit DW_FORM_udata
      [dwarf-read] read_debug_names_from_section:     DW_IDX_die_offset DW_FORM_ref_addr
      [dwarf-read] read_debug_names_from_section:     DW_IDX_GNU_language DW_FORM_udata
      [dwarf-read] read_debug_names_from_section:     DW_IDX_GNU_internal DW_FORM_flag_present

Excerpt of the CU list:

    [dwarf-read] build_and_check_cu_list_from_debug_names: building CU list from .debug_names (56 CUs)
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 0: offset 0x0
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 1: offset 0x1bac
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 2: offset 0x4262
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 3: offset 0x4ff0
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 4: offset 0x59e9
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 5: offset 0x67af
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 6: offset 0x8e1a
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 7: offset 0xa5cc
    [dwarf-read] build_and_check_cu_list_from_debug_names:   CU 8: offset 0xcd39

Some entries:

    [dwarf-read] scan_all_names: start: scanning 3418 names from .debug_names
      [dwarf-read] scan_entries: scanning entries for name 1: "(anonymous namespace)" (entry pool offset 0x0)
      [dwarf-read] scan_one_entry:   entry pool offset 0x0: abbrev 1, tag DW_TAG_namespace
      [dwarf-read] scan_one_entry:     DW_IDX_compile_unit (DW_FORM_udata): 55
      [dwarf-read] scan_one_entry:     DW_IDX_die_offset (DW_FORM_ref_addr): 0x7d06b
      [dwarf-read] scan_one_entry:     DW_IDX_GNU_language (DW_FORM_udata): 33
      [dwarf-read] scan_one_entry:     DW_IDX_parent (DW_FORM_data4): 38201
      [dwarf-read] scan_one_entry:     -> die_offset 0x7d06b, per_cu offset 0x5af0e
      [dwarf-read] scan_one_entry:   entry pool offset 0xb: end of entries (abbrev 0)
      [dwarf-read] scan_entries: scanning entries for name 2: "AUTO_SEEK_STREAM_STATE_PACKET_BEGAN" (entry pool offset 0xc)
      [dwarf-read] scan_one_entry:   entry pool offset 0xc: abbrev 2, tag DW_TAG_enumerator
      [dwarf-read] scan_one_entry:     DW_IDX_compile_unit (DW_FORM_udata): 17
      [dwarf-read] scan_one_entry:     DW_IDX_die_offset (DW_FORM_ref_addr): 0x1beea
      [dwarf-read] scan_one_entry:     DW_IDX_GNU_language (DW_FORM_udata): 29
      [dwarf-read] scan_one_entry:     DW_IDX_GNU_internal (DW_FORM_flag_present): 1
      [dwarf-read] scan_one_entry:     -> die_offset 0x1beea, per_cu offset 0x1a28e
      [dwarf-read] scan_one_entry:   entry pool offset 0x13: end of entries (abbrev 0)

Change-Id: I4a40bfb73fa7feccb5038814a7d1a1bcd4f6231b
Approved-By: Tom Tromey <tom@tromey.com>
3 weeks agogdb/dwarf: generate foreign type units in .debug_names
Simon Marchi [Mon, 11 May 2026 15:40:30 +0000 (11:40 -0400)] 
gdb/dwarf: generate foreign type units in .debug_names

The DWARF 5 .debug_names index makes the distinction between local type
units and foreign type units.  Local type units are those present
directly in the main file.  Foreign type units are those present in .dwo
files.  GDB only knows how to produce local type units today, which
leads to invalid indexes whenever there are type units in .dwo files.

To observe this, run test gdb.dwarf2/fission-with-type-unit.exp with
board cc-with-debug-names.  The test passes, but we see this in the log:

    (gdb) file
/home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/fission-with-type-unit/fission-with-type-unit^M
    Reading symbols from
/home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/fission-with-type-unit/fission-with-type-unit...^M
    warning: Section .debug_names has incorrect entry in TU table,
ignoring .debug_names.^M

These are the units involved in this test.  The first and last CUs are
dummy CUs added by the DWARF assembler, they are not important.

  - CU at offset 0x0  of .debug_info     in fission-with-type-unit -- dummy
  - CU at offset 0xc  of .debug_info     in fission-with-type-unit
  - CU at offset 0x25 of .debug_info     in fission-with-type-unit -- dummy
  - TU at offset 0x0  of .debug_info.dwo in fission-with-type-unit-dw.dwo

This is the content of the produced .debug_names:

Contents of the .debug_names section:

    $ readelf --debug-dump=gdb_index testsuite/outputs/gdb.dwarf2/fission-with-type-unit/fission-with-type-unit
    ...
    Version 5
    Augmentation string: 47 44 42 33 00 00 00 00  ("GDB3")
    CU table:
    [  0] 0
    [  1] 0xc
    [  2] 0x25

    TU table:
    [  0] 0

    Foreign TU table:

    Used 0 of 0 buckets.

    Symbol table:
    [  1] global_var: <0><1> DW_TAG_variable DW_IDX_compile_unit=(udata)=1 DW_IDX_die_offset=(ref_addr)=<0x1c> DW_IDX_GNU_language=(udata)=0 DW_IDX_GNU_internal=(flag_present)=1
    [  2] int:
            <0x8><2> DW_TAG_base_type DW_IDX_compile_unit=(udata)=1 DW_IDX_die_offset=(ref_addr)=<0x15> DW_IDX_GNU_language=(udata)=0
            <0xf><3> DW_TAG_base_type DW_IDX_type_unit=(udata)=0 DW_IDX_die_offset=(ref_addr)=<0x19> DW_IDX_GNU_language=(udata)=0

The TU table claims that there is a TU at offset 0 in the main file
(fission-with-type-unit).  This is wrong: the TU is in
fission-with-type-unit-dw.dwo.  It should be listed in the Foreign TU
table instead.

This patch therefore teaches GDB to use the foreign TU table for TUs in
.dwo files.

A note about foreign type units and skeletons: in the early history of
split DWARF and type units, gcc 4.x used to create skeletons for type
units in .dwo files, but subsequent versions don't.  DWARF 5 doesn't
have support for type unit skeletons at all.  So skeletons for type
units are mostly a historical curiosity at this point, the norm is to
not have them.  But if for some reason a type unit in a .dwo file had a
matching skeleton in the main file, then it would be ok for that TU to
be listed in the "TU table".  The offset would be that of the skeleton.

While the list of CUs and local TUs contain the offset within the
.debug_info section where to find the unit, the foreign TU list only
contains the 8-byte signature of the types.  With just that, a reader
wouldn't be able to easily locate a .dwo that contain the type with a
given signature.

To help with this, index entries for foreign type units may also include
a reference to a compilation unit that can be followed in order to find
a .dwo file containing the type.  This patch implements it.

Implementation details
----------------------

The first change is the addition of the dwo_unit::per_cu field, which
allows going from the dwo_unit to the dwarf2_per_cu structure (which
describes the skeleton) that was used to lookup this dwo_unit.  This
fields starts at nullptr, and it gets set in lookup_dwo_cutu whenever we
look up the dwo_unit for a given dwarf2_per_cu.  This will come handy
later.  I made this field an std::atomic, because I think it would be
possible to craft a weird test case that would make two indexer threads
try to set the field on the same dwo_unit.  During normal operation, we
expect the field for each dwo_unit representing a CU to be written
exactly once.

In index-write.c, change the get_unit_lists function in
dwarf2/index-write.c to segregate local and foreign type units.  Then,
update write_debug_names to emit the list of foreign TUs in the
.debug_names header.  This consists of a list of type signatures.

In debug_names::build, for foreign type units, emit a
DW_IDX_compile_unit field.  This is the reference to the CU that can be
used to locate the .dwo file containing that type unit.  To obtain the
value for this field, look up a CU in the same dwo_file that has its
dwo_unit::per_cu field set (typically there will be exactly one CU, and
the field will be set).

With this patch, the index for the test case above looks like:

    $ readelf --debug-dump=gdb_index testsuite/outputs/gdb.dwarf2/fission-with-type-unit/fission-with-type-unit
    ...
    Version 5
    Augmentation string: 47 44 42 33 00 00 00 00  ("GDB3")
    CU table:
    [  0] 0
    [  1] 0xc
    [  2] 0x25

    TU table:

    Foreign TU table:
    [  0] 000000000000cafe

    Used 0 of 0 buckets.

    Symbol table:
    [  1] global_var: <0><1> DW_TAG_variable DW_IDX_compile_unit=(udata)=1 DW_IDX_die_offset=(ref_addr)=<0x1c> DW_IDX_GNU_language=(udata)=0 DW_IDX_GNU_internal=(flag_present)=1
    [  2] int:
            <0x8><2> DW_TAG_base_type DW_IDX_compile_unit=(udata)=1 DW_IDX_die_offset=(ref_addr)=<0x15> DW_IDX_GNU_language=(udata)=0
            <0xf><3> DW_TAG_base_type DW_IDX_type_unit=(udata)=0 DW_IDX_compile_unit=(udata)=1 DW_IDX_die_offset=(ref_addr)=<0x19> DW_IDX_GNU_language=(udata)=0   ...

We can see that the TU is correctly placed in the foreign TU list, and
that the index entry (the last line) points to the TU at index 0, but
also to the CU at index 1, which is indeed the CU that the reader can
follow to find the type unit.

With this patch, GDB still rejects the index:

    (gdb) file /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/fission-with-type-unit/fission-with-type-unit
    Reading symbols from /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/fission-with-type-unit/fission-with-type-unit...
    warning: Section .debug_names in /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/fission-with-type-unit/fission-with-type-unit has unsupported 1 foreign TUs, ignoring .debug_names.

But at least, we don't produce a bogus index anymore, that's already an
improvement.  A following patch in this series implements the reading
side

Change-Id: I311fd7b4ca57d9ff6d64ae08df805c6635961eed
Approved-By: Tom Tromey <tom@tromey.com>
3 weeks agogdb/dwarf: add dwo_file::find_tus
Simon Marchi [Mon, 11 May 2026 15:40:29 +0000 (11:40 -0400)] 
gdb/dwarf: add dwo_file::find_tus

Add this little helper to make finding a TU a bit simpler.  I always
find the STL way of doing things cryptic, so I think that hiding it in
small helper methods makes the code clearer.

A subsequent patch will add more uses of it

Change-Id: Ibfb20d0e44c65d2ff729f3e0980ec4435f223aef
Approved-By: Tom Tromey <tom@tromey.com>
3 weeks agogdb/dwarf: move dwarf2_cu::section to cu.c
Simon Marchi [Mon, 11 May 2026 15:40:28 +0000 (11:40 -0400)] 
gdb/dwarf: move dwarf2_cu::section to cu.c

Following the previous patch that moves the dwo_unit structure from
dwarf2/read.c to dwarf2/dwo.h, dwarf2_cu::section has no reason to be
implemented in dwarf2/read.c anymore.  Move it to dwarf2/cu.c.

Change-Id: I67e2bb42d878ac18e4bf3460d75f1394477a46ce
Approved-By: Tom Tromey <tom@tromey.com>
3 weeks agogdb/dwarf: move dwo_unit and dwo_file to dwo.h
Simon Marchi [Mon, 11 May 2026 15:40:27 +0000 (11:40 -0400)] 
gdb/dwarf: move dwo_unit and dwo_file to dwo.h

Move these types and some related things to a new dwo.h header file.  My
goal is to allow index-write.c to see these types, in a later patch.  I
initially moved them to read.h, but Tom suggested in review that read.h
was getting a bit too large.

Change-Id: Ia32e0643f95561d3a1bfb67d501c8e20f5682f0e
Approved-By: Tom Tromey <tom@tromey.com>
3 weeks agogdb/doc: split 'AMD GPU' and 'AMD ROCm' acronyms
Tankut Baris Aktemur [Wed, 13 May 2026 11:49:45 +0000 (06:49 -0500)] 
gdb/doc: split 'AMD GPU' and 'AMD ROCm' acronyms

Split @acronym{AMD GPU} into @acronym{AMD} @acronym{GPU},
and @acronym{AMD ROCm} into @acronym{AMD} @acronym{ROCm}.

Approved-By: Eli Zaretskii <eliz@gnu.org>
3 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 13 May 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 12 May 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 weeks agoinclude/elf: fix order of AMDGPU constants
Simon Marchi [Fri, 8 May 2026 20:55:56 +0000 (16:55 -0400)] 
include/elf: fix order of AMDGPU constants

This list is meant to be in order of value.

Change-Id: I9d181f656823a83df673bfd851e95fb35d7d0f3a

3 weeks agogdb/amd-dbgapi-target: assert register size in fetch/store_registers
Tankut Baris Aktemur [Mon, 11 May 2026 11:57:45 +0000 (06:57 -0500)] 
gdb/amd-dbgapi-target: assert register size in fetch/store_registers

Assert that register size is not larger than the max register size as
a safety measure against buffer overflow.

Approved-by: Lancelot Six <lancelot.six@amd.com>
3 weeks agogcore: handle known-all-zeroes hole mappings
Pedro Alves [Mon, 23 Mar 2026 21:54:12 +0000 (21:54 +0000)] 
gcore: handle known-all-zeroes hole mappings

This commit improves core generation on Linux.  The issue this
addresses became apparent when dumping core of HIP programs on AMD
GPUs, but it's strictly a CPU-side issue.

The AMD GPU runtime used by HIP (and other languages) programs creates
these big mappings in every program, the size of GPU VRAM.  E.g., on
gfx942 with 256GB VRAM, we end up with 256GB of such mappings:

  (gdb) info proc mappings
  ...
  0x00007fbfe7000000 0x00007fc7e7000000 0x800000000        0x0                ---p
  0x00007fc7e7200000 0x00007fcfe7200000 0x800000000        0x0                ---p
  0x00007fcfe7400000 0x00007fd7e7400000 0x800000000        0x0                ---p
  0x00007fd7e7600000 0x00007fdfe7600000 0x800000000        0x0                ---p
  0x00007fdfe7800000 0x00007fe7e7800000 0x800000000        0x0                ---p
  0x00007fe7e7a00000 0x00007fefe7a00000 0x800000000        0x0                ---p
  0x00007fefe7c00000 0x00007ff7e7c00000 0x800000000        0x0                ---p
  ...

They show up like this in /proc/pid/smaps

  ...
  7fbfe7000000-7fc7e7000000 ---p 00000000 00:00 0
  Size:           33554432 kB
  KernelPageSize:        4 kB
  MMUPageSize:           4 kB
  Rss:                   0 kB
  Pss:                   0 kB
  Pss_Dirty:             0 kB
  Shared_Clean:          0 kB
  Shared_Dirty:          0 kB
  Private_Clean:         0 kB
  Private_Dirty:         0 kB
  Referenced:            0 kB
  Anonymous:             0 kB
  KSM:                   0 kB
  LazyFree:              0 kB
  AnonHugePages:         0 kB
  ShmemPmdMapped:        0 kB
  FilePmdMapped:         0 kB
  Shared_Hugetlb:        0 kB
  Private_Hugetlb:       0 kB
  Swap:                  0 kB
  SwapPss:               0 kB
  Locked:                0 kB
  THPeligible:           0
  ProtectionKey:         0
  VmFlags: mr mw me nr sd
  ...

Note the mappings in question have no backing data: the Rss: and Swap:
fields are zero.  The mappings exist only to reserve VMAs on the CPU
side.

When the Linux kernel itself dumps core for such a process, here's
what objdump -h on the core shows for such mappings:

 Idx Name          Size      VMA               LMA               File off  Algn
 ...
 39 load17        800000000  000070aeb3200000  0000000000000000  17555000  2**12
                  ALLOC, READONLY
 40 load18        800000000  000070b6b3400000  0000000000000000  17555000  2**12
                  ALLOC, READONLY
 ...

GDB's gcore, not knowing the mappings contain only zeroes, reads all
their contents from inferior memory, all 256GB of it.  On gfx942, that
makes the gcore command take around 1 minute when dumping a small HIP
program.

GDB's gcore currently generates load segments of these mappings like
this:

 Idx Name          Size      VMA               LMA               File off  Algn
 ...
 40 load17        800000000  00007fcfe7400000  0000000000000000  101e0a7bd0  2**0

  CONTENTS, ALLOC, LOAD, READONLY

 41 load18        800000000  00007fd7e7600000  0000000000000000  181e0a7bd0  2**0

  CONTENTS, ALLOC, LOAD, READONLY
 ...

The fact that GDB makes CONTENTS/LOAD segments makes it so that the
resulting core files are much larger than what the Linux kernel
produces (note "File off" column), even though it's mostly apparent
size as gdb knows how to produce sparse cores:

 $ ls -als --hu core/*
 440M -rw------- 1 pedalves pedalves 474M Mar 24 08:14 core/kernel.core
  51M -rw-rw-r-- 1 pedalves pedalves 257G Mar 24 08:16 core/gdb-before.core
 ^^^^ real                           ^^^^ apparent

This commit teaches linux-tdep.c to identify anonymous mappings that
have no backing data from /proc/pid/smaps (which we already parse), so
that the gcore code can skip reading inferior memory for them, and
their load segments can be emitted with no CONTENTS/LOAD.

The skip-reading-inferior-memory part speeds up core dumping of small
HIP inferiors on gfx942 GPUs by a large factor.  E.g.:

With:

 $ time rocgdb --batch -q small-test-program \
      -ex "with breakpoint pending on -- b gpu_code" \
      -ex "r" \
      -ex "gcore" \
      -ex "k"

On gfx942, before the patch:

 real    1m6.518s
 user    0m5.984s
 sys     1m0.218s

On gfx942, after the patch:

 real    0m4.456s
 user    0m2.219s
 sys     0m1.829s

And the fact that we no longer emit segments with CONTENTS/LOAD makes
the resulting gdb-generated cores's apparent size be much smaller,
closer to kernel-generated core file's:

 $ ls -als --hu core/*
 440M -rw------- 1 pedalves pedalves 474M Mar 24 08:14 core/kernel.core
  51M -rw-rw-r-- 1 pedalves pedalves 257G Mar 24 08:16 core/gdb-before.core
  52M -rw-rw-r-- 1 pedalves pedalves 642M Mar 24 09:12 core/gdb-after.core

This commit also adds a new testcase that exercises both the scenario
in question (without relying on the HIP runtime), and the converse of
making sure that we don't skip dumping anonymous private PROT_NONE
mappings with backing data, by mistake.

Approved-By: Andrew Burgess <aburgess@redhat.com>
Change-Id: I2cf21409af36266094bcff5614770605fab4030e
commit-id: d3d471d8

3 weeks agogdb/amd-dbgapi-target: fix a whitespace and a typo
Tankut Baris Aktemur [Mon, 11 May 2026 11:14:02 +0000 (06:14 -0500)] 
gdb/amd-dbgapi-target: fix a whitespace and a typo

Fix a minor whitespace issue and a typo in file
gdb/amd-dbgapi-target.c.

3 weeks agogdb/MAINTAINERS: update my email address
Tankut Baris Aktemur [Mon, 11 May 2026 10:56:07 +0000 (05:56 -0500)] 
gdb/MAINTAINERS: update my email address

3 weeks ago[gdb/testsuite] Fix gdb.dap/corefile.exp with Tcl 9.0
Tom de Vries [Mon, 11 May 2026 09:50:13 +0000 (11:50 +0200)] 
[gdb/testsuite] Fix gdb.dap/corefile.exp with Tcl 9.0

With test-case gdb.dap/corefile.exp and Tcl 9.0 I run into:
...
ERROR: tcl error sourcing gdb/testsuite/gdb.dap/corefile.exp.
ERROR: tcl error code TCL LOOKUP VARNAME reg_name
ERROR: can't read "reg_name": no such variable
    while executing
"s \$$reg_name"
    (in namespace eval "::ton::2json" script line 1)
    invoked from within
"namespace eval ton::2json $obj"
...

Fix this by making clear that reg_name is a variable in the global namespace.

Likewise for variable new_value.

Tested on aarch64-linux.

3 weeks agogdb: update store_integer's comment
Tankut Baris Aktemur [Thu, 8 Jan 2026 15:16:09 +0000 (15:16 +0000)] 
gdb: update store_integer's comment

The comment of store_integer seems slightly outdated and does not refer to
the variants that take an array view.  Update the comment and add comments
to the various instantiations.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
3 weeks agogdb: use correct target in notify_thread_exited()
Markus Metzger [Fri, 24 Apr 2026 13:11:07 +0000 (13:11 +0000)] 
gdb: use correct target in notify_thread_exited()

clean_up_just_stopped_threads_fsms() may call notify_thread_exited() in
the context of a thread from a different target.

Switch to the thread's inferior to get the target right.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
3 weeks agogdb, remote: fix notify debug nullptr dereference
Markus Metzger [Tue, 10 Mar 2026 05:44:18 +0000 (05:44 +0000)] 
gdb, remote: fix notify debug nullptr dereference

In remote_target:push_stop_reply, notif debug prints an element that has
been moved.  Print the element at the destination, instead.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
3 weeks agoRemove support for the Common Trace Format (CTF)
Sergio Durigan Junior [Sun, 10 May 2026 02:15:38 +0000 (22:15 -0400)] 
Remove support for the Common Trace Format (CTF)

Hi there,

The Debian maintainer of babeltrace (Michael, in CC) is working
towards removing the version 1 package from the archive in favour of
version 2.  This makes sense as version 1 is unsupported and projects
should move to version 2.

While digging through the archives I found PR buid/27142 (from
Matthias, also in Cc) which was filed 5 years ago requesting GDB to
support babeltrace v2.  At the time Simon started a thread on gdb@
suggesting that we should actually remove the support for CTF (Common
Trace Format) altogether, since it's a niche feature (CTF) within a
niche feature (tracepoints) and apparently GDB itself records CTF data
in an unconventional way that might break other tools.  You can see
the thread here:

  https://inbox.sourceware.org/gdb/3fb1fbb6-836a-0e39-73a9-ef721630da88@polymtl.ca/

Long story short, the consensus seems to be that CTF support is ripe
to be removed, so that's what this patch does.  I think I covered all
places that referred to either CTF or babeltrace; I recompiled GDB
here and things are still working as expected.  I ran the tests I
touched and there are some failures, but they're unrelated to CTF and
I could reproduce them in a pristine tree as well.

I've been a bit distant from the community so I don't know whether we
have a specific procedure to remove features from GDB.  I remember
that when we removed support for an architecture, we used to deprecate
it in release N and then proceed with the removal on release N+1.  Not
sure if this is applicable here, but let me know.

Either way, I intend to disable support for babeltrace on Debian's GDB
soon.

WDYT?

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27142
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
3 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 11 May 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 10 May 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agoHaiku/testsuite: Mark target as ELF
Maciej W. Rozycki [Sat, 9 May 2026 14:40:11 +0000 (15:40 +0100)] 
Haiku/testsuite: Mark target as ELF

All the Haiku targets are ELF:

$ sed -n '/haiku/{n;p}' < bfd/config.bfd
    targ_defvec=aarch64_elf64_le_vec
    targ_defvec=arm_elf32_le_vec
    targ_defvec=x86_64_elf64_vec
    targ_defvec=i386_elf32_vec
    targ_defvec=m68k_elf32_vec
    targ_defvec=mips_elf32_le_vec
    targ_defvec=powerpc_elf32_vec
    targ_defvec=sparc_elf64_vec
$

so update `is_elf_format' accordingly, complementing commit d85e70a35bff
("Add support for the haiku operating system.") and fixing regressions:

aarch64-haiku  -FAIL: GNU attributes v1/v2: no support for directive .gnu_attribute
aarch64-haiku  -FAIL: GNU attributes v2: no support for directive .gnu_subsection
arm-haiku  -FAIL: GNU attributes v1/v2: no support for directive .gnu_attribute
m68k-haiku  -FAIL: GNU attributes v1/v2: no support for directive .gnu_attribute
mipsel-haiku  -FAIL: GNU attributes v1/v2: no support for directive .gnu_attribute
powerpc-haiku  -FAIL: GNU attributes v1/v2: no support for directive .gnu_attribute
sparc64-haiku  -FAIL: GNU attributes v1/v2: no support for directive .gnu_attribute
sparc64-haiku  -FAIL: sparc relax CALL (a.out)

while widely broadening coverage, e.g. with `i486-haiku' we now get:

=== binutils Summary ===

# of expected passes 230
# of untested testcases 18
# of unsupported tests 21

=== gas Summary ===

# of expected passes 1066
# of unsupported tests 16

=== ld Summary ===

# of expected passes 595
# of expected failures 2
# of untested testcases 26
# of unsupported tests 215

vs:

=== binutils Summary ===

# of expected passes 77
# of untested testcases 13
# of unsupported tests 11

=== gas Summary ===

# of expected passes 806
# of unsupported tests 4

=== ld Summary ===

# of expected passes 188
# of expected failures 2
# of untested testcases 16
# of unsupported tests 62

The following regressions yet need to be addressed:

arm-haiku  +FAIL: bad .bss / .struct data allocation directives
arm-haiku  +FAIL: VFP11 denorm erratum fix, scalar operation
arm-haiku  +FAIL: VFP11 denorm erratum fix, vector operation
arm-haiku  +FAIL: script-type
arm-haiku  +FAIL: Branch future relocations for armv8.1-m.main target
arm-haiku  +FAIL: Mixed ARM/Thumb arch5 dynamic application
arm-haiku  +FAIL: Thumb-2-as-Thumb-1 BL
arm-haiku  +FAIL: Thumb-2 BL bad noeabi
arm-haiku  +FAIL: .noinit sections
arm-haiku  +FAIL: .persistent sections
m68k-haiku  +FAIL: DT_TEXTREL map file warning
m68k-haiku  +FAIL: pr20995
m68k-haiku  +FAIL: pr20995-2
powerpc-haiku  +FAIL: Build pr20995-2.so
powerpc-haiku  +FAIL: pr20995-2

There are the usual regressions with `mipsel-haiku' as well coming from
the use of the IRIX variant of the ELF format, to be handled separately.

4 weeks agoi386/Haiku/GAS/testsuite: Suppress SVR4 comment character test
Maciej W. Rozycki [Sat, 9 May 2026 14:40:11 +0000 (15:40 +0100)] 
i386/Haiku/GAS/testsuite: Suppress SVR4 comment character test

Exclude the SVR4 comment character test on Haiku targets, as `/' is not
a comment character there (cf. gas/config/te-haiku.h), so as to prevent
a regression caused by enabling ELF tests with Haiku targets:

i486-haiku  +FAIL: SVR4 comment char escape handling

4 weeks agoAarch64/Haiku/binutils/testsuite: Suppress PEI test
Maciej W. Rozycki [Sat, 9 May 2026 14:40:11 +0000 (15:40 +0100)] 
Aarch64/Haiku/binutils/testsuite: Suppress PEI test

There is no PEI BFD target included by default with the Haiku target
configuration, so exclude the EFI test, preventing a regression caused
by enabling ELF tests with Haiku targets:

aarch64-haiku  +FAIL: Check if efi app format is recognized

4 weeks agoMIPS/Haiku/LD/testsuite: Set the correct emulation and flags
Maciej W. Rozycki [Sat, 9 May 2026 14:40:11 +0000 (15:40 +0100)] 
MIPS/Haiku/LD/testsuite: Set the correct emulation and flags

The Haiku target has its own LD emulation and uses the IRIX ELF variant.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 9 May 2026 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agogdb: refuse to produce .gdb_index when skeletonless type units are present
Simon Marchi [Mon, 10 Nov 2025 21:19:40 +0000 (16:19 -0500)] 
gdb: refuse to produce .gdb_index when skeletonless type units are present

Running test gdb.dwarf2/fission-with-type-unit.exp with the
cc-with-gdb-index target board fails with:

    (gdb) maint expand-symtabs
    /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:3064: internal-error: cutu_reader: Assertion `sig_type->signature == cu->header.signature' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    ----- Backtrace -----
    FAIL: gdb.dwarf2/fission-with-type-unit.exp: maint expand-symtabs (GDB internal error)

This is a consequence of .gdb_index not supporting skeletonless type
units in .dwo files.  That is, type units in .dwo files that don't have
a corresponding skeleton (or stub) in the main file.

For context: in DWARF 4, gcc 4.x used to create skeletons for type units
in .dwo files, but subsequent versions don't.  DWARF 5 doesn't have
support for type unit skeletons at all.  So skeletons for type units are
mostly a historical curiosity at this point, the norm is to not have
them.

Here's what leads up to the crash.  First, this is what is in the main
file's .debug_info section (the first and last CUs are dummy CUs added
by the testsuite):

      Compilation Unit @ offset 0:
       Length:        0x8 (32-bit)
       Version:       4
       Abbrev Offset: 0
       Pointer Size:  8
     <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)

      Compilation Unit @ offset 0xc:
       Length:        0x15 (32-bit)
       Version:       5
       Unit Type:     DW_UT_skeleton (4)
       Abbrev Offset: 0x6
       Pointer Size:  8
       DWO ID:        0xf00d
     <0><20>: Abbrev Number: 1 (DW_TAG_compile_unit)
        <21>   DW_AT_dwo_name    : (strp) (offset: 0): fission-with-type-unit-dw.dwo

      Compilation Unit @ offset 0x25:
       Length:        0x8 (32-bit)
       Version:       4
       Abbrev Offset: 0xe
       Pointer Size:  8
     <0><30>: Abbrev Number: 1 (DW_TAG_compile_unit)

And here is what is in the fission-with-type-unit-dw.dwo file (one TU
and the CU):

    Contents of the .debug_info.dwo section:

      Compilation Unit @ offset 0:
       Length:        0x1d (32-bit)
       Version:       5
       Unit Type:     DW_UT_type (2)
       Abbrev Offset: 0
       Pointer Size:  8
       Signature:     0xcafe
       Type Offset:   0x19
     <0><18>: Abbrev Number: 1 (DW_TAG_type_unit)
     <1><19>: Abbrev Number: 2 (DW_TAG_base_type)
        <1a>   DW_AT_byte_size   : (sdata) 4
        <1b>   DW_AT_encoding    : (sdata) 5        (signed)
        <1c>   DW_AT_name        : (string) int
     <1><20>: Abbrev Number: 0

    Contents of the .debug_info.dwo section:

      Compilation Unit @ offset 0:
       Length:        0x2d (32-bit)
       Version:       5
       Unit Type:     DW_UT_split_compile (5)
       Abbrev Offset: 0
       Pointer Size:  8
       DWO ID:        0xf00d
     <0><14>: Abbrev Number: 3 (DW_TAG_compile_unit)
     <1><15>: Abbrev Number: 4 (DW_TAG_base_type)
        <16>   DW_AT_byte_size   : (sdata) 4
        <17>   DW_AT_encoding    : (sdata) 5        (signed)
        <18>   DW_AT_name        : (string) int
     <1><1c>: Abbrev Number: 5 (DW_TAG_variable)
        <1d>   DW_AT_name        : (string) global_var
        <28>   DW_AT_type        : (ref4) <0x15>, int
        <2c>   DW_AT_location    : (exprloc) 3 byte block: 8 c 9f   (DW_OP_const1u: 12; DW_OP_stack_value)
     <1><30>: Abbrev Number: 0

After loading the above in GDB, here is what is in GDB's mind (contents
of dwarf2_per_bfd::all_units):

 - CU at offset 0x0  of .debug_info     in fission-with-type-unit -- dummy
 - CU at offset 0xc  of .debug_info     in fission-with-type-unit
 - CU at offset 0x25 of .debug_info     in fission-with-type-unit -- dummy
 - TU at offset 0x0  of .debug_info.dwo in fission-with-type-unit-dw.dwo

This is correct.  Then, this is the generated .gdb_index:

    Contents of the .gdb_index section:

    Version 9

    CU table:
    [  0] 0 - 0xb     -- dummy
    [  1] 0xc - 0x24
    [  2] 0x25 - 0x30 -- dummy

    TU table:
    [  0] 0 0x19 000000000000cafe

    Address table:

    Symbol table:
    [  3] global_var: 1 [static, variable]
    [754] int: 1 [static, type]

    Shortcut table:
    Language of main: unknown: 0
    Name of main: <unknown>

The TU table says that there exists a TU at offset 0.  Unfortunately,
there is no way for a reader of that index to know that this TU is
really in a .dwo file, not in the main file.  So when GDB loads this
index back (creating dwarf2_per_bfd::all_units from .gdb_index this
time, rather than walking the debug info), this is what is in its mind:

 - CU at offset 0x0  of .debug_info in fission-with-type-unit -- dummy
 - TU at offset 0x0  of .debug_info in fission-with-type-unit
 - CU at offset 0xc  of .debug_info in fission-with-type-unit
 - CU at offset 0x25 of .debug_info in fission-with-type-unit -- dummy

GDB now incorrectly believes there's a TU at offset 0 of .debug_info in
the main file, which is wrong.  When trying to expand that TU with
"maint expand-symtabs", we're not really reading the TU, so we hit the
assert checking that the signature in the TU header matches what was
given by the index.

The .debug_names format has a way to list the TUs found in the .dwo
files, called the "foreign TU list" (see section 6.1.1.2 "Structure of
the Name Index" of DWARF 5).  That list only includes the signature of
the type, and there is some capability to figure out which .dwo file
contains that type unit.  The .gdb_index format does not have something
like that.  We could try to retrofit such a feature in the .gdb_index
format, but I think we prefer to put our efforts on the standard
.debug_names format.

To avoid producing a misleading index like shown above, I propose to
make GDB refuse to produce an index if there exists a skeletonless type
unit.  This patch implements that by looking at section of all
signatured_types.  If the containing section ends with .dwo, then this
is a skeletonless type unit.

As a reminder: if a unit has a skeleton, the dwarf2_per_cu section will
point at the skeleton section, in the main file.  If the unit does not
have a skeleton, the dwarf2_per_cu section will point at the section in
the .dwo file.  All .dwo section names end with ".dwo".

Add a "endswith" utils function to help with that.

With this patch, running the gdb.dwarf/fission-with-type-unit.exp leads
to a compilation failure:

    gdb compile failed, Error while writing index for `/home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/fission-with-type-unit/.tmp/fission-with-type-unit': Found skeletonless type units, unable to produce .gdb_index.  Consider using .debug_names instead.

... which makes the test "untested".

Add a new test, gdb.dwarf2/gdb-index-skeletonless-tu.exp, to verify the new error path.

Change-Id: I1e2e0204c9c2b48763aa99ce63521ae4a5262b22
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: XML: Don't return -1 nor 0 from top-level
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:28 +0000 (20:04 -0300)] 
GDB: testsuite: XML: Don't return -1 nor 0 from top-level

This patch changes statements that return -1 or 0 from the top level.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: TUI: Don't return 0 from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:27 +0000 (20:04 -0300)] 
GDB: testsuite: TUI: Don't return 0 from top-level (manual)

This patch changes statements that return 0 from the top level, and also
one "return -1" statement that wasn't caught by sed.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: TUI: Don't return -1 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:26 +0000 (20:04 -0300)] 
GDB: testsuite: TUI: Don't return -1 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

inside gdb/testsuite/gdb.tui.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: threads: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:25 +0000 (20:04 -0300)] 
GDB: testsuite: threads: Don't return value from top-level (manual)

This patch manually changes "return -1" statements that weren't caught
by the sed command.

These return statements fall into one of these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside block such as for loops,
  with_test_prefix, foreach_with_prefix, gdb_test_multiple.

I also fixed a couple cases of "return 0" from top-level that also
weren't caught by sed, and even a couple cases of "return 1" from
top-level.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: threads: Don't return 0 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:24 +0000 (20:04 -0300)] 
GDB: testsuite: threads: Don't return 0 from top-level (sed)

This patch is a bit different than the others.  I noticed that
gdb.threads has many cases of "return 0" from the top level, so this
patch is purely the result of running:

$ sed -i 's/^    return 0/    return/' *.exp*

inside gdb/testsuite/gdb.threads.

There were a number of false positives so not all sed changes were
incorporated.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: threads: Don't return -1 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:23 +0000 (20:04 -0300)] 
GDB: testsuite: threads: Don't return -1 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

inside gdb/testsuite/gdb.threads.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: server: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:22 +0000 (20:04 -0300)] 
GDB: testsuite: server: Don't return value from top-level (manual)

This patch manually changes "return -1" statements that weren't caught
by the sed command.

These return statements return at top level but inside block such as
save_vars and with_test_prefix.

I also fixed one case of top-level "return 0".

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: server: Don't return -1 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:21 +0000 (20:04 -0300)] 
GDB: testsuite: server: Don't return -1 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

inside gdb/testsuite/gdb.server.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: reverse: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:20 +0000 (20:04 -0300)] 
GDB: testsuite: reverse: Don't return value from top-level (manual)

This patch manually changes "return -1" statements that weren't caught
by the sed command.  It also changes a few "return 0" statements.

These return statements fall into one of these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside block such as with_test_prefix,
  foreach_with_prefix, with_timeout_factor, gdb_test_multiple.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: reverse: Don't return -1 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:19 +0000 (20:04 -0300)] 
GDB: testsuite: reverse: Don't return -1 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

inside gdb/testsuite/gdb.reverse.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: MI: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:18 +0000 (20:04 -0300)] 
GDB: testsuite: MI: Don't return value from top-level (manual)

This patch manually changes "return -1" statements that weren't caught
by the sed command.  It also changes a couple of "return 0" statements.

These return statements fall into one of these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside block such as with_test_prefix,
  foreach_with_prefix, gdb_expect.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: MI: Don't return -1 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:17 +0000 (20:04 -0300)] 
GDB: testsuite: MI: Don't return -1 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

inside gdb/testsuite/gdb.mi.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: linespec: Don't return value from top-level
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:16 +0000 (20:04 -0300)] 
GDB: testsuite: linespec: Don't return value from top-level

Most changes are the result of running:

$ sed -i 's/^    return -1/    return/' *.exp

inside gdb/testsuite/gdb.linespec.  The exceptions fall into one of
these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside a namespace block.

A couple of "return 0" statements were also fixed.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: Python: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:15 +0000 (20:04 -0300)] 
GDB: testsuite: Python: Don't return value from top-level (manual)

This patch manually changes "return -1" and "return 0" statements that
weren't caught by the sed command.

These return statements fall into one of these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside block such as save_vars,
  with_test_prefix, foreach, gdb_test_multiple.

In a couple of cases the whole if block was in a single line:

  if { condition } { return -1 }

In those cases the formatting was changed to the multi-line style we
tend to use.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: Python: Don't return 0 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:14 +0000 (20:04 -0300)] 
GDB: testsuite: Python: Don't return 0 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

inside gdb/testsuite/gdb.python.  A couple of false positives weren't
included.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: Python: Don't return -1 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:13 +0000 (20:04 -0300)] 
GDB: testsuite: Python: Don't return -1 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

inside gdb/testsuite/gdb.python.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: Guile: Don't return -1 from top-level
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:12 +0000 (20:04 -0300)] 
GDB: testsuite: Guile: Don't return -1 from top-level

All changes are the result of running:

$ sed -i 's/^    return -1/    return/' *.exp

inside gdb/testsuite/gdb.guile.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: GDB: Don't return -1 from top-level
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:11 +0000 (20:04 -0300)] 
GDB: testsuite: GDB: Don't return -1 from top-level

All changes except for one are the result of running:

$ sed -i 's/^    return -1/    return/' *.exp

inside gdb/testsuite/gdb.gdb.  The exception is a return statement in
index-file.exp, which is inside a with_timeout_factor block.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: DWARF: Don't return -1 from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:10 +0000 (20:04 -0300)] 
GDB: testsuite: DWARF: Don't return -1 from top-level (manual)

This patch manually changes "return -1" statements that weren't caught
by the sed command.

These return statements fall into one of these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside block such as save_vars,
  with_test_prefix, foreach, gdb_test_multiple.

Some weren't changed because they didn't meet the criteria above, or
weren't trivial to check.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: DWARF: Don't return value from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:09 +0000 (20:04 -0300)] 
GDB: testsuite: DWARF: Don't return value from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

and

$ sed -i 's/^    return 0/    return/' *.exp*

inside gdb/testsuite/gdb.dwarf2.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: C++: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:08 +0000 (20:04 -0300)] 
GDB: testsuite: C++: Don't return value from top-level (manual)

This patch manually changes "return -1" and "return 0" statements that
weren't caught by the sed command.

These return statements fall into one of these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside block such as save_vars,
  with_test_prefix, foreach, gdb_test_multiple.

Some weren't changed because they didn't meet the criteria above, or
weren't trivial to check.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: C++: Don't return value from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:07 +0000 (20:04 -0300)] 
GDB: testsuite: C++: Don't return value from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

and

$ sed -i 's/^    return 0/    return/' *.exp*

inside gdb/testsuite/gdb.cp.

I didn't include changes made to return statements inside procedures.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: base: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:06 +0000 (20:04 -0300)] 
GDB: testsuite: base: Don't return value from top-level (manual)

This patch manually changes "return -1" and "return 0" statements that
weren't caught by the sed command.

These return statements fall into one of these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside a block such as save_vars,
  with_test_prefix, foreach, gdb_test_multiple.

Some weren't changed because they didn't meet the criteria above, or
weren't trivial to check.

There was also one return statement with an unnecessary semi-colon at
the end, which was removed.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: base: Don't return 0 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:05 +0000 (20:04 -0300)] 
GDB: testsuite: base: Don't return 0 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return 0/    return/' *.exp*

inside gdb/testsuite/gdb.base.

I didn't include changes made to return statements inside procedures.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: base: Don't return -1 from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:04 +0000 (20:04 -0300)] 
GDB: testsuite: base: Don't return -1 from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' *.exp*

inside gdb/testsuite/gdb.base.

I didn't include changes made to return statements inside procedures.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: Don't return value from top-level in multi-arch tests
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:03 +0000 (20:04 -0300)] 
GDB: testsuite: Don't return value from top-level in multi-arch tests

Oddly enough, there are multi-arch arch tests.  This patch contains
fixes for them.

Some changes are the result of running:

$ sed -i 's/^    return -1/    return/' *.exp

inside gdb/testsuite/gdb.arch and the others are manual changes.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: Don't return value from top-level in tests of various arches
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:02 +0000 (20:04 -0300)] 
GDB: testsuite: Don't return value from top-level in tests of various arches

This patch contains fixes for alpha, arc, avr, hppa and sh architectures.

Some changes are the result of running:

$ sed -i 's/^    return -1/    return/' *.exp

and

$ sed -i 's/^    return 0/    return/' *.exp

inside gdb/testsuite/gdb.arch and some are manual changes.

I didn't include changes made to return statements inside procedures.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: sparc: Don't return value from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:01 +0000 (20:04 -0300)] 
GDB: testsuite: sparc: Don't return value from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' sparc*.exp*

and

$ sed -i 's/^    return 0/    return/' sparc*.exp*

inside gdb/testsuite/gdb.arch.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: s390: Don't return value from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:04:00 +0000 (20:04 -0300)] 
GDB: testsuite: s390: Don't return value from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' s390*.exp*

and

$ sed -i 's/^    return 0/    return/' s390*.exp*

inside gdb/testsuite/gdb.arch.

I didn't include changes made to return statements inside procedures.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: riscv: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:03:59 +0000 (20:03 -0300)] 
GDB: testsuite: riscv: Don't return value from top-level (manual)

This patch manually changes the "return -1" and "return 0" statements
that weren't caught by the sed command.

This happened only in one testcase due to the statements being inside a
foreach_with_prefix block, and in the others because the return
statement was in a misaligned line, which is now fixed.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: riscv: Don't return value from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:03:58 +0000 (20:03 -0300)] 
GDB: testsuite: riscv: Don't return value from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' riscv*.exp*

and

$ sed -i 's/^    return 0/    return/' riscv*.exp*

inside gdb/testsuite/gdb.arch.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: powerpc: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:03:57 +0000 (20:03 -0300)] 
GDB: testsuite: powerpc: Don't return value from top-level (manual)

This patch manually changes the "return -1" statements that weren't
caught by the sed command because they were in a misaligned line, which
is then aligned by this patch.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: powerpc: Don't return value from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:03:56 +0000 (20:03 -0300)] 
GDB: testsuite: powerpc: Don't return value from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' \
      aix*.exp* altivec*.exp* e500*.exp* powerpc*.exp* ppc*.exp* vsx*.exp*

and

$ sed -i 's/^    return 0/    return/' \
      aix*.exp* altivec*.exp* e500*.exp* powerpc*.exp* ppc*.exp* vsx*.exp*

inside gdb/testsuite/gdb.arch.

I didn't include changes made to return statements inside procedures.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: x86, amd64, i386: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:03:55 +0000 (20:03 -0300)] 
GDB: testsuite: x86, amd64, i386: Don't return value from top-level (manual)

This patch manually changes the "return -1" statements that weren't
caught by the sed command.

In amd64-shadow-stack-cmds.exp the return statements have extra
indentation due to being inside a save_vars block.

In i386-bp_permanent.exp this was caused by misaligned lines, which are
now fixed.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: x86, amd64, i386, ia64: Don't return value from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:03:54 +0000 (20:03 -0300)] 
GDB: testsuite: x86, amd64, i386, ia64: Don't return value from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' \
      amd64-*.exp* i386-*.exp* x86*.exp* ia64*.exp* core-file-pid0.exp

and

$ sed -i 's/^    return 0/    return/' \
      amd64-*.exp* i386-*.exp* x86*.exp* ia64*.exp* core-file-pid0.exp

inside gdb/testsuite/gdb.arch.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: aarch64, arm: Don't return value from top-level (manual)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:03:53 +0000 (20:03 -0300)] 
GDB: testsuite: aarch64, arm: Don't return value from top-level (manual)

This patch manually changes the "return -1" statements that weren't
caught by the sed command.

In aarch64-prologue.exp and arm-cmse-sgstubs.exp, this was caused by a
misaligned line, which is now fixed.

In aarch64-mte.exp, aarch64-non-address-bits.exp,
arm-pthread_cond_timedwait-bt.exp and thumb2-it.exp this is because the
return statements have extra indentation due to being inside
with_test_prefix, save_vars or gdb_test_multiple blocks.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoGDB: testsuite: aarch64, arm: Don't return value from top-level (sed)
Thiago Jung Bauermann [Wed, 29 Apr 2026 23:03:52 +0000 (20:03 -0300)] 
GDB: testsuite: aarch64, arm: Don't return value from top-level (sed)

This patch is purely the result of running:

$ sed -i 's/^    return -1/    return/' \
      aarch64-*.exp* arm-*.exp* thumb*.exp* iwmmxt-regs.exp pr25124.exp

and

$ sed -i 's/^    return 0/    return/' \
      aarch64-*.exp* arm-*.exp* thumb*.exp* iwmmxt-regs.exp pr25124.exp

inside gdb/testsuite/gdb.arch.

I didn't include changes made to return statements inside procedures.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoUse address style with throw_error
Tom Tromey [Wed, 8 Apr 2026 00:33:52 +0000 (18:33 -0600)] 
Use address style with throw_error

This changes a call to throw_error to use address_style.

4 weeks agoUse function style with throw_error
Tom Tromey [Wed, 8 Apr 2026 00:22:42 +0000 (18:22 -0600)] 
Use function style with throw_error

This changes some calls to throw_error to use function_name_style.

4 weeks agoUse command style with throw_error
Tom Tromey [Wed, 8 Apr 2026 00:25:22 +0000 (18:25 -0600)] 
Use command style with throw_error

This changes some calls to throw_error to use command_style.

4 weeks agoUse file- and line-styling with throw_error
Tom Tromey [Wed, 8 Apr 2026 00:23:57 +0000 (18:23 -0600)] 
Use file- and line-styling with throw_error

This changes some throw_error calls to apply file_name_style and
line_number_style.  This patch does both at the same time because the
two styles often appear in the same message.

4 weeks agoAllow styling when using throw_* functions
Tom Tromey [Wed, 8 Apr 2026 00:18:40 +0000 (18:18 -0600)] 
Allow styling when using throw_* functions

The throw_* family of functions use the varargs constructor for
gdb_exception, which then calls string_vprintf.  This means that
styling cannot be applied here by gdb.

This patch changes this code to use a client-supplied formatting
function.  For gdbserver this remains string_vprintf, but for gdb it
now allows styling.

I did look at unifying 'error' and the throw_* functions a bit more,
but this would have meant unravelling some IPA code.

4 weeks agoAdd missing quote to a comment
Tom Tromey [Wed, 22 Apr 2026 18:30:34 +0000 (12:30 -0600)] 
Add missing quote to a comment

I noticed that one particular comment was missing the closing double
quote around the word "auto".

4 weeks agoUse bool in map_matching_symbols
Tom Tromey [Wed, 15 Apr 2026 14:02:17 +0000 (08:02 -0600)] 
Use bool in map_matching_symbols

This changes ada-lang.c:map_matching_symbols to take a bool parameter,
then fixes up the callers.

Approved-By: Andrew Burgess <aburgess@redhat.com>
4 weeks agoUse bool in ada_add_all_symbols
Tom Tromey [Wed, 15 Apr 2026 14:01:35 +0000 (08:01 -0600)] 
Use bool in ada_add_all_symbols

This changes ada_add_all_symbols to use bool, then fixes up the
callers.

Approved-By: Andrew Burgess <aburgess@redhat.com>
4 weeks agoinclude: add reference URLs in elf/amdgpu.h
Simon Marchi [Thu, 7 May 2026 19:33:25 +0000 (15:33 -0400)] 
include: add reference URLs in elf/amdgpu.h

During review, a question was "where are those numbers that you are
adding defined".  Add some URLs pointing to the source of truth for
those numbers.

Change-Id: I11b7cb351a9b818fca66a532bfcd27286ec0ddfd

4 weeks agoreadelf: Add support for AMDGPU code object V6
Lancelot Six [Fri, 31 Oct 2025 17:54:11 +0000 (17:54 +0000)] 
readelf: Add support for AMDGPU code object V6

AMDGPU code object V6 adds the EF_AMDGPU_GENERIC_VERSION_V field.
Decode it when decoding the e_flags value for amdgpu.

The output for such generic GFX targets will look like:

$ readelf -h gpu.elf
  ELF Header:
    ...
    Flags:     0x1000151, gfx9-generic, xnack any, generic v1
                                                   ----------
    ...

... indicating that this ELF has the "generic code object v1" flag.

Change-Id: I0cb8014fc23150e16f43ab98adb3832ede253c88
Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoAdd AMDGPU generic targets
Simon Marchi [Thu, 7 May 2026 16:01:22 +0000 (12:01 -0400)] 
Add AMDGPU generic targets

Add the following generic AMDGPU architectures:

  - gfx9-generic
  - gfx9-4-generic
  - gfx10-1-generic
  - gfx10-3-generic
  - gfx11-generic
  - gfx12-generic
  - gfx12-5-generic

Change-Id: Ibf600d7c70ba8499f8ef75d8d57a71929f1cd4d4
Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoUpdate list of supported AMDGPU architectures
Lancelot Six [Fri, 31 Oct 2025 17:54:09 +0000 (17:54 +0000)] 
Update list of supported AMDGPU architectures

This patch updates the list of supported AMDGPU architectures in bfd/
binutils/ and include/elf/.

The following architectures have been added:

- gfx942
- gfx950
- gfx1150
- gfx1151
- gfx1152
- gfx1153
- gfx1200
- gfx1201
- gfx1250

The canonical source for these numbers is:

https://llvm.org/docs/AMDGPUUsage.html#amdgpu-ef-amdgpu-mach-table

Co-Authored-By: Laurent Morichetti <laurent.morichetti@amd.com>
Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Co-Authored-By: Olu Ogunbowale <oogunbow@amd.com>
Co-Authored-By: Shahab Vahedi <shahab.vahedi@amd.com>
Co-Authored-By: Anurag Kumar <AnuragKumar.Vulisha@amd.com>
Change-Id: I80e76c8ec98b725937fe445883fae707097ec2b7

4 weeks agoObjdump: Add "-M annotate" option to the AArch64 disassembler.
Nick Clifton [Fri, 8 May 2026 10:10:05 +0000 (11:10 +0100)] 
Objdump: Add "-M annotate" option to the AArch64 disassembler.

4 weeks agold/doc: correct misrepresented wording
PranavRJoshi [Fri, 8 May 2026 09:48:37 +0000 (11:48 +0200)] 
ld/doc: correct misrepresented wording

The file ld.texi contains two space-separated terms: 'subseque nt'. It was probably meant to be 'subsequent'.

Manual documentation in html format also contains this error. I submitted a patch for it too, which can be
link: https://sourceware.org/pipermail/binutils/2026-May/149206.html
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
4 weeks agoobjcopy: zap ELF visibility when localizing symbols
Jan Beulich [Fri, 8 May 2026 09:45:26 +0000 (11:45 +0200)] 
objcopy: zap ELF visibility when localizing symbols

The spec explicitly precludes STB_LOCAL together with STV_PROTECTED (and,
implicitly, STV_HIDDEN or STV_INTERNAL), so we better wouldn't (entirely
silently) write out symbols violating this.

4 weeks agogas/ELF: warn upon non-default visibility of local symbols
Jan Beulich [Fri, 8 May 2026 09:45:04 +0000 (11:45 +0200)] 
gas/ELF: warn upon non-default visibility of local symbols

The spec explicitly precludes STB_LOCAL together with STV_PROTECTED (and,
implicity, STV_HIDDEN or STV_INTERNAL), so we better wouldn't entirely
silently write out symbols violating this.

LoongArch's tc_symbol_new_hook() simply needs dropping. If FAKE_LABEL_NAME
symbols can end up global, marking them hidden would need doing elsewhere.
There not being a need to make any testsuite adjustments suggests though
that this won't normally (ever?) happen.

A couple of testcases then also need adjustment.

4 weeks agogas/ELF: restrict visibility changes
Jan Beulich [Fri, 8 May 2026 09:44:09 +0000 (11:44 +0200)] 
gas/ELF: restrict visibility changes

Since the spec mandates that the most restricting visibility ought to
propagate when linking, the same rule should apply when assembling.

4 weeks agogdb/solib: use early return in solib_read_symbols
Simon Marchi [Tue, 9 Dec 2025 19:32:06 +0000 (14:32 -0500)] 
gdb/solib: use early return in solib_read_symbols

This reduces the indent a bit, and makes it clearer where the
"interesting" part of the function is.

At the same time, move the comment to solib.h.

Change-Id: I8004895757ce296742bcec929799a0ce6041938b
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoAutomatic date update in version.in
GDB Administrator [Fri, 8 May 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agold: Append LDFLAGS to flags variable in default_ld_link
John David Anglin [Thu, 7 May 2026 21:43:54 +0000 (17:43 -0400)] 
ld: Append LDFLAGS to flags variable in default_ld_link

The following change is needed to fix errors trying to load the
milli.a archive for the hppa*64*-*-hpux* target when the host
system isn't hpux.

We need to create a dummy milli.a archive for this target and
append the directory of this archive to LDFLAGS.

This assumes the testsuite takes the LDFLAGS environment variable
into account.  However, some tests in the ld testsuite use the
low-level `ld-link' procedure and it fails to take LDFLAGS into
account.

This change modifies the `default_ld_link' procedure to append
$LDFLAGS to the flags variable and fix the above issue.

This change potentially affects the `alpha*-*-*vms*' target but
currently no tests run for it make direct use of `ld-link'.

Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>
2026-04-27  John David Anglin  <danglin@gcc.gnu.org>

ld/ChangeLog:

* testsuite/lib/ld-lib.exp (default_ld_link): Append
LDFLAGS to `flags' variable.  Also use the append command
to append the board flags.

4 weeks agohppa64: Re-enable -gc-section support on hppa*64*-*-hpux*
John David Anglin [Thu, 7 May 2026 18:55:33 +0000 (14:55 -0400)] 
hppa64: Re-enable -gc-section support on hppa*64*-*-hpux*

The previous change to elf_hppa_final_link_relocate didn't eliminate
relocatios with invalid offsets.  Here we take a different approach
to handle invalid offsets on hpux.  We allocate 16 bytes at the start
of the .data section for the linker.  If we encounter a relocation
with an invalid offset, we set the relocation's offset to the start
of the data section.  As a result, the HP dynamic linker is happy
and we can re-enable -gc-section support.

2026-05-07  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* elf64-hppa.c (elf_hppa_final_link_relocate): Rework
handling of relocations with invalid offsets on hpux.
(elf_backend_can_gc_sections): Set to one on hpux.

ld/ChangeLog:

* emulparams/elf64hppa.sh (DATA_START_SYMBOLS): Define.
* testsuite/ld-elf/group8a.d: Revert commit d6ce0aa3f877.
* testsuite/ld-elf/group8b.d: Likewise.
* testsuite/ld-elf/group9a.d: Likewise.
* testsuite/ld-elf/group9b.d: Likewise.
* testsuite/ld-elf/pr12851.d: Likewise.
* testsuite/ld-elf/pr22677.d: Likewise.

4 weeks agoWindows gdb: Avoid hang second attach/run
Pedro Alves [Fri, 2 Jun 2023 22:08:49 +0000 (23:08 +0100)] 
Windows gdb: Avoid hang second attach/run

gdb.base/attach.exp starts a second inferior and tries to attach the
second inferior to the same process that inferior 1 is already
debugging.  The point is to make sure that the backend errors out when
it tries to attach to a process that is already being debugged.

windows_nat_target::attach and windows_nat_target::create_inferior
both hang in this situation, because they call into do_synchronously,
which hangs because the 'process_thread' thread is blocked in
WaitForDebugEvent.

E.g.:

  attach 4420
  FAIL: gdb.base/attach.exp: do_attach_failure_tests: fail to attach again (timeout)

Until the Windows backend is taught to debug multiple processes, which
will probably require having one process_thread thread per inferior,
detect the situation and error out before GDB hangs.

This results in the following progression in gdb.base/attach.exp:

 -FAIL: gdb.base/attach.exp: do_attach_failure_tests: fail to attach again (timeout)
 -FAIL: gdb.base/attach.exp: do_attach_failure_tests: set confirm off (timeout)
 -FAIL: gdb.base/attach.exp: do_attach_failure_tests: switch to inferior 1 (timeout)
 -FAIL: gdb.base/attach.exp: do_attach_failure_tests: exit after attach failures (timeout)
 -FAIL: gdb.base/attach.exp: do_attach_failure_tests: gdb_breakpoint: set breakpoint at main (timeout)
 -FAIL: gdb.base/attach.exp: do_attach_failure_tests: stop at main (timeout)
 +PASS: gdb.base/attach.exp: do_attach_failure_tests: fail to attach again
 +PASS: gdb.base/attach.exp: do_attach_failure_tests: set confirm off
 +PASS: gdb.base/attach.exp: do_attach_failure_tests: switch to inferior 1
 +PASS: gdb.base/attach.exp: do_attach_failure_tests: exit after attach failures
 +PASS: gdb.base/attach.exp: do_attach_failure_tests: stop at main

There are still other failures not addressed by this patch.

Tests that launch a second program with "run" exist, but are normally
gated by allow_multi_inferior_tests.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I55b4438795439673c49fa55f55ddf0191f4f0ea8
commit-id: 1caa5be0

4 weeks agoWindows gdb: all-stop, interrupt with "stopped" instead of SIGTRAP
Pedro Alves [Fri, 5 May 2023 14:51:31 +0000 (15:51 +0100)] 
Windows gdb: all-stop, interrupt with "stopped" instead of SIGTRAP

Currently, "interrupt" uses DebugBreakProcess (or equivalent), which
injects a new thread in the inferior that executes an int3 instruction
(on x86), which raises a SIGTRAP.  With the target backend in non-stop
mode, its easy to avoid all that and make interrupt in all-stop just
suspend a pre-existing thread and report "stopped", like "set non-stop
on" does (via target_stop).

E.g., before:

 (gdb) c&
 Continuing.
 ...
 (gdb) info threads
   Id   Target Id          Frame
 * 1    Thread 1180.0x1374 (running)
   2    Thread 1180.0xc3c  (running)
   3    Thread 1180.0x6ec  (running)
   5    Thread 1180.0x1378 (running)
 (gdb)
 ...
 [New Thread 1180.0xc70]
 [Thread 1180.0x1378 exited with code 0]
 [Thread 1180.0xc70 exited with code 0]
 [New Thread 1180.0xdc0]
 ...
 interrupt
 (gdb) [New Thread 1180.0x1010]

 Thread 8 received signal SIGTRAP, Trace/breakpoint trap.
 [Switching to Thread 1180.0x1010]
 0x00007ffa57490b71 in ntdll!DbgBreakPoint () from C:\Windows\SYSTEM32\ntdll.dll
 info threads
   Id   Target Id          Frame
   1    Thread 1180.0x1374 0x00007ffa5748d6e4 in ntdll!ZwDelayExecution () from C:\Windows\SYSTEM32\ntdll.dll
   2    Thread 1180.0xc3c  0x00007ffa57490ad4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\Windows\SYSTEM32\ntdll.dll
   3    Thread 1180.0x6ec  0x00007ffa5748d6e4 in ntdll!ZwDelayExecution () from C:\Windows\SYSTEM32\ntdll.dll
   7    Thread 1180.0xdc0  0x00007ffa5748d6e4 in ntdll!ZwDelayExecution () from C:\Windows\SYSTEM32\ntdll.dll
 * 8    Thread 1180.0x1010 0x00007ffa57490b71 in ntdll!DbgBreakPoint () from C:\Windows\SYSTEM32\ntdll.dll
 (gdb)

After:

 (gdb) info threads
   Id   Target Id          Frame
 * 1    Thread 5912.0x394  (running)
   2    Thread 5912.0x608  (running)
   3    Thread 5912.0x1704 (running)
   10   Thread 5912.0x870  (running)
 (gdb)
 ...
 [Thread 5912.0x870 exited with code 0]
 ...
 (gdb) interrupt
 (gdb)
 Thread 1 stopped.
 0x00007ffa5748d6e4 in ntdll!ZwDelayExecution () from C:\Windows\SYSTEM32\ntdll.dll
 info threads
   Id   Target Id          Frame
 * 1    Thread 5912.0x394  0x00007ffa5748d6e4 in ntdll!ZwDelayExecution () from C:\Windows\SYSTEM32\ntdll.dll
   2    Thread 5912.0x608  0x00007ffa57490ad4 in ntdll!ZwWaitForWorkViaWorkerFactory () from C:\Windows\SYSTEM32\ntdll.dll
   3    Thread 5912.0x1704 0x00007ffa5748d6e4 in ntdll!ZwDelayExecution () from C:\Windows\SYSTEM32\ntdll.dll
   8    Thread 5912.0x1200 0x00007ffa5748d6e4 in ntdll!ZwDelayExecution () from C:\Windows\SYSTEM32\ntdll.dll
 (gdb)

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I569fc69392ce9a070a2ebe1003388b7386412b14
commit-id: 8f6b76d2

4 weeks agoUpdate the SECURITY.txt document. Clarify what is meant by a "direct compromise of...
Nick Clifton [Thu, 7 May 2026 09:53:46 +0000 (10:53 +0100)] 
Update the SECURITY.txt document. Clarify what is meant by a "direct compromise of security", emphasise that the tools do not provide a sevrice of any kind, and show that bugs that rely upon untrusted input must be able to cross a trust boundary in order to be considered as a security issue.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Thu, 7 May 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agoRemove Andreas Jaeger from the x86_64 maintainers.
Nick Clifton [Wed, 6 May 2026 12:57:56 +0000 (13:57 +0100)] 
Remove Andreas Jaeger from the x86_64 maintainers.

4 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 6 May 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agohppa64: Disable -gc-section support on hppa*64*-*-hpux*
John David Anglin [Tue, 5 May 2026 18:51:40 +0000 (14:51 -0400)] 
hppa64: Disable -gc-section support on hppa*64*-*-hpux*

The HP-UX dynamic linker on hppa generates an error if it detects
a dynamic relocation with the R_PARISC_NONE type.  As a result,
there is no way to handle relocations in sections that are garbage
collected.  Although these can mostly be avoided, I think it best
to disable -gc-section support.

2026-05-06  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* elf64-hppa.c (elf_hppa_final_link_relocate): Rework
BFD_ASSERT to only trigger on hpux.  Zero rela if the
new offset is invalid.
(elf_backend_can_gc_sections): Set to zero on hpux.

ld/ChangeLog:

* testsuite/ld-elf/group8a.d: xfail hppa*64*-*-hpux*.
* testsuite/ld-elf/group8b.d: Likewise.
* testsuite/ld-elf/group9a.d: Likewise.
* testsuite/ld-elf/group9b.d: Likewise.
* testsuite/ld-elf/pr12851.d: Likewise.
* testsuite/ld-elf/pr22677.d: Likewise.

4 weeks agogdb/dwarf: Use the function scope for DW_TAG_imported_declaration
Abdul Basit Ijaz [Wed, 8 Apr 2026 08:03:57 +0000 (10:03 +0200)] 
gdb/dwarf: Use the function scope for DW_TAG_imported_declaration

All Fortran imported variable aliases (`use module, alias => var`)
were being added to "global scope", regardless of whether they appeared
in:
- Program/module scope (should be global)
- Function scope (should be local)

This caused conflicts when different functions had the same alias name
pointing to different variables.

DW_TAG_imported_declaration and DW_TAG_namespace cases are now handled
separately.  This patch modifies the case for DW_TAG_imported_
declaration in the function new_symbol () to use cu->list_in_scope
instead of global symbols for all languages.  This ensures that
function-scoped aliases use the current scope rather than being forced
into the global scope.

Bug Scenario:

  subroutine sub1
    use mod1, var_i_alias=>var_i  ! alias points to mod1::var_i
    var_i_alias = 3
    var_i = 4
  end subroutine

  subroutine sub2
    use mod2, var_i_alias=>var_i  ! alias points to mod2::var_i
    var_i_alias = 23
    var_i = 25
  end subroutine

Before: var_i_alias in sub2 incorrectly resolved to mod1::var_i
(value 25)
After: Each function's alias correctly resolves to its own imported
variable (value 23)

New test files verify the fix and include regression tests for global
program-scope imports:
  - gdb/testsuite/gdb.fortran/module_declarations.exp
  - gdb/testsuite/gdb.fortran/module_declarations.f90

Before the change:
(gdb) print var_i_alias
$4 = 25
FAIL: gdb.fortran/module_declarations.exp: sub2_test: print var_i_alias

After the change:
(gdb) print var_i_alias
$4 = 23
PASS: gdb.fortran/module_declarations.exp: sub2_test: print var_i_alias

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 5 May 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agogdb: notify of inferior switch when needed from 'thread' command
Andrew Burgess [Tue, 30 Sep 2025 12:14:11 +0000 (13:14 +0100)] 
gdb: notify of inferior switch when needed from 'thread' command

While working on the commit:

  commit 9959019545d8d6d71d927f20f088efba944b1e9c
  Date:   Sun Sep 28 16:16:53 2025 +0100

      gdb: fix for 'set suppress-cli-notifications on' missed case

I spotted this message in the gdb.mi/user-selected-context-sync.exp
test script:

  # Idea for the future: selecting a thread in a different inferior.  For now,
  # GDB doesn't show an inferior switch, but if it did, it would be a nice
  # place to test it.

What this message is talking about is this behaviour:

  (gdb) info threads
    Id   Target Id                              Frame
    1.1  Thread 0xf7dbc700 (LWP 818430) "thr" 0xf7eb2888 in clone () from /lib/libc.so.6
    1.2  Thread 0xf7dbbb40 (LWP 818433) "thr" 0xf7fd0579 in __kernel_vsyscall ()
    1.3  Thread 0xf73ffb40 (LWP 818434) "thr" breakpt () at thr.c:19
    2.1  Thread 0xf7dbc700 (LWP 818456) "thr" 0xf7eb2888 in clone () from /lib/libc.so.6
    2.2  Thread 0xf7dbbb40 (LWP 818457) "thr" breakpt () at thr.c:19
  * 2.3  Thread 0xf73ffb40 (LWP 818458) "thr" breakpt () at thr.c:19
  (gdb) inferior 1
  [Switching to inferior 1 [process 818430] (/home/andrew/tmp/thr)]
  [Switching to thread 1.1 (Thread 0xf7dbc700 (LWP 818430))]
  #0  0xf7eb2888 in clone () from /lib/libc.so.6
  (gdb) thread 2.2
  [Switching to thread 2.2 (Thread 0xf7dbbb40 (LWP 818457))]
  #0  breakpt () at thr.c:19
  19   while (stop)
  (gdb)

Notice that when we switch from thread 2.3 to 1.1 using the 'inferior
1' command, GDB tells us that the inferior has changed, and that the
thread has changed (and also that the frame has changed).

But, when we switch from 1.1 to 2.2 using the 'thread 2.2' command, we
are only told about the thread change.

The 'Switching to inferior ...' line includes some useful information,
the process PID and the executable name, and I think it is a shame
that these are not presented when using the 'thread' command to switch
inferior.

So, this commit addresses this issue.

A question that came up during review, and which I'm clarifying here:
this change only affects the output of GDB when the thread command is
also used to switch inferiors.  I am (in effect) arguing that the
command 'thread 2.2' should be treated as a shorthand for 'inferior 2;
thread 2', and should display all of the associated output.  If the
user is only switching threads within a single inferior then it is not
necessary to re-display the inferior information.

I acknowledge that this does mean the output of the 'thread' command
will now be different depending on whether the user changes inferior
or not.  However, I think this is better than the alternative, having
the 'thread' command always re-print the inferior information.  I
think this would introduce excess noise that is not useful.

There are changes in basically two areas.  The easy part is in
thread_command (thread.c).  Here we spot when the inferior has changed
as a result of the 'thread' command, and include
USER_SELECTED_INFERIOR in the set of state passed to the
notify_user_selected_context_changed function.

The change in mi/mi-main.c is a little more involved.  In the
mi_cmd_execute function we use an instance of user_selected_context to
spot if any inferior state (frame, thread, or inferior) changes after
an MI command, this is then used to decide if there should be a call
to interps_notify_user_selected_context_changed.

First, by calling interps_notify_user_selected_context_changed
directly, instead of notify_user_selected_context_changed, we fail to
trigger the Python selected_context event, which feels like a
mistake.  If the context is changed via an MI command, I think we
should still trigger the Python event.  So the first thing I did was
change the interps_notify_user_selected_context_changed call into a
call to notify_user_selected_context_changed.  I updated the
gdb.python/py-selected-context.exp test to cover this case.

After that, in mi_cmd_execute, notify_user_selected_context_changed is
always passed 'USER_SELECTED_THREAD | USER_SELECTED_FRAME'.  This
makes sense, the MI doesn't allow "switching inferiors" as a command,
instead, an MI frontend must switch threads, and the inferior is
switched as a consequence.  But this does mean that if a user has a
CLI and MI interpreter running, and the MI switches threads, the CLI
will only receive the thread switch style notifications, that is,
there will be no "Switching to inferior ..." line.

What I've done is rename user_selected_context::has_changed to
user_selected_context::what_changed, this function is now responsible
for returning the set of USER_SELECTED_* flags that indicate what
changed.

If anything has changed then we always return USER_SELECTED_THREAD |
USER_SELECTED_FRAME as a minimum.  This retains the existing
behaviour, but is possibly more aggressive than we need to be; the
-stack-select-frame command can only change the frame, so maybe in
this case we should only return USER_SELECTED_FRAME?  I've left that
for the future though.

However, the important change is that in ::what_changed, I now spot
when the inferior has changed and include USER_SELECTED_INFERIOR in
the set of flags that are returned.

In mi_cmd_execute we now call the new what_changed function, and use
the set of flags returned when calling
notify_user_selected_context_changed.  This means that the CLI will
now receive inferior changed notifications when appropriate.

The gdb.mi/user-selected-context-sync.exp script has been updated,
replacing the comment I quoted above with an actual test that the
inferior change is announced correctly.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
4 weeks agogdb, fortran: Fix local variable lookup in Fortran parser
Abdul Basit Ijaz [Tue, 14 Apr 2026 21:23:51 +0000 (23:23 +0200)] 
gdb, fortran: Fix local variable lookup in Fortran parser

This change fixes https://sourceware.org/bugzilla/show_bug.cgi?id=34059.

The Fortran expression parser in GDB ("gdb/f-exp.y") previously performed
symbol lookup in this order when parsing identifiers:

- SEARCH_STRUCT_DOMAIN (types/structs)
- SEARCH_VFT ("C-like" name lookups for variables/types/functions)
- SEARCH_MODULE_DOMAIN (modules)

It searched for "types before variables", causing type names from shared
libraries to shadow local variable names.

For a reproducer like the one given below, the Fortran parser fails to
look up local variable name "array" and treats it as a type value instead
of a variable, because there's a conflicting "array" type from system
libraries.

1 program test
2
3  ! Declare variables used in this test.
4  integer, dimension (-2:2) :: array
5
6  array = 1
7
8  print *, ""           ! Break here
9  print *, array
10
11 end program test

Before the change, GDB shows:

'''
./gdb --data-directory=./data-directory --args /tmp/a.out
GNU gdb (GDB) 18.0.50.20260408-git
Copyright (C) 2026 Free Software Foundation, Inc.
...
Reading symbols from /tmp/a.out...
(gdb) break 8
Breakpoint 1 at 0x11b3: file test.f90, line 8.
(gdb) run
Starting program: /tmp/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, test () at test.f90:8
8         print *, ""           ! Break here
(gdb) info locals
array = (1, 1, 1, 1, 1)
(gdb) print array
Attempt to use a type name as an expression
(gdb) ptype array
type = Type array
    Type, C_Union :: :: u
    PTR TO -> ( char :: scratch(0:15 ))
End Type array
'''

This issue is fixed in the Fortran expression parser in GDB ("gdb/f-exp.y")
by prioritizing SEARCH_VFT over other search domains during symbol lookup.
After the change, the 'array' variable is resolved to the correct value.

'''
(gdb) print array
$1 = (1, 1, 1, 1, 1)
(gdb) ptype array
type = integer(kind=4) (-2:2)
'''

Approved-by: Kevin Buettner <kevinb@redhat.com>
4 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 4 May 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks agogprof: Fix strchr discarded qualifier call
Mark Wielaard [Sat, 2 May 2026 16:56:51 +0000 (18:56 +0200)] 
gprof: Fix strchr discarded qualifier call

In annotate_source strrchr is called on a const char *. So the result
should also be stored in a const char *.

* gprof/source.c (annotate_source): Make name_only a const char *.

4 weeks agold: Fix calls to strchr that discard or use wrong const qualifiers
Mark Wielaard [Sat, 2 May 2026 16:56:52 +0000 (18:56 +0200)] 
ld: Fix calls to strchr that discard or use wrong const qualifiers

* ld/emultempl/pe.em (pe_fixup_stdcalls): Make at a const char *.
(gldEMULATION_NAME_after_open): Make pnt a const char *.
(gldEMULATION_NAME_place_orphan): Make dollar a const char *.
* ld/emultempl/pep.em (pep_fixup_stdcalls): Make at a
const char *. Introduce at2 as non-const char *.
(gldEMULATION_NAME_after_open): Make pnt a const char *.
(gldEMULATION_NAME_place_orphan): Make dollar a const char *.
* ld/emultempl/spuelf.em (spu_elf_load_ovl_mgr): Make p a
const char *. Introduce np as char *.
* ld/ldelf.c (ldelf_search_needed): Call strchr on freeme, so
slash is non-const, then assign freeme to replacement.

4 weeks agoSimplify elf64_alpha_relocate_section
Alan Modra [Sun, 3 May 2026 11:36:37 +0000 (21:06 +0930)] 
Simplify elf64_alpha_relocate_section

Prior to Nick implementing _bfd_elf_make_dynamic_reloc_section, alpha
made no use of elf_section_data(sec)->sreloc to store the dynamic
relocation section associated with sec.  After commit 83bac4b01082 the
elf_section_data was set but not used in relocate_section.

* elf64-alpha.c (elf64_alpha_relocate_section): Use
elf_section_data to get dynamic relocation section associated
with the input section.