diff options
-rw-r--r-- | gdb/ChangeLog | 59 | ||||
-rw-r--r-- | gdb/ada-lang.c | 12 | ||||
-rw-r--r-- | gdb/c-lang.c | 14 | ||||
-rw-r--r-- | gdb/cp-support.h | 3 | ||||
-rw-r--r-- | gdb/d-lang.c | 1 | ||||
-rw-r--r-- | gdb/dictionary.c | 6 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 2 | ||||
-rw-r--r-- | gdb/f-lang.c | 11 | ||||
-rw-r--r-- | gdb/go-lang.c | 1 | ||||
-rw-r--r-- | gdb/language.c | 50 | ||||
-rw-r--r-- | gdb/language.h | 42 | ||||
-rw-r--r-- | gdb/linespec.c | 2 | ||||
-rw-r--r-- | gdb/m2-lang.c | 1 | ||||
-rw-r--r-- | gdb/minsyms.c | 6 | ||||
-rw-r--r-- | gdb/objc-lang.c | 1 | ||||
-rw-r--r-- | gdb/opencl-lang.c | 1 | ||||
-rw-r--r-- | gdb/p-lang.c | 1 | ||||
-rw-r--r-- | gdb/psymtab.c | 2 | ||||
-rw-r--r-- | gdb/rust-lang.c | 1 | ||||
-rw-r--r-- | gdb/symtab.c | 4 |
20 files changed, 151 insertions, 69 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ae93dd6..0cb660f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,64 @@ 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 initializer. * c-lang.c (c_language_data): Likewise. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 5caa171..c91597e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13862,7 +13862,7 @@ literal_symbol_name_matcher (const char *symbol_search_name, 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 * @@ -13920,7 +13920,6 @@ extern const struct language_data ada_language_data = 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 */ @@ -14105,6 +14104,15 @@ public: { 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. */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 9d72c0e..8edab07 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -917,7 +917,6 @@ extern const struct language_data c_language_data = 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 */ @@ -1032,7 +1031,6 @@ extern const struct language_data cplus_language_data = 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 */ @@ -1184,6 +1182,16 @@ public: { 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. */ @@ -1225,7 +1233,6 @@ extern const struct language_data asm_language_data = 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 */ @@ -1295,7 +1302,6 @@ extern const struct language_data minimal_language_data = 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 */ diff --git a/gdb/cp-support.h b/gdb/cp-support.h index 7c948b2..d031ad9 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -127,8 +127,7 @@ extern struct type *cp_lookup_rtti_type (const char *name, "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); diff --git a/gdb/d-lang.c b/gdb/d-lang.c index ad16f99..4842d4b 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -160,7 +160,6 @@ extern const struct language_data d_language_data = 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 */ diff --git a/gdb/dictionary.c b/gdb/dictionary.c index da44946..c94a49e 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -584,7 +584,7 @@ iter_match_first_hashed (const struct dictionary *dict, 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; @@ -612,7 +612,7 @@ iter_match_next_hashed (const lookup_name_info &name, { 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; @@ -828,7 +828,7 @@ iter_match_next_linear (const lookup_name_info &name, 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; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d15eba9..34915be 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4097,7 +4097,7 @@ dw2_expand_symtabs_matching_symbol 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, diff --git a/gdb/f-lang.c b/gdb/f-lang.c index d748db8..42e6c98 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -620,7 +620,6 @@ extern const struct language_data f_language_data = 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 */ @@ -699,6 +698,16 @@ public: { 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. */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 9196cd3..661cabb 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -545,7 +545,6 @@ extern const struct language_data go_language_data = 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 */ diff --git a/gdb/language.c b/gdb/language.c index 2b2584f..363481b 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -622,9 +622,10 @@ language_defn::print_array_index (struct type *index_type, LONGEST index, 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) @@ -649,6 +650,31 @@ default_symbol_name_matcher (const char *symbol_search_name, /* 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) { @@ -661,24 +687,6 @@ 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 @@ -774,7 +782,6 @@ extern const struct language_data unknown_language_data = 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 */ @@ -848,7 +855,6 @@ extern const struct language_data auto_language_data = 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 */ diff --git a/gdb/language.h b/gdb/language.h index 523a7a9..7e5837f 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -338,19 +338,6 @@ struct language_data 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; @@ -443,6 +430,20 @@ struct language_defn : language_data 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 @@ -530,6 +531,14 @@ struct language_defn : language_data /* 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 @@ -698,13 +707,6 @@ void c_get_string (struct value *value, 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 diff --git a/gdb/linespec.c b/gdb/linespec.c index ddca05b..4a634e3 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1232,7 +1232,7 @@ find_methods (struct type *t, enum language t_lang, const char *name, 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); diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 87bf1eb..9245ebb 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -379,7 +379,6 @@ extern const struct language_data m2_language_data = 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 */ diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 47c6f0b..f4a2544 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -363,8 +363,8 @@ lookup_minimal_symbol (const char *name, const char *sfile, % 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; @@ -507,7 +507,7 @@ iterate_over_minimal_symbols 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; diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 8b23c55..9a77f6c 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -354,7 +354,6 @@ extern const struct language_data objc_language_data = 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 */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 00f88c6..377c550 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1033,7 +1033,6 @@ extern const struct language_data opencl_language_data = 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 */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 869c89e..189617a 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -410,7 +410,6 @@ extern const struct language_data pascal_language_data = 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 */ diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 5960c59..47e31aa 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -557,7 +557,7 @@ psymbol_name_matches (partial_symbol *psym, { 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); } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 296bfe1..3f187bd 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -2065,7 +2065,6 @@ extern const struct language_data rust_language_data = 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 */ diff --git a/gdb/symtab.c b/gdb/symtab.c index b255cc7..ec0d94b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1016,7 +1016,7 @@ symbol_matches_search_name (const struct general_symbol_info *gsymbol, 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); } @@ -5258,7 +5258,7 @@ compare_symbol_name (const char *symbol_name, language symbol_language, 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); } |