* ada-lang.c (ada_lookup_symbol_list_worker): New function, contents
of old ada_lookup_symbol_list. In !full_search case, don't search superblocks. (ada_lookup_symbol_list): Delete arg full_search, all callers updated. Call ada_lookup_symbol_list_worker. (ada_iterate_over_symbols): Call ada_lookup_symbol_list_worker. * ada-lang.h (ada_lookup_symbol_list): Update. * language.h (language_defn): Update comment for la_iterate_over_symbols. * linespec.c (iterate_over_file_blocks): New function. (iterate_over_all_matching_symtabs): Call it. (lookup_prefix_sym): Ditto. (get_current_search_block): New function. (get_search_block): Delete. (find_label_symbols): Call get_current_search_block. (add_matching_symbols_to_info): Call iterate_over_file_blocks. * symtab.c (iterate_over_symbols): Don't search superblocks.
This commit is contained in:
parent
62b0d0d5f3
commit
4eeaa230f4
@ -1,3 +1,23 @@
|
||||
2013-03-05 Doug Evans <dje@google.com>
|
||||
|
||||
* ada-lang.c (ada_lookup_symbol_list_worker): New function, contents
|
||||
of old ada_lookup_symbol_list. In !full_search case, don't
|
||||
search superblocks.
|
||||
(ada_lookup_symbol_list): Delete arg full_search, all callers
|
||||
updated. Call ada_lookup_symbol_list_worker.
|
||||
(ada_iterate_over_symbols): Call ada_lookup_symbol_list_worker.
|
||||
* ada-lang.h (ada_lookup_symbol_list): Update.
|
||||
* language.h (language_defn): Update comment for
|
||||
la_iterate_over_symbols.
|
||||
* linespec.c (iterate_over_file_blocks): New function.
|
||||
(iterate_over_all_matching_symtabs): Call it.
|
||||
(lookup_prefix_sym): Ditto.
|
||||
(get_current_search_block): New function.
|
||||
(get_search_block): Delete.
|
||||
(find_label_symbols): Call get_current_search_block.
|
||||
(add_matching_symbols_to_info): Call iterate_over_file_blocks.
|
||||
* symtab.c (iterate_over_symbols): Don't search superblocks.
|
||||
|
||||
2013-03-05 Yao Qi <yao@codesourcery.com>
|
||||
|
||||
* cli/cli-decode.c (add_setshow_zuinteger_unlimited_cmd): Change
|
||||
|
@ -1025,7 +1025,7 @@ block_lookup (struct block *context, char *raw_name)
|
||||
else
|
||||
name = ada_encode (raw_name);
|
||||
|
||||
nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms, 1);
|
||||
nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
|
||||
if (context == NULL
|
||||
&& (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK))
|
||||
symtab = lookup_symtab (name);
|
||||
@ -1282,7 +1282,7 @@ write_var_or_type (const struct block *block, struct stoken name0)
|
||||
|
||||
encoded_name[tail_index] = '\0';
|
||||
nsyms = ada_lookup_symbol_list (encoded_name, block,
|
||||
VAR_DOMAIN, &syms, 1);
|
||||
VAR_DOMAIN, &syms);
|
||||
encoded_name[tail_index] = terminator;
|
||||
|
||||
/* A single symbol may rename a package or object. */
|
||||
@ -1430,7 +1430,7 @@ write_name_assoc (struct stoken name)
|
||||
{
|
||||
struct ada_symbol_info *syms;
|
||||
int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block,
|
||||
VAR_DOMAIN, &syms, 1);
|
||||
VAR_DOMAIN, &syms);
|
||||
if (nsyms != 1 || SYMBOL_CLASS (syms[0].sym) == LOC_TYPEDEF)
|
||||
write_exp_op_with_string (OP_NAME, name);
|
||||
else
|
||||
|
113
gdb/ada-lang.c
113
gdb/ada-lang.c
@ -3110,7 +3110,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
||||
ada_lookup_symbol_list (SYMBOL_LINKAGE_NAME
|
||||
(exp->elts[pc + 2].symbol),
|
||||
exp->elts[pc + 1].block, VAR_DOMAIN,
|
||||
&candidates, 1);
|
||||
&candidates);
|
||||
|
||||
if (n_candidates > 1)
|
||||
{
|
||||
@ -3202,7 +3202,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
||||
ada_lookup_symbol_list (SYMBOL_LINKAGE_NAME
|
||||
(exp->elts[pc + 5].symbol),
|
||||
exp->elts[pc + 4].block, VAR_DOMAIN,
|
||||
&candidates, 1);
|
||||
&candidates);
|
||||
if (n_candidates == 1)
|
||||
i = 0;
|
||||
else
|
||||
@ -3254,7 +3254,7 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
|
||||
n_candidates =
|
||||
ada_lookup_symbol_list (ada_encode (ada_decoded_op_name (op)),
|
||||
(struct block *) NULL, VAR_DOMAIN,
|
||||
&candidates, 1);
|
||||
&candidates);
|
||||
i = ada_resolve_function (candidates, n_candidates, argvec, nargs,
|
||||
ada_decoded_op_name (op), NULL);
|
||||
if (i < 0)
|
||||
@ -5052,26 +5052,28 @@ add_nonlocal_symbols (struct obstack *obstackp, const char *name,
|
||||
}
|
||||
}
|
||||
|
||||
/* Find symbols in DOMAIN matching NAME0, in BLOCK0 and enclosing
|
||||
scope and in global scopes, returning the number of matches.
|
||||
/* Find symbols in DOMAIN matching NAME0, in BLOCK0 and, if full_search is
|
||||
non-zero, enclosing scope and in global scopes, returning the number of
|
||||
matches.
|
||||
Sets *RESULTS to point to a vector of (SYM,BLOCK) tuples,
|
||||
indicating the symbols found and the blocks and symbol tables (if
|
||||
any) in which they were found. This vector are transient---good only to
|
||||
the next call of ada_lookup_symbol_list. Any non-function/non-enumeral
|
||||
any) in which they were found. This vector is transient---good only to
|
||||
the next call of ada_lookup_symbol_list.
|
||||
|
||||
When full_search is non-zero, any non-function/non-enumeral
|
||||
symbol match within the nest of blocks whose innermost member is BLOCK0,
|
||||
is the one match returned (no other matches in that or
|
||||
enclosing blocks is returned). If there are any matches in or
|
||||
surrounding BLOCK0, then these alone are returned. Otherwise, if
|
||||
FULL_SEARCH is non-zero, then the search extends to global and
|
||||
file-scope (static) symbol tables.
|
||||
surrounding BLOCK0, then these alone are returned.
|
||||
|
||||
Names prefixed with "standard__" are handled specially: "standard__"
|
||||
is first stripped off, and only static and global symbols are searched. */
|
||||
|
||||
int
|
||||
ada_lookup_symbol_list (const char *name0, const struct block *block0,
|
||||
domain_enum namespace,
|
||||
struct ada_symbol_info **results,
|
||||
int full_search)
|
||||
static int
|
||||
ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
|
||||
domain_enum namespace,
|
||||
struct ada_symbol_info **results,
|
||||
int full_search)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct block *block;
|
||||
@ -5107,10 +5109,24 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
|
||||
|
||||
/* Check the non-global symbols. If we have ANY match, then we're done. */
|
||||
|
||||
ada_add_local_symbols (&symbol_list_obstack, name, block, namespace,
|
||||
wild_match_p);
|
||||
if (num_defns_collected (&symbol_list_obstack) > 0 || !full_search)
|
||||
goto done;
|
||||
if (block != NULL)
|
||||
{
|
||||
if (full_search)
|
||||
{
|
||||
ada_add_local_symbols (&symbol_list_obstack, name, block,
|
||||
namespace, wild_match_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In the !full_search case we're are being called by
|
||||
ada_iterate_over_symbols, and we don't want to search
|
||||
superblocks. */
|
||||
ada_add_block_symbols (&symbol_list_obstack, block, name,
|
||||
namespace, NULL, wild_match_p);
|
||||
}
|
||||
if (num_defns_collected (&symbol_list_obstack) > 0 || !full_search)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* No non-global symbols found. Check our cache to see if we have
|
||||
already performed this search before. If we have, then return
|
||||
@ -5153,6 +5169,37 @@ done:
|
||||
return ndefns;
|
||||
}
|
||||
|
||||
/* Find symbols in DOMAIN matching NAME0, in BLOCK0 and enclosing scope and
|
||||
in global scopes, returning the number of matches, and setting *RESULTS
|
||||
to a vector of (SYM,BLOCK) tuples.
|
||||
See ada_lookup_symbol_list_worker for further details. */
|
||||
|
||||
int
|
||||
ada_lookup_symbol_list (const char *name0, const struct block *block0,
|
||||
domain_enum domain, struct ada_symbol_info **results)
|
||||
{
|
||||
return ada_lookup_symbol_list_worker (name0, block0, domain, results, 1);
|
||||
}
|
||||
|
||||
/* Implementation of the la_iterate_over_symbols method. */
|
||||
|
||||
static void
|
||||
ada_iterate_over_symbols (const struct block *block,
|
||||
const char *name, domain_enum domain,
|
||||
symbol_found_callback_ftype *callback,
|
||||
void *data)
|
||||
{
|
||||
int ndefs, i;
|
||||
struct ada_symbol_info *results;
|
||||
|
||||
ndefs = ada_lookup_symbol_list_worker (name, block, domain, &results, 0);
|
||||
for (i = 0; i < ndefs; ++i)
|
||||
{
|
||||
if (! (*callback) (results[i].sym, data))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If NAME is the name of an entity, return a string that should
|
||||
be used to look that entity up in Ada units. This string should
|
||||
be deallocated after use using xfree.
|
||||
@ -5178,25 +5225,6 @@ ada_name_for_lookup (const char *name)
|
||||
return canon;
|
||||
}
|
||||
|
||||
/* Implementation of the la_iterate_over_symbols method. */
|
||||
|
||||
static void
|
||||
ada_iterate_over_symbols (const struct block *block,
|
||||
const char *name, domain_enum domain,
|
||||
symbol_found_callback_ftype *callback,
|
||||
void *data)
|
||||
{
|
||||
int ndefs, i;
|
||||
struct ada_symbol_info *results;
|
||||
|
||||
ndefs = ada_lookup_symbol_list (name, block, domain, &results, 0);
|
||||
for (i = 0; i < ndefs; ++i)
|
||||
{
|
||||
if (! (*callback) (results[i].sym, data))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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
|
||||
choices.
|
||||
@ -5215,9 +5243,7 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block,
|
||||
gdb_assert (info != NULL);
|
||||
memset (info, 0, sizeof (struct ada_symbol_info));
|
||||
|
||||
n_candidates = ada_lookup_symbol_list (name, block, namespace, &candidates,
|
||||
1);
|
||||
|
||||
n_candidates = ada_lookup_symbol_list (name, block, namespace, &candidates);
|
||||
if (n_candidates == 0)
|
||||
return;
|
||||
|
||||
@ -5509,8 +5535,7 @@ full_match (const char *sym_name, const char *search_name)
|
||||
/* Add symbols from BLOCK matching identifier NAME in DOMAIN to
|
||||
vector *defn_symbols, updating the list of symbols in OBSTACKP
|
||||
(if necessary). If WILD, treat as NAME with a wildcard prefix.
|
||||
OBJFILE is the section containing BLOCK.
|
||||
SYMTAB is recorded with each symbol added. */
|
||||
OBJFILE is the section containing BLOCK. */
|
||||
|
||||
static void
|
||||
ada_add_block_symbols (struct obstack *obstackp,
|
||||
@ -10692,7 +10717,7 @@ get_var_value (char *name, char *err_msg)
|
||||
int nsyms;
|
||||
|
||||
nsyms = ada_lookup_symbol_list (name, get_selected_block (0), VAR_DOMAIN,
|
||||
&syms, 1);
|
||||
&syms);
|
||||
|
||||
if (nsyms != 1)
|
||||
{
|
||||
|
@ -228,8 +228,7 @@ extern enum language ada_update_initial_language (enum language);
|
||||
extern void clear_ada_sym_cache (void);
|
||||
|
||||
extern int ada_lookup_symbol_list (const char *, const struct block *,
|
||||
domain_enum, struct ada_symbol_info**,
|
||||
int);
|
||||
domain_enum, struct ada_symbol_info**);
|
||||
|
||||
extern char *ada_fold_name (const char *);
|
||||
|
||||
|
@ -326,9 +326,9 @@ struct language_defn
|
||||
/* Find all symbols in the current program space matching NAME in
|
||||
DOMAIN, according to this language's rules.
|
||||
|
||||
The search starts with BLOCK. This function iterates upward
|
||||
through blocks. When the outermost block has been finished,
|
||||
the function returns.
|
||||
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 and the DATA
|
||||
argument. If CALLBACK returns zero, the iteration ends at that
|
||||
|
@ -318,6 +318,11 @@ typedef struct ls_parser linespec_parser;
|
||||
|
||||
/* Prototypes for local functions. */
|
||||
|
||||
static void iterate_over_file_blocks (struct symtab *symtab,
|
||||
const char *name, domain_enum domain,
|
||||
symbol_found_callback_ftype *callback,
|
||||
void *data);
|
||||
|
||||
static void initialize_defaults (struct symtab **default_symtab,
|
||||
int *default_line);
|
||||
|
||||
@ -1039,15 +1044,12 @@ iterate_over_all_matching_symtabs (struct linespec_state *state,
|
||||
|
||||
ALL_OBJFILE_PRIMARY_SYMTABS (objfile, symtab)
|
||||
{
|
||||
struct block *block;
|
||||
|
||||
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
|
||||
state->language->la_iterate_over_symbols (block, name, domain,
|
||||
callback, data);
|
||||
iterate_over_file_blocks (symtab, name, domain, callback, data);
|
||||
|
||||
if (include_inline)
|
||||
{
|
||||
struct symbol_and_data_callback cad = { callback, data };
|
||||
struct block *block;
|
||||
int i;
|
||||
|
||||
for (i = FIRST_LOCAL_BLOCK;
|
||||
@ -1063,28 +1065,37 @@ iterate_over_all_matching_symtabs (struct linespec_state *state,
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the block to be used for symbol searches for the given SYMTAB,
|
||||
which may be NULL. */
|
||||
/* Returns the block to be used for symbol searches from
|
||||
the current location. */
|
||||
|
||||
static struct block *
|
||||
get_search_block (struct symtab *symtab)
|
||||
get_current_search_block ()
|
||||
{
|
||||
struct block *block;
|
||||
enum language save_language;
|
||||
|
||||
/* get_selected_block can change the current language when there is
|
||||
no selected frame yet. */
|
||||
save_language = current_language->la_language;
|
||||
block = get_selected_block (0);
|
||||
set_language (save_language);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
/* Iterate over static and global blocks. */
|
||||
|
||||
static void
|
||||
iterate_over_file_blocks (struct symtab *symtab,
|
||||
const char *name, domain_enum domain,
|
||||
symbol_found_callback_ftype *callback, void *data)
|
||||
{
|
||||
struct block *block;
|
||||
|
||||
if (symtab != NULL)
|
||||
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
|
||||
else
|
||||
{
|
||||
enum language save_language;
|
||||
|
||||
/* get_selected_block can change the current language when there is
|
||||
no selected frame yet. */
|
||||
save_language = current_language->la_language;
|
||||
block = get_selected_block (0);
|
||||
set_language (save_language);
|
||||
}
|
||||
|
||||
return block;
|
||||
for (block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
|
||||
block != NULL;
|
||||
block = BLOCK_SUPERBLOCK (block))
|
||||
LA_ITERATE_OVER_SYMBOLS (block, name, domain, callback, data);
|
||||
}
|
||||
|
||||
/* A helper for find_method. This finds all methods in type T which
|
||||
@ -2711,17 +2722,14 @@ lookup_prefix_sym (struct linespec_state *state, VEC (symtab_p) *file_symtabs,
|
||||
}
|
||||
else
|
||||
{
|
||||
struct block *search_block;
|
||||
|
||||
/* Program spaces that are executing startup should have
|
||||
been filtered out earlier. */
|
||||
gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
|
||||
set_current_program_space (SYMTAB_PSPACE (elt));
|
||||
search_block = get_search_block (elt);
|
||||
LA_ITERATE_OVER_SYMBOLS (search_block, class_name, STRUCT_DOMAIN,
|
||||
collect_one_symbol, &collector);
|
||||
LA_ITERATE_OVER_SYMBOLS (search_block, class_name, VAR_DOMAIN,
|
||||
collect_one_symbol, &collector);
|
||||
iterate_over_file_blocks (elt, class_name, STRUCT_DOMAIN,
|
||||
collect_one_symbol, &collector);
|
||||
iterate_over_file_blocks (elt, class_name, VAR_DOMAIN,
|
||||
collect_one_symbol, &collector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3176,7 +3184,7 @@ find_label_symbols (struct linespec_state *self,
|
||||
if (function_symbols == NULL)
|
||||
{
|
||||
set_current_program_space (self->program_space);
|
||||
block = get_search_block (NULL);
|
||||
block = get_current_search_block ();
|
||||
|
||||
for (;
|
||||
block && !BLOCK_FUNCTION (block);
|
||||
@ -3580,9 +3588,8 @@ add_matching_symbols_to_info (const char *name,
|
||||
been filtered out earlier. */
|
||||
gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
|
||||
set_current_program_space (SYMTAB_PSPACE (elt));
|
||||
LA_ITERATE_OVER_SYMBOLS (get_search_block (elt), name,
|
||||
VAR_DOMAIN, collect_symbols,
|
||||
info);
|
||||
iterate_over_file_blocks (elt, name, VAR_DOMAIN,
|
||||
collect_symbols, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
gdb/symtab.c
32
gdb/symtab.c
@ -2023,16 +2023,13 @@ lookup_block_symbol (const struct block *block, const char *name,
|
||||
}
|
||||
}
|
||||
|
||||
/* Iterate over the symbols named NAME, matching DOMAIN, starting with
|
||||
BLOCK.
|
||||
/* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK.
|
||||
|
||||
For each symbol that matches, CALLBACK is called. The symbol and
|
||||
DATA are passed to the callback.
|
||||
|
||||
If CALLBACK returns zero, the iteration ends. Otherwise, the
|
||||
search continues. This function iterates upward through blocks.
|
||||
When the outermost block has been finished, the function
|
||||
returns. */
|
||||
search continues. */
|
||||
|
||||
void
|
||||
iterate_over_symbols (const struct block *block, const char *name,
|
||||
@ -2040,24 +2037,19 @@ iterate_over_symbols (const struct block *block, const char *name,
|
||||
symbol_found_callback_ftype *callback,
|
||||
void *data)
|
||||
{
|
||||
while (block)
|
||||
struct block_iterator iter;
|
||||
struct symbol *sym;
|
||||
|
||||
for (sym = block_iter_name_first (block, name, &iter);
|
||||
sym != NULL;
|
||||
sym = block_iter_name_next (name, &iter))
|
||||
{
|
||||
struct block_iterator iter;
|
||||
struct symbol *sym;
|
||||
|
||||
for (sym = block_iter_name_first (block, name, &iter);
|
||||
sym != NULL;
|
||||
sym = block_iter_name_next (name, &iter))
|
||||
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
|
||||
SYMBOL_DOMAIN (sym), domain))
|
||||
{
|
||||
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
|
||||
SYMBOL_DOMAIN (sym), domain))
|
||||
{
|
||||
if (!callback (sym, data))
|
||||
return;
|
||||
}
|
||||
if (!callback (sym, data))
|
||||
return;
|
||||
}
|
||||
|
||||
block = BLOCK_SUPERBLOCK (block);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user