aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2018-01-05 14:04:09 +0000
committerPedro Alves <palves@redhat.com>2018-01-05 16:07:00 +0000
commitde63c46b549d1cf4f7851e47872cb759a12983f4 (patch)
tree7add37dcfdc2f4eae12a6f78b17fa45edb0ff9fb
parentf98fc17b3ac4750842ec0fe28a18b51691ddfbda (diff)
downloadfsf-binutils-gdb-de63c46b549d1cf4f7851e47872cb759a12983f4.zip
fsf-binutils-gdb-de63c46b549d1cf4f7851e47872cb759a12983f4.tar.gz
fsf-binutils-gdb-de63c46b549d1cf4f7851e47872cb759a12983f4.tar.bz2
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.
-rw-r--r--gdb/ChangeLog37
-rw-r--r--gdb/ada-lang.c26
-rw-r--r--gdb/block.c3
-rw-r--r--gdb/block.h1
-rw-r--r--gdb/c-valprint.c9
-rw-r--r--gdb/compile/compile-object-load.c6
-rw-r--r--gdb/cp-namespace.c4
-rw-r--r--gdb/cp-support.c1
-rw-r--r--gdb/infrun.c3
-rw-r--r--gdb/p-valprint.c10
-rw-r--r--gdb/psymtab.c6
-rw-r--r--gdb/stack.c8
-rw-r--r--gdb/symtab.c55
-rw-r--r--gdb/symtab.h25
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.ada/access_tagged_param.exp40
-rw-r--r--gdb/testsuite/gdb.ada/access_tagged_param/foo.adb20
-rw-r--r--gdb/testsuite/gdb.ada/access_tagged_param/pck.adb21
-rw-r--r--gdb/testsuite/gdb.ada/access_tagged_param/pck.ads21
19 files changed, 271 insertions, 31 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index badced8..10aabcd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,6 +1,43 @@
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
* ada-lang.c (ada_lookup_encoded_symbol): Reimplement in terms of
ada_lookup_symbol.
(ada_lookup_symbol): Reimplement in terms of
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index e7c2197..622cfd0 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -14412,12 +14412,38 @@ ada_symbol_name_matches (const char *symbol_search_name,
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
diff --git a/gdb/block.c b/gdb/block.c
index fb91eb9..57da7ba 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -673,12 +673,13 @@ block_iter_match_next (const lookup_name_info &name,
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))
{
diff --git a/gdb/block.h b/gdb/block.h
index 8f400cf..ff12725 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -258,6 +258,7 @@ extern struct symbol *block_iter_match_next
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
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 7f8154e..c4c0918 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -198,14 +198,17 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
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)
{
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 0b7215b..fac16d7 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -439,7 +439,10 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
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;
@@ -466,6 +469,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
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);
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 0751fda..185607e 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -141,7 +141,9 @@ cp_basic_lookup_symbol (const char *name, const struct block *block,
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;
}
}
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 2efc385..dde417b 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1793,6 +1793,7 @@ cp_get_symbol_name_matcher (const lookup_name_info &lookup_name)
{
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;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 3f7d185..7e8d8da 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -7489,7 +7489,8 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
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))
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 6d53586..933dbfb 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -246,15 +246,17 @@ pascal_val_print (struct type *type,
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)
{
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 3075be2..88d234a 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -2254,7 +2254,8 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
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)
{
@@ -2271,7 +2272,8 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
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)
{
diff --git a/gdb/stack.c b/gdb/stack.c
index 263e7bb..9993ae6 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -616,8 +616,8 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
{
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))
@@ -2141,8 +2141,8 @@ iterate_over_block_arg_vars (const struct block *b,
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);
}
}
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 3865420..146dc2e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -75,6 +75,7 @@ static int find_line_common (struct linetable *, int, int *, int);
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,
@@ -82,6 +83,7 @@ static struct block_symbol
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);
@@ -1773,14 +1775,18 @@ demangle_for_lookup_info::demangle_for_lookup_info
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. */
@@ -1876,7 +1882,9 @@ lookup_symbol_in_language (const char *name, const struct block *block,
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);
}
@@ -1895,6 +1903,16 @@ lookup_symbol (const char *name, const struct block *block,
/* 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)
{
@@ -1915,7 +1933,9 @@ lookup_language_this (const struct language_defn *lang,
{
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)
@@ -1986,7 +2006,8 @@ check_field (struct type *type, const char *name,
(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)
{
@@ -2015,7 +2036,7 @@ lookup_symbol_aux (const char *name, const struct block *block,
/* 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)
@@ -2097,7 +2118,9 @@ lookup_symbol_aux (const char *name, const struct block *block,
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)
{
@@ -2112,7 +2135,7 @@ lookup_local_symbol (const char *name, const struct block *block,
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};
@@ -2165,7 +2188,8 @@ lookup_objfile_from_block (const struct block *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;
@@ -2181,7 +2205,7 @@ lookup_symbol_in_block (const char *name, const struct block *block,
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)
@@ -2370,7 +2394,8 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, int block_index,
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);
@@ -2483,7 +2508,9 @@ lookup_symbol_in_static_block (const char *name,
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,
diff --git a/gdb/symtab.h b/gdb/symtab.h
index b49d56b..a7b1ed2 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -60,6 +60,16 @@ enum class symbol_name_match_type
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,
@@ -1554,6 +1564,20 @@ extern struct block_symbol lookup_symbol (const char *,
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. */
@@ -1603,6 +1627,7 @@ extern struct block_symbol
extern struct symbol *
lookup_symbol_in_block (const char *name,
+ symbol_name_match_type match_type,
const struct block *block,
const domain_enum domain);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 9448631..18ad740 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gdb/testsuite/gdb.ada/access_tagged_param.exp b/gdb/testsuite/gdb.ada/access_tagged_param.exp
new file mode 100644
index 0000000..598cf89
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/access_tagged_param.exp
@@ -0,0 +1,40 @@
+# 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 .*"
diff --git a/gdb/testsuite/gdb.ada/access_tagged_param/foo.adb b/gdb/testsuite/gdb.ada/access_tagged_param/foo.adb
new file mode 100644
index 0000000..76d738c
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/access_tagged_param/foo.adb
@@ -0,0 +1,20 @@
+-- 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;
diff --git a/gdb/testsuite/gdb.ada/access_tagged_param/pck.adb b/gdb/testsuite/gdb.ada/access_tagged_param/pck.adb
new file mode 100644
index 0000000..d156cee
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/access_tagged_param/pck.adb
@@ -0,0 +1,21 @@
+-- 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;
diff --git a/gdb/testsuite/gdb.ada/access_tagged_param/pck.ads b/gdb/testsuite/gdb.ada/access_tagged_param/pck.ads
new file mode 100644
index 0000000..f1973d2
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/access_tagged_param/pck.ads
@@ -0,0 +1,21 @@
+-- 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;