]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
4 weeks agoReturn bool from ada_is_ignored_field
Tom Tromey [Tue, 10 Mar 2026 13:52:06 +0000 (07:52 -0600)] 
Return bool from ada_is_ignored_field

This changes ada_is_ignored_field to return bool.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agogprofng: fix display gmon option error handling
Claudiu Zissulescu [Fri, 6 Mar 2026 10:20:52 +0000 (12:20 +0200)] 
gprofng: fix display gmon option error handling

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.

4 weeks agogdb/testsuite: Skip rwatch in watchpoint-unaligned.exp on s390x
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>
4 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 11 Mar 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 weeks ago[gdb] Minor refactoring of is_dynamic_type_internal
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

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoRemove note about C++ demangler from Rust documentation
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.

Approved-By: Eli Zaretskii <eliz@gnu.org>
4 weeks agogdb/dwarf: implement section_and_offset comparison using operator==
Simon Marchi [Tue, 10 Mar 2026 17:44:57 +0000 (13:44 -0400)] 
gdb/dwarf: implement section_and_offset comparison using operator==

This was suggested during review.

Change-Id: Iabe893f5b7ee1c4dce9655cbc323e3640e061aa3
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/dwarf: use gdb::unordered_map for line headers
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>
4 weeks agogdb/dwarf: use (section, offset-in-section) as key for line_header hash
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>
4 weeks agogdb/dwarf: use (section, offset) as stmt_list key
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>
4 weeks agogdb/dwarf: store dwarf2_cus in expansion queue
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:

     gdb_assert (per_objfile->get_cu (sig_entry) == NULL);

   Now that the queue holds dwarf2_cus, if there is no dwarf2_cu
   associated to a sig_entry, then necessarily that sig_entry is not
   enqueued.

Change-Id: I8ef0eb5f45f04b4cb45c3804627084d94bc6c4fd
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/dwarf: inline queue_and_load_dwo_tu
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>
4 weeks agogdb/dwarf: return dwarf2_cu from load_full_{comp,type}_unit
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>
4 weeks agogdb/dwarf: remove read_signatured_type
Simon Marchi [Sat, 21 Feb 2026 20:07:28 +0000 (15:07 -0500)] 
gdb/dwarf: remove read_signatured_type

load_full_type_unit is a thin wrapper around read_signatured_type, with
two asserts:

    static void
    load_full_type_unit (signatured_type *sig_type, dwarf2_per_objfile *per_objfile)
    {
      gdb_assert (per_objfile->get_cu (sig_type) == nullptr);
      read_signatured_type (sig_type, per_objfile);
      gdb_assert (per_objfile->get_cu (sig_type) != nullptr);
    }

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>
4 weeks agogdb/dwarf: remove unnecessary compunit_symtab_set_p check in process_queue
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>
4 weeks agogdb/dwarf: remove unnecessary compunit_symtab_set_p check in dw2_do_instantiate_symtab
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>
4 weeks agogdb/dwarf: remove just_read_cus from dwarf2_per_bfd
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>
4 weeks agogdb/dwarf: make process_full_{comp,type}_unit return a compunit_symtab
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>
4 weeks agogdb/dwarf: make dw2_search_one a method of dwarf2_base_index_functions
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>
4 weeks agogdb/dwarf: rename symtab -> compunit_symtab
Simon Marchi [Sat, 21 Feb 2026 20:07:22 +0000 (15:07 -0500)] 
gdb/dwarf: rename symtab -> compunit_symtab

In dwarf2_per_objfile, rename:

 - m_symtabs -> m_compunit_symtabs
 - get_symtab -> get_compunit_symtab
 - set_symtab -> set_compunit_symtab

In GDB, symtabs and compunit_symtabs are different things, so this
rename should make things clearer.

Change-Id: Iff3cdba68b72ec78ffd87f0b035b3367d7c03cf3
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoReturn bool from some Ada wild-match functions
Tom Tromey [Tue, 3 Mar 2026 17:54:01 +0000 (10:54 -0700)] 
Return bool from some Ada wild-match functions

This changes a few wild-match-related functions to return bool.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoReturn bool from ada-lang.c:is_name_suffix
Tom Tromey [Tue, 3 Mar 2026 17:53:26 +0000 (10:53 -0700)] 
Return bool from ada-lang.c:is_name_suffix

This changes ada-lang.c:is_name_suffix to return bool.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoMore Ada boolean-ization
Tom Tromey [Tue, 3 Mar 2026 17:52:33 +0000 (10:52 -0700)] 
More Ada boolean-ization

This changes a few more Ada functions to return bool.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoReturn bool from iterate_over_objfiles_in_search_order callbacks
Tom Tromey [Tue, 3 Mar 2026 17:50:39 +0000 (10:50 -0700)] 
Return bool from iterate_over_objfiles_in_search_order callbacks

I noticed that many callbacks passed to
iterate_over_objfiles_in_search_order were still returning 0/1 rather
than false/true.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoReturn bool from lookup_cached_symbol
Tom Tromey [Tue, 3 Mar 2026 17:46:15 +0000 (10:46 -0700)] 
Return bool from lookup_cached_symbol

This changes ada-lang.c:lookup_cached_symbol to return bool.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoReturn bool from various Ada type predicates
Tom Tromey [Tue, 3 Mar 2026 17:45:56 +0000 (10:45 -0700)] 
Return bool from various Ada type predicates

This changes a few more Ada type predicates to return bool.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoReturn bool from array-related Ada predicates
Tom Tromey [Tue, 3 Mar 2026 17:39:51 +0000 (10:39 -0700)] 
Return bool from array-related Ada predicates

This changes various array-related predicate functions in ada-lang.c
to return bool type.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoReturn bool from ada-lang.c:is_suffix
Tom Tromey [Tue, 3 Mar 2026 17:36:14 +0000 (10:36 -0700)] 
Return bool from ada-lang.c:is_suffix

Change ada-lang.c:is_suffix to return bool.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agogdb/testsuite: fix gdb.python/py-selected-context.exp with glibc debuginfo but no...
Jan Vrany [Tue, 10 Mar 2026 13:13:42 +0000 (13:13 +0000)] 
gdb/testsuite: fix gdb.python/py-selected-context.exp with glibc debuginfo but no source

