Bug 22670 - regressions in Ada caused by introduction of wild matching in C++ patch series
Summary: regressions in Ada caused by introduction of wild matching in C++ patch series
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 8.1
Assignee: Joel Brobecker
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-04 04:24 UTC by Joel Brobecker
Modified: 2018-03-31 12:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joel Brobecker 2018-01-04 04:24:16 UTC
Opening a PR mostly because I'd like to add some testcases which show the various regressions; and to avoid creating new failures that are expected while we investigate the issue, I will KFAIL the tests, which means I need a PR number.

This will allow us to track the work towards fixing those regressions also.
Comment 1 Sourceware Commits 2018-01-04 08:32:19 UTC
The master branch has been updated by Joel Brobecker <brobecke@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=66fc87a0d50d2b91322cc24d17461c07925fa867

commit 66fc87a0d50d2b91322cc24d17461c07925fa867
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Wed Jan 3 23:28:14 2018 -0500

    Add gdb.ada/info_addr_mixed_case new testcase
    
    This patch adds a new testcase to demonstrate a regression introduced by:
    
        commit b5ec771e60c1a0863e51eb491c85c674097e9e13
        Date:   Wed Nov 8 14:22:32 2017 +0000
        Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
    
    The purpose of the testcase is to verify that a user can use any
    casing for an Ada symbol name passed to the "info address" command.
    After the patch above was applied, GDB was no longer able to find
    the symbol:
    
        (gdb) info address My_Table
        No symbol "My_Table" in current context.
    
    gdb/testsuite/ChangeLog:
    
    	PR gdb/22670
    	* gdb.ada/info_addr_mixed_case: New testcase.
    
    Tested on x86_64-linux, both before and after the patch.
Comment 2 Sourceware Commits 2018-01-04 08:32:20 UTC
The master branch has been updated by Joel Brobecker <brobecke@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=344420da6beac1e0b2f7964e7101f8dcdb509b0d

commit 344420da6beac1e0b2f7964e7101f8dcdb509b0d
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Thu Jan 4 02:39:58 2018 -0500

    Add "complete break ada" test to gdb.ada/complete.exp
    
    This patch adds a new test to demonstrate a regression introduced by:
    
        commit b5ec771e60c1a0863e51eb491c85c674097e9e13
        Date:   Wed Nov 8 14:22:32 2017 +0000
        Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
    
    The original purpose of the new test is to exercise the "complete"
    command with an expression for which a large number of matches are
    returned and to verify that each match returned is a plausible match.
    In this particular case, the commit above causes GDB to generate
    additional matches which should in fact not appear in the list
    (internally generated symbols, or symbols that should be enclosed
    between "<...>"). These extraneous entries are easy to spot, because
    they have uppercase characters, such as:
    
        break ada__stringsS
        break ada__strings__R11s
        [etc]
    
    For now, the new test is KFAIL'ed, to avoid generating a new FAIL
    while we work on fixing that regression.
    
    gdb/testsuite/ChangeLog:
    
            PR gdb/22670
            * gdb.ada/complete.exp: Add "complete break ada" test.
    
    Tested on x86_64-linux with GDB built before and after the patch
    that caused the regression (b5ec771e60c1a0863e51eb491c85c674097e9e13).
    The test passes before the regression, and generates a KFAIL after.
Comment 3 Sourceware Commits 2018-01-04 08:32:41 UTC
The master branch has been updated by Joel Brobecker <brobecke@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=289483b6a06c7a24ee9ae9021d2728ca4700b7a6

commit 289483b6a06c7a24ee9ae9021d2728ca4700b7a6
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Thu Jan 4 03:10:34 2018 -0500

    Add new gdb.ada/bp_c_mixed_case testcase for PR gdb/22670
    
    This patch adds a new testcase to demonstrate a regression introduced by:
    
        commit b5ec771e60c1a0863e51eb491c85c674097e9e13
        Date:   Wed Nov 8 14:22:32 2017 +0000
        Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
    
    The purpose of the testcase is to verify that a user can insert
    a breakpoint on a C function while debugging Ada, even if the name
    of the function includes uppercase letters, requiring us to use
    Ada's "<...>" notation to tell the GDB that the symbol name should
    be looked up verbatim.
    
    As of the commit above, GDB is no longer finding the function:
    
        (gdb) break <MixedCaseFunc>
        Function "<MixedCaseFunc>" not defined.
        Make breakpoint pending on future shared library load? (y or [n])
    
    Before the patch, the breakpoint was inserted without problem.
    
    gdb/testsuite/ChangeLog:
    
            PR gdb/22670
            * gdb.ada/bp_c_mixed_case: New testcase.
    
    Tested on x86_64-linux; generates a KPASS before the regression
    was introduced, and now generates a KFAIL.
Comment 4 Sourceware Commits 2018-01-04 09:41:14 UTC
The master branch has been updated by Joel Brobecker <brobecke@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7365ec2ff4a7028503f39655bd2628d54418106c

