]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move lookup_block_symbol to block.c, rename to block_lookup_symbol.
authorDoug Evans <xdje42@gmail.com>
Fri, 7 Nov 2014 06:32:25 +0000 (22:32 -0800)
committerDoug Evans <xdje42@gmail.com>
Fri, 7 Nov 2014 06:32:25 +0000 (22:32 -0800)
There is another function, lookup_symbol_aux_block, and
the names lookup_block_symbol and lookup_symbol_aux_block don't
convey any real difference between them.

The difference is that lookup_block_symbol lives in the lower level
block API, and lookup_symbol_aux_block lives in the higher level symtab API.
This patch makes this distinction clear.

gdb/ChangeLog:

* symtab.c (lookup_block_symbol): Moved to ...
* block.c (block_lookup_symbol):  ... here and renamed.
All callers updated.
* block.h (block_lookup_symbol): Declare.
* symtab.h (lookup_block_symbol): Delete.

gdb/ChangeLog
gdb/block.c
gdb/block.h
gdb/dwarf2read.c
gdb/psymtab.c
gdb/spu-tdep.c
gdb/symtab.c
gdb/symtab.h

index 89937e25ca4c5bdfd7454e18e0eef680198d8d71..dc78a6a44ece285920125015d06a0b06d9a2429a 100644 (file)
@@ -1,3 +1,11 @@
+2014-11-06  Doug Evans  <xdje42@gmail.com>
+
+       * symtab.c (lookup_block_symbol): Moved to ...
+       * block.c (block_lookup_symbol):  ... here and renamed.
+       All callers updated.
+       * block.h (block_lookup_symbol): Declare.
+       * symtab.h (lookup_block_symbol): Delete.
+
 2014-11-06  Doug Evans  <xdje42@gmail.com>
 
        * ada-lang.c (ada_make_symbol_completion_list): Use
index 8d40c9d59319e9bc78b2a58f358d4ce443833860..3bb9de0cbaaa0139daec687d42f769e71321d7a6 100644 (file)
@@ -685,3 +685,61 @@ block_iter_match_next (const char *name,
 
   return block_iter_match_step (iterator, name, compare, 0);
 }
+
+/* See block.h.
+
+   Note that if NAME is the demangled form of a C++ symbol, we will fail
+   to find a match during the binary search of the non-encoded names, but
+   for now we don't worry about the slight inefficiency of looking for
+   a match we'll never find, since it will go pretty quick.  Once the
+   binary search terminates, we drop through and do a straight linear
+   search on the symbols.  Each symbol which is marked as being a ObjC/C++
+   symbol (language_cplus or language_objc set) has both the encoded and
+   non-encoded names tested for a match.  */
+
+struct symbol *
+block_lookup_symbol (const struct block *block, const char *name,
+                    const domain_enum domain)
+{
+  struct block_iterator iter;
+  struct symbol *sym;
+
+  if (!BLOCK_FUNCTION (block))
+    {
+      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))
+           return sym;
+       }
+      return NULL;
+    }
+  else
+    {
+      /* Note that parameter symbols do not always show up last in the
+        list; this loop makes sure to take anything else other than
+        parameter symbols first; it only uses parameter symbols as a
+        last resort.  Note that this only takes up extra computation
+        time on a match.  */
+
+      struct symbol *sym_found = NULL;
+
+      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))
+           {
+             sym_found = sym;
+             if (!SYMBOL_IS_ARGUMENT (sym))
+               {
+                 break;
+               }
+           }
+       }
+      return (sym_found);      /* Will be NULL if not found.  */
+    }
+}
index 30aaf98e88dcf3a32ab617a2cd997f7b0bc10809..e8d34528ecdb0948f1baaac36f9a028b8d96c43c 100644 (file)
@@ -271,6 +271,12 @@ extern struct symbol *block_iter_match_next (const char *name,
                                             symbol_compare_ftype *compare,
                                             struct block_iterator *iterator);
 
+/* Search BLOCK for symbol NAME in DOMAIN.  */
+
+extern struct symbol *block_lookup_symbol (const struct block *block,
+                                          const char *name,
+                                          const domain_enum domain);
+
 /* Macro to loop through all symbols in BLOCK, in no particular
    order.  ITER helps keep track of the iteration, and must be a
    struct block_iterator.  SYM points to the current symbol.  */
index 76f62b506e34567726aaac7ee52c36b104d66ebf..ce37adfe72e11594148e7c4af3290e948c944a0f 100644 (file)
@@ -3616,7 +3616,7 @@ dw2_lookup_symbol (struct objfile *objfile, int block_index,
              const struct blockvector *bv = BLOCKVECTOR (stab);
              struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
 
-             sym = lookup_block_symbol (block, name, domain);
+             sym = block_lookup_symbol (block, name, domain);
            }
 
          if (sym && strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0)
index 6c0c880a97ab6a5597bc70c802f69047c17de1ca..2514b55def2de0442d7eda9876e2450d3537c9ef 100644 (file)
@@ -519,7 +519,7 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
            const struct blockvector *bv = BLOCKVECTOR (stab);
            struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
 
-           sym = lookup_block_symbol (block, name, domain);
+           sym = block_lookup_symbol (block, name, domain);
          }
 
        if (sym && strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0)
