aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-exp.y
AgeCommit message (Collapse)AuthorFilesLines
2024-10-22Implement 'Object_SizeTom Tromey1-5/+7
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-09-27gdb/symtab: pass program space to lookup_symtab and iterate_over_symtabsSimon Marchi1-1/+1
Make the current program space references bubble up. In collect_symtabs_from_filename, remove the calls to set_current_program_space and just pass the relevant pspaces. This appears safe to do, because nothing in the `collector` callback cares about the current pspace. Change-Id: I00a7ed484bfbe5264f01a6abf0d33b51de373cbb Reviewed-by: Keith Seitz <keiths@redhat.com>
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-12gdb: drop struct keyword when using bound_minimal_symbolSimon Marchi1-1/+1
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-15gdb: pass program space to have_{full,partial}_symbolsSimon Marchi1-1/+3
Make the current program space reference bubble up one level. Change-Id: I19c4fc2ca955f9c828ef426a077b43983865697b Approved-By: Tom Tromey <tom@tromey.com> Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
2024-06-24Include needed unordered_map headerMartin Simmons1-0/+1
Compiling on FreeBSD 13.2 with the default clang version 14.0.5 and top level configure options --with-python=/usr/local/bin/python3.9 gives this error: CXX ada-exp.o ./../binutils-gdb/gdb/ada-exp.y:100:8: error: no template named 'unordered_map' in namespace 'std' std::unordered_map<std::string, std::vector<ada_index_var_operation *>> ~~~~~^ 1 error generated. This change fixes it. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31918 Approved-By: Tom Tromey <tom@tromey.com>
2024-06-14Simplify ada_lookup_encoded_symbolTom Tromey1-5/+5
This patch simplifies ada_lookup_encoded_symbol by having it return its result, rather than returning void and having an out parameter.
2024-04-02Move "returned_complete" into ada_parse_stateTom Tromey1-0/+7
This moves the "returned_complete" global into ada_parse_state.
2024-04-02Move "paren_depth" into ada_parse_stateTom Tromey1-0/+3
This moves the "paren_depth" global into ada_parse_state.
2024-04-02Move "temp_parse_space" into ada_parse_stateTom Tromey1-17/+11
This patch moves the "temp_parse_space" global into ada_parse_state. It is also renamed to remove the redundant "parse". Finally, it is changed to an auto_obstack to avoid the need for any manual management.
2024-04-02Move "iterated_associations" into ada_parse_stateTom Tromey1-13/+12
This patch moves the "iterated_associations" global into ada_parse_state.
2024-04-02Move "assignments" global into ada_parse_stateTom Tromey1-13/+12
This patch moves the "assignments" global into ada_parse_state.
2024-04-02Move "components" and "associations" into ada_parse_stateTom Tromey1-17/+15
This patch moves the "components" and "associations" globals into ada_parse_state.
2024-04-02Move "int_storage" global into ada_parse_stateTom Tromey1-6/+11
This patch moves the "int_storage" global into ada_parse_state.
2024-04-02Introduce ada_parse_stateTom Tromey1-17/+34
This patch introduces the ada_parse_state class and the ada_parser global. It also changes find_completion_bounds to be a method of this new type. Note that find_completion_bounds never used its parameter; and because it is generally fine to use the 'pstate' global throughout the parser, this patch removes the parameter entirely.
2024-04-02Implement Ada 2022 iterated assignmentTom Tromey1-4/+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-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-1/+11
Ada 2022 includes a "delta aggregates" feature that can sometimes simplify aggregate creation. This patch implements this feature for GDB.
2024-03-18Remove some unnecessary Ada expression codeTom Tromey1-6/+6
ada_bitwise_operation differs from the "usual" bitwise operations only in that it calls value_cast at the end. However, because gdb is generally fairly lax about integer types, and because (perhaps oddly) C-style binary promotion is done here anyway, it seems to me that this code isn't needed.
2024-01-28Simplify some symbol searches in Ada codeTom Tromey1-2/+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_global_symbol_languageTom Tromey1-6/+7
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-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.
2024-01-04gdb: merge error handling from different expression parsersAndrew Burgess1-1/+1
Many (all?) of the expression parsers implement yyerror to handle parser errors, and all of these functions are basically identical. This commit adds a new parser_state::parse_error() function, which implements the common error handling code, this function can then be called from all the different yyerror functions. The benefit of this is that (in a future commit) I can improve the error output, and all the expression parsers will benefit. This commit is pure refactoring though, and so, there should be no user visible changes after this commit. Approved-By: John Baldwin <jhb@FreeBSD.org>
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-07-21Implement Ada target name symbolTom Tromey1-7/+34
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-13Implement 'Enum_Val and 'Enum_RepTom Tromey1-1/+13
This patch implements the Ada 2022 attributes 'Enum_Val and 'Enum_Rep. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-05-23Add PARSER_DEBUG flagTom Tromey1-1/+1
This adds a new PARSER_DEBUG constant and changes the parser code to use it. This lets us make the 'parser_debug' global 'static'.
2023-04-17Add 128-bit integer support to the Ada parserTom Tromey1-4/+18
This adds support for 128-bit integers to the Ada parser. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30188
2023-04-17Remove some Ada parser helper functionsTom Tromey1-43/+9
These helper functions in the Ada parser don't seem all that worthwhile to me, so this patch removes them.
2023-03-20Remove some unnecessary includes from *-exp.yTom Tromey1-3/+0
I noticed a weird comment in one of the .y files, and then ended up removing some unnecessary #includes from these files. Tested by rebuilding. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-19Convert block_objfile to methodTom Tromey1-1/+1
This converts block_objfile to be a method. This was mostly written by script.
2023-02-13Turn value_type into methodTom Tromey1-2/+2
This changes value_type to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker1-1/+1
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-10-19internal_error: remove need to pass __FILE__/__LINE__Pedro Alves1-2/+1
Currently, every internal_error call must be passed __FILE__/__LINE__ explicitly, like: internal_error (__FILE__, __LINE__, "foo %d", var); The need to pass in explicit __FILE__/__LINE__ is there probably because the function predates widespread and portable variadic macros availability. We can use variadic macros nowadays, and in fact, we already use them in several places, including the related gdb_assert_not_reached. So this patch renames the internal_error function to something else, and then reimplements internal_error as a variadic macro that expands __FILE__/__LINE__ itself. The result is that we now should call internal_error like so: internal_error ("foo %d", var); Likewise for internal_warning. The patch adjusts all calls sites. 99% of the adjustments were done with a perl/sed script. The non-mechanical changes are in gdbsupport/errors.h, gdbsupport/gdb_assert.h, and gdb/gdbarch.py. Approved-By: Simon Marchi <simon.marchi@efficios.com> Change-Id: Ia6f372c11550ca876829e8fd85048f4502bdcf06
2022-10-18fixup! gdb, ada: update ada_lookup_simple_minsymMarkus Metzger1-3/+0
remove get_selected_block()
2022-10-18gdb, ada: update ada_lookup_simple_minsymMarkus Metzger1-1/+8
Iterate over objfile in search order using the objfile of the context block as current_objfile so the iteration can stay inside the block's linker namespace.
2022-09-21gdb: remove TYPE_TARGET_TYPESimon Marchi1-1/+1
Remove the macro, replace all uses by calls to type::target_type. Change-Id: Ie51d3e1e22f94130176d6abd723255282bb6d1ed
2022-09-12Use checked_static_cast in more placesTom Tromey1-3/+1
I went through all the uses of dynamic_cast<> in gdb, looking for ones that could be replaced with checked_static_cast. This patch is the result. Regression tested on x86-64 Fedora 34.
2022-04-27gdb: remove BLOCKVECTOR_BLOCK and BLOCKVECTOR_NBLOCKS macrosSimon Marchi1-2/+1
Replace with calls to blockvector::blocks, and the appropriate method call on the returned array_view. Change-Id: I04d1f39603e4d4c21c96822421431d9a029d8ddd
2022-04-11gdb: remove symbol value macrosSimon Marchi1-1/+1
Remove all macros related to getting and setting some symbol value: #define SYMBOL_VALUE(symbol) (symbol)->value.ivalue #define SYMBOL_VALUE_ADDRESS(symbol) \ #define SET_SYMBOL_VALUE_ADDRESS(symbol, new_value) \ #define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain #define MSYMBOL_VALUE(symbol) (symbol)->value.ivalue #define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->value.address + 0) #define MSYMBOL_VALUE_ADDRESS(objfile, symbol) \ #define BMSYMBOL_VALUE_ADDRESS(symbol) \ #define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value) \ #define MSYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes #define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block Replace them with equivalent methods on the appropriate objects. Change-Id: Iafdab3b8eefc6dc2fd895aa955bf64fafc59ed50
2022-04-07gdb: remove symtab::blockvectorSimon Marchi1-1/+2
symtab::blockvector is a wrapper around compunit_symtab::blockvector. It is a bit misleadnig, as it gives the impression that a symtab has a blockvector. Remove it, change all users to fetch the blockvector through the compunit instead. Change-Id: Ibd062cd7926112a60d52899dff9224591cbdeebf
2022-04-04Add context-sensitive field name completion to Ada parserTom Tromey1-6/+111
This updates the Ada expression parser to implement context-sensitive field name completion. This is PR ada/28727. This is somewhat complicated due to some choices in the Ada lexer -- it chooses to represent a sequence of "."-separated identifiers as a single token, so the parser must partially recreate the completer's logic to find the completion word boundaries. Despite the minor warts in this patch, though, it is a decent improvement. It's possible that the DWARF reader rewrite will help fix the package completion problem pointed out in this patch as well. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28727
2022-04-04Remove the Ada DOT_ALL tokenTom Tromey1-9/+9
The Ada parser has a DOT_ALL token to represent ".all", and another token to represent other ".<identifier>" forms. However, for completion it is a bit more convenient to unify these cases, so this patch removes DOT_ALL.
2022-04-04Implement completion for Ada attributesTom Tromey1-1/+30
This adds a completer for Ada attributes. Some work in the lexer is required in order to match end-of-input correctly, as flex does not have a general-purpose way of doing this. (The approach taken here is recommended in the flex manual.)
2022-04-04Enable "set debug parser" for AdaTom Tromey1-0/+3
I noticed that "set debug parser 1" did not affect Ada parsing. This patch fixes the problem. Because this is rarely useful, and pretty much only for maintainers, I didn't write a test case.
2022-03-16Reimplement array concatenation for Ada and DTom Tromey1-1/+1
This started as a patch to implement string concatenation for Ada. However, while working on this, I looked at how this code could possibly be called. It turns out there are only two users of concat_operation: Ada and D. So, in addition to implementing this for Ada, this patch rewrites value_concat, removing the odd "concatenate or repeat" semantics, which were completely unused. As Ada and D both seem to represent strings using TYPE_CODE_ARRAY, this removes the TYPE_CODE_STRING code from there as well.
2022-03-07Handle non-ASCII identifiers in AdaTom Tromey1-3/+7
Ada allows non-ASCII identifiers, and GNAT supports several such encodings. This patch adds the corresponding support to gdb. GNAT encodes non-ASCII characters using special symbol names. For character sets like Latin-1, where all characters are a single byte, it uses a "U" followed by the hex for the character. So, for example, thorn would be encoded as "Ufe" (0xFE being lower case thorn). For wider characters, despite what the manual says (it claims Shift-JIS and EUC can be used), in practice recent versions only support Unicode. Here, characters in the base plane are represented using "Wxxxx" and characters outside the base plane using "WWxxxxxxxx". GNAT has some further quirks here. Ada is case-insensitive, and GNAT emits symbols that have been case-folded. For characters in ASCII, and for all characters in non-Unicode character sets, lower case is used. For Unicode, however, characters that fit in a single byte are converted to lower case, but all others are converted to upper case. Furthermore, there is a bug in GNAT where two symbols that differ only in the case of "Y WITH DIAERESIS" (and potentially others, I did not check exhaustively) can be used in one program. I chose to omit handling this case from gdb, on the theory that it is hard to figure out the logic, and anyway if the bug is ever fixed, we'll regret having a heuristic. This patch introduces a new "ada source-charset" setting. It defaults to Latin-1, as that is GNAT's default. This setting controls how "U" characters are decoded -- W/WW are always handled as UTF-32. The ada_tag_name_from_tsd change is needed because this function will read memory from the inferior and interpret it -- and this caused an encoding failure on PPC when running a test that tries to read uninitialized memory. This patch implements its own UTF-32-based case folder. This avoids host platform quirks, and is relatively simple. A short Python program to generate the case-folding table is included. It simply relies on whatever version of Unicode is used by the host Python, which seems basically acceptable. Test cases for UTF-8, Latin-1, and Latin-3 are included. This exercises most of the new code paths, aside from Y WITH DIAERESIS as noted above.
2022-02-28Handle multi-byte bracket sequences in Ada lexerTom Tromey1-4/+12
As noted in an earlier patch, the Ada lexer does not handle multi-byte bracket sequences. This patch adds support for these for character literals. gdb does not generally seem to handle the Ada wide string types, so for the time being these continue to be excluded -- but an explicit error is added to make this more clear.
2022-02-06gdb: remove SYMBOL_TYPE macroSimon Marchi1-5/+5
Add a getter and a setter for a symbol's type. Remove the corresponding macro and adjust all callers. Change-Id: Ie1a137744c5bfe1df4d4f9ae5541c5299577c8de
2022-02-06gdb: remove SYMBOL_DOMAIN macroSimon Marchi1-2/+2
Add a getter and a setter for a symbol's domain. Remove the corresponding macro and adjust all callers. Change-Id: I54465b50ac89739c663859a726aef8cdc6e4b8f3