+2020-06-17 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * ada-lang.c (ada_get_symbol_name_matcher): Update header comment.
+ (ada_language_data): Delete la_get_symbol_name_matcher
+ initializer.
+ (language_defn::get_symbol_name_matcher_inner): New member
+ function.
+ * c-lang.c (c_language_data): Delete la_get_symbol_name_matcher
+ initializer.
+ (cplus_language_data): Likewise.
+ (cplus_language::get_symbol_name_matcher_inner): New member
+ function.
+ (asm_language_data): Delete la_get_symbol_name_matcher initializer.
+ (minimal_language_data): Likewise.
+ * cp-support.h (cp_get_symbol_name_matcher): Update header comment.
+ * d-lang.c (d_language_data): Delete la_get_symbol_name_matcher
+ initializer.
+ * dictionary.c (iter_match_first_hashed): Update call to
+ get_symbol_name_matcher.
+ (iter_match_next_hashed): Likewise.
+ (iter_match_next_linear): Likewise.
+ * dwarf2/read.c (dw2_expand_symtabs_matching_symbol): Likewise.
+ * f-lang.c (f_language_data): Delete la_get_symbol_name_matcher
+ initializer.
+ (f_language::get_symbol_name_matcher_inner): New member function.
+ * go-lang.c (go_language_data): Delete la_get_symbol_name_matcher
+ initializer.
+ * language.c (default_symbol_name_matcher): Update header comment,
+ make static.
+ (language_defn::get_symbol_name_matcher): New definition.
+ (language_defn::get_symbol_name_matcher_inner): Likewise.
+ (get_symbol_name_matcher): Delete.
+ (unknown_language_data): Delete la_get_symbol_name_matcher
+ initializer.
+ (auto_language_data): Likewise.
+ * language.h (language_data): Delete la_get_symbol_name_matcher
+ field.
+ (language_defn::get_symbol_name_matcher): New member function.
+ (language_defn::get_symbol_name_matcher_inner): Likewise.
+ (default_symbol_name_matcher): Delete declaration.
+ * linespec.c (find_methods): Update call to
+ get_symbol_name_matcher.
+ * m2-lang.c (m2_language_data): Delete la_get_symbol_name_matcher
+ initializer.
+ * minsyms.c (lookup_minimal_symbol): Update call to
+ get_symbol_name_matcher.
+ (iterate_over_minimal_symbols): Likewise.
+ * objc-lang.c (objc_language_data): Delete
+ la_get_symbol_name_matcher initializer.
+ * opencl-lang.c (opencl_language_data): Likewise.
+ * p-lang.c (pascal_language_data): Likewise.
+ * psymtab.c (psymbol_name_matches): Update call to
+ get_symbol_name_matcher.
+ * rust-lang.c (rust_language_data): Delete
+ la_get_symbol_name_matcher initializer.
+ * symtab.c (symbol_matches_search_name): Update call to
+ get_symbol_name_matcher.
+ (compare_symbol_name): Likewise.
+
2020-06-17 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Delete la_compute_program
return false;
}
-/* Implement the "la_get_symbol_name_matcher" language_defn method for
+/* Implement the "get_symbol_name_matcher" language_defn method for
Ada. */
static symbol_name_matcher_ftype *
ada_get_gdb_completer_word_break_characters,
ada_collect_symbol_completion_matches,
ada_watch_location_expression,
- ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
&ada_varobj_ops,
ada_is_string_type,
"(...)" /* la_struct_too_deep_ellipsis */
{
ada_print_type (type, varstring, stream, show, level, flags);
}
+
+protected:
+ /* See language.h. */
+
+ symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+ (const lookup_name_info &lookup_name) const override
+ {
+ return ada_get_symbol_name_matcher (lookup_name);
+ }
};
/* Single instance of the Ada language class. */
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&c_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- cp_get_symbol_name_matcher,
&cplus_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
{
return cp_class_name_from_physname (physname);
}
+
+protected:
+
+ /* See language.h. */
+
+ symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+ (const lookup_name_info &lookup_name) const override
+ {
+ return cp_get_symbol_name_matcher (lookup_name);
+ }
};
/* The single instance of the C++ language class. */
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
"function" or "bar::function" in all namespaces is possible. */
extern unsigned int cp_search_name_hash (const char *search_name);
-/* Implement the "la_get_symbol_name_matcher" language_defn method for
- C++. */
+/* Implement the "get_symbol_name_matcher" language_defn method for C++. */
extern symbol_name_matcher_ftype *cp_get_symbol_name_matcher
(const lookup_name_info &lookup_name);
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
unsigned int hash_index = (name.search_name_hash (lang->la_language)
% DICT_HASHED_NBUCKETS (dict));
symbol_name_matcher_ftype *matches_name
- = get_symbol_name_matcher (lang, name);
+ = lang->get_symbol_name_matcher (name);
struct symbol *sym;
DICT_ITERATOR_DICT (iterator) = dict;
{
const language_defn *lang = DICT_LANGUAGE (DICT_ITERATOR_DICT (iterator));
symbol_name_matcher_ftype *matches_name
- = get_symbol_name_matcher (lang, name);
+ = lang->get_symbol_name_matcher (name);
struct symbol *next;
for (next = DICT_ITERATOR_CURRENT (iterator)->hash_next;
const struct dictionary *dict = DICT_ITERATOR_DICT (iterator);
const language_defn *lang = DICT_LANGUAGE (dict);
symbol_name_matcher_ftype *matches_name
- = get_symbol_name_matcher (lang, name);
+ = lang->get_symbol_name_matcher (name);
int i, nsyms = DICT_LINEAR_NSYMS (dict);
struct symbol *sym, *retval = NULL;
const language_defn *lang = language_def (lang_e);
symbol_name_matcher_ftype *name_matcher
- = get_symbol_name_matcher (lang, lookup_name_without_params);
+ = lang->get_symbol_name_matcher (lookup_name_without_params);
name_and_matcher key {
name_matcher,
f_word_break_characters,
f_collect_symbol_completion_matches,
c_watch_location_expression,
- cp_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
&default_varobj_ops,
f_is_string_type_p,
"(...)" /* la_struct_too_deep_ellipsis */
{
f_print_type (type, varstring, stream, show, level, flags);
}
+
+protected:
+
+ /* See language.h. */
+
+ symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+ (const lookup_name_info &lookup_name) const override
+ {
+ return cp_get_symbol_name_matcher (lookup_name);
+ }
};
/* Single instance of the Fortran language class. */
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
go_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
fprintf_filtered (stream, "] = ");
}
-/* See language.h. */
+/* The default implementation of the get_symbol_name_matcher_inner method
+ from the language_defn class. Matches with strncmp_iw. */
-bool
+static bool
default_symbol_name_matcher (const char *symbol_search_name,
const lookup_name_info &lookup_name,
completion_match_result *comp_match_res)
/* See language.h. */
+symbol_name_matcher_ftype *
+language_defn::get_symbol_name_matcher
+ (const lookup_name_info &lookup_name) const
+{
+ /* If currently in Ada mode, and the lookup name is wrapped in
+ '<...>', hijack all symbol name comparisons using the Ada
+ matcher, which handles the verbatim matching. */
+ if (current_language->la_language == language_ada
+ && lookup_name.ada ().verbatim_p ())
+ return current_language->get_symbol_name_matcher_inner (lookup_name);
+
+ return this->get_symbol_name_matcher_inner (lookup_name);
+}
+
+/* See language.h. */
+
+symbol_name_matcher_ftype *
+language_defn::get_symbol_name_matcher_inner
+ (const lookup_name_info &lookup_name) const
+{
+ return default_symbol_name_matcher;
+}
+
+/* See language.h. */
+
bool
default_is_string_type_p (struct type *type)
{
return (type->code () == TYPE_CODE_STRING);
}
-/* See language.h. */
-
-symbol_name_matcher_ftype *
-get_symbol_name_matcher (const language_defn *lang,
- const lookup_name_info &lookup_name)
-{
- /* If currently in Ada mode, and the lookup name is wrapped in
- '<...>', hijack all symbol name comparisons using the Ada
- matcher, which handles the verbatim matching. */
- if (current_language->la_language == language_ada
- && lookup_name.ada ().verbatim_p ())
- return current_language->la_get_symbol_name_matcher (lookup_name);
-
- if (lang->la_get_symbol_name_matcher != nullptr)
- return lang->la_get_symbol_name_matcher (lookup_name);
- return default_symbol_name_matcher;
-}
-
/* Define the language that is no language. */
static int
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
default_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
default_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
gdb::unique_xmalloc_ptr<char> (*la_watch_location_expression)
(struct type *type, CORE_ADDR addr);
- /* Return a pointer to the function that should be used to match a
- symbol name against LOOKUP_NAME, according to this language's
- rules. The matching algorithm depends on LOOKUP_NAME. For
- example, on Ada, the matching algorithm depends on the symbol
- name (wild/full/verbatim matching), and on whether we're doing
- a normal lookup or a completion match lookup.
-
- This field may be NULL, in which case
- default_symbol_name_matcher is used to perform the
- matching. */
- symbol_name_matcher_ftype *(*la_get_symbol_name_matcher)
- (const lookup_name_info &);
-
/* Various operations on varobj. */
const struct lang_varobj_ops *la_varobj_ops;
return ::iterate_over_symbols (block, name, domain, callback);
}
+ /* Return a pointer to the function that should be used to match a
+ symbol name against LOOKUP_NAME, according to this language's
+ rules. The matching algorithm depends on LOOKUP_NAME. For
+ example, on Ada, the matching algorithm depends on the symbol
+ name (wild/full/verbatim matching), and on whether we're doing
+ a normal lookup or a completion match lookup.
+
+ As Ada wants to capture symbol matching for all languages in some
+ cases, then this method is a non-overridable interface. Languages
+ should override GET_SYMBOL_NAME_MATCHER_INNER if they need to. */
+
+ symbol_name_matcher_ftype *get_symbol_name_matcher
+ (const lookup_name_info &lookup_name) const;
+
/* If this language allows compilation from the gdb command line, then
this method will return an instance of struct gcc_context appropriate
to the language. If compilation for this language is generally
/* List of all known languages. */
static const struct language_defn *languages[nr_languages];
+
+protected:
+
+ /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
+ See that method for a description of the arguments. */
+
+ virtual symbol_name_matcher_ftype *get_symbol_name_matcher_inner
+ (const lookup_name_info &lookup_name) const;
};
/* Pointer to the language_defn for our current language. This pointer
int *length, struct type **char_type,
const char **charset);
-/* The default implementation of la_symbol_name_matcher. Matches with
- strncmp_iw. */
-extern bool default_symbol_name_matcher
- (const char *symbol_search_name,
- const lookup_name_info &lookup_name,
- completion_match_result *comp_match_res);
-
/* Get LANG's symbol_name_matcher method for LOOKUP_NAME. Returns
default_symbol_name_matcher if not set. LANG is used as a hint;
the function may ignore it depending on the current language and
int method_counter;
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
symbol_name_matcher_ftype *symbol_name_compare
- = get_symbol_name_matcher (language_def (t_lang), lookup_name);
+ = language_def (t_lang)->get_symbol_name_matcher (lookup_name);
t = check_typedef (t);
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
m2_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
% MINIMAL_SYMBOL_HASH_SIZE);
symbol_name_matcher_ftype *match
- = get_symbol_name_matcher (language_def (lang),
- lookup_name);
+ = language_def (lang)->get_symbol_name_matcher
+ (lookup_name);
struct minimal_symbol **msymbol_demangled_hash
= objfile->per_bfd->msymbol_demangled_hash;
enum language lang = (enum language) liter;
const language_defn *lang_def = language_def (lang);
symbol_name_matcher_ftype *name_match
- = get_symbol_name_matcher (lang_def, lookup_name);
+ = lang_def->get_symbol_name_matcher (lookup_name);
unsigned int hash
= lookup_name.search_name_hash (lang) % MINIMAL_SYMBOL_HASH_SIZE;
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
default_word_break_characters,
default_collect_symbol_completion_matches,
c_watch_location_expression,
- NULL, /* la_compare_symbol_for_completion */
&default_varobj_ops,
pascal_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
{
const language_defn *lang = language_def (psym->ginfo.language ());
symbol_name_matcher_ftype *name_match
- = get_symbol_name_matcher (lang, lookup_name);
+ = lang->get_symbol_name_matcher (lookup_name);
return name_match (psym->ginfo.search_name (), lookup_name, NULL);
}
default_word_break_characters,
default_collect_symbol_completion_matches,
rust_watch_location_expression,
- NULL, /* la_get_symbol_name_matcher */
&default_varobj_ops,
rust_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
const lookup_name_info &name)
{
symbol_name_matcher_ftype *name_match
- = get_symbol_name_matcher (language_def (gsymbol->language ()), name);
+ = language_def (gsymbol->language ())->get_symbol_name_matcher (name);
return name_match (gsymbol->search_name (), name, NULL);
}
const language_defn *lang = language_def (symbol_language);
symbol_name_matcher_ftype *name_match
- = get_symbol_name_matcher (lang, lookup_name);
+ = lang->get_symbol_name_matcher (lookup_name);
return name_match (symbol_name, lookup_name, &match_res);
}