@@ -2038,7 +2038,7 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
     length = ps->n_static_syms;
     while (length--)
       {
-       sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
+       sym = block_lookup_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
                                   SYMBOL_DOMAIN (*psym));
        if (!sym)
          {
@@ -2055,7 +2055,7 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
     length = ps->n_global_syms;
     while (length--)
       {
-       sym = lookup_block_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
+       sym = block_lookup_symbol (b, SYMBOL_LINKAGE_NAME (*psym),
                                   SYMBOL_DOMAIN (*psym));
        if (!sym)
          {
index 032f5de4618c3d7d9bab5eaa7e5e1eac6b9aa36e..30e569f2e123b244e6f58912247e5fc2d16250e2 100644 (file)
@@ -1987,7 +1987,7 @@ spu_catch_start (struct objfile *objfile)
       struct symbol *sym;
       struct symtab_and_line sal;
 
-      sym = lookup_block_symbol (block, "main", VAR_DOMAIN);
+      sym = block_lookup_symbol (block, "main", VAR_DOMAIN);
       if (sym)
        {
          fixup_symbol_section (sym, objfile);
index e9f37bc6c3dbcf7758ff56443b722d2a733e3bf7..482a23dde68d7cadb707843216b7c440b32cccc9 100644 (file)
@@ -1344,7 +1344,7 @@ lookup_language_this (const struct language_defn *lang,
     {
       struct symbol *sym;
 
-      sym = lookup_block_symbol (block, lang->la_name_of_this, VAR_DOMAIN);
+      sym = block_lookup_symbol (block, lang->la_name_of_this, VAR_DOMAIN);
       if (sym != NULL)
        {
          block_found = block;
@@ -1572,7 +1572,7 @@ lookup_symbol_aux_block (const char *name, const struct block *block,
 {
   struct symbol *sym;
 
-  sym = lookup_block_symbol (block, name, domain);
+  sym = block_lookup_symbol (block, name, domain);
   if (sym)
     {
       block_found = block;
@@ -1604,7 +1604,7 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile,
        {
          bv = BLOCKVECTOR (s);
          block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-         sym = lookup_block_symbol (block, name, domain);
+         sym = block_lookup_symbol (block, name, domain);
          if (sym)
            {
              block_found = block;
@@ -1639,7 +1639,7 @@ lookup_symbol_aux_objfile (struct objfile *objfile, int block_index,
     {
       bv = BLOCKVECTOR (s);
       block = BLOCKVECTOR_BLOCK (bv, block_index);
-      sym = lookup_block_symbol (block, name, domain);
+      sym = block_lookup_symbol (block, name, domain);
       if (sym)
        {
          block_found = block;
@@ -1747,7 +1747,7 @@ lookup_symbol_aux_quick (struct objfile *objfile, int block_index,
 
   bv = BLOCKVECTOR (symtab);
   block = BLOCKVECTOR_BLOCK (bv, block_index);
-  sym = lookup_block_symbol (block, name, domain);
+  sym = block_lookup_symbol (block, name, domain);
   if (!sym)
     error_in_psymtab_expansion (block_index, name, symtab);
   block_found = block;
@@ -1931,7 +1931,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, int block_index,
 
   bv = BLOCKVECTOR (symtab);
   block = BLOCKVECTOR_BLOCK (bv, block_index);
-  sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+  sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
   if (!sym)
     error_in_psymtab_expansion (block_index, name, symtab);
 
@@ -1968,7 +1968,7 @@ basic_lookup_transparent_type (const char *name)
       {
        bv = BLOCKVECTOR (s);
        block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-       sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+       sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
        if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
          {
            return SYMBOL_TYPE (sym);
@@ -1996,7 +1996,7 @@ basic_lookup_transparent_type (const char *name)
       {
        bv = BLOCKVECTOR (s);
        block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
-       sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+       sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
        if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
          {
            return SYMBOL_TYPE (sym);
@@ -2014,64 +2014,6 @@ basic_lookup_transparent_type (const char *name)
   return (struct type *) 0;
 }
 
-/* See symtab.h.
-
-   Note that if NAME is the demangled form of a C++ symbol, we will fail
-   to find a match during the binary search of the non-encoded names, but
-   for now we don't worry about the slight inefficiency of looking for
-   a match we'll never find, since it will go pretty quick.  Once the
-   binary search terminates, we drop through and do a straight linear
-   search on the symbols.  Each symbol which is marked as being a ObjC/C++
-   symbol (language_cplus or language_objc set) has both the encoded and
-   non-encoded names tested for a match.  */
-
-struct symbol *
-lookup_block_symbol (const struct block *block, const char *name,
-                    const domain_enum domain)
-{
-  struct block_iterator iter;
-  struct symbol *sym;
-
-  if (!BLOCK_FUNCTION (block))
-    {
-      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))
-           return sym;
-       }
-      return NULL;
-    }
-  else
-    {
-      /* Note that parameter symbols do not always show up last in the
-        list; this loop makes sure to take anything else other than
-        parameter symbols first; it only uses parameter symbols as a
-        last resort.  Note that this only takes up extra computation
-        time on a match.  */
-
-      struct symbol *sym_found = NULL;
-
-      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))
-           {
-             sym_found = sym;
-             if (!SYMBOL_IS_ARGUMENT (sym))
-               {
-                 break;
-               }
-           }
-       }
-      return (sym_found);      /* Will be NULL if not found.  */
-    }
-}
-
 /* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK.
    
    For each symbol that matches, CALLBACK is called.  The symbol and
index 73108f02015df4e03938fa47f2a4a1ecb1044d32..7fa42a68e862e84413ff8253f341dbe84e6752bf 100644 (file)
@@ -1125,11 +1125,6 @@ extern struct symbol *lookup_language_this (const struct language_defn *lang,
 extern struct symbol *lookup_static_symbol_aux (const char *name,
                                                const domain_enum domain);
 
-/* Search BLOCK for symbol NAME in DOMAIN.  */
-
-extern struct symbol *lookup_block_symbol (const struct block *, const char *,
-                                          const domain_enum);
-
 /* Lookup a [struct, union, enum] by name, within a specified block.  */
 
 extern struct type *lookup_struct (const char *, const struct block *);