commit 7365ec2ff4a7028503f39655bd2628d54418106c
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Thu Jan 4 04:40:17 2018 -0500

    gdb.ada/maint_with_ada.exp: New testcase
    
    This commit adds a new testcase testing the "check-psymtabs" and
    "check-symtabs" maintenance commands.
    
    The "maintenance check-psymtabs" commands is currently known to
    produce some errors. While the situation was admetedly made worse
    by the following patch...
    
        commit b5ec771e60c1a0863e51eb491c85c674097e9e13
        Date:   Wed Nov 8 14:22:32 2017 +0000
        Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
    
    ... hence the reference to PR gdb/22670, the command was already
    spotting one inconsistency prior to it:
    
        (gdb) maintenance check-psymtabs
        Global symbol `interfaces__cS' only found in /[...]/b~var_arr_typedef.adb psymtab
    
    For now, the "check-psymtab" test is KFAIL-ed.
    
    gdb/testsuite/ChangeLog:
    
            PR gdb/22670
            * gdb.ada/maint_with_ada: New testcase.
    
    Tested on x86_64-linux.
Comment 5 Sourceware Commits 2018-01-05 16:05:24 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f98fc17b3ac4750842ec0fe28a18b51691ddfbda

commit f98fc17b3ac4750842ec0fe28a18b51691ddfbda
Author: Pedro Alves <palves@redhat.com>
Date:   Fri Jan 5 16:01:57 2018 +0000

    Fix gdb.ada/info_addr_mixed_case.exp (PR gdb/22670)
    
    The comments about mixed case in the testcase are actually a red
    herring.  The problem here is that we'd get to
    ada_lookup_encoded_symbol with "my_table", which wraps the looked up
    name in "<>"s to force a verbatim match, and that in turn disables
    wild matching.
    
    Fix this by swapping around the internals of ada_lookup_encoded_symbol
    and ada_lookup_symbol, thus avoiding the encoding and
    verbatim-wrapping in the ada_lookup_symbol case, the case that starts
    with a user-provided lookup name.
    
    Ada encoding is still done of course, in the ada_lookup_name_info
    ctor.  This could be also seen as avoiding the double-encoding problem
    in a different way.
    
    gdb/ChangeLog:
    2018-01-05  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* ada-lang.c (ada_lookup_encoded_symbol): Reimplement in terms of
    	ada_lookup_symbol.
    	(ada_lookup_symbol): Reimplement in terms of
    	ada_lookup_symbol_list, bits factored out from
    	ada_lookup_encoded_symbol.
    
    gdb/testsuite/ChangeLog:
    2018-01-05  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* gdb.ada/info_addr_mixed_case.exp: Remove kfail.  Extend test to
    	exercise lower case too, and to exercise both full matching and
    	wild matching.
Comment 6 Sourceware Commits 2018-01-05 16:06:43 UTC
The gdb-8.1-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7a19098f86ba3a4abfeb4dff33e2a1929f6fbaa8

commit 7a19098f86ba3a4abfeb4dff33e2a1929f6fbaa8
Author: Pedro Alves <palves@redhat.com>
Date:   Fri Jan 5 16:05:34 2018 +0000

    Fix gdb.ada/info_addr_mixed_case.exp (PR gdb/22670)
    
    The comments about mixed case in the testcase are actually a red
    herring.  The problem here is that we'd get to
    ada_lookup_encoded_symbol with "my_table", which wraps the looked up
    name in "<>"s to force a verbatim match, and that in turn disables
    wild matching.
    
    Fix this by swapping around the internals of ada_lookup_encoded_symbol
    and ada_lookup_symbol, thus avoiding the encoding and
    verbatim-wrapping in the ada_lookup_symbol case, the case that starts
    with a user-provided lookup name.
    
    Ada encoding is still done of course, in the ada_lookup_name_info
    ctor.  This could be also seen as avoiding the double-encoding problem
    in a different way.
    
    gdb/ChangeLog:
    2018-01-05  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* ada-lang.c (ada_lookup_encoded_symbol): Reimplement in terms of
    	ada_lookup_symbol.
    	(ada_lookup_symbol): Reimplement in terms of
    	ada_lookup_symbol_list, bits factored out from
    	ada_lookup_encoded_symbol.
    
    gdb/testsuite/ChangeLog:
    2018-01-05  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* gdb.ada/info_addr_mixed_case.exp: Remove kfail.  Extend test to
    	exercise lower case too, and to exercise both full matching and
    	wild matching.
Comment 7 Sourceware Commits 2018-01-05 16:19:27 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=de63c46b549d1cf4f7851e47872cb759a12983f4

commit de63c46b549d1cf4f7851e47872cb759a12983f4
Author: Pedro Alves <palves@redhat.com>
Date:   Fri Jan 5 14:04:09 2018 +0000

    Fix regresssion(internal-error) printing subprogram argument (PR gdb/22670)
    
    At <https://sourceware.org/ml/gdb-patches/2017-12/msg00298.html>, Joel
    wrote:
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Consider the following code which first declares a tagged type (the
    equivalent of a class in Ada), and then a procedure which takes a
    pointer (access) to this type's 'Class.
    
        package Pck is
           type Top_T is tagged record
              N : Integer := 1;
           end record;
           procedure Inspect (Obj: access Top_T'Class);
        end Pck;
    
    Putting a breakpoint in that procedure and then running to it triggers
    an internal error:
    
        (gdb) break inspect
        (gdb) continue
        Breakpoint 1, pck.inspect (obj=0x63e010
        /[...]/gdb/stack.c:621: internal-error: void print_frame_args(symbol*, frame_info*, int, ui_file*): Assertion `nsym != NULL' failed.
    
    What's special about this subprogram is that it takes an access to
    what we call a 'Class type, and for implementation reasons, the
    compiler adds an extra argument named "objL". If you are curious why,
    it allows the compiler for perform dynamic accessibility checks that
    are mandated by the language.
    
    If we look at the location where we get the internal error (in
    stack.c), we find that we are looping over the symbol of each
    parameter, and for each parameter, we do:
    
        /* We have to look up the symbol because arguments can have
           two entries (one a parameter, one a local) and the one we
           want is the local, which lookup_symbol will find for us.
        [...]
            nsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
                                  b, VAR_DOMAIN, NULL).symbol;
            gdb_assert (nsym != NULL);
    
    The lookup_symbol goes through the lookup structure, which means the
    symbol's linkage name ("objL") gets transformed into a
    lookup_name_info object (in block_lookup_symbol), before it gets fed
    to the block symbol dictionary iterators.  This, in turn, triggers the
    symbol matching by comparing the "lookup" name which, for Ada, means
    among other things, lowercasing the given name to "objl".  It is this
    transformation that causes the lookup find no matches, and therefore
    trip this assertion.
    
    Going back to the "offending" call to lookup_symbol in stack.c, what
    we are trying to do, here, is do a lookup by linkage name.  So, I
    think what we mean to be doing is a completely literal symbol lookup,
    so maybe not even strcmp_iw, but actually just plain strcmp???
    
    In the past, in practice, you could get that effect by doing a lookup
    using the C language. But that doesn't work, because we still end up
    somehow using Ada's lookup_name routine which transforms "objL".
    
    So, ideally, as I hinted before, I think what we need is a way to
    perform a literal lookup so that searches by linkage names like the
    above can be performed.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    This commit fixes the problem by implementing something similar to
    Joel's literal idea, but with some important differences.
    
    I considered adding a symbol_name_match_type::LINKAGE and supporting
    searching by linkage name for any language, but the problem with that
    is that the dictionaries only work with SYMBOL_SEARCH_NAME, because
    that's what is used for hashing.  We'd need separate dictionaries for
    hashed linkage names.
    
    So with the current symbol tables infrastructure, it's not literal
    linkage names that we want to pass down, but instead literal _search_
    names (SYMBOL_SEARCH_NAME, etc.).
    
    However, psymbols have no overload/function parameter info in C++, so
    a straight strcmp doesn't work properly for C++ name matching.
    
    So what we do is be a little less aggressive then and add a new
    symbol_name_match_type::SEARCH_SYMBOL instead that takes as input a
    non-user-input search symbol, and then we skip any decoding/demangling
    steps and make:
    
     - Ada treat that as a verbatim match,
     - other languages treat it as symbol_name_match_type::FULL.
    
    This also fixes the new '"maint check-psymtabs" for Ada' testcase for
    me (gdb.ada/maint_with_ada.exp).  I've not removed the kfail yet
    because Joel still sees that testcase failing with this patch.
    That'll be fixed in follow up patches.
    
    gdb/ChangeLog:
    2018-01-05  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* ada-lang.c (literal_symbol_name_matcher): New function.
    	(ada_get_symbol_name_matcher): Use it for
    	symbol_name_match_type::SEARCH_NAME.
    	* block.c (block_lookup_symbol): New parameter 'match_type'.  Pass
    	it down instead of assuming symbol_name_match_type::FULL.
    	* block.h (block_lookup_symbol): New parameter 'match_type'.
    	* c-valprint.c (print_unpacked_pointer): Use
    	lookup_symbol_search_name instead of lookup_symbol.
    	* compile/compile-object-load.c (get_out_value_type): Pass down
    	symbol_name_match_type::SEARCH_NAME.
    	* cp-namespace.c (cp_basic_lookup_symbol): Pass down
    	symbol_name_match_type::FULL.
    	* cp-support.c (cp_get_symbol_name_matcher): Handle
    	symbol_name_match_type::SEARCH_NAME.
    	* infrun.c (insert_exception_resume_breakpoint): Use
    	lookup_symbol_search_name.
    	* p-valprint.c (pascal_val_print): Use lookup_symbol_search_name.
    	* psymtab.c (maintenance_check_psymtabs): Use
    	symbol_name_match_type::SEARCH_NAME and SYMBOL_SEARCH_NAME.
    	* stack.c (print_frame_args): Use lookup_symbol_search_name and
    	SYMBOL_SEARCH_NAME.
    	* symtab.c (lookup_local_symbol): Don't demangle the lookup name
    	if symbol_name_match_type::SEARCH_NAME.
    	(lookup_symbol_in_language): Pass down
    	symbol_name_match_type::FULL.
    	(lookup_symbol_search_name): New.
    	(lookup_language_this): Pass down
    	symbol_name_match_type::SEARCH_NAME.
    	(lookup_symbol_aux, lookup_local_symbol): New parameter
    	'match_type'.  Pass it down.
    	* symtab.h (symbol_name_match_type::SEARCH_NAME): New enumerator.
    	(lookup_symbol_search_name): New declaration.
    	(lookup_symbol_in_block): New 'match_type' parameter.
    
    gdb/testsuite/ChangeLog:
    2018-01-05  Joel Brobecker  <brobecker@adacore.com>
    
    	PR gdb/22670
    	* gdb.ada/access_tagged_param.exp: New file.
    	* gdb.ada/access_tagged_param/foo.adb: New file.
Comment 8 Sourceware Commits 2018-01-05 16:23:10 UTC
The gdb-8.1-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a76cf1f43d27f022562d9e70eb91e212dbd0da4a

commit a76cf1f43d27f022562d9e70eb91e212dbd0da4a
Author: Pedro Alves <palves@redhat.com>
Date:   Fri Jan 5 16:19:17 2018 +0000

    Fix regresssion(internal-error) printing subprogram argument (PR gdb/22670)
    
    At <https://sourceware.org/ml/gdb-patches/2017-12/msg00298.html>, Joel
    wrote:
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Consider the following code which first declares a tagged type (the
    equivalent of a class in Ada), and then a procedure which takes a
    pointer (access) to this type's 'Class.
    
        package Pck is
           type Top_T is tagged record
              N : Integer := 1;
           end record;
           procedure Inspect (Obj: access Top_T'Class);
        end Pck;
    
    Putting a breakpoint in that procedure and then running to it triggers
    an internal error:
    
        (gdb) break inspect
        (gdb) continue
        Breakpoint 1, pck.inspect (obj=0x63e010
        /[...]/gdb/stack.c:621: internal-error: void print_frame_args(symbol*, frame_info*, int, ui_file*): Assertion `nsym != NULL' failed.
    
    What's special about this subprogram is that it takes an access to
    what we call a 'Class type, and for implementation reasons, the
    compiler adds an extra argument named "objL". If you are curious why,
    it allows the compiler for perform dynamic accessibility checks that
    are mandated by the language.
    
    If we look at the location where we get the internal error (in
    stack.c), we find that we are looping over the symbol of each
    parameter, and for each parameter, we do:
    
        /* We have to look up the symbol because arguments can have
           two entries (one a parameter, one a local) and the one we
           want is the local, which lookup_symbol will find for us.
        [...]
            nsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
                                  b, VAR_DOMAIN, NULL).symbol;
            gdb_assert (nsym != NULL);
    
    The lookup_symbol goes through the lookup structure, which means the
    symbol's linkage name ("objL") gets transformed into a
    lookup_name_info object (in block_lookup_symbol), before it gets fed
    to the block symbol dictionary iterators.  This, in turn, triggers the
    symbol matching by comparing the "lookup" name which, for Ada, means
    among other things, lowercasing the given name to "objl".  It is this
    transformation that causes the lookup find no matches, and therefore
    trip this assertion.
    
    Going back to the "offending" call to lookup_symbol in stack.c, what
    we are trying to do, here, is do a lookup by linkage name.  So, I
    think what we mean to be doing is a completely literal symbol lookup,
    so maybe not even strcmp_iw, but actually just plain strcmp???
    
    In the past, in practice, you could get that effect by doing a lookup
    using the C language. But that doesn't work, because we still end up
    somehow using Ada's lookup_name routine which transforms "objL".
    
    So, ideally, as I hinted before, I think what we need is a way to
    perform a literal lookup so that searches by linkage names like the
    above can be performed.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    This commit fixes the problem by implementing something similar to
    Joel's literal idea, but with some important differences.
    
    I considered adding a symbol_name_match_type::LINKAGE and supporting
    searching by linkage name for any language, but the problem with that
    is that the dictionaries only work with SYMBOL_SEARCH_NAME, because
    that's what is used for hashing.  We'd need separate dictionaries for
    hashed linkage names.
    
    So with the current symbol tables infrastructure, it's not literal
    linkage names that we want to pass down, but instead literal _search_
    names (SYMBOL_SEARCH_NAME, etc.).
    
    However, psymbols have no overload/function parameter info in C++, so
    a straight strcmp doesn't work properly for C++ name matching.
    
    So what we do is be a little less aggressive then and add a new
    symbol_name_match_type::SEARCH_SYMBOL instead that takes as input a
    non-user-input search symbol, and then we skip any decoding/demangling
    steps and make:
    
     - Ada treat that as a verbatim match,
     - other languages treat it as symbol_name_match_type::FULL.
    
    This also fixes the new '"maint check-psymtabs" for Ada' testcase for
    me (gdb.ada/maint_with_ada.exp).  I've not removed the kfail yet
    because Joel still sees that testcase failing with this patch.
    That'll be fixed in follow up patches.
    
    gdb/ChangeLog:
    2018-01-05  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* ada-lang.c (literal_symbol_name_matcher): New function.
    	(ada_get_symbol_name_matcher): Use it for
    	symbol_name_match_type::SEARCH_NAME.
    	* block.c (block_lookup_symbol): New parameter 'match_type'.  Pass
    	it down instead of assuming symbol_name_match_type::FULL.
    	* block.h (block_lookup_symbol): New parameter 'match_type'.
    	* c-valprint.c (print_unpacked_pointer): Use
    	lookup_symbol_search_name instead of lookup_symbol.
    	* compile/compile-object-load.c (get_out_value_type): Pass down
    	symbol_name_match_type::SEARCH_NAME.
    	* cp-namespace.c (cp_basic_lookup_symbol): Pass down
    	symbol_name_match_type::FULL.
    	* cp-support.c (cp_get_symbol_name_matcher): Handle
    	symbol_name_match_type::SEARCH_NAME.
    	* infrun.c (insert_exception_resume_breakpoint): Use
    	lookup_symbol_search_name.
    	* p-valprint.c (pascal_val_print): Use lookup_symbol_search_name.
    	* psymtab.c (maintenance_check_psymtabs): Use
    	symbol_name_match_type::SEARCH_NAME and SYMBOL_SEARCH_NAME.
    	* stack.c (print_frame_args): Use lookup_symbol_search_name and
    	SYMBOL_SEARCH_NAME.
    	* symtab.c (lookup_local_symbol): Don't demangle the lookup name
    	if symbol_name_match_type::SEARCH_NAME.
    	(lookup_symbol_in_language): Pass down
    	symbol_name_match_type::FULL.
    	(lookup_symbol_search_name): New.
    	(lookup_language_this): Pass down
    	symbol_name_match_type::SEARCH_NAME.
    	(lookup_symbol_aux, lookup_local_symbol): New parameter
    	'match_type'.  Pass it down.
    	* symtab.h (symbol_name_match_type::SEARCH_NAME): New enumerator.
    	(lookup_symbol_search_name): New declaration.
    	(lookup_symbol_in_block): New 'match_type' parameter.
    
    gdb/testsuite/ChangeLog:
    2018-01-05  Joel Brobecker  <brobecker@adacore.com>
    
    	PR gdb/22670
    	* gdb.ada/access_tagged_param.exp: New file.
    	* gdb.ada/access_tagged_param/foo.adb: New file.
Comment 9 Sourceware Commits 2018-01-05 18:02:00 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a655456c134e5e02bab33941e1c738ca33905d23

commit a655456c134e5e02bab33941e1c738ca33905d23
Author: Pedro Alves <palves@redhat.com>
Date:   Fri Jan 5 17:56:33 2018 +0000

    Fix gdb/spu-tdep.c build breakage
    
    Commit de63c46b549d ("Fix regresssion(internal-error) printing
    subprogram argument (PR gdb/22670)") missed updating spu-tdep.c for
    the block_lookup_symbol interface change, resulting in:
    
      ../../binutils-gdb/gdb/spu-tdep.c: In function void spu_catch_start(objfile*):
      ../../binutils-gdb/gdb/spu-tdep.c:1969:59: error: cannot convert domain_enum_tag to symbol_name_match_type for argument 3 to symbol* block_lookup_symbol(const block*, const char*, symbol_name_match_type, domain_enum)
    	 sym = block_lookup_symbol (block, "main", VAR_DOMAIN);
    							     ^
    
    gdb/ChangeLog:
    2018-01-05  Pedro Alves  <palves@redhat.com>
    
    	* spu-tdep.c (spu_catch_start): Pass
    	symbol_name_match_type::SEARCH_NAME to block_lookup_symbol.
Comment 10 Sourceware Commits 2018-01-05 18:08:01 UTC
The gdb-8.1-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1dc9069e0620fafe99628cd7d849033161258074

commit 1dc9069e0620fafe99628cd7d849033161258074
Author: Pedro Alves <palves@redhat.com>
Date:   Fri Jan 5 18:03:10 2018 +0000

    Fix gdb/spu-tdep.c build breakage
    
    Commit de63c46b549d ("Fix regresssion(internal-error) printing
    subprogram argument (PR gdb/22670)") missed updating spu-tdep.c for
    the block_lookup_symbol interface change, resulting in:
    
      ../../binutils-gdb/gdb/spu-tdep.c: In function void spu_catch_start(objfile*):
      ../../binutils-gdb/gdb/spu-tdep.c:1969:59: error: cannot convert domain_enum_tag to symbol_name_match_type for argument 3 to symbol* block_lookup_symbol(const block*, const char*, symbol_name_match_type, domain_enum)
    	 sym = block_lookup_symbol (block, "main", VAR_DOMAIN);
    							     ^
    
    gdb/ChangeLog:
    2018-01-05  Pedro Alves  <palves@redhat.com>
    
    	* spu-tdep.c (spu_catch_start): Pass
    	symbol_name_match_type::SEARCH_NAME to block_lookup_symbol.
Comment 11 Sourceware Commits 2018-01-10 23:13:49 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8825213e97f0476068dc3b52b1b61df96b40708a

commit 8825213e97f0476068dc3b52b1b61df96b40708a
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Jan 10 20:38:06 2018 +0000

    Fix gdb.ada/bp_c_mixed_case.exp (PR gdb/22670)
    
    The problem here is that we are using the user-provided lookup name
    literally for name comparisons.  I.e., "<MixedCase>" with the "<>"s
    included.
    
    This commit fixes the minsym lookup case.  psymbol/symbol lookup will
    be fixed in a follow up.
    
    In the minsym case, we're using using the user-provided lookup name
    literally for linkage name comparisons.  That obviously can't work
    since the "<>" are not really part of the linkage name.
    
    The original idea was that we'd use the symbol's language to select
    the right symbol name matching algorithm, but that doesn't work for
    Ada because it's not really possible to unambiguously tell from the
    linkage name alone whether we're dealing with Ada symbols, so Ada
    minsyms end up with no language set, or sometimes C++ set.
    
    So fix this by treating Ada mode specially when determining the
    linkage name to match against.
    
    gdb/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* minsyms.c (linkage_name_str): New function.
    	(iterate_over_minimal_symbols): Use it.
    
    gdb/testsuite/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* gdb.ada/bp_c_mixed_case.exp: Remove setup_kfail calls.
Comment 12 Sourceware Commits 2018-01-10 23:13:54 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d4c2a405cb7535d25b88e9b8dad0e557242950ca

commit d4c2a405cb7535d25b88e9b8dad0e557242950ca
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Jan 10 20:38:07 2018 +0000

    Fix gdb.ada/complete.exp's "complete break ada" test (PR gdb/22670)
    
    This patch fixes the regression covered by the test added by:
    
        commit 344420da6beac1e0b2f7964e7101f8dcdb509b0d
        Date: Thu Jan 4 03:30:37 2018 -0500
        Subject: Add "complete break ada" test to gdb.ada/complete.exp
    
    The regression had been introduced by:
    
        commit b5ec771e60c1a0863e51eb491c85c674097e9e13
        Date:   Wed Nov 8 14:22:32 2017 +0000
        Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
    
    The gist of it is that linespec completion in Ada mode is generating
    additional matches that should not appear in the match list
    (internally generated symbols, or symbols that should be enclosed
    between "<...>").  These extraneous entries have uppercase characters, such as:
    
        break ada__stringsS
        break ada__strings__R11s
        [etc]
    
    These matches come from minimal symbols.  The problem is that Ada
    minsyms end up with no language set (language_auto), and thus we end
    up using the generic symbol name matcher for those instead of Ada's.
    We already had a special case for in compare_symbol_name to handle
    this, but it was limited to expressions, while the case at hand is
    completing a linespec.  Fix this by applying the special case to
    linespec completion as well.  I.e., remove the EXPRESSION check from
    compare_symbol_name.  That alone turns out to not be sufficient still
    -- GDB would still show a couple entries that shouldn't be there:
    
    ~~
        break ada__exceptions__exception_data__append_info_exception_name__2Xn
        break ada__exceptions__exception_data__exception_name_length__2Xn
    ~~
    
    The reason is that these minimal symbols end up with their language
    set to language_cplus / C++, because those encoded names manage to
    demangle successfully as C++ symbols (using an old C++ mangling
    scheme):
    
      $ echo ada__exceptions__exception_data__append_info_exception_name__2Xn | c++filt
      Xn::ada__exceptions__exception_data__append_info_exception_name(void)
    
    It's unfortunate that Ada's encoding scheme doesn't start with some
    unique prefix like "_Z" in the C++ Itanium ABI mangling scheme.  For
    now, paper over that by treating C++ minsyms as Ada minsyms.
    
    gdb/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
            PR gdb/22670
    	* ada-lang.c (ada_collect_symbol_completion_matches): If the
    	minsym's language is language_auto or language_cplus, pass down
    	language_ada instead.
    	* symtab.c (compare_symbol_name): Don't frob symbol language here.
    
    gdb/testsuite/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
            PR gdb/22670
    	* gdb.ada/complete.exp ("complete break ada"): Replace kfail with
    	a fail.
Comment 13 Sourceware Commits 2018-01-10 23:14:00 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c63d3e8d12f0b08cda95f89aa13274defed215f0

commit c63d3e8d12f0b08cda95f89aa13274defed215f0
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Jan 10 20:38:07 2018 +0000

    Ada: make verbatim matcher override other language matchers (PR gdb/22670)
    
    A previous patch fixed verbatim matching in the lookup at the minimal
    symbol level, but we should also be finding that same symbol through
    the partial/full symtab search.
    
    For example, this is what happens if we use "print" instead of
    "break":
    
        (gdb) p <MixedCaseFunc>
        $1 = {<text variable, no debug info>} 0x4024dc <MixedCaseFunc>
    
    Before the C++ wildmatching series, GDB knows that MixedCaseFunc is a
    function without parameters, and the expression above means calling
    it.  If you try it before having started the inferior, you'd get the
    following (expected) error:
    
        (gdb) print  <MixedCaseFunc>
        You can't do that without a process to debug.
    
    The main idea behind making the name matcher be determined by the
    symbol's language is so that C++ (etc.) wildmatching in linespecs
    works even if the current language is not C++, as e.g., when you step
    through C or assembly code.
    
    Ada's verbatim matching syntax however ("<...>") isn't quite the same.
    It is more a property of the current language than of a particular
    symbol's language.  We want to support this syntax when debugging an
    Ada program, but it's reason of existence is to find non-Ada symbols.
    This suggests going back to enabling it depending on current language
    instead of language of the symbol being matched.
    
    I'm not entirely happy with the "current_language" reference (though I
    think that it's harmless).  I think we could try storing the current
    language in the lookup_name_info object, and then convert a bunch of
    functions more to pass around lookup_name_info objects instead of
    "const char *" names.  I.e., build the lookup_name_info higher up.
    I'm not sure about that, I'll have to think more about it.  Maybe
    something different will be better.  Meanwhile, this gets us going.
    
    I've extended the testcase to also exercise a no-debug-info function,
    for extra coverage of the minsyms-only paths.
    
    gdb/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* dwarf2read.c
    	(gdb_index_symbol_name_matcher::gdb_index_symbol_name_matcher):
    	Adjust to use language_get_symbol_name_matcher instead of
    	language_defn::la_get_symbol_name_matcher.
    	* language.c (language_get_symbol_name_matcher): If in Ada mode
    	and the lookup name is a verbatim match, return Ada's matcher.
    	* language.h (language_get_symbol_name_matcher): Adjust comment.
    	(ada_lookup_name_info::verbatim_p):: New method.
    
    gdb/testsuite/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* gdb.ada/bp_c_mixed_case.exp: Add intro comment.  Test printing C
    	functions too.  Test setting breakpoints and printing C functions
    	with no debug info too.
    	* gdb.ada/bp_c_mixed_case/qux.c: New file.
Comment 14 Sourceware Commits 2018-01-10 23:35:49 UTC
The gdb-8.1-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bd140f1f5ef06b801156c787331f2d3ad72320a1

commit bd140f1f5ef06b801156c787331f2d3ad72320a1
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Jan 10 23:14:06 2018 +0000

    Fix gdb.ada/bp_c_mixed_case.exp (PR gdb/22670)
    
    The problem here is that we are using the user-provided lookup name
    literally for name comparisons.  I.e., "<MixedCase>" with the "<>"s
    included.
    
    This commit fixes the minsym lookup case.  psymbol/symbol lookup will
    be fixed in a follow up.
    
    In the minsym case, we're using using the user-provided lookup name
    literally for linkage name comparisons.  That obviously can't work
    since the "<>" are not really part of the linkage name.
    
    The original idea was that we'd use the symbol's language to select
    the right symbol name matching algorithm, but that doesn't work for
    Ada because it's not really possible to unambiguously tell from the
    linkage name alone whether we're dealing with Ada symbols, so Ada
    minsyms end up with no language set, or sometimes C++ set.
    
    So fix this by treating Ada mode specially when determining the
    linkage name to match against.
    
    gdb/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* minsyms.c (linkage_name_str): New function.
    	(iterate_over_minimal_symbols): Use it.
    
    gdb/testsuite/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* gdb.ada/bp_c_mixed_case.exp: Remove setup_kfail calls.
Comment 15 Sourceware Commits 2018-01-10 23:35:54 UTC
The gdb-8.1-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=be1f9aabab1be45e324ae4cd30e7b08cb7e6c083

commit be1f9aabab1be45e324ae4cd30e7b08cb7e6c083
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Jan 10 23:14:07 2018 +0000

    Fix gdb.ada/complete.exp's "complete break ada" test (PR gdb/22670)
    
    This patch fixes the regression covered by the test added by:
    
        commit 344420da6beac1e0b2f7964e7101f8dcdb509b0d
        Date: Thu Jan 4 03:30:37 2018 -0500
        Subject: Add "complete break ada" test to gdb.ada/complete.exp
    
    The regression had been introduced by:
    
        commit b5ec771e60c1a0863e51eb491c85c674097e9e13
        Date:   Wed Nov 8 14:22:32 2017 +0000
        Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
    
    The gist of it is that linespec completion in Ada mode is generating
    additional matches that should not appear in the match list
    (internally generated symbols, or symbols that should be enclosed
    between "<...>").  These extraneous entries have uppercase characters, such as:
    
        break ada__stringsS
        break ada__strings__R11s
        [etc]
    
    These matches come from minimal symbols.  The problem is that Ada
    minsyms end up with no language set (language_auto), and thus we end
    up using the generic symbol name matcher for those instead of Ada's.
    We already had a special case for in compare_symbol_name to handle
    this, but it was limited to expressions, while the case at hand is
    completing a linespec.  Fix this by applying the special case to
    linespec completion as well.  I.e., remove the EXPRESSION check from
    compare_symbol_name.  That alone turns out to not be sufficient still
    -- GDB would still show a couple entries that shouldn't be there:
    
    ~~
        break ada__exceptions__exception_data__append_info_exception_name__2Xn
        break ada__exceptions__exception_data__exception_name_length__2Xn
    ~~
    
    The reason is that these minimal symbols end up with their language
    set to language_cplus / C++, because those encoded names manage to
    demangle successfully as C++ symbols (using an old C++ mangling
    scheme):
    
      $ echo ada__exceptions__exception_data__append_info_exception_name__2Xn | c++filt
      Xn::ada__exceptions__exception_data__append_info_exception_name(void)
    
    It's unfortunate that Ada's encoding scheme doesn't start with some
    unique prefix like "_Z" in the C++ Itanium ABI mangling scheme.  For
    now, paper over that by treating C++ minsyms as Ada minsyms.
    
    gdb/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
            PR gdb/22670
    	* ada-lang.c (ada_collect_symbol_completion_matches): If the
    	minsym's language is language_auto or language_cplus, pass down
    	language_ada instead.
    	* symtab.c (compare_symbol_name): Don't frob symbol language here.
    
    gdb/testsuite/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
            PR gdb/22670
    	* gdb.ada/complete.exp ("complete break ada"): Replace kfail with
    	a fail.
Comment 16 Sourceware Commits 2018-01-10 23:35:59 UTC
The gdb-8.1-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2707f065bea6f20db9296dbda4577ce45b69093a

commit 2707f065bea6f20db9296dbda4577ce45b69093a
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Jan 10 23:14:07 2018 +0000

    Ada: make verbatim matcher override other language matchers (PR gdb/22670)
    
    A previous patch fixed verbatim matching in the lookup at the minimal
    symbol level, but we should also be finding that same symbol through
    the partial/full symtab search.
    
    For example, this is what happens if we use "print" instead of
    "break":
    
        (gdb) p <MixedCaseFunc>
        $1 = {<text variable, no debug info>} 0x4024dc <MixedCaseFunc>
    
    Before the C++ wildmatching series, GDB knows that MixedCaseFunc is a
    function without parameters, and the expression above means calling
    it.  If you try it before having started the inferior, you'd get the
    following (expected) error:
    
        (gdb) print  <MixedCaseFunc>
        You can't do that without a process to debug.
    
    The main idea behind making the name matcher be determined by the
    symbol's language is so that C++ (etc.) wildmatching in linespecs
    works even if the current language is not C++, as e.g., when you step
    through C or assembly code.
    
    Ada's verbatim matching syntax however ("<...>") isn't quite the same.
    It is more a property of the current language than of a particular
    symbol's language.  We want to support this syntax when debugging an
    Ada program, but it's reason of existence is to find non-Ada symbols.
    This suggests going back to enabling it depending on current language
    instead of language of the symbol being matched.
    
    I'm not entirely happy with the "current_language" reference (though I
    think that it's harmless).  I think we could try storing the current
    language in the lookup_name_info object, and then convert a bunch of
    functions more to pass around lookup_name_info objects instead of
    "const char *" names.  I.e., build the lookup_name_info higher up.
    I'm not sure about that, I'll have to think more about it.  Maybe
    something different will be better.  Meanwhile, this gets us going.
    
    I've extended the testcase to also exercise a no-debug-info function,
    for extra coverage of the minsyms-only paths.
    
    gdb/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* dwarf2read.c
    	(gdb_index_symbol_name_matcher::gdb_index_symbol_name_matcher):
    	Adjust to use language_get_symbol_name_matcher instead of
    	language_defn::la_get_symbol_name_matcher.
    	* language.c (language_get_symbol_name_matcher): If in Ada mode
    	and the lookup name is a verbatim match, return Ada's matcher.
    	* language.h (language_get_symbol_name_matcher): Adjust comment.
    	(ada_lookup_name_info::verbatim_p):: New method.
    
    gdb/testsuite/ChangeLog:
    2018-01-10  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/22670
    	* gdb.ada/bp_c_mixed_case.exp: Add intro comment.  Test printing C
    	functions too.  Test setting breakpoints and printing C functions
    	with no debug info too.
    	* gdb.ada/bp_c_mixed_case/qux.c: New file.
Comment 17 Pedro Alves 2018-01-10 23:51:18 UTC
All fixed, I believe.
Comment 18 Sourceware Commits 2018-03-27 13:58:16 UTC
The master branch has been updated by Joel Brobecker <brobecke@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=59cc4834e53565da1de4a7b615ed8890ed55c7da

commit 59cc4834e53565da1de4a7b615ed8890ed55c7da
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Tue Mar 27 08:57:16 2018 -0500

    problem looking up some symbols when they have a linkage name
    
    This patch fixes a known failure in gdb.ada/maint_with_ada.exp
    (maintenance check-psymtabs). Another way to witness the same
    issue is by considering the following Ada declarations...
    
       type Wrapper is record
          A : Integer;
       end record;
       u00045 : constant Wrapper := (A => 16#060287af#);
       pragma Export (C, u00045, "symada__cS");
    
    ... which declares a variable name "u00045" but with a linkage
    name which is "symada__cS". This variable is a record with one
    component, the Ada equivalent of a struct with one field in C.
    Trying to print that variable's value currently yields:
    
        (gdb) p /x <symada__cS>
        'symada(char, signed)' has unknown type; cast it to its declared type
    
    This indicates that GDB was only able to find the minimal symbol,
    but not the full symbol. The expected output is:
    
        (gdb) print /x <symada__cS>
        $1 = (a => 0x60287af)
    
    The error message gives a hint about what's happening: We processed
    the symbol through gdb_demangle, which in the case of this particular
    symbol name, ends up matching the C++ naming scheme. As a result,
    the demangler transforms our symbol name into 'symada(char, signed)',
    thus breaking Ada lookups.
    
    This patch fixes the issue by first introducing a new language_defn
    attribute called la_store_sym_names_in_linkage_form_p, which is a boolean
    to be set to true for the few languages that do not want their symbols
    to have their names stored in demangled form, and false otherwise.
    We then use this language attribute to skip the call to gdb_demangle
    for all languages whose la_store_sym_names_in_linkage_form_p is true.
    
    In terms of the selection of languages for which the new attribute
    is set to true, the selection errs on the side of preserving the
    existing behavior, and only changes the behavior for the languages
    where we are certain storing symbol names in demangling form is not
    needed. It is conceivable that other languages might be in the same
    situation, but I not knowing in detail the symbol name enconding
    strategy, I decided to play it safe and let other language maintainers
    potentially adjust their language if it makes sense to do so.
    
    gdb/ChangeLog:
    
            PR gdb/22670
            * dwarf2read.c (dwarf2_physname): Do not return the demangled
            symbol name if the CU's language stores symbol names in linkage
            format.
            * language.h (struct language_defn)
            <la_store_sym_names_in_linkage_form_p>: New field.  Adjust
            all instances of this struct.
    
    gdb/testsuite/ChangeLog:
    
            * gdb.ada/maint_with_ada.exp: Remove PR gdb/22670 setup_kfail.
    
            * gdb.ada/notcplusplus: New testcase.
    
            * gdb.base/c-linkage-name.c: New file.
            * gdb.base/c-linkage-name.exp: New testcase.
    
    Tested on x86_64-linux.
    This also passes AdaCore's internal GDB testsuite.