When running gdb.python/py-selected-context.exp I get:

    thread 1
    [Switching to thread 1.1 (Thread 0x7ffff7da4740 (LWP 480841))]
    #0  __syscall_cancel_arch () at ../sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S:56
    warning: 56     ../sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S: No such file or directory
    Python Exception <class 'gdb.GdbError'>: error from gdb_selected_context_handler
    (gdb) FAIL: gdb.python/py-selected-context.exp: switch thread, handler raises an error

The problem is that glibc debug info is present but sources are not,
hence the warning.

Fix this by updating the regexp. Tested on x86_64 Linux with and without
glibc sources.

Approved-By: Tom de Vries <tdevries@suse.de>
4 weeks agogdb/python: add gdbpy_dict_wrapper:allocate_dict helper
Matthieu Longo [Fri, 27 Feb 2026 10:30:36 +0000 (10:30 +0000)] 
gdb/python: add gdbpy_dict_wrapper:allocate_dict helper

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.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/python: flatten functions calling PyObject_New and use gdbpy_ref
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.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/python: allow ref_ptr<T, Policy>::new_reference to accept subclasses of T
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.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: introduce rgb_color type to simplify existing code
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.

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

4 weeks agogas: don't duplicate include of config.h
Alan Modra [Mon, 9 Mar 2026 23:16:56 +0000 (09:46 +1030)] 
gas: don't duplicate include of config.h

The header is included by as.h, don't include it again.

4 weeks agoRemove POISON_BFD_BOOLEAN
Alan Modra [Mon, 9 Mar 2026 23:12:23 +0000 (09:42 +1030)] 
Remove POISON_BFD_BOOLEAN

We don't need this definition any more.  Incidentally, the poisoning
wasn't effective in gas since the define came after bfd.h was
included.

4 weeks agoUse store_unsigned_integer in findcmd.c
Tom Tromey [Sat, 7 Mar 2026 16:55:03 +0000 (09:55 -0700)] 
Use store_unsigned_integer in findcmd.c

This rewrites findcmd.c:put_bits to use store_unsigned_integer, and to
directly use the byte order.

Approved-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agoUse boolean constants in ft32-tdep.c
Tom Tromey [Sat, 7 Mar 2026 16:49:18 +0000 (09:49 -0700)] 
Use boolean constants in ft32-tdep.c

A couple of spots in ft32-tdep.c are using integer literals where
booleans are more appropriate.

Approved-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agogdb/target: remove async_callback_ftype
Simon Marchi [Mon, 2 Mar 2026 05:39:16 +0000 (00:39 -0500)] 
gdb/target: remove async_callback_ftype

It is unused.

Change-Id: I067dab91bac1707d2effa271d22c3a4bbf935a8f

4 weeks agogdb/gdbtypes: replace TYPE_IS_OPAQUE macro with method
Simon Marchi [Tue, 17 Feb 2026 19:13:58 +0000 (14:13 -0500)] 
gdb/gdbtypes: replace TYPE_IS_OPAQUE macro with method

Replace the TYPE_IS_OPAQUE macro with the method type::is_opaque.

Change-Id: I9d8875d9fedca5681f7b4a9a56e8e5cb0bf0ad78
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/gdbtypes: replace TYPE_ERROR_NAME macro with method
Simon Marchi [Tue, 17 Feb 2026 19:13:57 +0000 (14:13 -0500)] 
gdb/gdbtypes: replace TYPE_ERROR_NAME macro with method

Replace the TYPE_ERROR_NAME macro with the method type::error_name.

Change-Id: I59afa6a8ced9c3bb53f3961965479a11deb41407
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/gdbtypes: replace TYPE_SAFE_NAME macro with method
Simon Marchi [Tue, 17 Feb 2026 19:13:56 +0000 (14:13 -0500)] 
gdb/gdbtypes: replace TYPE_SAFE_NAME macro with method

Replace the TYPE_SAFE_NAME macro with the method type::safe_name.

Change-Id: I7ecaa6e5f88383821d2f227474c1c146ff731ff6
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_adjust_dwarf2_line parameter to bool
Simon Marchi [Mon, 9 Mar 2026 18:31:44 +0000 (14:31 -0400)] 
gdb: change gdbarch_adjust_dwarf2_line parameter to bool

Straightforward int to bool conversion.

Change-Id: I40b69ed4da58a375e5359d58768e58ad5afdf3be
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_print_registers_info parameter to bool
Simon Marchi [Mon, 9 Mar 2026 18:31:43 +0000 (14:31 -0400)] 
gdb: change gdbarch_print_registers_info parameter to bool

Straightforward int to bool conversion.

Change-Id: I27a35bb46c108474555cbad22fc33f0b4bcf7b51
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: remove psymtab.{c,h}
Simon Marchi [Sat, 28 Feb 2026 03:51:56 +0000 (22:51 -0500)] 
gdb: remove psymtab.{c,h}

The last user of psymtabs has been changed not to use them, remove them.

Update the tests minimally to avoid introducing failures (mostly due to
tests using the removed maintenance commands).  There are still a lot of
references to partial symtabs in the comments or test names.  There are
probably some tests that are just not relevant anymore.  It would be quite
difficult to do this job all at once, we can clean this up little by
little.

Update the docs to remove references to partial symbols/symtabs.

Mention the removal of the maintenance commands in NEWS.

Change-Id: I58ae48c30e0303bcaa48298146d69fb8f059cb32
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/ctf: don't use psymtabs, create symtabs directly
Simon Marchi [Sat, 28 Feb 2026 03:51:55 +0000 (22:51 -0500)] 
gdb/ctf: don't use psymtabs, create symtabs directly

The CTF debug info reader is the last user of partial symtabs.  Being a
fairly limited debug info format, CTF only uses a fraction of the
psymtab features.  So I see 3 ways forward:

 - keep psymtabs but trim them down, removing everything not useful for
   CTF

 - make the CTF reader implement its own index-like structure that
   implements the quick_symbol_functions interface (which would
   presumably be a small subset of partial symtabs)

 - make the CTF reader skip partial symtabs, create full symtabs
   directly

