gdb: Convert language la_iterate_over_symbols field to a method
This commit changes the language_data::la_iterate_over_symbols function pointer member variable into a member function of language_defn. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_add_all_symbols): Update comment. (ada_iterate_over_symbols): Delete, move implementation to... (ada_language::iterate_over_symbols): ...here, a new member function, rewrite to use range based for loop. (ada_language_data): Delete la_iterate_over_symbols initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_language_data): Likewise. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Delete la_iterate_over_symbols field. (language_defn::iterate_over_symbols): New member function. (LA_ITERATE_OVER_SYMBOLS): Update. * linespec.c (iterate_over_all_matching_symtabs): Update. * m2-lang.c (m2_language_data): Delete la_iterate_over_symbols initializer. * objc-lang.c (objc_language_data): Likewise. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise.
This commit is contained in:
parent
54f4ca4610
commit
4009ee92c4
14 changed files with 70 additions and 58 deletions
|
@ -1,3 +1,30 @@
|
||||||
|
2020-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
|
* ada-lang.c (ada_add_all_symbols): Update comment.
|
||||||
|
(ada_iterate_over_symbols): Delete, move implementation to...
|
||||||
|
(ada_language::iterate_over_symbols): ...here, a new member
|
||||||
|
function, rewrite to use range based for loop.
|
||||||
|
(ada_language_data): Delete la_iterate_over_symbols initializer.
|
||||||
|
* c-lang.c (c_language_data): Likewise.
|
||||||
|
(cplus_language_data): Likewise.
|
||||||
|
(asm_language_data): Likewise.
|
||||||
|
(minimal_language_data): Likewise.
|
||||||
|
* d-lang.c (d_language_data): Likewise.
|
||||||
|
* f-lang.c (f_language_data): Likewise.
|
||||||
|
* go-lang.c (go_language_data): Likewise.
|
||||||
|
* language.c (unknown_language_data): Likewise.
|
||||||
|
(auto_language_data): Likewise.
|
||||||
|
* language.h (language_data): Delete la_iterate_over_symbols field.
|
||||||
|
(language_defn::iterate_over_symbols): New member function.
|
||||||
|
(LA_ITERATE_OVER_SYMBOLS): Update.
|
||||||
|
* linespec.c (iterate_over_all_matching_symtabs): Update.
|
||||||
|
* m2-lang.c (m2_language_data): Delete la_iterate_over_symbols
|
||||||
|
initializer.
|
||||||
|
* objc-lang.c (objc_language_data): Likewise.
|
||||||
|
* opencl-lang.c (opencl_language_data): Likewise.
|
||||||
|
* p-lang.c (pascal_language_data): Likewise.
|
||||||
|
* rust-lang.c (rust_language_data): Likewise.
|
||||||
|
|
||||||
2020-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
|
2020-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* ada-lang.c (ada_language_data): Delete
|
* ada-lang.c (ada_language_data): Delete
|
||||||
|
|
|
@ -5681,7 +5681,7 @@ ada_add_all_symbols (struct obstack *obstackp,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* In the !full_search case we're are being called by
|
/* In the !full_search case we're are being called by
|
||||||
ada_iterate_over_symbols, and we don't want to search
|
iterate_over_symbols, and we don't want to search
|
||||||
superblocks. */
|
superblocks. */
|
||||||
ada_add_block_symbols (obstackp, block, lookup_name, domain, NULL);
|
ada_add_block_symbols (obstackp, block, lookup_name, domain, NULL);
|
||||||
}
|
}
|
||||||
|
@ -5782,28 +5782,6 @@ ada_lookup_symbol_list (const char *name, const struct block *block,
|
||||||
return ada_lookup_symbol_list_worker (lookup_name, block, domain, results, 1);
|
return ada_lookup_symbol_list_worker (lookup_name, block, domain, results, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation of the la_iterate_over_symbols method. */
|
|
||||||
|
|
||||||
static bool
|
|
||||||
ada_iterate_over_symbols
|
|
||||||
(const struct block *block, const lookup_name_info &name,
|
|
||||||
domain_enum domain,
|
|
||||||
gdb::function_view<symbol_found_callback_ftype> callback)
|
|
||||||
{
|
|
||||||
int ndefs, i;
|
|
||||||
std::vector<struct block_symbol> results;
|
|
||||||
|
|
||||||
ndefs = ada_lookup_symbol_list_worker (name, block, domain, &results, 0);
|
|
||||||
|
|
||||||
for (i = 0; i < ndefs; ++i)
|
|
||||||
{
|
|
||||||
if (!callback (&results[i]))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The result is as for ada_lookup_symbol_list with FULL_SEARCH set
|
/* The result is as for ada_lookup_symbol_list with FULL_SEARCH set
|
||||||
to 1, but choosing the first symbol found if there are multiple
|
to 1, but choosing the first symbol found if there are multiple
|
||||||
choices.
|
choices.
|
||||||
|
@ -13999,7 +13977,6 @@ extern const struct language_data ada_language_data =
|
||||||
ada_collect_symbol_completion_matches,
|
ada_collect_symbol_completion_matches,
|
||||||
ada_watch_location_expression,
|
ada_watch_location_expression,
|
||||||
ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
|
ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
|
||||||
ada_iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&ada_varobj_ops,
|
&ada_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -14114,6 +14091,25 @@ public:
|
||||||
lai->bool_type_symbol = NULL;
|
lai->bool_type_symbol = NULL;
|
||||||
lai->bool_type_default = builtin->builtin_bool;
|
lai->bool_type_default = builtin->builtin_bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See language.h. */
|
||||||
|
|
||||||
|
bool iterate_over_symbols
|
||||||
|
(const struct block *block, const lookup_name_info &name,
|
||||||
|
domain_enum domain,
|
||||||
|
gdb::function_view<symbol_found_callback_ftype> callback) const override
|
||||||
|
{
|
||||||
|
std::vector<struct block_symbol> results;
|
||||||
|
|
||||||
|
ada_lookup_symbol_list_worker (name, block, domain, &results, 0);
|
||||||
|
for (block_symbol &sym : results)
|
||||||
|
{
|
||||||
|
if (!callback (&sym))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Single instance of the Ada language class. */
|
/* Single instance of the Ada language class. */
|
||||||
|
|
|
@ -922,7 +922,6 @@ extern const struct language_data c_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&c_varobj_ops,
|
&c_varobj_ops,
|
||||||
c_get_compile_context,
|
c_get_compile_context,
|
||||||
|
@ -1022,7 +1021,6 @@ extern const struct language_data cplus_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
cp_get_symbol_name_matcher,
|
cp_get_symbol_name_matcher,
|
||||||
iterate_over_symbols,
|
|
||||||
cp_search_name_hash,
|
cp_search_name_hash,
|
||||||
&cplus_varobj_ops,
|
&cplus_varobj_ops,
|
||||||
cplus_get_compile_context,
|
cplus_get_compile_context,
|
||||||
|
@ -1164,7 +1162,6 @@ extern const struct language_data asm_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1235,7 +1232,6 @@ extern const struct language_data minimal_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -176,7 +176,6 @@ extern const struct language_data d_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -633,7 +633,6 @@ extern const struct language_data f_language_data =
|
||||||
f_collect_symbol_completion_matches,
|
f_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
cp_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
|
cp_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
cp_search_name_hash,
|
cp_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -561,7 +561,6 @@ extern const struct language_data go_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -838,7 +838,6 @@ extern const struct language_data unknown_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -905,7 +904,6 @@ extern const struct language_data auto_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -384,24 +384,6 @@ struct language_data
|
||||||
symbol_name_matcher_ftype *(*la_get_symbol_name_matcher)
|
symbol_name_matcher_ftype *(*la_get_symbol_name_matcher)
|
||||||
(const lookup_name_info &);
|
(const lookup_name_info &);
|
||||||
|
|
||||||
/* Find all symbols in the current program space matching NAME in
|
|
||||||
DOMAIN, according to this language's rules.
|
|
||||||
|
|
||||||
The search is done in BLOCK only.
|
|
||||||
The caller is responsible for iterating up through superblocks
|
|
||||||
if desired.
|
|
||||||
|
|
||||||
For each one, call CALLBACK with the symbol. If CALLBACK
|
|
||||||
returns false, the iteration ends at that point.
|
|
||||||
|
|
||||||
This field may not be NULL. If the language does not need any
|
|
||||||
special processing here, 'iterate_over_symbols' should be
|
|
||||||
used as the definition. */
|
|
||||||
bool (*la_iterate_over_symbols)
|
|
||||||
(const struct block *block, const lookup_name_info &name,
|
|
||||||
domain_enum domain,
|
|
||||||
gdb::function_view<symbol_found_callback_ftype> callback);
|
|
||||||
|
|
||||||
/* Hash the given symbol search name. Use
|
/* Hash the given symbol search name. Use
|
||||||
default_search_name_hash if no special treatment is
|
default_search_name_hash if no special treatment is
|
||||||
required. */
|
required. */
|
||||||
|
@ -508,6 +490,27 @@ struct language_defn : language_data
|
||||||
return basic_lookup_transparent_type (name);
|
return basic_lookup_transparent_type (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find all symbols in the current program space matching NAME in
|
||||||
|
DOMAIN, according to this language's rules.
|
||||||
|
|
||||||
|
The search is done in BLOCK only.
|
||||||
|
The caller is responsible for iterating up through superblocks
|
||||||
|
if desired.
|
||||||
|
|
||||||
|
For each one, call CALLBACK with the symbol. If CALLBACK
|
||||||
|
returns false, the iteration ends at that point.
|
||||||
|
|
||||||
|
This field may not be NULL. If the language does not need any
|
||||||
|
special processing here, 'iterate_over_symbols' should be
|
||||||
|
used as the definition. */
|
||||||
|
virtual bool iterate_over_symbols
|
||||||
|
(const struct block *block, const lookup_name_info &name,
|
||||||
|
domain_enum domain,
|
||||||
|
gdb::function_view<symbol_found_callback_ftype> callback) const
|
||||||
|
{
|
||||||
|
return ::iterate_over_symbols (block, name, domain, callback);
|
||||||
|
}
|
||||||
|
|
||||||
/* List of all known languages. */
|
/* List of all known languages. */
|
||||||
static const struct language_defn *languages[nr_languages];
|
static const struct language_defn *languages[nr_languages];
|
||||||
};
|
};
|
||||||
|
@ -617,7 +620,7 @@ extern enum language set_language (enum language);
|
||||||
options))
|
options))
|
||||||
|
|
||||||
#define LA_ITERATE_OVER_SYMBOLS(BLOCK, NAME, DOMAIN, CALLBACK) \
|
#define LA_ITERATE_OVER_SYMBOLS(BLOCK, NAME, DOMAIN, CALLBACK) \
|
||||||
(current_language->la_iterate_over_symbols (BLOCK, NAME, DOMAIN, CALLBACK))
|
(current_language->iterate_over_symbols (BLOCK, NAME, DOMAIN, CALLBACK))
|
||||||
|
|
||||||
/* Test a character to decide whether it can be printed in literal form
|
/* Test a character to decide whether it can be printed in literal form
|
||||||
or needs to be printed in another representation. For example,
|
or needs to be printed in another representation. For example,
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ iterate_over_all_matching_symtabs
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), i);
|
block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), i);
|
||||||
state->language->la_iterate_over_symbols
|
state->language->iterate_over_symbols
|
||||||
(block, lookup_name, name_domain,
|
(block, lookup_name, name_domain,
|
||||||
[&] (block_symbol *bsym)
|
[&] (block_symbol *bsym)
|
||||||
{
|
{
|
||||||
|
|
|
@ -386,7 +386,6 @@ extern const struct language_data m2_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -401,7 +401,6 @@ extern const struct language_data objc_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -1061,7 +1061,6 @@ extern const struct language_data opencl_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -416,7 +416,6 @@ extern const struct language_data pascal_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
c_watch_location_expression,
|
c_watch_location_expression,
|
||||||
NULL, /* la_compare_symbol_for_completion */
|
NULL, /* la_compare_symbol_for_completion */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -2093,7 +2093,6 @@ extern const struct language_data rust_language_data =
|
||||||
default_collect_symbol_completion_matches,
|
default_collect_symbol_completion_matches,
|
||||||
rust_watch_location_expression,
|
rust_watch_location_expression,
|
||||||
NULL, /* la_get_symbol_name_matcher */
|
NULL, /* la_get_symbol_name_matcher */
|
||||||
iterate_over_symbols,
|
|
||||||
default_search_name_hash,
|
default_search_name_hash,
|
||||||
&default_varobj_ops,
|
&default_varobj_ops,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue