Make ada_lookup_encoded_symbol "return" a struct ada_symbol_info
authorJoel Brobecker <brobecker@gnat.com>
Thu, 29 Mar 2012 18:23:00 +0000 (18:23 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Thu, 29 Mar 2012 18:23:00 +0000 (18:23 +0000)
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.

gdb/ChangeLog
gdb/ada-exp.y
gdb/ada-lang.c
gdb/ada-lang.h

index 981fda76070142ae3f0198f4ee6965f271e7586f..0c50bc85bfeb503ee00c4d98075c82236dd924c9 100644 (file)
@@ -1,3 +1,14 @@
+2012-03-29  Joel Brobecker  <brobecker@adacore.com>
+
+       * 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.
+
 2012-03-29  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-lang.h (struct ada_symbol_info): Reformat.  Improve
index 226cc1d8f11d22814bd486e896be87b8b52350c9..0fa1812153d02024ffeabedaf8a60f729bbeb8d4 100644 (file)
@@ -867,8 +867,7 @@ write_object_renaming (struct block *orig_left_context,
 {
   char *name;
   enum { SIMPLE_INDEX, LOWER_BOUND, UPPER_BOUND } slice_state;
-  struct symbol *sym;
-  struct block *block;
+  struct ada_symbol_info sym_info;
 
   if (max_depth <= 0)
     error (_("Could not find renamed symbol"));
@@ -877,29 +876,28 @@ write_object_renaming (struct block *orig_left_context,
     orig_left_context = get_selected_block (NULL);
 
   name = obsavestring (renamed_entity, renamed_entity_len, &temp_parse_space);
-  sym = ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, 
-                                  &block);
-  if (sym == NULL)
+  ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info);
+  if (sym_info.sym == NULL)
     error (_("Could not find renamed variable: %s"), ada_decode (name));
-  else if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+  else if (SYMBOL_CLASS (sym_info.sym) == LOC_TYPEDEF)
     /* We have a renaming of an old-style renaming symbol.  Don't
        trust the block information.  */
-    block = orig_left_context;
+    sym_info.block = orig_left_context;
 
   {
     const char *inner_renamed_entity;
     int inner_renamed_entity_len;
     const char *inner_renaming_expr;
 
-    switch (ada_parse_renaming (sym, &inner_renamed_entity, 
+    switch (ada_parse_renaming (sym_info.sym, &inner_renamed_entity,
                                &inner_renamed_entity_len,
                                &inner_renaming_expr))
       {
       case ADA_NOT_RENAMING:
-       write_var_from_sym (orig_left_context, block, sym);
+       write_var_from_sym (orig_left_context, sym_info.block, sym_info.sym);
        break;
       case ADA_OBJECT_RENAMING:
-       write_object_renaming (block,
+       write_object_renaming (sym_info.block,
                               inner_renamed_entity, inner_renamed_entity_len,
                               inner_renaming_expr, max_depth - 1);
        break;
@@ -939,7 +937,7 @@ write_object_renaming (struct block *orig_left_context,
          {
            const char *end;
            char *index_name;
-           struct symbol *index_sym;
+           struct ada_symbol_info index_sym_info;
 
            end = strchr (renaming_expr, 'X');
            if (end == NULL)
@@ -950,14 +948,15 @@ write_object_renaming (struct block *orig_left_context,
                            &temp_parse_space);
            renaming_expr = end;
 
-           index_sym = ada_lookup_encoded_symbol (index_name, NULL,
-                                                  VAR_DOMAIN, &block);
-           if (index_sym == NULL)
+           ada_lookup_encoded_symbol (index_name, NULL, VAR_DOMAIN,
+                                      &index_sym_info);
+           if (index_sym_info.sym == NULL)
              error (_("Could not find %s"), index_name);
-           else if (SYMBOL_CLASS (index_sym) == LOC_TYPEDEF)
+           else if (SYMBOL_CLASS (index_sym_info.sym) == LOC_TYPEDEF)
              /* Index is an old-style renaming symbol.  */
-             block = orig_left_context;
-           write_var_from_sym (NULL, block, index_sym);
+             index_sym_info.block = orig_left_context;
+           write_var_from_sym (NULL, index_sym_info.block,
+                               index_sym_info.sym);
          }
        if (slice_state == SIMPLE_INDEX)
          {
index 78a02617f8c1ae490efccc2f7c3386c17a225d73..146401ea4b612b45e4bf7280855194d0928bdf90 100644 (file)
@@ -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 *
index cbca3db3b39abd279da4e1c91d32ce6ba5796ec2..9a93c50dfff42fc0f1e59b038218b0935d13d043 100644 (file)
@@ -235,9 +235,9 @@ extern char *ada_fold_name (const char *);
 extern struct symbol *ada_lookup_symbol (const char *, const struct block *,
                                          domain_enum, int *);
 
-extern struct symbol *
-ada_lookup_encoded_symbol (const char *, const struct block *,
-                          domain_enum namespace, struct block **);
+extern void ada_lookup_encoded_symbol
+  (const char *name, const struct block *block, domain_enum namespace,
+   struct ada_symbol_info *symbol_info);
 
 extern struct minimal_symbol *ada_lookup_simple_minsym (const char *);
 
This page took 0.029848 seconds and 4 git commands to generate.