[+noconst,2/2] Unify lookup_symbol_in_objfile_symtabs

Message ID 20141203170714.GE25020@host2.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil Dec. 3, 2014, 5:07 p.m. UTC
  2014-12-03  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* symtab.c (lookup_symbol_in_objfile_symtabs): New declaration.
	(lookup_global_symbol_from_objfile): Call it.
  

Comments

Doug Evans Dec. 5, 2014, 6:04 p.m. UTC | #1
Jan Kratochvil <jan.kratochvil@redhat.com> writes:

> 2014-12-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
> 	* symtab.c (lookup_symbol_in_objfile_symtabs): New declaration.
> 	(lookup_global_symbol_from_objfile): Call it.
>
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 6d50ebe..213bd4e 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -79,6 +79,11 @@ struct symbol *lookup_local_symbol (const char *name,
>  				    const domain_enum domain,
>  				    enum language language);
>  
> +static struct symbol *
> +  lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
> +				    int block_index, const char *name,
> +				    const domain_enum domain);
> +
>  static
>  struct symbol *lookup_symbol_via_quick_fns (struct objfile *objfile,
>  					    int block_index,
> @@ -1546,24 +1551,12 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
>         objfile;
>         objfile = objfile_separate_debug_iterate (main_objfile, objfile))
>      {
> -      struct compunit_symtab *cust;
>        struct symbol *sym;
> -
> -      /* Go through symtabs.  */
> -      ALL_OBJFILE_COMPUNITS (objfile, cust)
> -	{
> -	  const struct blockvector *bv;
> -	  const struct block *block;
> -
> -	  bv = COMPUNIT_BLOCKVECTOR (cust);
> -	  block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
> -	  sym = block_lookup_symbol (block, name, domain);
> -	  if (sym)
> -	    {
> -	      block_found = block;
> -	      return fixup_symbol_section (sym, objfile);
> -	    }
> -	}
> +      
> +      sym = lookup_symbol_in_objfile_symtabs (objfile, GLOBAL_BLOCK, name,
> +					      domain);
> +      if (sym != NULL)
> +	return sym;
>  
>        sym = lookup_symbol_via_quick_fns (objfile, GLOBAL_BLOCK, name, domain);
>        if (sym)

Heh, I meant this version. :-)
[no-const]
  
Jan Kratochvil Dec. 5, 2014, 6:40 p.m. UTC | #2
On Fri, 05 Dec 2014 19:04:10 +0100, Doug Evans wrote:
> Heh, I meant this version. :-)
> [no-const]

Checked in:
	6c1c7be347154e17a8cf723395bb616d4f3258ed


Thanks,
Jan
  

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6d50ebe..213bd4e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -79,6 +79,11 @@  struct symbol *lookup_local_symbol (const char *name,
 				    const domain_enum domain,
 				    enum language language);
 
+static struct symbol *
+  lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
+				    int block_index, const char *name,
+				    const domain_enum domain);
+
 static
 struct symbol *lookup_symbol_via_quick_fns (struct objfile *objfile,
 					    int block_index,
@@ -1546,24 +1551,12 @@  lookup_global_symbol_from_objfile (struct objfile *main_objfile,
        objfile;
        objfile = objfile_separate_debug_iterate (main_objfile, objfile))
     {
-      struct compunit_symtab *cust;
       struct symbol *sym;
-
-      /* Go through symtabs.  */
-      ALL_OBJFILE_COMPUNITS (objfile, cust)
-	{
-	  const struct blockvector *bv;
-	  const struct block *block;
-
-	  bv = COMPUNIT_BLOCKVECTOR (cust);
-	  block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-	  sym = block_lookup_symbol (block, name, domain);
-	  if (sym)
-	    {
-	      block_found = block;
-	      return fixup_symbol_section (sym, objfile);
-	    }
-	}
+      
+      sym = lookup_symbol_in_objfile_symtabs (objfile, GLOBAL_BLOCK, name,
+					      domain);
+      if (sym != NULL)
+	return sym;
 
       sym = lookup_symbol_via_quick_fns (objfile, GLOBAL_BLOCK, name, domain);
       if (sym)