Commit Graph

1180 Commits

Author SHA1 Message Date
Tom Tromey
118245e166 Remove ada_ternop_slice
ada_ternop_slice can be merged with its sole caller.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-09-09 09:28:22 -06:00
Tom Tromey
b1618ec21a Remove ada_equal_binop
ada_equal_binop can be merged with its sole caller.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-09-09 09:27:28 -06:00
Tom Tromey
cfd104b66c Remove ada_unop_in_range
ada_unop_in_range can be merged with its sole caller.  This change
points out that one of the arguments was not needed.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-09-09 09:27:04 -06:00
Simon Marchi
fbb487b451 gdb: make iterate_over_objfiles_in_search_order methods of program_space and solib_ops
Change the "iterate over objfiles in search order" operation from a
gdbarch method to methods on both program_space and solib_ops.

The first motivation for this is that I want to encapsulate solib-svr4's
data into svr4_solib_ops (in a subsequent series), instead of it being
in a separate structure (svr4_info).  It is awkward to do so as long as
there are entry points that aren't the public solib_ops interface.

The second motivation is my project of making it able to have multiple
solib_ops per program space (which should be the subject of said
subsequent series), to better support heterogenousa systems (like ROCm,
with CPU and GPU in the same inferior).  When we have this, when stopped
in GPU code, it won't make sense to ask the host's architecture to do
the iteration, as the logic could be different for the GPU architecture.
Instead, program_space::iterate_over_objfiles_in_search_order will be
responsible to delegate to the various solib_ops using a logic that is
yet to be determined.

I included this patch in this series (rather than the following one)
so that svr4_solib_ops::iterate_over_objfiles_in_search_order can access
svr4_solib_ops::default_debug_base, introduced in a later patch in this
series.

default_iterate_over_objfiles_in_search_order becomes the default
implementation of solib_ops::iterate_over_objfiles_in_search_order.

As far as I know, all architectures using
svr4_iterate_over_objfiles_in_search_order also use solib_ops_svr4, so I
don't expect this patch to cause behavior changes.

Change-Id: I71f8a800b8ce782ab973af2f2eb5fcfe4e06ec76
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-08-22 10:45:47 -04:00
Simon Marchi
4260abb7a7 gdb: rename address_class -> location_class
The enum address_class and related fields and methods seem misnamed to
me.  Generalize it to "location_class".  The enumerators in
address_class are already prefixed with LOC, so the new name seems
logical to me.  Rename related fields and methods as well.

Plus, address_class could easily be mistaken for other unrelated things
named "address class" in GDB or DWARF.

Tested by rebuilding.

Change-Id: I0dca3738df412b350715286c608041b08e9b4d82
Approved-by: Kevin Buettner <kevinb@redhat.com>
2025-08-19 09:49:46 -04:00
Tom Tromey
89495c3326 Change type::fields to return an array_view
This patch changes type::fields to return an array_view of the fields,
then fixes up the fallout.

More cleanups would be possible here (in particular in the field
initialization code) but I haven't done so.

The main motivation for this patch was to make it simpler to iterate
over the fields of a type.

Regression tested on x86-64 Fedora 41.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-08-12 08:30:37 -06:00
Tom Tromey
5fe70629ce Change file initialization to use INIT_GDB_FILE macro
This patch introduces a new macro, INIT_GDB_FILE.  This is used to
replace the current "_initialize_" idiom when introducing a per-file
initialization function.  That is, rather than write:

    void _initialize_something ();
    void
    _initialize_something ()
    {
       ...
    }

... now you would write:

    INIT_GDB_FILE (something)
    {
       ...
    }

The macro handles both the declaration and definition of the function.

