aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2012-03-29 18:23:00 +0000
committerJoel Brobecker <brobecker@gnat.com>2012-03-29 18:23:00 +0000
commit4e5c77fe1ac64db7550f09c442563620fb1e7080 (patch)
treeb1332e5a2ae1680dc943c2ceb8a3f19acb85b1cf /gdb/ada-lang.c
parent1c0ac8c76635e64f933199c13d491e1b14b9363e (diff)
downloadgdb-4e5c77fe1ac64db7550f09c442563620fb1e7080.zip
gdb-4e5c77fe1ac64db7550f09c442563620fb1e7080.tar.gz
gdb-4e5c77fe1ac64db7550f09c442563620fb1e7080.tar.bz2
Make ada_lookup_encoded_symbol "return" a struct ada_symbol_info
This makes ada_lookup_encoded_symbol more consistent with other functions such as ada_lookup_symbol_list, and also makes it clearer in the code using that function that symbol and block are related. gdb/ChangeLog: * ada-lang.c (ada_lookup_encoded_symbol): Now returns void. Replace block_found argument by symbol_info. Adjust implementation accordingly. Add function documentation. (ada_lookup_symbol): Adjust to new ada_lookup_encoded_symbol. Fix documentation. * ada-lang.h (ada_lookup_encoded_symbol): Update declaration. * ada-exp.y (write_object_renaming): Adjust to new ada_lookup_encoded_symbol API.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 78a0261..146401e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5191,42 +5191,52 @@ ada_iterate_over_symbols (const struct block *block,
}
}
-struct symbol *
-ada_lookup_encoded_symbol (const char *name, const struct block *block0,
- domain_enum namespace, struct block **block_found)
+/* 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.
+
+ The result is stored in *SYMBOL_INFO, which must be non-NULL.
+ If no match is found, SYMBOL_INFO->SYM is set to NULL. */
+
+void
+ada_lookup_encoded_symbol (const char *name, const struct block *block,
+ domain_enum namespace,
+ struct ada_symbol_info *symbol_info)
{
struct ada_symbol_info *candidates;
int n_candidates;
- n_candidates = ada_lookup_symbol_list (name, block0, namespace, &candidates,
+ gdb_assert (symbol_info != NULL);
+ memset (symbol_info, 0, sizeof (struct ada_symbol_info));
+
+ n_candidates = ada_lookup_symbol_list (name, block, namespace, &candidates,
1);
if (n_candidates == 0)
- return NULL;
-
- if (block_found != NULL)
- *block_found = candidates[0].block;
+ return;
- return fixup_symbol_section (candidates[0].sym, NULL);
-}
+ *symbol_info = candidates[0];
+ symbol_info->sym = fixup_symbol_section (symbol_info->sym, NULL);
+}
/* Return a symbol in DOMAIN matching NAME, in BLOCK0 and enclosing
scope and in global scopes, or NULL if none. NAME is folded and
encoded first. Otherwise, the result is as for ada_lookup_symbol_list,
choosing the first symbol if there are multiple choices.
- *IS_A_FIELD_OF_THIS is set to 0 and *SYMTAB is set to the symbol
- table in which the symbol was found (in both cases, these
- assignments occur only if the pointers are non-null). */
+ If IS_A_FIELD_OF_THIS is not NULL, it is set to zero. */
+
struct symbol *
ada_lookup_symbol (const char *name, const struct block *block0,
domain_enum namespace, int *is_a_field_of_this)
{
+ struct ada_symbol_info symbol_info;
+
if (is_a_field_of_this != NULL)
*is_a_field_of_this = 0;
- return
- ada_lookup_encoded_symbol (ada_encode (ada_fold_name (name)),
- block0, namespace, NULL);
+ ada_lookup_encoded_symbol (ada_encode (ada_fold_name (name)),
+ block0, namespace, &symbol_info);
+ return symbol_info.sym;
}
static struct symbol *