aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
AgeCommit message (Collapse)AuthorFilesLines
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.
2023-09-19Use gdb::checked_static_cast for catchpointsTom Tromey1-1/+1
This replaces some casts to various kinds of catchpoint with checked_static_cast. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-09-07[gdb/ada] Extend type equivalence test in ada_resolve_enumTom de Vries1-3/+18
When running test-case gdb.ada/local-enum.exp with target board debug-types, I run into: ... (gdb) print v1(three)^M No name 'three' in enumeration type 'local__e1'^M (gdb) FAIL: gdb.ada/local-enum.exp: print v1 element ... The array V1 is of type A1 which is an array with index type E1, containing "three" as enumerator: ... type E1 is (one, two, three); type A1 is array (E1) of Integer; V1 : A1 := (0, 1, 2); ... There's also a type E2 that contains three as enumerator: ... type E2 is (three, four, five); ... When doing "print v1(three)", it's the job of ada_resolve_enum to resolve "three" to type E1 rather than type E2. When using target board debug-types, the enums E1 and E2 are replicated in the .debug_types section, and consequently in ada_resolve_enum the type equivalence check using a pointer comparison fails: ... for (int i = 0; i < syms.size (); ++i) { /* We already know the name matches, so we're just looking for an element of the correct enum type. */ if (ada_check_typedef (syms[i].symbol->type ()) == context_type) return i; } ... Fix this by also trying a structural comparison using ada_identical_enum_types_p. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com> PR ada/29335 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29335
2023-09-07[gdb/ada] Move identical enums handling laterTom de Vries1-15/+20
When running test-case gdb.ada/arr_acc_idx_w_gap.exp with target board cc-with-dwz, I run into: ... (gdb) print enum_with_gaps'enum_rep(lit3)^M 'Enum_Rep requires argument to have same type as enum^M (gdb) FAIL: gdb.ada/arr_acc_idx_w_gap.exp: enum_rep ... With target_board unix, we have instead: ... (gdb) print enum_with_gaps'enum_rep(lit3)^M $16 = 13^M (gdb) PASS: gdb.ada/arr_acc_idx_w_gap.exp: enum_rep ... Conversely, when I add this test to the test-case: ... gdb_test "print enum_with_gaps'enum_rep(lit3)" " = 13" \ "enum_rep" + gdb_test "print enum_subrange'enum_rep(lit3)" " = 13" \ + "other enum_rep" ... the extra test passes with target board cc-with-dwz, but fails with target board unix. The problem is here in remove_extra_symbols: ... if (symbols_are_identical_enums (syms)) syms.resize (1); ... where one of the two identical enums is picked before the enum_rep handling can resolve lit3 to one of the two. Fix this by moving the code to ada_resolve_variable. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com> PR ada/30726 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30726
2023-09-05Use ada_value_subscript in valpy_getitemTom Tromey1-0/+1
Ada has a few complexities when it comes to array handling. Currently these are all handled in Ada-specific code -- but unfortunately that means they aren't really accessible to Python. This patch changes the Python code to defer to Ada when given an Ada array. In order to make this work, one spot in ada-lang.c had to be updated to set the "GNAT-specific" flag on an array type. The test case for this will come in a later patch.
2023-09-05Read Ada main name from executable, not inferiorTom Tromey1-0/+7
An upstream bug report points out this bug: if the user switches from one Ada executable to another without "kill"ing the inferior, then the "start" command will fail. What happens here is that the Ada "main" name is found in a constant string in the executable. But, if the inferior is running, then the process_stratum target reads from the inferior memory. This patch fixes the problem by changing the main name code to set trust-readonly-sections, causing the target stack to read from the executable instead. I looked briefly at changing GNAT to emit DW_AT_main_subprogram instead, but this looks to be pretty involved. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=25811
2023-08-31Add symbol::matches methodTom Tromey1-3/+2
This adds symbol::matches, a wrapper for symbol_matches_domain. Most places calling symbol_matches_domain can call this method instead, which is a bit less wordy and also (IMO) clearer. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-08-31gdb: remove TYPE_FIELD_BITSIZESimon Marchi1-26/+26
Replace with type::field + field::bitsize. Change-Id: I2a24755a33683e4a2775a6d2a7b7a9ae7362e43a Approved-By: Tom Tromey <tom@tromey.com>
2023-08-31gdb: introduce field::bitsize / field::set_bitsizeSimon Marchi1-12/+15
Add these two methods, rename the field to m_bitsize to make it pseudo private. Change-Id: Ief95e5cf106e72f2c22ae47b033d0fa47202b413 Approved-By: Tom Tromey <tom@tromey.com>
2023-08-31[gdb/symtab] Factor out type::{alloc_fields,copy_fields}Tom de Vries1-16/+3
After finding this code in buildsym_compunit::finish_block_internal: ... ftype->set_fields ((struct field *) TYPE_ALLOC (ftype, nparams * sizeof (struct field))); ... and fixing PR30810 by using TYPE_ZALLOC, I wondered if there were more locations that needed fixing. I decided to make things easier to spot by factoring out a new function alloc_fields: ... /* Allocate the fields array of this type, with NFIELDS elements. If INIT, zero-initialize the allocated memory. */ void type::alloc_fields (unsigned int nfields, bool init = true); ... where: - a regular use would be "alloc_fields (nfields)", and - an exceptional use that needed no initialization would be "alloc_fields (nfields, false)". Pretty soon I discovered that most of the latter cases are due to initialization by memcpy, so I added two variants of copy_fields as well. After this rewrite there are 8 uses of set_fields left: ... gdb/coffread.c: type->set_fields (nullptr); gdb/coffread.c: type->set_fields (nullptr); gdb/coffread.c: type->set_fields (nullptr); gdb/eval.c: type->set_fields gdb/gdbtypes.c: type->set_fields (args); gdb/gdbtypes.c: t->set_fields (XRESIZEVEC (struct field, t->fields (), gdb/dwarf2/read.c: type->set_fields (new_fields); gdb/dwarf2/read.c: sub_type->set_fields (sub_type->fields () + 1); ... These fall into the following categories: - set to nullptr (coffread.c), - type not owned by objfile or gdbarch (eval.c), and - modifying an existing fields array, like adding an element at the end or dropping an element at the start (the rest). Tested on x86_64-linux.
2023-08-17[gdb/build, c++20] Fix deprecated implicit capture of thisTom de Vries1-1/+1
When building gdb with -std=c++20 I run into: ... gdb/ada-lang.c:10713:16: error: implicit capture of ‘this’ via ‘[=]’ is \ deprecated in C++20 [-Werror=deprecated] 10713 | auto do_op = [=] (LONGEST x, LONGEST y) | ^ gdb/ada-lang.c:10713:16: note: add explicit ‘this’ or ‘*this’ capture ... Fix this by using "[this]". Likewise in two more spots. Tested on x86_64-linux.
2023-08-16Avoid buffer overflow in ada_decodeTom Tromey1-1/+18
A bug report pointed out a buffer overflow in ada_decode, which Keith helpfully analyzed. ada_decode had a logic error when the input was all digits. While this isn't valid -- and would probably only appear in fuzzer tests -- it still should be handled properly. This patch adds a missing bounds check. Tested with the self-tests in an asan build. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30639 Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-08-16Fix obvious bug in aggregate expressionTom Tromey1-1/+8
I found an obvious bug in Ada aggregate expression handling: if (vvo != nullptr) error (_("Invalid record component association.")); name = vvo->get_symbol ()->natural_name (); Here the code errors when vvo is not null -- and then proceeds to use vvo. This hasn't caused a crash because, I believe, there's currently no way to reach this code in the null case. However, I'm not really willing to assert this... Fixing this shows another bug, which is that due to the way the parser works, a field name in an aggregate expression might erroneously be fully qualified if some global variable with the same base name exists. The included test case triggers both bugs. Note that the test includes a confounding case for array aggregates as well, but as these are harder to fix, I've left it as kfail. As this is Ada-specific, and has already been tested internally at AdaCore, I am checking it in.
2023-07-21Implement Ada target name symbolTom Tromey1-0/+1
Ada 2022 adds the "target name symbol", which can be used on the right hand side of an assignment to refer to the left hand side. This allows for convenient updates. This patch implements this for gdb's Ada expression parser. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-07-21Remove ancient Ada workaroundTom Tromey1-17/+0
I ran across this very old code in gdb's Ada support. After a bit of archaeology, we couldn't determine what bug this might have been working around. It is no longer needed, so this patch removes it. As this is entirely Ada-specific and was reviewed and tested at AdaCore, I'm checking it in.
2023-07-13Implement 'Enum_Val and 'Enum_RepTom Tromey1-10/+48
This patch implements the Ada 2022 attributes 'Enum_Val and 'Enum_Rep. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-07-13Remove ada_attribute_nameTom Tromey1-32/+9
ada_attribute_name uses an array that must be kept in sync with an enum -- but the comment here refers to an enum that no longer exists. Looking at the sole caller, I see this can only be called for two opcodes. So, remove this entirely and inline it.