The point of this approach is that it makes it harder to accidentally
cause an initializer to be omitted; see commit 2711e475 ("Ensure
cooked_index_entry self-tests are run").  Specifically, the regexp now
used by make-init-c seems harder to trick.

New in v2: un-did some erroneous changes made by the script.

The bulk of this patch was written by script.
Regression tested on x86-64 Fedora 41.
2025-06-26 06:15:59 -06:00
Tom Tromey
762d4b9862 Use gdb::unordered_set for Ada symbol cache
This changes the Ada symbol cache to use gdb::unordered_set rather
than an htab.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-04-15 17:30:48 -06:00
Tom Tromey
82595d9e39 Use gdb::string_set for decoded_names_store
This patch changes decoded_names_store to use a gdb::string_set rather
than an htab.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-04-15 16:55:12 -06:00
Tom de Vries
7bef406490 [gdb/ada] Fix gdb.ada/overloads.exp on s390x
On s390x-linux, with test-case gdb.ada/overloads.exp and gcc 7.5.0 I run into:
...
(gdb) print Oload(CA)^M
Could not find a match for oload^M
(gdb) FAIL: $exp: print Oload(CA)
...

The mismatch happens here in ada_type_match:
...
      return ftype->code () == atype->code ();
...
with:
...
(gdb) p ftype->code ()
$3 = TYPE_CODE_TYPEDEF
(gdb) p atype->code ()
$4 = TYPE_CODE_ARRAY
...

At the start of ada_type_match, typedefs are skipped:
...
  ftype = ada_check_typedef (ftype);
  atype = ada_check_typedef (atype);
...
but immediately after this, refs are skipped:
...
  if (ftype->code () == TYPE_CODE_REF)
    ftype = ftype->target_type ();
  if (atype->code () == TYPE_CODE_REF)
    atype = atype->target_type ();
...
which in this case makes ftype a typedef.

Fix this by using ada_check_typedef after skipping the refs as well.

Tested on x86_64-linux and s390x-linux.

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

PR ada/32409
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32409
2025-04-15 16:59:32 +02:00
Tom Tromey
d01e823438 Update copyright dates to include 2025
This updates the copyright headers to include 2025.  I did this by
running gdb/copyright.py and then manually modifying a few files as
noted by the script.

Approved-By: Eli Zaretskii <eliz@gnu.org>
2025-04-08 10:54:39 -06:00
Tom Tromey
973c575967 Many minor typo fixes
I ran codespell on gdb/*.[chyl] and fixed a bunch of simple typos.
Most of what remains is trickier, i.e., spots where a somewhat natural
name of something in the code is flagged as a typo.

Reviewed-By: Tom de Vries <tdevries@suse.de>
2025-04-03 10:56:32 -06:00
Tom Tromey
f83d71e9c7 Update ada_add_block_renamings for compiler changes
With the hierarchical name patches to GNAT, ada_add_block_renamings
must now be updated as well -- the comment there about the supported
forms of DW_TAG_imported_declaration is no longer correct, and now
full names must sometimes be constructed during the lookup process.
2025-03-06 14:17:18 -07:00
Tom Tromey
7eccd2e407 Compare unqualified names in ada_identical_enum_types_p
With the coming changes to GNAT, gdb must compare the unqualified
names of two enum types.

Currently, GNAT will fully-qualify enumeration constant names, so for
instance one might see "enum_with_gap__lit4" as the name.

GNAT also may emit a copy of an enumeration type when a newtype is
involved.  E.g., in the arr_acc_idx_w_gap.exp test case, this can
occur for the base type of this subtype:

   type Enum_Subrange is new Enum_With_Gaps range Lit1 .. Lit3;

(Note that the base type of this subrange is anonymous.)

With some forthcoming changes to GNAT, these names will no longer be
qualified -- and because the newtype is anonymous, they can't be
identically qualified.  But, in gdb we still want "lit4" to resolve
without ambiguity in this scenario.

The fix is to change ada_identical_enum_types_p to compare unqualified
enum names.  This will work correctly with both variants of the
compiler, and with -fgnat-encodings=all as well.
2025-03-06 14:17:17 -07:00
Tom Tromey
a855184971 Use ada_identical_enum_types_p in ada_atr_enum_rep
With the coming changes to GNAT, we may see two distinct but
equivalent enum types in the DWARF.  In this case, it's better to use
ada_identical_enum_types_p rather than types_equal when comparing
these types... something that matters when using 'Enum_Rep.
2025-03-06 14:17:17 -07:00
Tom Tromey
56ddbf7284 Fix latent crash in ada_variant_discrim_name
ada_variant_discrim_name does this:

  for (discrim_end = name + strlen (name) - 6; discrim_end != name;

If NAME is too short, this will construct an invalid pointer, perhaps
causing a crash.

This patch arranges to check the length first.
2025-03-06 14:17:17 -07:00
Tom Tromey
29faeceaa8 Allow for anonymous Ada enumeration types
With some forthcoming changes to GNAT, gdb might see a nameless enum
in ada_resolve_enum, causing a crash.  This patch allows an anonymous
enum type to be considered identical to a named type when the contents
are identical.
2025-03-06 14:17:17 -07:00
Tom Tromey
5393cfd07a Avoid double-decoding in ada_add_global_exceptions
I noticed that ada_add_global_exceptions calls ada_decode on
'search_name' -- and then passes this to name_matches_regex, which
also calls ada_decode.

name_matches_regex is also used later, where the result of
'natural_name ()' is passed to it -- but natural_name also calls
ada_decode.

So, I think the call to ada_decode in name_matches_regex is redundant.
This patch removes it, and turns name_matches_regex into an inner
function to avoid propagating its use.

Note that, right now, the DWARF implementation of
expand_symtabs_matching does not in fact pass an encoded name to this
callback.  So, this code remains slightly (but currently harmlessly)
wrong.  expand_symtabs_matching is fixed by another pending series of
mine.
2025-03-06 07:08:14 -07:00
Tom Tromey
fbfadf9659 Avoid crash with 'length
While testing gnat-llvm, I found a gdb crash when applying 'length to
a non-array type.  This patch fixes the crash.
2025-01-22 08:08:25 -07:00
Tom Tromey
66834f8da9 Use block::is_static_block in ada-lang.c
This changes one spot in ada-lang.c to use block::is_static_block
rather than a hand-rolled implementation.  Note this also fixes the
call -- what is currently written there is wrong.

Approved-By: Tom de Vries <tdevries@suse.de>
2024-12-20 10:07:03 -07:00
Tom Tromey
f6dcf290ce Use generic_printstr from ada_language::printstr
Currently, if you create a lazy string while in Ada language mode, the
string will be rendered strangely, like:

    "["d0"]["9f"]["d1"]["80"]["d0"]["b8"]...

This happens because ada_printstr does not really handle UTF-8
decoding.

This patch changes ada_language::printstr to use generic_printstr when
UTF-8 is used.

Note that this code could probably be improved some more -- the
current patch only addresses the narrow case of the Python API.  I've
filed a follow-up bug (PR ada/32413) for the remaining changes.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-12-12 07:41:12 -07:00
Tom Tromey
b6f3ac06ee Improve choice sorting in ada-lang.c
ada-lang.c has a "sort_choices" function that claims to sort the
symbol choices, but which does not really implement sorting.  This
patch changes this code to really sort the result vector, sorting
first by filename, then line number, and finally by the symbol name.

The filename sorting is done first by comparing basenames.  It turns
out that gnatmake and gprbuild invoke the compiler a bit differently,
so depending on which one you use, the results of a naive sort might
be different (due to the use of absolute or relative paths).
2024-11-20 13:18:40 -07:00
Tom Tromey
b6829c3c91 Use an iterator range for 'using' directives
This patch changes block::get_using to return an iterator range.  This
seemed cleaner to me than the current approach of returning a pointer
to the first using directive; all the callers actually use this to
iterate.
2024-11-11 07:51:05 -07:00
Tom Tromey
fc55e99ad7 Wrap help strings at 80 columns
This patch ensures that all ordinary help strings are wrapped at 80
columns.  For the most part this consists of changing code like this
(note the embedded \n and the trailing backslash without a newline):

-Manage the space-separated list of debuginfod server URLs that GDB will query \
-when missing debuginfo, executables or source files.\nThe default value is \
-copied from the DEBUGINFOD_URLS environment variable."),

... to end each line with \n\, like:

+Manage the space-separated list of debuginfod server URLs that GDB will\n\
+query when missing debuginfo, executables or source files.\n\
+The default value is copied from the DEBUGINFOD_URLS environment variable."),

Approved-By: Eli Zaretskii <eliz@gnu.org>
2024-11-11 07:44:27 -07:00
Tom Tromey
04ce6b03d9 Implement 'Object_Size
This patch started as an attempt to allow the 'Size attribute to be
applied to types, and not just objects.

However, that turns out to be difficult due to the Ada semantcs of
'Size.  In particular, Ada requires 'Size to denote the size of the
representation of the value, so for example Boolean'Size must be 1.
Implementing this properly requires information not readily available
to gdb... and while we could synthesize this information in many
cases, it also seemed to me that this wasn't strictly very useful when
debugging.

So instead, this patch adds support for the 'Object_Size attribute,
which is somewhat closer to 'sizeof'.

Note also that while 'Object_Size is defined for some dynamic types, I
chose not to implement this here, as again this information is not
readily available -- and I think it's preferable to error than to
print something that might be incorrect.

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

Tested on x86_64-linux.
2024-10-06 07:59:48 +02:00
Andrew Burgess
bcb92f7ba7 gdb: more file name styling
While looking at the recent line number styling commit I noticed a few
places where we could add more file name styling.  So lets do that.

Approved-By: Tom Tromey <tom@tromey.com>
2024-10-02 10:10:20 +01:00
Tom Tromey
1ce2312391 Introduce and use operation::type_p
There's currently code in gdb that checks if an expression evaluates
to a type.  In some spots this is done by comparing the opcode against
OP_TYPE, but other spots more correctly also compare with OP_TYPEOF
and OP_DECLTYPE.

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

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

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

Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-10-01 13:25:25 -06:00
Tom de Vries
00105aa1c4 [gdb/symtab] Don't expand non-Ada CUs for info exceptions
I noticed when running test-case gdb.ada/info_exc.exp with glibc debug info
installed, that the "info exceptions" command that lists all Ada exceptions
also expands non-Ada CUs, which includes CUs in
/lib64/ld-linux-x86-64.so.2 and /lib64/libc.so.6.

Fix this by:
- adding a new lang_matcher parameter to the expand_symtabs_matching
  function, and
- using that new parameter in the expand_symtabs_matching call in
  ada_add_global_exceptions.

The new parameter is a hint, meaning implementations are free to ignore it and
expand CUs with any language.  This is the case for partial symtabs, I'm not
sure whether it makes sense to implement support for this there.

Conversely, when processing a CU with language C and name "<artificial>"
(as produced by GCC LTO), the CU may not really have a single language and we
should ignore the lang_matcher.  See also commit d2f6771173
("Fix 'catch exception' with -flto").

Now that we have lang_matcher available, also use it to limit name splitting
styles and symbol matchers to those applicable to the matched languages.

Without this patch we have (with a gdb build with -O0):
...
$ time gdb -q -batch -x outputs/gdb.ada/info_exc/gdb.in.1 > /dev/null
real	0m1.866s
user	0m2.089s
sys	0m0.120s
...
and with this patch we have:
...
$ time gdb -q -batch -x outputs/gdb.ada/info_exc/gdb.in.1 > /dev/null
real	0m0.469s
user	0m0.777s
sys	0m0.051s
...

Or, to put it in terms of number of CUs, we have 1853 CUs:
...
$ gdb -q -batch -readnow outputs/gdb.ada/info_exc/foo \
    -ex start \
    -ex "maint info symtabs" \
    | grep -c " name "
1853
...

Without this patch, we have:
...
$ gdb -q -batch outputs/gdb.ada/info_exc/foo \
    -ex start \
    -ex "info exceptions" \
    -ex "maint info symtabs" \
    | grep -c " name "
1393
...
so ~75% of the CUs is expanded, and with this patch we have:
...
$ gdb <same-as-above>
20
...
so ~1% of the CUs is expanded.

Tested on x86_64-linux.

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

PR symtab/32182
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32182
2024-09-24 10:24:22 +02:00
Tom Tromey
2bf0419eea Move enum size check into ada_identical_enum_types_p
Currently, the callers of ada_identical_enum_types_p must check that
both enum types have the same number of members.  In another series
I'm working on, it was convenient to move this check into the callee
instead; and I broke this patch out to make that series a little
simpler.

Approved-By: Tom de Vries <tdevries@suse.de>
2024-09-09 11:47:17 -06:00
Tom Tromey
511c6575b2 Minor cleanup to ada_identical_enum_types_p
This moves the declaration of 'i' into the 'for' loops in
ada_identical_enum_types_p.  This is just a trivial cleanup.

Approved-By: Tom de Vries <tdevries@suse.de>
2024-09-09 11:47:17 -06:00
Tom Tromey
6b82623187 Boolify ada_identical_enum_types_p
This changes ada_identical_enum_types_p to return bool rather than
int.

Approved-By: Tom de Vries <tdevries@suse.de>
2024-09-09 11:47:17 -06:00
Andrew Burgess
6cce025114 gdb: only insert thread-specific breakpoints in the relevant inferior
This commit updates GDB so that thread or inferior specific
breakpoints are only inserted into the program space in which the
specific thread or inferior is running.

In terms of implementation, getting this basically working is easy
enough, now that a breakpoint's thread or inferior field is setup
prior to GDB looking for locations, we can easily use this information
to find a suitable program_space and pass this to as a filter when
creating the sals.

Or we could if breakpoint_ops::create_sals_from_location_spec allowed
us to pass in a filter program_space.

So, this commit extends breakpoint_ops::create_sals_from_location_spec
to take a program_space argument, and uses this to filter the set of
returned sals.  This accounts for about half the change in this patch.

The second set of changes starts from breakpoint_set_thread and
breakpoint_set_inferior, this is called when the thread or inferior
for a breakpoint changes, e.g. from the Python API.

Previously this call would never result in the locations of a
breakpoint changing, after all, locations were inserted in every
program space, and we just use the thread or inferior variable to
decide when we should stop.  Now though, changing a breakpoint's
thread or inferior can mean we need to figure out a new set of
breakpoint locations.

To support this I've added a new breakpoint_re_set_one function, which
is like breakpoint_re_set, but takes a single breakpoint, and just
updates the locations for that one breakpoint.  We only need to call
this function if the program_space in which a breakpoint's thread (or
inferior) is running actually changes.  If the program_space does
change then we call the new breakpoint_re_set_one function passing in
the program_space which should be used to filter the new locations (or
nullptr to indicate we should set locations in all program spaces).
This filter program_space needs to propagate down to all the re_set
methods, this accounts for the remaining half of the changes in this
patch.

There were a couple of existing tests that created thread or inferior
specific breakpoints and then checked the 'info breakpoints' output,
these needed updating.  These were:

  gdb.mi/user-selected-context-sync.exp
  gdb.multi/bp-thread-specific.exp
  gdb.multi/multi-target-continue.exp
  gdb.multi/multi-target-ping-pong-next.exp
  gdb.multi/tids.exp
  gdb.mi/new-ui-bp-deleted.exp
  gdb.multi/inferior-specific-bp.exp
  gdb.multi/pending-bp-del-inferior.exp

I've also added some additional tests to:

  gdb.multi/pending-bp.exp

I've updated the documentation and added a NEWS entry.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-09-07 21:48:35 +01:00
Tom Tromey
d2f6771173 Fix 'catch exception' with -flto
A user noticed that when an Ada program (including the runtime) is
compiled with -flto, then "catch exception" does not work -- even
though setting the equivalent breakpoint by hand does work.

Looking into this, it turns out that GCC puts the exception functions
from the Ada runtime into a CU that uses the C language, not Ada.
Then, when trying to look up the relevant symbol,
lookup_name_info::search_name_hash uses the "verbatim" form of the
symbol name (like "<__gnat_debug_raise_exception>") rather than the
"<>"-less form, causing the symbol not to be found.

This patch fixes the problem in two steps.

First, lookup_name_info::search_name_hash is changed to use the same
hack that language_defn::get_symbol_name_matcher uses.  That is, when
the current language is Ada, verbatim-mode lookups are special-cased.
(This is a bit unfortunate; perhaps a better long term approach would
be to promote verbatim mode to a fundamental mode of
lookup_name_info.)

Second, although the above fixes the problem in the Ada language mode,
the code still fails in other languages.  However, due to the way
these lookups are coded in ada-lang.c, I think it makes sense to
temporarily set the current language to Ada in
create_ada_exception_catchpoint.

Tested on x86-64 Fedora 38.

A new test case that mimics the -flto scenario is included.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2024-09-06 12:31:50 -06:00
Tom Tromey
6a4eb277b7 Clear Ada symbol cache
This patch changes "maint flush symbol-cache" to also flush the
Ada-specific symbol cache.  This can be helpful when working on the
Ada code.

Approved-By: Tom de Vries <tdevries@suse.de>
2024-09-06 11:08:41 -06:00
Tom de Vries
bbc8c5a1d1 [gdb] Fix typos
Fix a few typos.

unconditionaly -> unconditionally
gratuitiously -> gratuitously
configureable -> configurable
represention -> representation
distiguished -> distinguished
breakpointer -> breakpoint
asssignments -> assignments
architectual -> architectural
compatibity -> compatibility
adjustement -> adjustment
unexcepted -> unexpected
propogated -> propagated
consistant -> consistent
succeding -> succeeding
higlight -> highlight
detachs -> detach

Tested by rebuilding on x86_64-linux.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-09-03 17:30:37 +02:00
Tom Tromey
16ffddc6b9 Simplify ada_identical_enum_types_p
This patch changes ada_identical_enum_types_p to reuse the field names
that are computed earlier in the loop.  This is a simple cleanup, but
also is useful for a larger change that I'm working on.

Tested on x86-64 Fedora 38.
2024-08-26 13:29:04 -06:00
Tom Tromey
a55790e992 Use SEARCH_FUNCTION_DOMAIN when looking for Ada exception symbols
While working on another bug, I noticed that the Ada code to find
exception symbols uses SEARCH_VFT.  This will find variables and types
-- but only functions are needed here.  This patch changes the code to
use SEARCH_FUNCTION_DOMAIN.

Tested on x86-64 Fedora 38, using a version of GNAT with the debuginfo
installed, to ensure the exception-related tests work.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-08-20 07:58:06 -06:00
Simon Marchi
4144d36a68 gdb: add program_space parameter to lookup_minimal_symbol
>From what I can see, lookup_minimal_symbol doesn't have any dependencies
on the global current state other than the single reference to
current_program_space.  Add a program_space parameter and make that
current_program_space reference bubble up one level.

Change-Id: I759415e2f9c74c9627a2fe05bd44eb4147eee6fe
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12 10:31:09 -04:00
Simon Marchi
c8979ae4fb gdb: make lookup_minimal_symbol objf and sfile parameters optional
Most calls to lookup_minimal_symbol don't pass a value for sfile and
objf.  Make these parameters optional (have a default value of
nullptr).  And since passing a value to `objf` is much more common than
passing a value to `sfile`, swap the order so `objf` comes first, to
avoid having to pass a nullptr value to `sfile` when wanting to pass a
value to `objf`.

Change-Id: I8e9cc6b942e593bec640f9dfd30f62786b0f5a27
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12 10:31:09 -04:00
Simon Marchi
03b40f6f55 gdb: drop struct keyword when using bound_minimal_symbol
This is a simple find / replace from "struct bound_minimal_symbol" to
"bound_minimal_symbol", to make things shorter and more consisten
througout.  In some cases, move variable declarations where first used.

Change-Id: Ica4af11c4ac528aa842bfa49a7afe8fe77a66849
Reviewed-by: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-08-12 10:31:09 -04:00
Tom de Vries
de272a5e90 [gdb/exp] Allow internal function to indicate return type
Currently an internal function handler has this prototype:
...
struct value *handler (struct gdbarch *gdbarch,
                       const struct language_defn *language,
                       void *cookie, int argc, struct value **argv);
...

Also allow an internal function with a handler with an additional
"enum noside noside" parameter:
...
struct value *handler (struct gdbarch *gdbarch,
                       const struct language_defn *language, void *cookie,
                       int argc, struct value **argv, enum noside noside);
...

In case such a handler is called with noside == EVAL_AVOID_SIDE_EFFECTS, it's
expected to return some value with the correct return type.

At least, provided it can do so without side effects, otherwise it should
throw an error.

No functional changes.

Tested on x86_64-linux and aarch64-linux.

Reviewed-By: Keith Seitz <keiths@redhat.com>
2024-07-24 16:32:35 +02:00
Simon Marchi
134a0a106c gdb: make objfile::pspace private
Rename to m_pspace, add getter.  An objfile's pspace never changes, so
no setter is necessary.

Change-Id: If4dfb300cb90dc0fb9776ea704ff92baebb8f626
2024-07-15 13:55:00 +00:00
Tom Tromey
3739147957 Simplify ada_lookup_encoded_symbol
This patch simplifies ada_lookup_encoded_symbol by having it return
its result, rather than returning void and having an out parameter.
2024-06-14 11:18:22 -06:00
Simon Marchi
05d9d66d92 gdb: remove unused includes in utils.h
Remove some includes reported as unused by clangd.  Add some includes in
other files that were previously relying on the transitive include.

Change-Id: Ibdd0a998b04d21362a20d0ca8e5267e21e2e133e
2024-05-30 22:43:52 -04:00
Simon Marchi
5b9707eb87 gdb: remove gdbcmd.h
Most files including gdbcmd.h currently rely on it to access things
actually declared in cli/cli-cmds.h (setlist, showlist, etc).  To make
things easy, replace all includes of gdbcmd.h with includes of
cli/cli-cmds.h.  This might lead to some unused includes of
cli/cli-cmds.h, but it's harmless, and much faster than going through
the 170 or so files by hand.

Change-Id: I11f884d4d616c12c05f395c98bbc2892950fb00f
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-25 12:59:02 -04:00
Simon Marchi
e5dc0d5d04 gdb: move a bunch of quit-related things to event-top.{c,h}
Move some declarations related to the "quit" machinery from defs.h to
event-top.h.  Most of the definitions associated to these declarations
are in event-top.c.  The exceptions are `quit()` and `maybe_quit()`,
that are defined in utils.c.  For consistency, move these two
definitions to event-top.c.

Include "event-top.h" in many files that use these things.

Change-Id: I6594f6df9047a9a480e7b9934275d186afb14378
Approved-By: Tom Tromey <tom@tromey.com>
2024-04-23 11:26:14 -04:00
Simon Marchi
ec45252592 gdb: move store/extract integer functions to extract-store-integer.{c,h}
Move the declarations out of defs.h, and the implementations out of
findvar.c.

I opted for a new file, because this functionality of converting
integers to bytes and vice-versa seems a bit to generic to live in
findvar.c.

Change-Id: I524858fca33901ee2150c582bac16042148d2251
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
Tom Tromey
542ea7fe46 Implement Ada 2022 iterated assignment
Ada 2022 includes iterated assignment for array initialization.  This
patch implements a subset of this for gdb.  In particular, only arrays
with integer index types really work -- currently there's no decent
way to get the index type in EVAL_AVOID_SIDE_EFFECTS mode during
parsing.  Fixing this probably requires the Ada parser to take a
somewhat more sophisticated approach to type resolution; and while
this would help fix another bug in this area, this patch is already
useful without it.
2024-04-02 11:24:27 -06:00
Tom Tromey
d9d782dd8b Introduce and use aggregate_assigner type
This patch is a refactoring to add a new aggregate_assigner type.
This type is passed to Ada aggregate assignment operations in place of
passing a number of separate arguments.  This new approach makes it
simpler to change some aspects of aggregate assignment behavior.
2024-04-02 11:24:26 -06:00