aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lex.l
AgeCommit message (Collapse)AuthorFilesLines
11 days[gdb] Fix common misspellingsTom de Vries1-1/+1
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-04-07gdb: ignore -Wregister instead of -Wdeprecated-registerSimon Marchi1-6/+4
When building GDB on Centos 7 (which has flex 2.5.37) and Clang, I get: $ make ada-exp.o YACC ada-exp.c LEX ada-lex.c CXX ada-exp.o In file included from /home/smarchi/src/binutils-gdb/gdb/ada-exp.y:1179: <stdout>:1106:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 1106 | register yy_state_type yy_current_state; | ^~~~~~~~ In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`, which for Clang translates to ignoring `-Wdeprecated-register` [1]. I think that was produced when compiling as C++11, but now that we always compile as C++17, Clang produces a `-Wregister` error [2]. For GCC, `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER` already translates to ignoring `-Wregister`. So, rename `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER` to `DIAGNOSTIC_IGNORE_REGISTER` and ignore `-Wregister` for Clang too. [1] https://releases.llvm.org/17.0.1/tools/clang/docs/DiagnosticsReference.html#wdeprecated-register [2] https://releases.llvm.org/17.0.1/tools/clang/docs/DiagnosticsReference.html#wregister include/ChangeLog: * diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER): Rename to... (DIAGNOSTIC_IGNORE_REGISTER): ... this. Ignore `-Wregister` instead of `-Wdeprecated-register`. Change-Id: I8a4a51c7222c68577fa22ecacdddfcba32d9dbc5
2024-04-02Constify ada-lex.l:attributesTom Tromey1-1/+1
While examining the Ada parser globals with 'nm', I noticed that the lexer's "attributes" array should be const. This change moves it into read-only storage.
2024-04-02Remove "numbuf" globalTom Tromey1-3/+8
The lexer has a "numbuf" global that is only used for temporary storage. This patch removes the global and redeclares it at the points of use.
2024-04-02Move "returned_complete" into ada_parse_stateTom Tromey1-10/+2
This moves the "returned_complete" global into ada_parse_state.
2024-04-02Move "paren_depth" into ada_parse_stateTom Tromey1-8/+4
This moves the "paren_depth" global into ada_parse_state.
2024-04-02Move "temp_parse_space" into ada_parse_stateTom Tromey1-3/+4
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 "int_storage" global into ada_parse_stateTom Tromey1-2/+1
This patch moves the "int_storage" global into ada_parse_state.
2024-04-02Implement Ada 2022 iterated assignmentTom Tromey1-0/+1
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-21Implement Ada 2022 delta aggregatesTom Tromey1-0/+2
Ada 2022 includes a "delta aggregates" feature that can sometimes simplify aggregate creation. This patch implements this feature for GDB.
2024-02-04Use reference result of emplace_backTom Tromey1-2/+2
Starting with C++17, emplace_back returns a reference to the new object. This patch changes code that uses emplace_back followed by a call to back() to simply use this reference instead. Approved-By: Simon Marchi <simon.marchi@efficios.com>
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-11-21gdb: Replace gdb::optional with std::optionalLancelot Six1-1/+1
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-07-13Implement 'Enum_Val and 'Enum_RepTom Tromey1-0/+2
This patch implements the Ada 2022 attributes 'Enum_Val and 'Enum_Rep. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-06-05[gdb] Fix more typosTom de Vries1-1/+1
Fix some more typos: - distinquish -> distinguish - actualy -> actually - singe -> single - frash -> frame - chid -> child - dissassembler -> disassembler - uninitalized -> uninitialized - precontidion -> precondition - regsiters -> registers - marge -> merge - sate -> state - garanteed -> guaranteed - explictly -> explicitly - prefices (nonstandard plural) -> prefixes - bondary -> boundary - formated -> formatted - ithe -> the - arrav -> array - coresponding -> corresponding - owend -> owned - fials -> fails - diasm -> disasm - ture -> true - tpye -> type There's one code change, the name of macro SIG_CODE_BONDARY_FAULT changed to SIG_CODE_BOUNDARY_FAULT. Tested on x86_64-linux.
2023-04-17Add 128-bit integer support to the Ada parserTom Tromey1-42/+25
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-4/+4
These helper functions in the Ada parser don't seem all that worthwhile to me, so this patch removes them.
2023-03-14Add methods and operators to gdb_mpzTom Tromey1-5/+4
This adds various methods and operators to gdb_mpz, as a step toward hiding the implementation. This only adds the operators that were needed. Many more could be added as required.
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-09-21gdb: remove TYPE_LENGTHSimon Marchi1-1/+1
Remove the macro, replace all uses with calls to type::length. Change-Id: Ib9bdc954576860b21190886534c99103d6a47afb
2022-07-30[gdb/testsuite] Fix gdb.ada/literals.exp with aarch64Tom de Vries1-2/+2
On aarch64-linux, I run into: ... (gdb) print 16#ffffffffffffffff#^M $7 = 18446744073709551615^M (gdb) FAIL: gdb.ada/literals.exp: print 16#ffffffffffffffff# ... while on x86_64-linux instead, I get: ... (gdb) print 16#ffffffffffffffff#^M $7 = -1^M (gdb) PASS: gdb.ada/literals.exp: print 16#ffffffffffffffff# ... We can easily reproduce this on x86_64-linux using: ... $ gdb -q -batch -ex "set lang ada" -ex "set arch i386" \ -ex "print 16#ffffffffffffffff#" $1 = -1 $ gdb -q -batch -ex "set lang ada" -ex "set arch aarch64" \ -ex "print 16#ffffffffffffffff#" $1 = 18446744073709551615 ... With i386, we have: ... (gdb) p int_bits $3 = 32 (gdb) p long_bits $4 = 32 (gdb) p long_long_bits $5 = 64 ... and so in processInt we hit the fits-in-unsigned-long-long case where we use as type long long: ... /* Note: Interprets ULLONG_MAX as -1. */ yylval.typed_val.type = type_long_long (par_state); ... With aarch64, we have instead: ... (gdb) p int_bits $1 = 32 (gdb) p long_bits $2 = 64 (gdb) p long_long_bits $3 = 64 ... and so in processInt we hit the fits-in-unsigned-long case where we use as type unsigned long: ... yylval.typed_val.type = builtin_type (par_state->gdbarch ())->builtin_unsigned_long; ... It's not clear why for ada we're using long long for the fits-in-unsigned-long-long case. Fix this by using unsigned long long for the fits-in-unsigned-long-long case, meaning the new reference output is 18446744073709551615 instead of -1. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29416
2022-06-04[gdb/ada] Fix literal truncationTom de Vries1-4/+23
Make sure we error out on overflow instead of truncating in all cases. Tested on x86_64-linux, with a build with --enable-targets=all.
2022-04-12Fix bug in Ada number lexingTom Tromey1-2/+2
On irc, Pedro pointed out that Ada couldn't properly handle 0xffffffffffffffff. This used to work, but is a regression due to some patches I wrote in the Ada lexer. This patch fixes the bug.
2022-04-04Add context-sensitive field name completion to Ada parserTom Tromey1-6/+18
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-04Consolidate single-char tokens in ada-lex.lTom Tromey1-3/+1
There are two rules in ada-lex.l that match single-character tokens. This merges them. Also, this removes '.' from the list of such tokens. '.' is not used in any production in ada-exp.y, and removing it here helps the subsequent completion patches.
2022-04-04Remove the Ada DOT_ALL tokenTom Tromey1-2/+0
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-04Refactor ada-lex.l:processIdTom Tromey1-18/+13
processId in ada-lex.l is a bit funny -- it uses an "if" and a "switch", and a nested loop. This patch cleans it up a bit, changing it to use a boolean flag and a simpler "if".
2022-04-04Implement completion for Ada attributesTom Tromey1-11/+60
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-04Fix bug in Ada attributes lexingTom Tromey1-1/+6
The Ada lexer allows whitespace between the apostrophe and the attribute text, but processAttribute does not handle this. This patch fixes the problem and introduces a regression test.
2022-04-04Remove null sentinel from 'attributes'Tom Tromey1-12/+10
In a subsequent patch, it's handy if the 'attributes' array in ada-lex.l does not have a NULL sentinel at the end. In C++, this is easy to avoid.
2022-03-07Implement real literal extension for AdaTom Tromey1-20/+78
Sometimes it is convenient to be able to specify the exact bits of a floating-point literal. For example, you may want to set a floating-point register to a denormalized value, or to a particular NaN. In C, you can do this by combining the "{}" cast with an array literal, like: (gdb) p {double}{0x576488BDD2AE9FFE} $1 = 9.8765449999999996e+112 This patch adds a somewhat similar idea to Ada. It extends the lexer to allow "l" and "f" suffixes in a based literal. The "f" indicates a floating-point literal, and the "l"s control the size of the floating-point type. Note that this differs from Ada's based real literals. I believe those can also be used to control the bits of a floating-point value, but they are a bit more cumbersome to use (simplest is binary but that's also very lengthy). Also, these aren't implemented in GDB. I chose not to allow this extension to work with based integer literals with exponents. That didn't seem very useful.
2022-03-07Fix Ada integer literals with exponentsTom Tromey1-3/+6
While working on another patch, I noticed that Ada integer literals with exponents did not work. For example, with one form you get an error: (gdb) print 8e2 Invalid digit `e' in based literal And with another form you get an incorrect value: (gdb) print 16#8#e2 $2 = 8 This patch fixes the bugs and adds tests.
2022-03-07Handle non-ASCII identifiers in AdaTom Tromey1-1/+1
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-03-07Simplify a regular expression in ada-lex.lTom Tromey1-1/+1
ada-lex.l uses "%option case-insensitive", so there is no need for regular expressions to match upper case.
2022-02-28Handle multi-byte bracket sequences in Ada lexerTom Tromey1-10/+14
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-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-01-01Update copyright year range in all GDB filesJoel Brobecker1-1/+1
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-08-23ada-lex.l: Ignore register diagnostic also for g++ defaulting to ISO C++17Mark Wielaard1-1/+3
Building with a really old flex and a really new g++ is probably not recommended, but it should not cause compile errors. gdb/ChangeLog: * ada-lex.l: Extend register warnings diagnostics comment for g++. include/ChangeLog: * diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER): Also define for GCC version 7.0 or higher.
2020-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files.
2019-06-14Recognize _ in attribute namesTom Tromey1-1/+1
Ada attribute names can contain "_", but the lexer currently does not allow this -- even though the "attributes" array lists some attributes spelled this way. This patch fixes the bug and adds test cases for the existing attributes. This was reviewed off-list by Joel. I'm checking it in. gdb/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * ada-lex.l: Allow "_" in attribute names. gdb/testsuite/ChangeLog 2019-06-14 Tom Tromey <tromey@adacore.com> * gdb.ada/formatted_ref.exp (test_p_x_addr): Check 'unchecked_access and 'unrestricted_access as well.
2019-05-03Add noyywrap to ada-lex.lDilyan Palauzov1-7/+1
This patch comes from PR ada/21406. It adds the noyywrap option to ada-lex.l. This was already done (by the same author) for other .l files in the binutils-gdb tree, so it seems reasonably safe. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-05-03 Dilyan Palauzov <dilyan.palauzov@aegee.org> PR ada/21406: * ada-exp.y (yywrap): Don't define. * ada-lex.l (%option): Add noyywrap (yywrap): Remove.
2019-04-04Move lexptr and prev_lexptr to parser_stateTom Tromey1-6/+6
This removes the lexptr and prev_lexptr globals, in favor of members of parser_state. prev_lexptr could be isolated to each parser, but since every parser uses it, that did not seem necessary. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y (struct rust_parser) <lex_hex, lex_escape, lex_operator, push_back>: New methods. Update all rules. (rust_parser::lex_hex, lex_escape): Rename and update. (rust_parser::lex_string, rust_parser::lex_identifier): Update. (rust_parser::lex_operator): Rename and update. (rust_parser::lex_number, rustyylex, rustyyerror) (rust_lex_test_init, rust_lex_test_sequence) (rust_lex_test_push_back, rust_lex_tests): Update. * parser-defs.h (struct parser_state) <parser_state>: Add "input" parameter. <lexptr, prev_lexptr>: New members. (lexptr, prev_lexptr): Don't declare. * parse.c (lexptr, prev_lexptr): Remove globals. (parse_exp_in_context): Update. * p-exp.y (yylex, yyerror): Update. * m2-exp.y (parse_number, yylex, yyerror): Update. * go-exp.y (lex_one_token, yyerror): Update. * f-exp.y (match_string_literal, yylex, yyerror): Update. * d-exp.y (lex_one_token, yyerror): Update. * c-exp.y (scan_macro_expansion, finished_macro_expansion) (lex_one_token, yyerror): Update. * ada-lex.l (YY_INPUT): Update. (rewind_to_char): Update. * ada-exp.y (yyerror): Update.
2019-04-04Move comma_terminates global to parser_stateTom Tromey1-1/+1
This moves the comma_terminates global to parser_state. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y (rustyylex, rust_lex_tests): Update. * parser-defs.h (struct parser_state) <parser_state>: Add new parameter. <comma_terminates>: New member. (comma_terminates): Don't declare global. * parse.c (comma_terminates): Remove global. (parse_exp_in_context): Update. * p-exp.y (yylex): Update. * m2-exp.y (yylex): Update. * go-exp.y (lex_one_token): Update. * f-exp.y (yylex): Update. * d-exp.y (lex_one_token): Update. * c-exp.y (lex_one_token): Update. * ada-lex.l: Update.
2019-04-04Remove paren_depth globalTom Tromey1-0/+4
This removes the "paren_depth" global. In most cases, it is made into a static global in a given parser. I consider this a slight improvement, because it makes it clear that the variable isn't used for communication between different modules of gdb. The one exception is the Rust parser, which already incorporates all local state into a transient object; in this case the parser depth is now a member. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y (struct rust_parser) <paren_depth>: New member. (rustyylex, rust_lex_test_init, rust_lex_test_one) (rust_lex_test_sequence, rust_lex_test_push_back): Update. * parser-defs.h (paren_depth): Don't declare. * parse.c (paren_depth): Remove global. (parse_exp_in_context): Update. * p-exp.y (paren_depth): New global. (pascal_parse): Initialize it. * m2-exp.y (paren_depth): New global. (m2_parse): Initialize it. * go-exp.y (paren_depth): New global. (go_parse): Initialize it. * f-exp.y (paren_depth): New global. (f_parse): Initialize it. * d-exp.y (paren_depth): New global. (d_parse): Initialize it. * c-exp.y (paren_depth): New global. (c_parse): Initialize it. * ada-lex.l (paren_depth): New global. (lexer_init): Initialize it.
2019-04-04Turn parse_gdbarch into a methodTom Tromey1-4/+4
This changes parse_gdbarch into a method of parser_state. This patch was written by a script. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y: Replace "parse_gdbarch" with method call. * parse.c (write_dollar_variable, insert_type_address_space): Replace "parse_gdbarch" with method call. * p-exp.y (parse_type, yylex): Replace "parse_gdbarch" with method call. * objc-lang.c (end_msglist): Replace "parse_gdbarch" with method call. * m2-exp.y (parse_type, parse_m2_type, yylex): Replace "parse_gdbarch" with method call. * go-exp.y (parse_type, classify_name): Replace "parse_gdbarch" with method call. * f-exp.y (parse_type, parse_f_type, yylex): Replace "parse_gdbarch" with method call. * d-exp.y (parse_type, parse_d_type, lex_one_token): Replace "parse_gdbarch" with method call. * c-exp.y (parse_type, parse_number, classify_name): Replace "parse_gdbarch" with method call. * ada-lex.l: Replace "parse_gdbarch" with method call. * ada-exp.y (parse_type, find_primitive_type, type_char) (type_system_address): Replace "parse_gdbarch" with method call.
2019-01-08Fix build failure with macOS bisonTom Tromey1-1/+1
PR gdb/24060 points out a compilation failure of the C, Fortran and Pascal parsers when they are built using the macOS system bison. The bug is a name clash between the VARIABLE token name and the VARIABLE enumerator in ui-out.h. This patch renames VARIABLE in c-exp.y, f-exp.y and p-exp.y to DOLLAR_VARIABLE to avoid the clash. It also renames similar variables in other .y files so that all languages use the same name. gdb/ChangeLog 2019-01-07 Tom Tromey <tom@tromey.com> 2019-01-07 Simon Marchi <simon.marchi@ericsson.com> PR gdb/24060: * ada-exp.y (DOLLAR_VARIABLE): Rename from SPECIAL_VARIABLE. * ada-lex.l (DOLLAR_VARIABLE): Likewise. * c-exp.y (DOLLAR_VARIABLE): Rename from VARIABLE. * f-exp.y (DOLLAR_VARIABLE): Likewise. * m2-exp.y (DOLLAR_VARIABLE): Rename from INTERNAL_VAR. * p-exp.y (DOLLAR_VARIABLE): Rename from VARIABLE.
2019-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2018-06-01Move gdb/common/diagnostics.h to include/diagnostics.hH.J. Lu1-1/+1
Move gdb/common/diagnostics.h to include/diagnostics.h so that it can be used in binutils. gdb/ * ada-lex.l: Include "diagnostics.h" instead of "common/diagnostics.h". * unittests/environ-selftests.c: Likewise. * common/diagnostics.h: Moved to ../include. include/ * diagnostics.h: Moved from ../gdb/common/diagnostics.h.
2018-01-02Update copyright year range in all GDB filesJoel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files
2017-11-08Introduce lookup_name_info and generalize Ada's FULL/WILD name matchingPedro Alves1-16/+6
Summary: - This is preparation for supporting wild name matching on C++ too. - This is also preparation for TAB-completion fixes. - Makes symbol name matching (think strcmp_iw) be based on a per-language method. - Merges completion and non-completion name comparison (think language_ops::la_get_symbol_name_cmp generalized). - Avoid re-hashing lookup name multiple times - Centralizes preparing a name for lookup (Ada name encoding / C++ Demangling), both completion and non-completion. - Fixes Ada latent bug with verbatim name matches in expressions - Makes ada-lang.c use common|symtab.c completion code a bit more. Ada's wild matching basically means that "(gdb) break foo" will find all methods named "foo" in all packages. Translating to C++, it's roughly the same as saying that "break klass::method" sets breakpoints on all "klass::method" methods of all classes, no matter the namespace. A following patch will teach GDB about fullname vs wild matching for C++ too. This patch is preparatory work to get there. Another idea here is to do symbol name matching based on the symbol language's algorithm. I.e., avoid dependency on current language set. This allows for example doing (gdb) b foo::bar< int > (<tab> and having gdb name match the C++ symbols correctly even if the current language is C or Assembly (or Rust, or Ada, or ...), which can easily happen if you step into an Assembly/C runtime library frame. By encapsulating all the information related to a lookup name in a class, we can also cache hash computation for a given language in the lookup name object, to avoid recomputing it over and over. Similarly, because we don't really know upfront which languages the lookup name will be matched against, for each language we store the lookup name transformed into a search name. E.g., for C++, that means demangling the name. But for Ada, it means encoding the name. This actually forces us to centralize all the different lookup name encoding in a central place, resulting in clearer code, IMO. See e.g., the new ada_lookup_name_info class. The lookup name -> symbol search name computation is also done only once per language. The old language->la_get_symbol_name_cmp / symbol_name_cmp_ftype are generalized to work with both completion, and normal symbol look up. At some point early on, I had separate completion vs non-completion language vector entry points, but a single method ends up being better IMO for simplifying things -- the more we merge the completion / non-completion name lookup code paths, the less changes for bugs causing completion vs normal lookup finding different symbols. The ada-lex.l change is necessary because when doing (gdb) p <UpperCase> then the name that is passed to write_ write_var_or_type -> ada_lookup_symbol_list misses the "<>", i.e., it's just "UpperCase", and we end up doing a wild match against "UpperCase" lowercased by ada_lookup_name_info's constructor. I.e., "uppercase" wouldn't ever match "UpperCase", and the symbol lookup fails. This wouldn't cause any regression in the testsuite, but I added a new test that would pass before the patch and fail after, if it weren't for that fix. This is latent bug that happens to go unnoticed because that particular path was inconsistent with the rest of Ada symbol lookup by not lowercasing the lookup name. Ada's symbol_completion_add is deleted, replaced by using common code's completion_list_add_name. To make the latter work for Ada, we needed to add a new output parameter, because Ada wants to return back a custom completion candidates that are not the symbol name. With this patch, minimal symbol demangled name hashing is made consistent with regular symbol hashing. I.e., it now goes via the language vector's search_name_hash method too, as I had suggested in a previous patch. dw2_expand_symtabs_matching / .gdb_index symbol names were a challenge. The problem is that we have no way to telling what is the language of each symbol name found in the index, until we expand the corresponding full symbol, which is off course what we're trying to avoid. Language information is simply not considered in the index format... Since the symbol name hashing and comparison routines are per-language, we now have a problem. The patch sorts this out by matching each name against all languages. This is inneficient, and indeed slows down completion several times. E.g., with: $ cat script.cmd set pagination off set $count = 0 while $count < 400 complete b string_prin printf "count = %d\n", $count set $count = $count + 1 end $ time gdb --batch -q ./gdb-with-index -ex "source script-string_printf.cmd" I get, before patch (-O2, x86-64): real 0m1.773s user 0m1.737s sys 0m0.040s While after patch (-O2, x86-64): real 0m9.843s user 0m9.482s sys 0m0.034s However, the following patch will optimize this, and will actually make this use case faster compared to the "before patch" above: real 0m1.321s user 0m1.285s sys 0m0.039s gdb/ChangeLog: 2017-11-08 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_encode): Rename to .. (ada_encode_1): ... this. Add throw_errors parameter and handle it. (ada_encode): Reimplement. (match_name): Delete, folded into full_name. (resolve_subexp): No longer pass the encoded name to ada_lookup_symbol_list. (should_use_wild_match): Delete. (name_match_type_from_name): New. (ada_lookup_simple_minsym): Use lookup_name_info and the language's symbol_name_matcher_ftype. (add_symbols_from_enclosing_procs, ada_add_local_symbols) (ada_add_block_renamings): Adjust to use lookup_name_info. (ada_lookup_name): New. (add_nonlocal_symbols, ada_add_all_symbols) (ada_lookup_symbol_list_worker, ada_lookup_symbol_list) (ada_iterate_over_symbols): Adjust to use lookup_name_info. (ada_name_for_lookup): Delete. (ada_lookup_encoded_symbol): Construct a verbatim name. (wild_match): Reverse sense of return type. Use bool. (full_match): Reverse sense of return type. Inline bits of old match_name here. (ada_add_block_symbols): Adjust to use lookup_name_info. (symbol_completion_match): Delete, folded into... (ada_lookup_name_info::matches): ... .this new method. (symbol_completion_add): Delete. (ada_collect_symbol_completion_matches): Add name_match_type parameter. Adjust to use lookup_name_info and completion_list_add_name. (get_var_value, ada_add_global_exceptions): Adjust to use lookup_name_info. (ada_get_symbol_name_cmp): Delete. (do_wild_match, do_full_match): New functions. (ada_lookup_name_info::ada_lookup_name_info): New method. (ada_symbol_name_matches, ada_get_symbol_name_matcher): New functions. (ada_language_defn): Install ada_get_symbol_name_matcher. * ada-lex.l (processId): If name starts with '<', copy it verbatim. * block.c (block_iter_match_step, block_iter_match_first) (block_iter_match_next, block_lookup_symbol) (block_lookup_symbol_primary, block_find_symbol): Adjust to use lookup_name_info. * block.h (block_iter_match_first, block_iter_match_next) (ALL_BLOCK_SYMBOLS_WITH_NAME): Adjust to use lookup_name_info. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * completer.c (complete_files_symbols) (collect_explicit_location_matches, symbol_completer): Pass a symbol_name_match_type down. * completer.h (class completion_match, completion_match_result): New classes. (completion_tracker::reset_completion_match_result): New method. (completion_tracker::m_completion_match_result): New field. * cp-support.c (make_symbol_overload_list_block): Adjust to use lookup_name_info. (cp_fq_symbol_name_matches, cp_get_symbol_name_matcher): New functions. * cp-support.h (cp_get_symbol_name_matcher): New declaration. * d-lang.c: Adjust comments to refer to la_get_symbol_name_matcher. * dictionary.c (dict_vector) <iter_match_first, iter_match_next>: Adjust to use lookup_name_info. (dict_iter_match_first, dict_iter_match_next) (iter_match_first_hashed, iter_match_next_hashed) (iter_match_first_linear, iter_match_next_linear): Adjust to work with a lookup_name_info. * dictionary.h (dict_iter_match_first, dict_iter_match_next): Likewise. * dwarf2read.c (dw2_lookup_symbol): Adjust to use lookup_name_info. (dw2_map_matching_symbols): Adjust to use symbol_name_match_type. (gdb_index_symbol_name_matcher): New class. (dw2_expand_symtabs_matching) Adjust to use lookup_name_info and gdb_index_symbol_name_matcher. Accept a NULL symbol_matcher. * f-lang.c (f_collect_symbol_completion_matches): Adjust to work with a symbol_name_match_type. (f_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * go-lang.c (go_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * language.c (default_symbol_name_matcher) (language_get_symbol_name_matcher): New functions. (unknown_language_defn, auto_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * language.h (symbol_name_cmp_ftype): Delete. (language_defn) <la_collect_symbol_completion_matches>: Add match type parameter. <la_get_symbol_name_cmp>: Delete field. <la_get_symbol_name_matcher>: New field. <la_iterate_over_symbols>: Adjust to use lookup_name_info. (default_symbol_name_matcher, language_get_symbol_name_matcher): Declare. * linespec.c (iterate_over_all_matching_symtabs) (iterate_over_file_blocks): Adjust to use lookup_name_info. (find_methods): Add language parameter, and use lookup_name_info and the language's symbol_name_matcher_ftype. (linespec_complete_function): Adjust. (lookup_prefix_sym): Use lookup_name_info. (add_all_symbol_names_from_pspace): Adjust. (find_superclass_methods): Add language parameter and pass it down. (find_method): Pass symbol language down. (find_linespec_symbols): Don't demangle or Ada encode here. (search_minsyms_for_name): Add lookup_name_info parameter. (add_matching_symbols_to_info): Add name_match_type parameter. Use lookup_name_info. * m2-lang.c (m2_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * minsyms.c: Include <algorithm>. (add_minsym_to_demangled_hash_table): Remove table parameter and add objfile parameter. Use search_name_hash, and add language to demangled languages vector. (struct found_minimal_symbols): New struct. (lookup_minimal_symbol_mangled, lookup_minimal_symbol_demangled): New functions. (lookup_minimal_symbol): Adjust to use them. Don't canonicalize input names here. Use lookup_name_info instead. Lookup up demangled names once for each language in the demangled names vector. (iterate_over_minimal_symbols): Use lookup_name_info. Lookup up demangled names once for each language in the demangled names vector. (build_minimal_symbol_hash_tables): Adjust. * minsyms.h (iterate_over_minimal_symbols): Adjust to pass down a lookup_name_info. * objc-lang.c (objc_language_defn): Adjust comment to refer to la_get_symbol_name_matcher. * objfiles.h: Include <vector>. (objfile_per_bfd_storage) <demangled_hash_languages>: New field. * opencl-lang.c (opencl_language_defn): Adjust comment to refer to la_get_symbol_name_matcher. * p-lang.c (pascal_language_defn): Adjust comment to refer to la_get_symbol_name_matcher. * psymtab.c (psym_lookup_symbol): Use lookup_name_info. (match_partial_symbol): Use symbol_name_match_type, lookup_name_info and psymbol_name_matches. (lookup_partial_symbol): Use lookup_name_info. (map_block): Use symbol_name_match_type and lookup_name_info. (psym_map_matching_symbols): Use symbol_name_match_type. (psymbol_name_matches): New. (recursively_search_psymtabs): Use lookup_name_info and psymbol_name_matches. Rename 'kind' parameter to 'domain'. (psym_expand_symtabs_matching): Use lookup_name_info. Rename 'kind' parameter to 'domain'. * rust-lang.c (rust_language_defn): Adjust comment to refer to la_get_symbol_name_matcher. * symfile-debug.c (debug_qf_map_matching_symbols) (debug_qf_map_matching_symbols): Use symbol_name_match_type. (debug_qf_expand_symtabs_matching): Use lookup_name_info. * symfile.c (expand_symtabs_matching): Use lookup_name_info. * symfile.h (quick_symbol_functions) <map_matching_symbols>: Adjust to use symbol_name_match_type. <expand_symtabs_matching>: Adjust to use lookup_name_info. (expand_symtabs_matching): Adjust to use lookup_name_info. * symmisc.c (maintenance_expand_symtabs): Use lookup_name_info::match_any (). * symtab.c (symbol_matches_search_name): New. (eq_symbol_entry): Adjust to use lookup_name_info and the language's matcher. (demangle_for_lookup_info::demangle_for_lookup_info): New. (lookup_name_info::match_any): New. (iterate_over_symbols, search_symbols): Use lookup_name_info. (compare_symbol_name): Add language, lookup_name_info and completion_match_result parameters, and use them. (completion_list_add_name): Make extern. Add language and lookup_name_info parameters. Use them. (completion_list_add_symbol, completion_list_add_msymbol) (completion_list_objc_symbol): Add lookup_name_info parameters and adjust. Pass down language. (completion_list_add_fields): Add lookup_name_info parameters and adjust. Pass down language. (add_symtab_completions): Add lookup_name_info parameters and adjust. (default_collect_symbol_completion_matches_break_on): Add name_match_type parameter, and use it. Use lookup_name_info. (default_collect_symbol_completion_matches) (collect_symbol_completion_matches): Add name_match_type parameter, and pass it down. (collect_symbol_completion_matches_type): Adjust. (collect_file_symbol_completion_matches): Add name_match_type parameter, and use lookup_name_info. * symtab.h: Include <string> and "common/gdb_optional.h". (enum class symbol_name_match_type): New. (class ada_lookup_name_info): New. (struct demangle_for_lookup_info): New. (class lookup_name_info): New. (symbol_name_matcher_ftype): New. (SYMBOL_MATCHES_SEARCH_NAME): Use symbol_matches_search_name. (symbol_matches_search_name): Declare. (MSYMBOL_MATCHES_SEARCH_NAME): Delete. (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_file_symbol_completion_matches): Add name_match_type parameter. (iterate_over_symbols): Use lookup_name_info. (completion_list_add_name): Declare. * utils.c (enum class strncmp_iw_mode): Moved to utils.h. (strncmp_iw_with_mode): Now extern. * utils.h (enum class strncmp_iw_mode): Moved from utils.c. (strncmp_iw_with_mode): Declare. gdb/testsuite/ChangeLog: 2017-11-08 Pedro Alves <palves@redhat.com> * gdb.ada/complete.exp (p <Exported_Capitalized>): New test. (p Exported_Capitalized): New test. (p exported_capitalized): New test.