Jan Beulich [Fri, 13 Mar 2026 06:50:45 +0000 (07:50 +0100)]
gas: conditionalize body of create_obj_attrs_section()
This way bfd_elf_obj_attr_size() and bfd_elf_set_obj_attr_contents() will
remain unused for targets not supporting object attributes, which allows
libbfd to not provide them.
Also correct the surrounding #if-s: OBJ_MAYBE_ELF really needs taking into
consideration as well.
Alan Modra [Thu, 12 Mar 2026 22:25:04 +0000 (08:55 +1030)]
check sframe version in _bfd_elf_parse_sframe
Currently if you attempt to link an object file with sframe version 2
contents, the linker will complain in _bfd_elf_merge_section_sframe
and fail to produce an output. This affects anyone who has objects
assembled by binutils-2.45 with .sframe sections. A work-around is to
pass --discard-sframe to ld.
Ideally the linker would rewrite version 2 sframe input to version 3,
but in the absence of that support it would be nicer if ld just
ignored version 2 (or 1) sframe sections without needing to pass
--discard-sframe. That is the aim of this patch.
It does so by checking the sframe version in _bfd_elf_parse_sframe
where various failing checks result in an error being printed and the
section not being marked as SEC_INFO_TYPE_SFRAME, but causes no
overall linker failure. In addition, an sframe version failure now
also marks the sframe section with SEC_EXCLUDE. This is also done for
other sframe failures. See the changelog below for other fixes.
bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Don't check
sframe version here.
(_bfd_elf_parse_sframe): Check sframe version here instead.
Do the "already parsed" check first. Reorder various other
checks. Do not bother parsing or print errors when
discard_sframe is set. Free section contents on failure
paths. Set SEC_EXCLUDE for fails. Check for NULL bfd_zalloc
return, and only allocate after successfully parsing sframe.
On errors report that the section will be ignored, not "no
.sframe will be created".
binutils/
* testsuite/lib/binutils-common.exp: Ignore sframe version
errors.
Tom de Vries [Thu, 12 Mar 2026 20:16:59 +0000 (21:16 +0100)]
[gdb/testsuite] Handle debuginfod output in gdb.debuginfod/solib-with-dwz.exp
I ran into a timeout in test-case gdb.debuginfod/solib-with-dwz.exp.
GDB times out like this:
...
Download failed: Timer expired. \
Continuing without source file solib-with-dwz-bar.c.
...
My theory is that the download fails because debuginfod becomes unresponsive,
because it's stuck trying to write output into some buffer that is already
full.
Fix this by regularly draining debuginfod output in the test-case, using a new
proc drain_debuginfod.
Debuginfod is run with "-vvvv", which makes it rather verbose, and dropping
that also fixes the timeouts, but it might be useful for debugging, so I went
with the output draining method, and left the "-vvvv" as is.
Reviewed-By: Keith Seitz <keiths@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33901
Tom Tromey [Thu, 12 Mar 2026 17:17:31 +0000 (11:17 -0600)]
Fix the --disable-libctf build
If you configure with --disable-libctf, currently gdb will fail to
build. The fix is to rename the stub function elfctf_build_psymtabs
to remove the "p".
Simon Marchi [Wed, 11 Mar 2026 18:05:26 +0000 (14:05 -0400)]
gdb/dwarf: change die_needs_namespace to return bool
Change the return type to bool, and do some other trivial refactoring:
- remove unnecessary `attr` variable, which I don't think helps code
readability
- change an `if (cond) return false; return true` pattern to be just
one return expression.
Change-Id: I647c3ad73af94bb76c4b59f580bbdfd1eef45888 Approved-By: Tom Tromey <tom@tromey.com>
The code sign extending the low 32 bits into the high 32 bits in this
function does not have any address checking as it ignores the result
from bfd_perform_relocation. Even if it did take notice that isn't
sufficient. In little-endian mode a testcase could be crafted with
the low word at the end of a section which would put the high word out
of bounds.
I notice also that mips32_64bit_reloc is called from a rela R_MIPS_64
reloc howto. Using a rel R_MIPS_32 howto for the lower word can't be
correct as it retrieves the addend from section contents rather than
the reloc.
Fix both of these problems by performing the entire normal 64-bit
relocation first rather than trying to be clever doing it by pieces.
Nowadays config.bfd ensures that mips elf targets always have a 64-bit
bfd.
Also, don't trim addends to 32 bits for relocatable linking or gas.
That doesn't seem necessary and in any case wasn't done properly for
the rela case, where the addend is not in section contents but in the
relocation. Note that relocatable linking will usually be done by
elfxx-mips.c:_bfd_mips_elf_relocate_section. The main use of these
howtos is in gas and bfd_simple_get_relocated_section_contents.
Tom Tromey [Wed, 11 Mar 2026 13:46:11 +0000 (07:46 -0600)]
Do not reuse 'attr' in read_array_type
I was looking at dwarf2/read.c:read_array_type and I thought it would
be nicer if the 'attr' wasn't reused. This patch changes it to be
redeclared in every 'if' where it is used, making it clear that its
value is local to just the one block.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
MIPS/BFD: Make `_bfd_mips_elf_sign_extend' static inline
Let the function be inlined from outside elfxx-mips.c as well, avoiding
the call overhead for a simple arithmetic calculation, though we have no
such user at the moment.
Use common branchless code for `_bfd_mips_elf_sign_extend', typically
avoiding the branch penalty and also reducing code size when inlined in
elfxx-mips.c.
Tom Tromey [Tue, 10 Mar 2026 14:49:28 +0000 (08:49 -0600)]
Return void from ada-valprint.c:print_optional_low_bound
This changes ada-valprint.c:print_optional_low_bound to return void.
At first I was going to have it return bool, but then I noticed the
return value is never used.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Tom Tromey [Tue, 10 Mar 2026 13:55:47 +0000 (07:55 -0600)]
Use bool in ada_is_tagged_type
This changes ada_is_tagged_type to use 'bool' for its return and
parameter type, and then also changes ada_lookup_struct_elt_type to
propagate the boolean-ness.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Parse display gmon options only once so invalid arguments are not
reported twice and exit status is set to failure for invalid usage.
Also add tests in gp-gmon.exp to verify unknown options and missing
-o argument fail as expected and produce a single diagnostic.
gprofng/
* src/gp-gmon.cc (usage_and_exit): New function.
(check_mods): Change number of parameters.
(checkflagterm): Fix error text, update to use new functions.
* testsuite/gprofng.display/gp-gmon.exp: Add new test.
Kevin Buettner [Wed, 11 Mar 2026 00:14:10 +0000 (17:14 -0700)]
gdb/testsuite: Skip rwatch in watchpoint-unaligned.exp on s390x
The watchpoint-unaligned.exp test requires both read and write
hardware watchpoints. s390x only supports write watchpoints, causing
one test failure when the rwatch command fails with "Target does not
support this type of hardware watchpoint."
This commit causes the test using the rwatch command in this file to
be skipped when allow_hw_watchpoint_access_tests is false.
Co-Authored-By: Tom de Vries <tdevries@suse.de> Approved-By: Tom de Vries <tdevries@suse.de>
Tom de Vries [Tue, 10 Mar 2026 20:44:01 +0000 (21:44 +0100)]
[gdb] Minor refactoring of is_dynamic_type_internal
Simplify is_dynamic_type_internal by:
- factoring out type->field (i) for the TYPE_CODE_STRUCT/UNION case.
- merging a loop iteration variable declaration into a for statement
Tom Tromey [Tue, 10 Mar 2026 18:00:43 +0000 (12:00 -0600)]
Remove note about C++ demangler from Rust documentation
A note about the C++ demangler in the Rust documentation hasn't been
accurate for a while. Also, it probably isn't clear to users how this
related to the next bit of text in the same bullet point. This patch
removes the obsolete comment.
Simon Marchi [Sat, 21 Feb 2026 20:07:34 +0000 (15:07 -0500)]
gdb/dwarf: use gdb::unordered_map for line headers
Change htab_t for gdb::unordered_map, more specifically the
unordered_section_and_offset_map specialization.
It is no longer necessary to keep the section and offset inside the
line_header structure itself, because it's just used for the map key, so
remove that.
I tried my best to preserve the logic in decode_line_header_for_cu, but
I don't fully understand it.
Change-Id: I512652e6da8b25db77ac9974135f9a06ce3d831e Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:33 +0000 (15:07 -0500)]
gdb/dwarf: use (section, offset-in-section) as key for line_header hash
Similar to the previous patch, use the (section, offset-in-section)
tuple as the key to uniquely identify a line table header. Currently,
line_header objects are hashed based on the (offset-in-section, is-dwz)
tuple.
This removes the last instances of "offset_in_dwz" parameters, which I
never really liked, as they were oddly specific. Specifying the section
does the same job in a more generic way.
Change-Id: Ia4666f68111ce2210dc58f716eff37cf913eeeb9 Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:32 +0000 (15:07 -0500)]
gdb/dwarf: use (section, offset) as stmt_list key
It occurred to me that we could use (section, offset-in-section) tuples
as the key for a line table, replacing stmt_list_hash, just like we use
(section, offset-in-section) as the sort key in the
dwarf2_per_bfd::all_units vector. This is functionally the same, the
goal is to uniquely identify a line table, but I think it's clearer this
way. The tuple (section, offset-in-section) precisely and unambiguously
specifies a spot in an object file.
This allows deleting some specialized code, and eventually share code
with other places that would want to use section_and_offset as a key.
Change-Id: I1b45c7f653d71656b964c3f3789d8bb459774340 Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:31 +0000 (15:07 -0500)]
gdb/dwarf: store dwarf2_cus in expansion queue
The CU expansion queue currently holds dwarf2_per_cu items (see
dwarf2_queue_item). But there is this invariant that if a per_cu is
queued for expansion, then its DIEs are loaded in memory and a matching
dwarf2_cu object exists in dwarf2_per_objfile.
When a caller calls maybe_queue_comp_unit, a return value of `true`
indicates "the per_cu was enqueued, but its DIEs are not currently
loaded (a dwarf2_cu does not exist for it yet), so you must do it". The
caller is then responsible for calling some function to make it happen
and ensure the invariant is respected.
This feels backwards to me, I think it would be simpler if it was the
other way around. The queue should hold dwarf2_cu objects directly. To
enqueue a CU for expansion, a caller would therefore have to make sure
that a dwarf2_cu exists in the first place (i.e. that the unit's DIEs
are loaded), to pass it to queue_comp_unit. Often, the caller wants to
use the dwarf2_cu anyway, so it's not lost.
- Change dwarf2_queue_item to hold dwarf2_cu pointers. No need to have
a dwarf2_per_objfile anymore, since a dwarf2_cu provides it.
- Change queue_comp_unit and maybe_queue_comp_unit to take a dwarf2_cu.
- Change the order of operation in the spots that call
maybe_queue_comp_unit. Make sure the target unit is loaded first, by
calling one of the new ensure_loaded_* functions. Then, if the
return value is not nullptr (which happens if the unit is dummy),
then call maybe_queue_comp_unit.
- process_queue does not need to deal with possible dummy units, since
that is now filtered earlier. It is not possible to have a dwarf2_cu
for a dummy unit.
- Move the queued flag from dwarf2_per_cu to dwarf2_cu.
- Remove this assert from fill_in_sig_entry_from_dwo_entry, since the
queued flag is not longer in dwarf2_per_cu:
gdb_assert (! sig_entry->queued);
I think that the assert just below does the same job:
Simon Marchi [Sat, 21 Feb 2026 20:07:30 +0000 (15:07 -0500)]
gdb/dwarf: inline queue_and_load_dwo_tu
I noticed that queue_and_load_dwo_tu unnecessarily returned an integer
value, so I started by removing that. Then, I thought that it didn't
really need to be a separate function anymore, it would be clear enough
if the code was inlined into queue_and_load_all_dwo_tus.
Change-Id: Ibc5a83e87a10e6c0bf67ca955fcabbc90d9ac2ef Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:29 +0000 (15:07 -0500)]
gdb/dwarf: return dwarf2_cu from load_full_{comp,type}_unit
Make load_full_{comp,type}_unit return a non-owning reference to the
created dwarf2_cu. The functions still install the dwarf2_cu in
dwarf2_per_objfile::m_dwarf2_cus with dwarf2_per_objfile::set_cu.
Make dwarf2_per_objfile::set_cu return a non-owning reference as well,
for convenience. This makes things easier to follow, and reduces the
number of calls of unnecessary dwarf2_per_objfile::get_cu calls (i.e.
map lookups).
Change-Id: I51ed32585521cad0b89a4ca398915d7e0c1141e1 Approved-By: Tom Tromey <tom@tromey.com>
The first one is unnecessary, since the same assert is in
read_signatured_type.
The second one might be wrong, since read_signatured_type could in
theory not set the cu, if it is dummy.
Remove the existing load_full_type_unit and rename read_signatured_type
to load_full_type_unit. I prefer the latter name, for the parallel with
load_full_comp_unit, but also because I think it's clearer.
read_signatured_type makes it sound like it will read the type and build
the symbols, which is not the case. It only loads the DIEs in memory.
Change-Id: Ia411ccdaeae091298986b18e26d5583b896b2aa5 Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:27 +0000 (15:07 -0500)]
gdb/dwarf: remove unnecessary compunit_symtab_set_p check in process_queue
We know that enqueued per_cu objects never have a matching
compunit_symtab object set.
The two places where per_cus are enqueued are:
- maybe_queue_comp_unit, which has its own compunit_symtab_set_p check
- dw2_do_instantiate_symtab, which is only called if per_cu does not
have a compunit_symtab yet
process_queue therefore does not need to consider the possibility of
the compunit_symtab being set already.
Change-Id: Id8565d7f659813047ee15603598f9abd39993adc Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:26 +0000 (15:07 -0500)]
gdb/dwarf: remove unnecessary compunit_symtab_set_p check in dw2_do_instantiate_symtab
dw2_do_instantiate_symtab is called by dw2_instantiate_symtab, only if
per_cu does not have a matching compunit_symtab yet.
dw2_do_instantiate_symtab therefore does not need this
compunit_symtab_set_p itself.
Change-Id: Ie665980bb65016b56206c4aac36f4c2fc13c61de Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:25 +0000 (15:07 -0500)]
gdb/dwarf: remove just_read_cus from dwarf2_per_bfd
It is not necessary to keep the just_read_cus vector inside
dwarf2_per_bfd. This vector is only needed shortly, while we process
the CU expansion queue.
Instead of appending expanded comp units in process_full_comp_unit,
instantiate a local vector in process_queue, populate it with the
expanded comp units, and call process_cu_includes from there.
Remove the `if (!iter->is_debug_types ())` check in process_cu_includes:
we know that we only append comp units to this vector, no type units.
In compute_compunit_symtab_includes, remove the `if (cust == NULL)`
check: in process_queue, we only append the per_cus for which a
compunit_symtab was indeed created, no need to check it again here.
Change-Id: Ia50b703f379ae9dc90c9abc1d5269d4932f16e2d Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:24 +0000 (15:07 -0500)]
gdb/dwarf: make process_full_{comp,type}_unit return a compunit_symtab
This change makes it so that there is a single point in the code where
compunit symtabs are set (where dwarf2_per_objfile::set_compunit_symtab
is called), which I think helps understand how things work.
Change-Id: Ie84aa5141ebe1e2c7a990f59a62d95401a4b3e4a Approved-By: Tom Tromey <tom@tromey.com>
Simon Marchi [Sat, 21 Feb 2026 20:07:23 +0000 (15:07 -0500)]
gdb/dwarf: make dw2_search_one a method of dwarf2_base_index_functions
This function is used as a helper for readnow_functions::search and
cooked_index_functions::search. Just to better organize things, make it
a protected static method in the base class,
dwarf2_base_index_functions.
Change-Id: I0273c92379bf2337df16d28e21586125716e7de6 Approved-By: Tom Tromey <tom@tromey.com>
Python extension objects that support __dict__ must inherit from
gdbpy_dict_wrapper, a wrapper class that stores the PyObject
corresponding to the __dict__ attribute.
Currently, management of this dictionary is not centralized, and
each Python extension object implements its own logic to create,
access, and destroy it.
This patch focuses on the allocation of the dictionary, introduces
a new method, gdbpy_dict_wrapper::allocate_dict(), and
adapts the existing code to use this method.
Matthieu Longo [Thu, 26 Feb 2026 16:08:27 +0000 (16:08 +0000)]
gdb/python: flatten functions calling PyObject_New and use gdbpy_ref
This patch aims at systematically using gdbpy_ref<> at all call sites
of PyObject_New(). This prepares for future patches that expect
gdbby_ref<> parameters and affect return handling.
As part of this change, flattening the affected functions so that the
return logic becomes clearer and more flexible to adjust.
Matthieu Longo [Thu, 26 Feb 2026 17:20:20 +0000 (17:20 +0000)]
gdb/python: allow ref_ptr<T, Policy>::new_reference to accept subclasses of T
When ref_ptr<T,Policy>::new_reference() is specialized for 'PyObject'
(i.e. gdbpy_ref<>), it currently requires the argument type to be exactly
'PyObject *'. As a result, pointers to subclasses of 'PyObject' must be
explicitly cast before being passed, making call sites unnecessarily
verbose.
This patch makes ref_ptr<T,Policy>::new_reference() a template method
that accepts both T and subclasses of T, performing the cast to 'T *'
internally when needed. This removes redundant casts at call sites
without changing behavior.
Matthieu Longo [Fri, 20 Feb 2026 10:45:27 +0000 (10:45 +0000)]
gdb: introduce rgb_color type to simplify existing code
This patch replaces the raw uint8[3] buffer used to represent RGB values
with a more convenient wrapper, rgb_color, around std::array<uint8_t, 3>.
It also changes the return type of ui_file_style::color::get_rgb to
rgb_color instead of filling a caller-provided buffer, and updates all
callers accordingly.
This expected benefit of this change consists in:
- removing the manual size handling.
- proving accessors without using hard-coded indexes.
- making the API safer.
- simplifying call sites.
This refactoring does not introduce any functional change.