aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-06-03 12:52:54 -0600
committerTom Tromey <tromey@adacore.com>2024-06-14 11:18:22 -0600
commit3739147957a5bb37352033bec9ca21b88f98c7e9 (patch)
tree175f0a8c581586b272ffd1ab2741e7bd34b791e2 /gdb
parent9c23c0df0dc47560bf3e253186e0192bc9630c80 (diff)
downloadgdb-3739147957a5bb37352033bec9ca21b88f98c7e9.zip
gdb-3739147957a5bb37352033bec9ca21b88f98c7e9.tar.gz
gdb-3739147957a5bb37352033bec9ca21b88f98c7e9.tar.bz2
Simplify ada_lookup_encoded_symbol
This patch simplifies ada_lookup_encoded_symbol by having it return its result, rather than returning void and having an out parameter.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ada-exp.y10
-rw-r--r--gdb/ada-lang.c16
-rw-r--r--gdb/ada-lang.h5
3 files changed, 12 insertions, 19 deletions
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index f3cef6d..c2ab1de 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1322,7 +1322,6 @@ write_object_renaming (struct parser_state *par_state,
{
char *name;
enum { SIMPLE_INDEX, LOWER_BOUND, UPPER_BOUND } slice_state;
- struct block_symbol sym_info;
if (max_depth <= 0)
error (_("Could not find renamed symbol"));
@@ -1332,7 +1331,8 @@ write_object_renaming (struct parser_state *par_state,
name = obstack_strndup (&ada_parser->temp_space, renamed_entity,
renamed_entity_len);
- ada_lookup_encoded_symbol (name, orig_left_context, SEARCH_VFT, &sym_info);
+ block_symbol sym_info = ada_lookup_encoded_symbol (name, orig_left_context,
+ SEARCH_VFT);
if (sym_info.symbol == NULL)
error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ());
else if (sym_info.symbol->aclass () == LOC_TYPEDEF)
@@ -1390,7 +1390,6 @@ write_object_renaming (struct parser_state *par_state,
{
const char *end;
char *index_name;
- struct block_symbol index_sym_info;
end = strchr (renaming_expr, 'X');
if (end == NULL)
@@ -1401,8 +1400,9 @@ write_object_renaming (struct parser_state *par_state,
end - renaming_expr);
renaming_expr = end;
- ada_lookup_encoded_symbol (index_name, orig_left_context,
- SEARCH_VFT, &index_sym_info);
+ block_symbol index_sym_info
+ = ada_lookup_encoded_symbol (index_name, orig_left_context,
+ SEARCH_VFT);
if (index_sym_info.symbol == NULL)
error (_("Could not find %s"), index_name);
else if (index_sym_info.symbol->aclass () == LOC_TYPEDEF)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 01978e0..46c2057 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4792,7 +4792,7 @@ standard_lookup (const char *name, const struct block *block,
if (lookup_cached_symbol (name, domain, &sym.symbol, NULL))
return sym.symbol;
- ada_lookup_encoded_symbol (name, block, domain, &sym);
+ sym = ada_lookup_encoded_symbol (name, block, domain);
cache_symbol (name, domain, sym.symbol, sym.block);
return sym.symbol;
}
@@ -5703,15 +5703,11 @@ ada_lookup_symbol_list (const char *name, const struct block *block,
/* 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.
+ choices. */
- The result is stored in *INFO, which must be non-NULL.
- If no match is found, INFO->SYM is set to NULL. */
-
-void
+block_symbol
ada_lookup_encoded_symbol (const char *name, const struct block *block,
- domain_search_flags domain,
- struct block_symbol *info)
+ domain_search_flags domain)
{
/* Since we already have an encoded name, wrap it in '<>' to force a
verbatim match. Otherwise, if the name happens to not look like
@@ -5720,9 +5716,7 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block,
would e.g., incorrectly lowercase object renaming names like
"R28b" -> "r28b". */
std::string verbatim = add_angle_brackets (name);
-
- gdb_assert (info != NULL);
- *info = ada_lookup_symbol (verbatim.c_str (), block, domain);
+ return ada_lookup_symbol (verbatim.c_str (), block, domain);
}
/* Return a symbol in DOMAIN matching NAME, in BLOCK0 and enclosing
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 5083d00..d14bfd4 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -236,9 +236,8 @@ extern struct block_symbol ada_lookup_symbol (const char *,
const struct block *,
domain_search_flags);
-extern void ada_lookup_encoded_symbol
- (const char *name, const struct block *block, domain_search_flags domain,
- struct block_symbol *symbol_info);
+extern block_symbol ada_lookup_encoded_symbol
+ (const char *name, const struct block *block, domain_search_flags domain);
extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *,
objfile *);