My hypothesis is that CTF debug info is typically small enough and fast
enough to process that it's not worth it to bother with an intermediate
step before full symbols.  But I will need help to see if this is true,
I'm not sure what representatively big C project I can build with CTF
debug info.  I tried to build the Linux kernel with -gctf, but I got
plenty of warnings like:

  ld: warning: orphan section `.ctf' from `vmlinux.o' being placed in section `.ctf'

GDB is still able to load the resulting ELF, and there are about 150k
calls to ctf_add_type_cb.  Before this patch, elfctf_build_psymtabs
takes anywhere between 300-350 ms.  With this patch, it's around 400 ms.

Implementation
--------------

This patch gets rid of the ctf_psymtab step, creating full symtabs from
the start.

The entry point elfctf_build_psymtabs gets renamed to
elfctf_build_symtabs.

Everything related to ctf_psymtab or partial symtabs is removed.

The build_ctf_archive_member function nows contains the code to build a
full symtab out of one CTF dict.  This code is not new for the most
part, it has been moved from other functions that used to be called when
expanding one symtab.

Change-Id: I728c1ef35785218c178fb467b80db71d59269a6d
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: make expanded_symbols_functions hold compunit symtabs
Simon Marchi [Sat, 28 Feb 2026 03:51:54 +0000 (22:51 -0500)] 
gdb: make expanded_symbols_functions hold compunit symtabs

Change the expanded_symbols_functions quick functions type to hold and
use a list of compunit symtab to search.

Currently, an expanded_symbols_functions instance will search all the
compunits in the objfile.  This is not efficient if an
expanded_symbols_functions instance exists alongside another quick
functions object in an objfile, as the compunits belonging to that other
object will be unnecessarily searched.

And at worst, I think it could be a source of subtle bugs.  For
instance, if the order of quick functions determine the order in which
we want the search to happen (the comment in elf_symfile_read suggests
this is the case), then having expanded_symbols_functions search the
compunits from other quick functions objects would not respect that
ordering.

Update the expanded_symbols_functions constructor to accept a vector of
compunits and store this vector in a field.  Update
expanded_symbols_functions methods to use that vector instead of the
objfile's compunits.

Right now the sole user of expanded_symbols_functions is JIT.  Update it
to keep a vector of compunits as they are finalized, and pass this
vector to the expanded_symbols_functions object.

Change-Id: Idf8de18b25fd3f71766166d6f420184af3c26b7e
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/ctf: add scoped_time_it in elfctf_build_psymtabs
Simon Marchi [Sat, 28 Feb 2026 03:51:53 +0000 (22:51 -0500)] 
gdb/ctf: add scoped_time_it in elfctf_build_psymtabs

This will be useful to determine the impact on the startup time getting
rid of partial symtabs has.

I use it like so:

    $ ./gdb -q -nx --data-directory=data-directory -iex "maint set per-command time on" /home/simark/src/linux/vmlinux.unstripped -batch
    ...
    Time for "elfctf_build_psymtabs": wall 0.381, user 0.357, sys 0.015, user+sys 0.372, 97.6 % CPU

Change-Id: I021319212f27eee0bf0f6c230f4e7cdd9c3602c1
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/ctf: check return value of ctf_type_align
Simon Marchi [Sat, 28 Feb 2026 03:51:52 +0000 (22:51 -0500)] 
gdb/ctf: check return value of ctf_type_align

I tried to build the Linux kernel with -gctf.  I am not sure if the
result is good, because I got plenty of warnings like:

    ld: warning: orphan section `.ctf' from `vmlinux.o' being placed in section `.ctf'

