aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
AgeCommit message (Collapse)AuthorFilesLines
2024-10-06[gdb] Fix common misspellingsTom de Vries1-3/+3
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-02gdb: more file name stylingAndrew Burgess1-6/+9
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-01Introduce and use operation::type_pTom Tromey1-1/+1
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-09-24[gdb/symtab] Don't expand non-Ada CUs for info exceptionsTom de Vries1-1/+6
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 d2f67711730 ("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-09Move enum size check into ada_identical_enum_types_pTom Tromey1-10/+4
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-09Minor cleanup to ada_identical_enum_types_pTom Tromey1-4/+2
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-09Boolify ada_identical_enum_types_pTom Tromey1-6/+7
This changes ada_identical_enum_types_p to return bool rather than int. Approved-By: Tom de Vries <tdevries@suse.de>
2024-09-07gdb: only insert thread-specific breakpoints in the relevant inferiorAndrew Burgess1-3/+3
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-06Fix 'catch exception' with -fltoTom Tromey1-0/+4
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-06Clear Ada symbol cacheTom Tromey1-2/+2
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-03[gdb] Fix typosTom de Vries1-1/+1
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-08-26Simplify ada_identical_enum_types_pTom Tromey1-6/+3
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-20Use SEARCH_FUNCTION_DOMAIN when looking for Ada exception symbolsTom Tromey1-2/+4
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-12gdb: add program_space parameter to lookup_minimal_symbolSimon Marchi1-3/+6
>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-12gdb: make lookup_minimal_symbol objf and sfile parameters optionalSimon Marchi1-3/+3
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-12gdb: drop struct keyword when using bound_minimal_symbolSimon Marchi1-6/+6
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-07-24[gdb/exp] Allow internal function to indicate return typeTom de Vries1-8/+1
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-15gdb: make objfile::pspace privateSimon Marchi1-2/+2
Rename to m_pspace, add getter. An objfile's pspace never changes, so no setter is necessary. Change-Id: If4dfb300cb90dc0fb9776ea704ff92baebb8f626
2024-06-14Simplify ada_lookup_encoded_symbolTom Tromey1-11/+5
This patch simplifies ada_lookup_encoded_symbol by having it return its result, rather than returning void and having an out parameter.
2024-05-30gdb: remove unused includes in utils.hSimon Marchi1-0/+1
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-04-25gdb: remove gdbcmd.hSimon Marchi1-1/+1
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-23gdb: move a bunch of quit-related things to event-top.{c,h}Simon Marchi1-0/+1
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-22gdb: move store/extract integer functions to extract-store-integer.{c,h}Simon Marchi1-0/+1
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-02Implement Ada 2022 iterated assignmentTom Tromey1-1/+48
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-02Introduce and use aggregate_assigner typeTom Tromey1-85/+68
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-03-26gdb, gdbserver, gdbsupport: remove includes of early headersSimon Marchi1-1/+0
Now that defs.h, server.h and common-defs.h are included via the `-include` option, it is no longer necessary for source files to include them. Remove all the inclusions of these files I could find. Update the generation scripts where relevant. Change-Id: Ia026cff269c1b7ae7386dd3619bc9bb6a5332837 Approved-By: Pedro Alves <pedro@palves.net>
2024-03-21Implement Ada 2022 delta aggregatesTom Tromey1-4/+38
Ada 2022 includes a "delta aggregates" feature that can sometimes simplify aggregate creation. This patch implements this feature for GDB.
2024-03-19Speed up lookup of "type_specific_data"Tom Tromey1-1/+3
I noticed that "info locals" on a certain large Ada program was very slow. I tracked this down to ada_get_tsd_type expanding nearly every CU in the program. This patch fixes the problem by changing this code to use the more efficient lookup_transparent_type which, unlike the Ada-specific lookup functions, does not try to find all matching instances. Note that I first tried fixing this by changing ada_find_any_type, but this did not work -- I may revisit this approach at some later date. Also note that the copyright dates on the test files are set that way because I copied them from another test. New in v2: the new test failed on the Linaro regression tester. Looking at the logs, it seems that gdb was picking up a 'value' from libgnat: $1 = {<text variable, no debug info>} 0xf7e227a4 <ada.calendar.formatting.value> This version renames the local variable in an attempt to work around this. v3: In v2, while trying to reproduce the problem locally, I accidentally forgot to commit one of the changes.
2024-03-18Fix Ada 'ptype' of access to arrayTom Tromey1-1/+7
ptype is a bit funny, in that it accepts both expressions and type names. It also evaluates the resulting expression using EVAL_AVOID_SIDE_EFFECTS -- which both seems sensible (as a user would you expect ptype to possibly cause inferior execution?), but is also a historical artifact of how expressions are implemented (there's no EVAL_FOR_TYPE). In Ada, calling a function with an array will sometimes result in a "thick pointer" array descriptor being made. This is essentially a structure holding a pointer and bounds information. Currently, in such a callee, printing the type of the array will yield funny results: (gdb) print str.all $1 = "Hello World" (gdb) ptype str type = array (<>) of character (gdb) ptype str.all type = array (1 .. 0) of character That "1 .. 0" is the result of an EVAL_AVOID_SIDE_EFFECTS branch trying to do "something" with an array descriptor, without doing too much. I tried briefly to make this code really dereference the array descriptor and get the correct runtime type. However, that proved to be tricky; it certainly can't be done for all access types, because that will cause dynamic type resolution and end up printing just the runtime type -- which with variants may be pretty far from what the user may expect. Instead, this patch arranges to just leave such types alone in this situation. I don't think this should have an extra effects, because things like array subscripting still work on thick pointers. This patch also touches arrayptr.exp, because in that case the access type is a "thin pointer", and this ensures that the output does not change in that scenario.
2024-02-26Remove two unnecessary castsTom Tromey1-1/+1
I noticed a spot in ada-lang.c where the return value of value_as_address was cast to CORE_ADDR -- a no-op cast. I searched and found another. This patch fixes both.
2024-02-20gdb: pass frames as `const frame_info_ptr &`Simon Marchi1-5/+5
We currently pass frames to function by value, as `frame_info_ptr`. This is somewhat expensive: - the size of `frame_info_ptr` is 64 bytes, which is a bit big to pass by value - the constructors and destructor link/unlink the object in the global `frame_info_ptr::frame_list` list. This is an `intrusive_list`, so it's not so bad: it's just assigning a few points, there's no memory allocation as if it was `std::list`, but still it's useless to do that over and over. As suggested by Tom Tromey, change many function signatures to accept `const frame_info_ptr &` instead of `frame_info_ptr`. Some functions reassign their `frame_info_ptr` parameter, like: void the_func (frame_info_ptr frame) { for (; frame != nullptr; frame = get_prev_frame (frame)) { ... } } I wondered what to do about them, do I leave them as-is or change them (and need to introduce a separate local variable that can be re-assigned). I opted for the later for consistency. It might not be clear why some functions take `const frame_info_ptr &` while others take `frame_info_ptr`. Also, if a function took a `frame_info_ptr` because it did re-assign its parameter, I doubt that we would think to change it to `const frame_info_ptr &` should the implementation change such that it doesn't need to take `frame_info_ptr` anymore. It seems better to have a simple rule and apply it everywhere. Change-Id: I59d10addef687d157f82ccf4d54f5dde9a963fd0 Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-02-05Handling of arrays with optimized-out boundsTom Tromey1-2/+2
In Ada, sometimes the compiler must emit array bounds by referencing an artificial variable that's created for this purpose. However, with optimization enabled, these variables can be optimized away. Currently this can result in displays like: (gdb) print mumble $1 = (warning: unable to get bounds of array, assuming null array ) This patch changes this to report that the array is optimized-out, instead, which is closer to the truth, and more generally useful. For example, Python pretty-printers can now recognize this situation. In order to accomplish this, I introduced a new PROP_OPTIMIZED_OUT enumerator and changed one place to use it. Reusing the "unknown" state wouldn't work properly, because in C it is normal for array bounds to be unknown.
2024-02-01Rename SEARCH_ALLTom Tromey1-1/+1
The constant SEARCH_ALL conflicts with a define in a Windows header. This patch renames the constant to SEARCH_ALL_DOMAINS to avoid the conflict. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31307
2024-01-28Simplify some symbol searches in Ada codeTom Tromey1-8/+2
This changes some of the Ada code to simplify symbol searches. For example, if a function is being looked for, the search is narrowed to use SEARCH_FUNCTION_DOMAIN rather than SEARCH_VFT. In one spot, a search of the "struct" domain is removed, because Ada does not have a tag domain.
2024-01-28Use domain_search_flags in lookup_symbol et alTom Tromey1-7/+3
This changes lookup_symbol and associated APIs to accept domain_search_flags rather than a domain_enum. Note that this introduces some new constants to Python and Guile. I chose to break out the documentation patch for this, because the internals here do not change until a later patch, and it seemed simpler to patch the docs just once, rather than twice.
2024-01-28Use domain_search_flags in lookup_global_symbol_languageTom Tromey1-35/+36
This changes quick_symbol_functions::lookup_global_symbol_language to accept domain_search_flags rather than just a domain_enum, and fixes up the fallout. To avoid introducing any regressions, any code passing VAR_DOMAIN now uses SEARCH_VFT. That is, no visible changes should result from this patch. However, it sets the stage to refine some searches later on.
2024-01-28Replace search_domain with domain_search_flagsTom Tromey1-3/+3
This patch changes gdb to replace search_domain with domain_search_flags everywhere. search_domain is removed.
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess1-1/+1
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2023-12-15Refine Ada overload matchingTom Tromey1-11/+34
Currently, the overload handling in Ada assumes that any two array types are compatible. However, this is obviously untrue, and a user reported an oddity where comparing two Ada strings resulted in a call to the "=" function for packed boolean arrays. This patch improves the situation somewhat, by requiring that the two arrays have the same arity and compatible base element types. This is still over-broad, but it seems safe and is better than the status quo.
2023-12-15Boolify ada_type_matchTom Tromey1-5/+5
This changes ada_type_match to return bool.
2023-12-06Always use expand_symtabs_matching in ada-lang.cTom Tromey1-104/+15
The previous patch fixed the immediate performance problem with Ada name matching, by having a subset of matches call expand_symtabs_matching rather than expand_matching_symbols. However, it seemed to me that expand_matching_symbols should not be needed at all. To achieve this, this patch changes ada_lookup_name_info::split_name to use the decoded name, rather than the encoded name. In order to make this work correctly, a new decoded form is used: one that does not decode operators (this is already done) and also does not decode wide characters. The latter change is done so that changes to the Ada source charset don't affect the DWARF index. With this in place, we can change ada-lang.c to always use expand_symtabs_matching rather than expand_matching_symbols.
2023-12-06Improve performance of Ada name searchesTom Tromey1-2/+10
A user reported that certain operations -- like printing a large structure -- could be slow. I tracked this down to ada-lang.c:map_matching_symbols taking an inordinate amount of time. Specifically, calls like the one to look for a parallel "__XVZ" variable, in ada_to_fixed_type_1, could result in gdb walking over all the entries in the cooked index over and over. Looking into this reveals that cooked_index_functions::expand_matching_symbols is not written efficiently -- it ignores its "ordered_compare" parameter. While fixing this would be good, it turns out that this entire method isn't needed; so this series removes it. However, the deletion is not done in this patch. This one, instead, fixes the immediate cause of the slowdown, by using objfile::expand_symtabs_matching when possible. This approach is faster because it is more selective about which index entries to examine.
2023-11-29Use C++17 [[fallthrough]] attributeTom Tromey1-1/+1
This changes gdb to use the C++17 [[fallthrough]] attribute rather than special comments. This was mostly done by script, but I neglected a few spellings and so also fixed it up by hand. I suspect this fixes the bug mentioned below, by switching to a standard approach that, presumably, clang supports. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23159 Approved-By: John Baldwin <jhb@FreeBSD.org> Approved-By: Luis Machado <luis.machado@arm.com> Approved-By: Pedro Alves <pedro@palves.net>
2023-11-21gdb: Remove uses of gdb::to_string (const std::string_view &)Lancelot Six1-12/+9
This patch removes all uses of to_string(const std::string_view&) and use the std::string ctor or implicit conversion from std::string_view to std::string instead. A later patch will remove this gdb::to_string while removing gdbsupport/gdb_string_view.h. Change-Id: I877cde557a0727be7b0435107e3c7a2aac165895 Approved-By: Tom Tromey <tom@tromey.com> Approved-By: Pedro Alves <pedro@palves.net>
2023-11-21gdb: Use std::string_view instead of gdb::string_viewLancelot Six1-4/+5
Given that GDB now requires a C++17, replace all uses of gdb::string_view with std::string_view. This change has mostly been done automatically: - gdb::string_view -> std::string_view - #include "gdbsupport/gdb_string_view.h" -> #include <string_view> One things which got brought up during review is that gdb::stging_view does support being built from "nullptr" while std::sting_view does not. Two places are manually adjusted to account for this difference: gdb/tui/tui-io.c:tui_getc_1 and gdbsupport/format.h:format_piece::format_piece. The above automatic change transformed "gdb::to_string (const gdb::string_view &)" into "gdb::to_string (const std::string_view &)". The various direct users of this function are now explicitly including "gdbsupport/gdb_string_view.h". A later patch will remove the users of gdb::to_string. The implementation and tests of gdb::string_view are unchanged, they will be removed in a following patch. Change-Id: Ibb806a7e9c79eb16a55c87c6e41ad396fecf0207 Approved-By: Tom Tromey <tom@tromey.com> Approved-By: Pedro Alves <pedro@palves.net>
2023-11-21gdb: Replace gdb::optional with std::optionalLancelot Six1-3/+3
Since GDB now requires C++17, we don't need the internally maintained gdb::optional implementation. This patch does the following replacing: - gdb::optional -> std::optional - gdb::in_place -> std::in_place - #include "gdbsupport/gdb_optional.h" -> #include <optional> This change has mostly been done automatically. One exception is gdbsupport/thread-pool.* which did not use the gdb:: prefix as it already lives in the gdb namespace. Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9 Approved-By: Tom Tromey <tom@tromey.com> Approved-By: Pedro Alves <pedro@palves.net>
2023-10-10gdb: remove target_gdbarchSimon Marchi1-3/+4
This function is just a wrapper around the current inferior's gdbarch. I find that having that wrapper just obscures where the arch is coming from, and that it's often used as "I don't know which arch to use so I'll use this magical target_gdbarch function that gets me an arch" when the arch should in fact come from something in the context (a thread, objfile, symbol, etc). I think that removing it and inlining `current_inferior ()->arch ()` everywhere will make it a bit clearer where that arch comes from and will trigger people into reflecting whether this is the right place to get the arch or not. Change-Id: I79f14b4e4934c88f91ca3a3155f5fc3ea2fadf6b Reviewed-By: John Baldwin <jhb@FreeBSD.org> Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-10-05gdb: add all_objfiles_removed observerSimon Marchi1-2/+4
The new_objfile observer is currently used to indicate both when a new objfile is added to program space (when passed non-nullptr) and when all objfiles of a program space were just removed (when passed nullptr). I think this is confusing (and Andrew apparently thinks so too [1]). Add a new "all_objfiles_removed" observer to remove the second role from "new_objfile". Some existing users of new_objfile do nothing if the passed objfile is nullptr. For them, we can simply drop the nullptr check. For others, add a new all_objfiles_removed callback, and refactor things a bit to keep the existing behavior as much as possible. Some callbacks relied on current_program_space, and following the refactoring now use either objfile->pspace or the pspace passed to all_objfiles_removed. I think this should be relatively safe, and in general a step in the right direction. On the notify side, I found only one call site to change from new_objfile to all_objfiles_removed, in clear_symtab_users. It is not entirely clear to me that this is entirely correct. clear_symtab_users appears to be called in spots that don't remove all objfiles (functions finish_new_objfile, remove_symbol_file_command, reread_symbols, do_module_cleanups). But I think that this patch at least makes the current code clearer. [1] https://gitlab.com/gnutools/binutils-gdb/-/commit/a0a031bce0527b1521788b5dad640e7883b3a252 Change-Id: Icb648f72862e056267f30f44dd439bd4ec766f13 Approved-By: Tom Tromey <tom@tromey.com>
2023-10-05gdb: add program_space parameter to ada_clear_symbol_cacheSimon Marchi1-4/+4
Make the references to current_program_space bubble up one level. Change-Id: I82acab5628c30f6535d52aa32ce2c1d0375cbeed Approved-By: Tom Tromey <tom@tromey.com>
2023-09-19Add is_array_like and to_array to language_defnTom Tromey1-0/+13
This adds new is_array_like and to_array methods to language_defn. This will be used in a subsequent patch that generalizes the new Python array- and string-handling code.