+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.
+
2018-01-05 Pedro Alves <palves@redhat.com>
PR gdb/22670
comp_match_res);
}
+/* A name matcher that matches the symbol name exactly, with
+ strcmp. */
+
+static bool
+literal_symbol_name_matcher (const char *symbol_search_name,
+ const lookup_name_info &lookup_name,
+ completion_match_result *comp_match_res)
+{
+ const std::string &name = lookup_name.name ();
+
+ int cmp = (lookup_name.completion_mode ()
+ ? strncmp (symbol_search_name, name.c_str (), name.size ())
+ : strcmp (symbol_search_name, name.c_str ()));
+ if (cmp == 0)
+ {
+ if (comp_match_res != NULL)
+ comp_match_res->set_match (symbol_search_name);
+ return true;
+ }
+ else
+ return false;
+}
+
/* Implement the "la_get_symbol_name_matcher" language_defn method for
Ada. */
static symbol_name_matcher_ftype *
ada_get_symbol_name_matcher (const lookup_name_info &lookup_name)
{
+ if (lookup_name.match_type () == symbol_name_match_type::SEARCH_NAME)
+ return literal_symbol_name_matcher;
+
if (lookup_name.completion_mode ())
return ada_symbol_name_matches;
else
struct symbol *
block_lookup_symbol (const struct block *block, const char *name,
+ symbol_name_match_type match_type,
const domain_enum domain)
{
struct block_iterator iter;
struct symbol *sym;
- lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
+ lookup_name_info lookup_name (name, match_type);
if (!BLOCK_FUNCTION (block))
{
extern struct symbol *block_lookup_symbol (const struct block *block,
const char *name,
+ symbol_name_match_type match_type,
const domain_enum domain);
/* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of
struct symbol *wsym = NULL;
struct type *wtype;
struct block *block = NULL;
- struct field_of_this_result is_this_fld;
if (want_space)
fputs_filtered (" ", stream);
if (msymbol.minsym != NULL)
- wsym = lookup_symbol (MSYMBOL_LINKAGE_NAME(msymbol.minsym), block,
- VAR_DOMAIN, &is_this_fld).symbol;
+ {
+ const char *search_name
+ = MSYMBOL_SEARCH_NAME (msymbol.minsym);
+ wsym = lookup_symbol_search_name (search_name, block,
+ VAR_DOMAIN).symbol;
+ }
if (wsym)
{
block = BLOCKVECTOR_BLOCK (bv, block_loop);
if (BLOCK_FUNCTION (block) != NULL)
continue;
- gdb_val_sym = block_lookup_symbol (block, COMPILE_I_EXPR_VAL, VAR_DOMAIN);
+ gdb_val_sym = block_lookup_symbol (block,
+ COMPILE_I_EXPR_VAL,
+ symbol_name_match_type::SEARCH_NAME,
+ VAR_DOMAIN);
if (gdb_val_sym == NULL)
continue;
gdb_type = check_typedef (gdb_type);
gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE,
+ symbol_name_match_type::SEARCH_NAME,
VAR_DOMAIN);
if (gdb_ptr_type_sym == NULL)
error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE);
if (global_block != NULL)
{
- sym.symbol = lookup_symbol_in_block (name, global_block, domain);
+ sym.symbol = lookup_symbol_in_block (name,
+ symbol_name_match_type::FULL,
+ global_block, domain);
sym.block = global_block;
}
}
{
case symbol_name_match_type::FULL:
case symbol_name_match_type::EXPRESSION:
+ case symbol_name_match_type::SEARCH_NAME:
return cp_fq_symbol_name_matches;
case symbol_name_match_type::WILD:
return cp_symbol_name_matches;
CORE_ADDR handler;
struct breakpoint *bp;
- vsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym), b, VAR_DOMAIN, NULL);
+ vsym = lookup_symbol_search_name (SYMBOL_SEARCH_NAME (sym),
+ b, VAR_DOMAIN);
value = read_var_value (vsym.symbol, vsym.block, frame);
/* If the value was optimized out, revert to the old behavior. */
if (! value_optimized_out (value))
struct symbol *wsym = NULL;
struct type *wtype;
struct block *block = NULL;
- struct field_of_this_result is_this_fld;
if (want_space)
fputs_filtered (" ", stream);
if (msymbol.minsym != NULL)
- wsym = lookup_symbol (MSYMBOL_LINKAGE_NAME (msymbol.minsym),
- block,
- VAR_DOMAIN, &is_this_fld).symbol;
+ {
+ const char *search_name
+ = MSYMBOL_SEARCH_NAME (msymbol.minsym);
+ wsym = lookup_symbol_search_name (search_name, block,
+ VAR_DOMAIN).symbol;
+ }
if (wsym)
{
length = ps->n_static_syms;
while (length--)
{
- sym = block_lookup_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
+ sym = block_lookup_symbol (b, SYMBOL_SEARCH_NAME (*psym),
+ symbol_name_match_type::SEARCH_NAME,
SYMBOL_DOMAIN (*psym));
if (!sym)
{
length = ps->n_global_syms;
while (length--)
{
- sym = block_lookup_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
+ sym = block_lookup_symbol (b, SYMBOL_SEARCH_NAME (*psym),
+ symbol_name_match_type::SEARCH_NAME,
SYMBOL_DOMAIN (*psym));
if (!sym)
{
{
struct symbol *nsym;
- nsym = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
- b, VAR_DOMAIN, NULL).symbol;
+ nsym = lookup_symbol_search_name (SYMBOL_SEARCH_NAME (sym),
+ b, VAR_DOMAIN).symbol;
gdb_assert (nsym != NULL);
if (SYMBOL_CLASS (nsym) == LOC_REGISTER
&& !SYMBOL_IS_ARGUMENT (nsym))
float). There are also LOC_ARG/LOC_REGISTER pairs which
are not combined in symbol-reading. */
- sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
- b, VAR_DOMAIN, NULL).symbol;
+ sym2 = lookup_symbol_search_name (SYMBOL_SEARCH_NAME (sym),
+ b, VAR_DOMAIN).symbol;
(*cb) (SYMBOL_PRINT_NAME (sym), sym2, cb_data);
}
}
static struct block_symbol
lookup_symbol_aux (const char *name,
+ symbol_name_match_type match_type,
const struct block *block,
const domain_enum domain,
enum language language,
static
struct block_symbol lookup_local_symbol (const char *name,
+ symbol_name_match_type match_type,
const struct block *block,
const domain_enum domain,
enum language language);
if (without_params != NULL)
{
- m_demangled_name = demangle_for_lookup (without_params.get (),
- lang, storage);
+ if (lookup_name.match_type () != symbol_name_match_type::SEARCH_NAME)
+ m_demangled_name = demangle_for_lookup (without_params.get (),
+ lang, storage);
return;
}
}
- m_demangled_name = demangle_for_lookup (lookup_name.name ().c_str (),
- lang, storage);
+ if (lookup_name.match_type () == symbol_name_match_type::SEARCH_NAME)
+ m_demangled_name = lookup_name.name ();
+ else
+ m_demangled_name = demangle_for_lookup (lookup_name.name ().c_str (),
+ lang, storage);
}
/* See symtab.h. */
demangle_result_storage storage;
const char *modified_name = demangle_for_lookup (name, lang, storage);
- return lookup_symbol_aux (modified_name, block, domain, lang,
+ return lookup_symbol_aux (modified_name,
+ symbol_name_match_type::FULL,
+ block, domain, lang,
is_a_field_of_this);
}
/* See symtab.h. */
+struct block_symbol
+lookup_symbol_search_name (const char *search_name, const struct block *block,
+ domain_enum domain)
+{
+ return lookup_symbol_aux (search_name, symbol_name_match_type::SEARCH_NAME,
+ block, domain, language_asm, NULL);
+}
+
+/* See symtab.h. */
+
struct block_symbol
lookup_language_this (const struct language_defn *lang,
const struct block *block)
{
struct symbol *sym;
- sym = block_lookup_symbol (block, lang->la_name_of_this, VAR_DOMAIN);
+ sym = block_lookup_symbol (block, lang->la_name_of_this,
+ symbol_name_match_type::SEARCH_NAME,
+ VAR_DOMAIN);
if (sym != NULL)
{
if (symbol_lookup_debug > 1)
(e.g., demangled name) of the symbol that we're looking for. */
static struct block_symbol
-lookup_symbol_aux (const char *name, const struct block *block,
+lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
+ const struct block *block,
const domain_enum domain, enum language language,
struct field_of_this_result *is_a_field_of_this)
{
/* Search specified block and its superiors. Don't search
STATIC_BLOCK or GLOBAL_BLOCK. */
- result = lookup_local_symbol (name, block, domain, language);
+ result = lookup_local_symbol (name, match_type, block, domain, language);
if (result.symbol != NULL)
{
if (symbol_lookup_debug)
Don't search STATIC_BLOCK or GLOBAL_BLOCK. */
static struct block_symbol
-lookup_local_symbol (const char *name, const struct block *block,
+lookup_local_symbol (const char *name,
+ symbol_name_match_type match_type,
+ const struct block *block,
const domain_enum domain,
enum language language)
{
while (block != static_block)
{
- sym = lookup_symbol_in_block (name, block, domain);
+ sym = lookup_symbol_in_block (name, match_type, block, domain);
if (sym != NULL)
return (struct block_symbol) {sym, block};
/* See symtab.h. */
struct symbol *
-lookup_symbol_in_block (const char *name, const struct block *block,
+lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
+ const struct block *block,
const domain_enum domain)
{
struct symbol *sym;
domain_name (domain));
}
- sym = block_lookup_symbol (block, name, domain);
+ sym = block_lookup_symbol (block, name, match_type, domain);
if (sym)
{
if (symbol_lookup_debug > 1)
bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, block_index);
- result.symbol = block_lookup_symbol (block, name, domain);
+ result.symbol = block_lookup_symbol (block, name,
+ symbol_name_match_type::FULL, domain);
if (result.symbol == NULL)
error_in_psymtab_expansion (block_index, name, cust);
domain_name (domain));
}
- sym = lookup_symbol_in_block (name, static_block, domain);
+ sym = lookup_symbol_in_block (name,
+ symbol_name_match_type::FULL,
+ static_block, domain);
if (symbol_lookup_debug)
{
fprintf_unfiltered (gdb_stdlog,
namespace/module/package. */
FULL,
+ /* Search name matching. This is like FULL, but the search name did
+ not come from the user; instead it is already a search name
+ retrieved from a SYMBOL_SEARCH_NAME/MSYMBOL_SEARCH_NAME call.
+ For Ada, this avoids re-encoding an already-encoded search name
+ (which would potentially incorrectly lowercase letters in the
+ linkage/search name that should remain uppercase). For C++, it
+ avoids trying to demangle a name we already know is
+ demangled. */
+ SEARCH_NAME,
+
/* Expression matching. The same as FULL matching in most
languages. The same as WILD matching in Ada. */
EXPRESSION,
const domain_enum,
struct field_of_this_result *);
+/* Find the definition for a specified symbol search name in domain
+ DOMAIN, visible from lexical block BLOCK if non-NULL or from
+ global/static blocks if BLOCK is NULL. The passed-in search name
+ should not come from the user; instead it should already be a
+ search name as retrieved from a
+ SYMBOL_SEARCH_NAME/MSYMBOL_SEARCH_NAME call. See definition of
+ symbol_name_match_type::SEARCH_NAME. Returns the struct symbol
+ pointer, or NULL if no symbol is found. The symbol's section is
+ fixed up if necessary. */
+
+extern struct block_symbol lookup_symbol_search_name (const char *search_name,
+ const struct block *block,
+ domain_enum domain);
+
/* A default version of lookup_symbol_nonlocal for use by languages
that can't think of anything better to do.
This implements the C lookup rules. */
extern struct symbol *
lookup_symbol_in_block (const char *name,
+ symbol_name_match_type match_type,
const struct block *block,
const domain_enum domain);
+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.
+
2018-01-05 Pedro Alves <palves@redhat.com>
PR gdb/22670
--- /dev/null
+# Copyright 2017-2018 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that we can print values of parameters of type 'pointer
+# (access) to tagged type'. See PR gdb/22670.
+
+load_lib "ada.exp"
+
+standard_ada_testfile foo
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+if ![runto "foo"] then {
+ perror "Couldn't run ${testfile}"
+ return
+}
+
+gdb_breakpoint "pck.inspect"
+
+# Continue until we reach the breakpoint, and verify that we can print
+# the value of all the parameters.
+
+gdb_test "continue" \
+ ".*Breakpoint $decimal, pck\\.inspect \\(obj=$hex, <objL>=2\\) at .*"
--- /dev/null
+-- Copyright 2017-2018 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+with Pck; use Pck;
+procedure Foo is
+begin
+ Inspect (new Top_T'(N => 2));
+end Foo;
--- /dev/null
+-- Copyright 2017-2018 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package body Pck is
+ procedure Inspect (Obj: access Top_T'Class) is
+ begin
+ null;
+ end Inspect;
+end Pck;
--- /dev/null
+-- Copyright 2017-2018 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package Pck is
+ type Top_T is tagged record
+ N : Integer := 1;
+ end record;
+ procedure Inspect (Obj: access Top_T'Class);
+end Pck;