Nevertheless, I tried to load it in GDB, and it didn't complain.
However, when doing "maint expand-symtabs", I did hit this assert:

    /home/simark/src/binutils-gdb/gdb/gdbtypes.c:3640: internal-error: set_type_align: Assertion `(align & (align - 1)) == 0' failed.

This is because ctf_type_align returns -1 for some types, which is an
indication of an error.  Update the code to check the return value of
ctf_type_align for errors, and emit complaints if it happens.

With this patch, if I enable the complaints, I see a bunch of messages
like this:

    During symbol reading: ctf_type_align read_structure_type failed - Type is not a complete type.

Change-Id: Ibed23e7f1490d9163b8dde1318b9e45dec2906d6
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/ctf: use ctf_per_objfile in ctf_archive_iter_psymtab_data and ctf_context
Simon Marchi [Sat, 28 Feb 2026 03:51:51 +0000 (22:51 -0500)] 
gdb/ctf: use ctf_per_objfile in ctf_archive_iter_psymtab_data and ctf_context

This patch slightly reorganizes the data structures in ctfread.c to be a
bit more like in the DWARF reader.  That is, instead of duplicating the
information (for instance, the objfile pointer), keep the information
once in the most general object where in make sense (in the
ctf_per_objfile in this case) and have the more specific objects (like
ctf_context, ctf_archive_iter_psymtab_data) have a link to the more
general object.

Concretely, that means removing the archive and parent_dict fields from
ctf_archive_iter_psymtab_data and ctf_context (those are per-objfile
information), adding backlink to the ctf_per_objfile and using the
parent_dict and archive fields there.  Similarly, remove the objfile
fields from these and add a new objfile field in ctf_per_objfile.

Remove the objfile and dict parameters from the ctf_psymtab_add_stt_*
functions, since they can be obtained from the other parameters.

No functional changes expected.

Change-Id: I837264eece869f2bb962842998dede8cd7806bfe
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/ctf: editorial renames
Simon Marchi [Sat, 28 Feb 2026 03:51:50 +0000 (22:51 -0500)] 
gdb/ctf: editorial renames

Rename a few things to fit a bit more with how we typically name things,
or make the names more accurate.  I think this makes the code easier to
follow for anyone familiar with the GDB codebase (or at least, familiar
with the DWARF reader).  It's not super important, but it did help me
understand better the flow of the reader.

 - struct ctf_dict_info -> struct ctf_per_objfile
 - ctf_per_objfile::dict -> ctf_per_objfile::parent_dict
 - ctf_dict_key -> ctf_per_objfile_key
 - ctf_per_tu_data -> ctf_archive_iter_psymtab_data
 - ctf_archive_iter_psymtab_data::dict -> ctf_archive_iter_psymtab_data::parent_dict
 - of -> objfile
 - arc -> archive
 - In build_ctf_archive_member, ctf -> dict

Change-Id: I40f3cba8e40e4c9d006a96032a4c3856bd762ed5
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/ctf: add unique_ptr types
Simon Marchi [Sat, 28 Feb 2026 03:51:49 +0000 (22:51 -0500)] 
gdb/ctf: add unique_ptr types

Add ctf_archive_up and ctf_dict_up to automatically manage the lifetime
of a ctf_archive_t or ctf_dict_t and use them.

Change-Id: I51b3548b1bb28941c7bad776a11a238eb25789e4
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/ctf: add debug logging in ctfread.c
Simon Marchi [Sat, 28 Feb 2026 03:51:48 +0000 (22:51 -0500)] 
gdb/ctf: add debug logging in ctfread.c

Add some debug statements, to be able to visualize what is happening
when loading CTF debug info.  Add a new "set debug ctf" command, with
the usual logging macros.

Here's an example of the result, when reading the binary from test
gdb.ctf/cruss-tu-cyclic:

    [ctf] elfctf_build_psymtabs: start: building psymtabs for /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.ctf/cross-tu-cyclic/cross-tu-cyclic
      [ctf] scan_partial_symbols: start: fname='.ctf'
        [ctf] scan_partial_symbols: is parent, using fname='/home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.ctf/cross-tu-cyclic/cross-tu-cyclic'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x1 kind=INTEGER name='int'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x2 kind=INTEGER name='long int'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x3 kind=FORWARD name='B'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x5 kind=FORWARD name='A'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x8 kind=STRUCT name='C'
        [ctf] ctf_psymtab_add_stt_entries: adding function psym 'main' tid=0x7 kind=FUNCTION
      [ctf] scan_partial_symbols: end: fname='.ctf'
      [ctf] scan_partial_symbols: start: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x80000001 kind=STRUCT name='B'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x80000002 kind=STRUCT name='A'
      [ctf] scan_partial_symbols: end: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c'
      [ctf] scan_partial_symbols: start: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x80000001 kind=STRUCT name='A'
      [ctf] scan_partial_symbols: end: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c'
      [ctf] scan_partial_symbols: start: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x80000001 kind=STRUCT name='A'
      [ctf] scan_partial_symbols: end: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c'
      [ctf] scan_partial_symbols: start: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x80000001 kind=STRUCT name='A'
        [ctf] ctf_psymtab_type_cb: adding type tid=0x80000002 kind=STRUCT name='B'
      [ctf] scan_partial_symbols: end: fname='/home/simark/src/binutils-gdb/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c'
    [ctf] elfctf_build_psymtabs: end: building psymtabs for /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.ctf/cross-tu-cyclic/cross-tu-cyclic

Change-Id: If3800d14dd965ccefa67a24ef5c4481aef70ffa4
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb/corelow: mark bytes unavailable when reading from unavailable mapping
Simon Marchi [Mon, 2 Mar 2026 03:23:05 +0000 (22:23 -0500)] 
gdb/corelow: mark bytes unavailable when reading from unavailable mapping

The main motivation for this change is to nicely support "lightweight"
core files on ROCm (more on this below), but I think that the change
also makes sense for regular core files.

When handling a file mappings from a core file, the core target
attempts to open the referenced file.  If successful, the mappings from
this file end up in the m_core_file_mappings vector.  Otherwise, they
end up in the m_core_unavailable_mappings vector.

When trying to read from an address within an unavailable mapping,
unless the executable target beneath is able to fulfill the request, the
core target returns an error (TARGET_XFER_E_IO).  This is from
gdb.base/corefile.exp before the patch:

    (gdb) PASS: gdb.base/corefile.exp: accessing mmapped data in core file with coremmap.data removed
    x/8bd buf2ro
    0x7f095a517000: Cannot access memory at address 0x7f095a517000

I think that this would be a good use case for the "unavailable" status.
We know the memory was there at runtime, it's just not available during
post-mortem debugging.  That is the definition of "unavailable".  After
changing core_target::xfer_partial to report the bytes as unavailable,
which this patch does, the same test now shows:

    (gdb) PASS: gdb.base/corefile.exp: accessing mmapped data in core file with coremmap.data removed
    x/8bd buf2ro
    0x7f0250f52000: <unavailable>   <unavailable>   <unavailable>   <unavailable>   <unavailable>   <unavailable>   <unavailable>   <unavailable>

I would say that the output of the x command isn't great, but that is
just a presentation issue.

The original motivation for me to do this change is that we are working
on lightweight GPU core dump support in ROCm.  By default, the ROC
runtime will dump all the memory allocated in the context of the
crashing wave.  This can result in absurdly big core dumps.  With
lightweight core dumps, the runtime only dumps a certain subset of the
information that is considered essential.  When trying to read a value
from a segment of memory that was not dumped, I believe that it is
natural to use the "unavailable" status.  That is handled by this patch.

In the following example, `d` is a kernel parameter of type `int *`.
Its value was collected in the core dump, but the memory it points to,
allocated with hipMalloc, was not.  Before:

    (gdb) p data
    $1 = (int *) 0x78bf26e00000
    (gdb) p data[5]
    ❌️ Cannot access memory at address 0x78bf26e00014

After:

    (gdb) p data
    $1 = (int *) 0x78bf26e00000
    (gdb) p data[5]
    $2 = <unavailable>

Note that the same concept exists on Linux with the minicoredumper
project [1].  We could adjust the core target to act the same way when
dealing with minicoredumps.

[1] https://www.linutronix.de/minicoredumper/

Change-Id: I4df82ba4116e87545691facec0cb662c4b2b7797
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: remove extern from function declarations in gdbarch-gen.h
Simon Marchi [Fri, 27 Feb 2026 20:05:33 +0000 (15:05 -0500)] 
gdb: remove extern from function declarations in gdbarch-gen.h

Using extern on function declarations is not necessary, and in my
opinion it's just noise.

Change-Id: Ie44ca14651d49e7eb04db9b0bedf0af7a3676b45
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: convert typedefs to using in gdbarch-gen.h
Simon Marchi [Fri, 27 Feb 2026 20:05:32 +0000 (15:05 -0500)] 
gdb: convert typedefs to using in gdbarch-gen.h

We're using modern C++, so why not.

Change-Id: Iff5177727f8ce37cb1a6a9f69f3d47ba7974bd6c
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: adjust formatting of pointers in gdbarch-gen.{c,h}
Simon Marchi [Fri, 27 Feb 2026 20:05:31 +0000 (15:05 -0500)] 
gdb: adjust formatting of pointers in gdbarch-gen.{c,h}

Omit the space after pointer types.  This is purely for aesthetic
reasons, so that the formatting matches what we would write by hand.

Change-Id: I391ad25f79e529bf38e40e7bf97345a9c096fb10
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: remove unnecessary predefaults in gdbarch.py
Simon Marchi [Fri, 27 Feb 2026 20:05:30 +0000 (15:05 -0500)] 
gdb: remove unnecessary predefaults in gdbarch.py

These predefaults are unnecessary, because 0/nullptr/false is already
the default value.

Change-Id: I28b82ec4802075faa8f349f13f724542fa43f054
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: NULL -> nullptr in gdbarch-gen.c
Simon Marchi [Fri, 27 Feb 2026 20:05:29 +0000 (15:05 -0500)] 
gdb: NULL -> nullptr in gdbarch-gen.c

Use nullptr instead of NULL throughout gdbarch-gen.c (not the comments
though).

Change-Id: I35d5589e69f436c9312f81d24c37e40e33c70142
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: better gdbarch init values
Simon Marchi [Fri, 27 Feb 2026 20:05:28 +0000 (15:05 -0500)] 
gdb: better gdbarch init values

Change the initial values of the gdbarch structure fields to be
nullptr, false or 0, depending on their types (instead of just 0).

Define an `init_value()` method in the Value and Function classes to
provide the appropriate initial value for the component.  Use it at a
few places in gdbarch.py.

Change-Id: I700ca49b08a062e4d745531620c4913a733ca3e8
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_vsyscall_range to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:27 +0000 (15:05 -0500)] 
gdb: change gdbarch_vsyscall_range to return bool

Change-Id: I4faa4086e8dd43f99095c97b78390afe86601c67
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_insn_is_{call,ret,jump} to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:26 +0000 (15:05 -0500)] 
gdb: change gdbarch_insn_is_{call,ret,jump} to return bool

Change-Id: I5ff05978a1526d9aaeb6c4e46440009ca0d51116
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_has_dos_based_file_system to bool
Simon Marchi [Fri, 27 Feb 2026 20:05:25 +0000 (15:05 -0500)] 
gdb: change gdbarch_has_dos_based_file_system to bool

Change-Id: I62125fd2657224bf112dd031b9251597dfdf3b06
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_fast_tracepoint_valid_at to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:24 +0000 (15:05 -0500)] 
gdb: change gdbarch_fast_tracepoint_valid_at to return bool

Change-Id: Ib88a1667df6f580745a647e8ea9672b9b49a3f5c
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_has_shared_address_space to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:23 +0000 (15:05 -0500)] 
gdb: change gdbarch_has_shared_address_space to return bool

Change the target_is_uclinux global in m68k-linux-tdep.c to be an
std::optional, for clarity.

Change-Id: Ifb401865bac15dbb9803aeeb9f3d61ed965d6541
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_has_global_{solist,breakpoints} to bool
Simon Marchi [Fri, 27 Feb 2026 20:05:22 +0000 (15:05 -0500)] 
gdb: change gdbarch_has_global_{solist,breakpoints} to bool

Change-Id: I136cfd2fd42e8a3e3fbfc2e34a4b99e9f8fd438a
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_dtrace_probe_is_enabled to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:21 +0000 (15:05 -0500)] 
gdb: change gdbarch_dtrace_probe_is_enabled to return bool

Change-Id: Ib8bb5d2a0cfc91398da96b661a9436ee1df0a194
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_stap_is_single_operand to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:20 +0000 (15:05 -0500)] 
gdb: change gdbarch_stap_is_single_operand to return bool

Change-Id: I46976d84d1971df2cec75b70a1cf75168d740a10
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_register_to_value to return and take bool
Simon Marchi [Fri, 27 Feb 2026 20:05:19 +0000 (15:05 -0500)] 
gdb: change gdbarch_register_to_value to return and take bool

Convert the return value as well as two output parameters.  Convert some
frame support functions that have the same output parameters as well.

Change-Id: I4ed54aa79126b6d0387b550c20382ca21e500f1b
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_convert_register_p to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:18 +0000 (15:05 -0500)] 
gdb: change gdbarch_convert_register_p to return bool

Change-Id: I69e8af0b0e2eb847104fe54c28e6b5109d630ff5
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_get_longjmp_target to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:17 +0000 (15:05 -0500)] 
gdb: change gdbarch_get_longjmp_target to return bool

Change-Id: Ib3470d7af11c28335aacd011c9c97f60ad9a9803
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_cannot_{fetch,store}_register to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:16 +0000 (15:05 -0500)] 
gdb: change gdbarch_cannot_{fetch,store}_register to return bool

Change-Id: Ic659aea25f5c5592d90545797fefa7843a6322ef
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_vbit_in_delta to bool
Simon Marchi [Fri, 27 Feb 2026 20:05:15 +0000 (15:05 -0500)] 
gdb: change gdbarch_vbit_in_delta to bool

Remove the set_gdbarch_vbit_in_delta call in msp430-tdep.c, since the
value defaults to false.

Change-Id: I1fd2fa3c5d4049598325e826900c894a14e18ea1
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_vtable_function_descriptors to bool
Simon Marchi [Fri, 27 Feb 2026 20:05:14 +0000 (15:05 -0500)] 
gdb: change gdbarch_vtable_function_descriptors to bool

Change-Id: I52f2f6eb4511bf0d61f36a98aae8308ca6e01dac
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change *_find_memory_regions to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:13 +0000 (15:05 -0500)] 
gdb: change *_find_memory_regions to return bool

Change target_ops::find_memory_region, gdbarch_find_memory_regions and
associated helpers to return bool instead of int.  This is a bit
confusing, because the logic is swapped.  Previously, 0 meant "success,
carry on" and non-zero meant "failure, stop".  Now, true means "success,
carry on" and false means "failure, stop".

The gcore_memory_sections already used that logic, so for that one it's
a simple int to bool conversion.

I build-tested this on Solaris, for the procfs.c changes, and on
FreeBSD, for the fbsd-nat.c changes.  I haven't build-tested the other
native files.

Change-Id: I27ba892bb0dc949cdb4363275c8aded73ce338bc
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_register_reggroup_p to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:12 +0000 (15:05 -0500)] 
gdb: change gdbarch_register_reggroup_p to return bool

Change-Id: I1052345c4e537c5dfba37e175f21c8d0c5db2fc3
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_have_nonsteppable_watchpoint to bool
Simon Marchi [Fri, 27 Feb 2026 20:05:11 +0000 (15:05 -0500)] 
gdb: change gdbarch_have_nonsteppable_watchpoint to bool

There is one unnecessary call to
set_gdbarch_have_nonsteppable_watchpoint that passes false (which is the
default), in arc-tdep.c, but I left it there because there is an
insightful comment and I didn't feel like deleting it.

Change-Id: Iccb9851c1cf28f48a075649b1dbc7c9388383df3
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_cannot_step_breakpoint to bool
Simon Marchi [Fri, 27 Feb 2026 20:05:10 +0000 (15:05 -0500)] 
gdb: change gdbarch_cannot_step_breakpoint to bool

Change-Id: Ib8effd7eb66c1af9f4ef021fabc8be3cc2de660f
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_stack_frame_destroyed_p to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:09 +0000 (15:05 -0500)] 
gdb: change gdbarch_stack_frame_destroyed_p to return bool

Change-Id: Iea7ff0028983fc54428d9627dd1d1106b02e9f07
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_in_solib_return_trampoline_ftype to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:08 +0000 (15:05 -0500)] 
gdb: change gdbarch_in_solib_return_trampoline_ftype to return bool

Change-Id: I96f683f1408034b3e740c9abda37008262226dd9
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_single_step_through_delay to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:07 +0000 (15:05 -0500)] 
gdb: change gdbarch_single_step_through_delay to return bool

Change-Id: Ic640c9def74641c5f6213ce0f2e773c00b92d00b
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_return_in_first_hidden_param_p to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:06 +0000 (15:05 -0500)] 
gdb: change gdbarch_return_in_first_hidden_param_p to return bool

Change-Id: I49c58e5c1728bc4db735d618a1f3cf8c40dc1967
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_code_of_frame_writable to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:05 +0000 (15:05 -0500)] 
gdb: change gdbarch_code_of_frame_writable to return bool

Change-Id: I8cb29dba83a640caaf67f9b2849dcfda99c23aec
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_char_signed to bool
Simon Marchi [Fri, 27 Feb 2026 20:05:04 +0000 (15:05 -0500)] 
gdb: change gdbarch_char_signed to bool

Just like the previous commit, but for gdbarch_char_signed.

Change-Id: I4cd1f893c45925722391a0f0bccb82c39595a364
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_wchar_signed to bool
Simon Marchi [Fri, 27 Feb 2026 20:05:03 +0000 (15:05 -0500)] 
gdb: change gdbarch_wchar_signed to bool

Although this means we can't have:

  predefault="-1"
  postdefault="1"

anymore.  But I think that if we just set the predefault to true, it
will achieve the same result: the default will be true.

Remove a bunch of calls to set_gdbarch_wchar_signed that passed true,
since this is the default anyway.

Change-Id: I85810196ea6e58e94aa01e1fca6e0bb725c3131d
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_ax_pseudo_register_push_stack to return bool
Simon Marchi [Fri, 27 Feb 2026 20:05:02 +0000 (15:05 -0500)] 
gdb: change gdbarch_ax_pseudo_register_push_stack to return bool

Change-Id: I1da4dc7a8976aa901875e452813b37fa3518cdb5
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agogdb: change gdbarch_ax_pseudo_register_collect to return void
Simon Marchi [Fri, 27 Feb 2026 20:05:01 +0000 (15:05 -0500)] 
gdb: change gdbarch_ax_pseudo_register_collect to return void

I initially changed it to return bool instead of int, but then realized
that none of the implementations actually ever returned an error, so
change the return type to void.

Use gdb_assert_not_reached instead of internal_error, and remove the use
of the gettext macro, because these messages are typically not
translated, if we look at other call sites of gdb_assert_not_reached.

Change-Id: Iab9804f090805ded5a50336dbab8d1a0c099ce33
Approved-By: Tom Tromey <tom@tromey.com>
4 weeks ago[gdb/contrib] Avoid NotImplementedError in dwarf-to-dwarf-assembler.py
Tom de Vries [Mon, 9 Mar 2026 15:13:02 +0000 (16:13 +0100)] 
[gdb/contrib] Avoid NotImplementedError in dwarf-to-dwarf-assembler.py

The previous commit mentions:
...
      File "dwarf-to-dwarf-assembler.py", line 173, in _format_value
        raise NotImplementedError(f"Unknown data type: {type(self.value)}")
    NotImplementedError: Unknown data type: <class 'elftools.construct.lib.container.ListContainer'>
...

While the NotImplementedError makes its point clear, it's unhelpful in two ways:
- it's hard to find out what part of the input causes the error, and
- it may be that the user is not interested at all in the bit triggering the
  error, but some part after it, and the error prevents the user from seeing it

Fix this by returning an error string instead of raising an error, resulting in this output:
...
  DW_AT_upper_bound Unknown data type: <class 'elftools.construct.lib.container.ListContainer'>: \
    [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] DW_FORM_data16
...

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks ago[gdb/contrib] Handle DW_FORM_data16 in dwarf-to-dwarf-assembler.py
Tom de Vries [Mon, 9 Mar 2026 15:13:02 +0000 (16:13 +0100)] 
[gdb/contrib] Handle DW_FORM_data16 in dwarf-to-dwarf-assembler.py

I ran gdb/contrib/dwarf-to-dwarf-assembler.py on testsuite executable
gdb.ada/task_bp/foo, and ran into:
...
Traceback (most recent call last):
  File "dwarf-to-dwarf-assembler.py", line 660, in <module>
    main(sys.argv)
    ~~~~^^^^^^^^^^
  File "dwarf-to-dwarf-assembler.py", line 656, in main
    generator.generate()
    ~~~~~~~~~~~~~~~~~~^^
  File "dwarf-to-dwarf-assembler.py", line 628, in generate
    self.generate_die(die, indent_count)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "dwarf-to-dwarf-assembler.py", line 607, in generate_die
    die_lines = die.format(self.dwarf_parser.offset_to_die, indent_count)
  File "dwarf-to-dwarf-assembler.py", line 297, in format
    return "\n".join(self.format_lines(offset_die_lookup, indent_count))
                     ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "dwarf-to-dwarf-assembler.py", line 394, in format_lines
    inner_lines = super().format_lines(offset_die_lookup, indent_count + 1)
  File "dwarf-to-dwarf-assembler.py", line 285, in format_lines
    child_lines = child.format_lines(
        offset_die_lookup, indent_count=indent_count + 1
    )
  File "dwarf-to-dwarf-assembler.py", line 269, in format_lines
    attr_line = attr.format(
        offset_die_lookup, indent_count=indent_count + 1
    )
  File "dwarf-to-dwarf-assembler.py", line 219, in format
    s += self._format_value(offset_die_lookup)
         ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "dwarf-to-dwarf-assembler.py", line 173, in _format_value
    raise NotImplementedError(f"Unknown data type: {type(self.value)}")
NotImplementedError: Unknown data type: <class 'elftools.construct.lib.container.ListContainer'>
...
when trying to print the DW_FORM_data16 constant for this upper bound:
...
 <1><3af88>: Abbrev Number: 47 (DW_TAG_subrange_type)
    <3af89>   DW_AT_lower_bound : 0
    <3af89>   DW_AT_upper_bound : 0xffffffffffffffffffffffffffffffff
    <3af99>   DW_AT_name        : system__put_images__lll_integer_images__unsigned_typeXn
...

Fix this by handling elftools.construct.lib.container.ListContainer.

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks ago[gdb/contrib] Handle DW_LANG_Mips_Assembler in dwarf-to-dwarf-assembler.py
Tom de Vries [Mon, 9 Mar 2026 15:13:02 +0000 (16:13 +0100)] 
[gdb/contrib] Handle DW_LANG_Mips_Assembler in dwarf-to-dwarf-assembler.py

I ran gdb/contrib/dwarf-to-dwarf-assembler.py on a hello world executable, and
ran into:
...
Traceback (most recent call last):
  File "dwarf-to-dwarf-assembler.py", line 654, in <module>
    main(sys.argv)
    ~~~~^^^^^^^^^^
  File "dwarf-to-dwarf-assembler.py", line 650, in main
    generator.generate()
    ~~~~~~~~~~~~~~~~~~^^
  File "dwarf-to-dwarf-assembler.py", line 622, in generate
    self.generate_die(die, indent_count)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "dwarf-to-dwarf-assembler.py", line 601, in generate_die
    die_lines = die.format(self.dwarf_parser.offset_to_die, indent_count)
  File "dwarf-to-dwarf-assembler.py", line 291, in format
    return "\n".join(self.format_lines(offset_die_lookup, indent_count))
                     ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "dwarf-to-dwarf-assembler.py", line 388, in format_lines
    inner_lines = super().format_lines(offset_die_lookup, indent_count + 1)
  File "dwarf-to-dwarf-assembler.py", line 263, in format_lines
    attr_line = attr.format(
        offset_die_lookup, indent_count=indent_count + 1
    )
  File "dwarf-to-dwarf-assembler.py", line 209, in format
    s += "@" + LANG_NAME[self.value]
               ~~~~~~~~~^^^^^^^^^^^^
KeyError: 32769
...

The problem is that the language 0x8001 (DW_LANG_lo_user + 1) is not listed in
elftools.dwarf.enums.ENUM_DW_LANG.

This is MIPS vendor extension DW_LANG_MIPS_assembler, commonly used for
any assembly in DWARF versions that don't define a value for it (starting v6,
there's DW_LANG_Assembly).

Fix the generic case by emitting:
...
    DW_AT_language 32769 DW_FORM_sdata
...
and this specific case by emitting:
...
    DW_AT_language @DW_LANG_Mips_Assembler
...

Approved-By: Tom Tromey <tom@tromey.com>
4 weeks agoRemove minimal_symbol_reader::record
Tom Tromey [Sun, 8 Mar 2026 12:22:59 +0000 (06:22 -0600)] 
Remove minimal_symbol_reader::record

After the various symbol reader removals, it seems that
minimal_symbol_reader::record is no longer needed.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
4 weeks agogdb/python: accept gdbpy_ref in init helpers and return bool
Matthieu Longo [Fri, 27 Feb 2026 10:28:34 +0000 (10:28 +0000)] 
gdb/python: accept gdbpy_ref in init helpers and return bool

Passing 'gdbpy_ref<> &' instead of raw 'PyObject *' to init helpers
makes ownership of PyObject clearer at call sites, and removes
unnecessary '.get()' calls.
Changing the return type from 'int' to 'bool' improves readability
and better expresses the success/failure semantics.

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

4 weeks agoz80: use signed char for relative offset
Alan Modra [Sun, 8 Mar 2026 12:14:23 +0000 (22:44 +1030)] 
z80: use signed char for relative offset

A char is signed on some hosts, unsigned on others.

* z80-dis.c (prt_e): Don't use plain char for offset.

4 weeks agoupdate libiberty changelog
Alan Modra [Sun, 8 Mar 2026 21:48:20 +0000 (08:18 +1030)] 
update libiberty changelog

The gcc project updates ChangeLog files daily from git commit logs.
Update libiberty/Changelog so the binutils copy matches.

4 weeks agolibiberty: Copy over .ARM.attributes section into *.debug.temp.o files [PR124365]
Jakub Jelinek [Thu, 5 Mar 2026 12:11:39 +0000 (13:11 +0100)] 
libiberty: Copy over .ARM.attributes section into *.debug.temp.o files [PR124365]

If gcc is configured on aarch64-linux against new binutils, such as
2.46, it doesn't emit into assembly markings like
        .section        .note.gnu.property,"a"
        .align  3
        .word   4
        .word   16
        .word   5
        .string "GNU"
        .word   0xc0000000
        .word   4
        .word   0x7
        .align  3
but instead emits
        .aeabi_subsection aeabi_feature_and_bits, optional, ULEB128
        .aeabi_attribute Tag_Feature_BTI, 1
        .aeabi_attribute Tag_Feature_PAC, 1
        .aeabi_attribute Tag_Feature_GCS, 1
The former goes into .note.gnu.propery section, the latter goes into
.ARM.attributes section.

Now, when linking without LTO or with LTO but without -g, all behaves
for the linked binaries the same, say for test.c
int main () {}
$ gcc -g -mbranch-protection=standard test.c -o test; readelf -j .note.gnu.property test

Displaying notes found in: .note.gnu.property
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_PROPERTY_TYPE_0
      Properties: AArch64 feature: BTI, PAC, GCS
$ gcc -flto -mbranch-protection=standard test.c -o test; readelf -j .note.gnu.property test

Displaying notes found in: .note.gnu.property
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_PROPERTY_TYPE_0
      Properties: AArch64 feature: BTI, PAC, GCS
$ gcc -flto -g -mbranch-protection=standard test.c -o test; readelf -j .note.gnu.property test
readelf: Warning: Section '.note.gnu.property' was not dumped because it does not exist

The problem is that the *.debug.temp.o object files created by lto-wrapper
don't have these markings.  The function copies over .note.GNU-stack section
(so that it doesn't similarly on most arches break PT_GNU_STACK segment
flags), and .note.gnu.property (which used to hold this stuff e.g. on
aarch64 or x86, added in PR93966).  But it doesn't copy the new
.ARM.attributes section.

The following patch fixes it by copying that section too.  The function
unfortunately only works on names, doesn't know if it is copying ELF or some
other format (PE, Mach-O) or if it is copying ELF, whether it is EM_AARCH64
or some other arch.  The following patch just copies the section always,
I think it is very unlikely people would use .ARM.attributes section for
some random unrelated stuff.  If we'd want to limit it to just EM_AARCH64,
guess it would need to be done in
libiberty/simple-object-elf.c (simple_object_elf_copy_lto_debug_sections)
instead as an exception for the (*pfn) callback results (and there it could
e.g. verify SHT_AARCH64_ATTRIBUTES type but even there dunno if it has
access to the Ehdr stuff).

No testcase from me, dunno if e.g. the linker can flag the lack of those
during linking with some option rather than using readelf after link and
what kind of effective targets we'd need for such a test.

2026-03-05  Jakub Jelinek  <jakub@redhat.com>

PR target/124365
* simple-object.c (handle_lto_debug_sections): Also copy over
.ARM.attributes section.

4 weeks agolibiberty: fix resource exhaustion in rust demangler (PR demangler/106641)
Ruslan Valiyev [Thu, 26 Feb 2026 19:15:06 +0000 (19:15 +0000)] 
libiberty: fix resource exhaustion in rust demangler (PR demangler/106641)

demangle_binder() parses the bound_lifetimes count as a base-62
integer with no upper bound.  A crafted symbol can encode a huge
lifetime count in very few bytes, causing OOM or CPU hang.

Cap bound_lifetimes at 1024 and check rdm->errored in the loop
so it bails out early on errors during iteration.

libiberty/ChangeLog:

PR demangler/106641
* rust-demangle.c (demangle_binder): Reject bound_lifetimes
above 1024 to prevent resource exhaustion from crafted symbols.
Add rdm->errored check in the loop condition.
* testsuite/rust-demangle-expected: Add regression test.

Signed-off-by: Ruslan Valiyev <linuxoid@gmail.com>
4 weeks agolibiberty, Darwin: Fix handling of file offsets.
Iain Sandoe [Tue, 24 Feb 2026 11:44:27 +0000 (11:44 +0000)] 
libiberty, Darwin: Fix handling of file offsets.

In the case where a Mach-O object is embedded inside some container
(e.g. an archive) we must account the offset from the start of that
container when reading.  In most cases, this has been done correctly.
However, we were missing the case for reading segment data.  This
only showed up once we tried using archives (since regular Mach-O
objects start at the begining of the file).

Fixed thus.

libiberty/ChangeLog:

* simple-object-mach-o.c
(simple_object_mach_o_segment): Account for the offset of
this Mach-O object from the start of any container.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 weeks agolibiberty: Preserve `errno` across calls to `libiberty_vprintf_buffer_size()`
LIU Hao [Mon, 9 Feb 2026 13:44:07 +0000 (21:44 +0800)] 
libiberty: Preserve `errno` across calls to `libiberty_vprintf_buffer_size()`

The MSVCRT `strtoul()` function resets `errno` to zero upon success. On such
a system, `libiberty_vprintf_buffer_size()` could clobber `errno` like this:

   MINGW64 ~
   $ ld nonexistent.file
   C:\MSYS64\mingw64\bin\ld.exe: cannot find nonexistent.file: No error

libiberty/ChangeLog:

* vprintf-support.c (do_strtoul): New function.
(libiberty_vprintf_buffer_size): Replace `strtoul` with `do_strtoul`.

Signed-off-by: LIU Hao <lh_mouse@126.com>
4 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 8 Mar 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in