This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] delete BLOCK_SHOULD_SORT


Here's the patch to delete BLOCK_SHOULD_SORT; Elena has approved this
and requested that I commit it separately from the dictionary stuff,
so I'm doing so.  Tested on GCC 3.1, DWARF 2, i686-pc-linux-gnu; no
new regressions.

David Carlton
carlton@bactrian.org

2003-06-11  David Carlton  <carlton@bactrian.org>

	* block.h (BLOCK_SHOULD_SORT): Delete.
	* symtab.c (lookup_block_symbol): Don't worry about sorted linear
	blocks.
	* ada-lang.c (ada_add_block_symbols): Ditto.
	* symfile.c (sort_block_syms): Delete.
	(sort_symtab_syms): Ditto.
	* symfile.h: Delete sort_symtabs_syms and sort_block_syms
	declarations.
	* coffread.c (coff_symfile_read): Don't call sort_symtab_syms.
	* dbxread.c (dbx_psymtab_to_symtab_1): Ditto.
	* dwarf2read.c (psymtab_to_symtab_1): Ditto.
	* dwarfread.c (psymtab_to_symtab_1): Ditto.
	* hpread.c (hpread_psymtab_to_symtab_1): Ditto.
	* mdebugread.c (psymtab_to_symtab_1): Ditto.
	* xcoffread.c (xcoff_psymtab_to_symtab_1): Ditto.

Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.27
diff -u -p -r1.27 ada-lang.c
--- ada-lang.c	2 Jun 2003 18:08:15 -0000	1.27
+++ ada-lang.c	11 Jun 2003 22:16:45 -0000
@@ -3953,7 +3953,6 @@ ada_add_block_symbols (struct block *blo
   struct symbol *arg_sym;
   /* Set true when we find a matching non-argument symbol */
   int found_sym;
-  int is_sorted = BLOCK_SHOULD_SORT (block);
   struct symbol *sym;
 
   arg_sym = NULL;
@@ -3990,45 +3989,14 @@ ada_add_block_symbols (struct block *blo
     }
   else
     {
-      if (is_sorted)
-	{
-	  int U;
-	  i = 0;
-	  U = BLOCK_NSYMS (block) - 1;
-	  while (U - i > 4)
-	    {
-	      int M = (U + i) >> 1;
-	      struct symbol *sym = BLOCK_SYM (block, M);
-	      if (DEPRECATED_SYMBOL_NAME (sym)[0] < name[0])
-		i = M + 1;
-	      else if (DEPRECATED_SYMBOL_NAME (sym)[0] > name[0])
-		U = M - 1;
-	      else if (strcmp (DEPRECATED_SYMBOL_NAME (sym), name) < 0)
-		i = M + 1;
-	      else
-		U = M;
-	    }
-	}
-      else
-	i = 0;
-
-      for (; i < BLOCK_BUCKETS (block); i += 1)
-	for (sym = BLOCK_BUCKET (block, i); sym != NULL; sym = sym->hash_next)
+      ALL_BLOCK_SYMBOLS (block, i, sym)
 	  {
 	    if (SYMBOL_DOMAIN (sym) == domain)
 	      {
 		int cmp = strncmp (name, DEPRECATED_SYMBOL_NAME (sym), name_len);
 
-		if (cmp < 0)
-		  {
-		    if (is_sorted)
-		      {
-			i = BLOCK_BUCKETS (block);
-			break;
-		      }
-		  }
-		else if (cmp == 0
-			 && is_name_suffix (DEPRECATED_SYMBOL_NAME (sym) + name_len))
+		if (cmp == 0
+		    && is_name_suffix (DEPRECATED_SYMBOL_NAME (sym) + name_len))
 		  {
 		    switch (SYMBOL_CLASS (sym))
 		      {
@@ -4065,30 +4033,8 @@ ada_add_block_symbols (struct block *blo
     {
       arg_sym = NULL;
       found_sym = 0;
-      if (is_sorted)
-	{
-	  int U;
-	  i = 0;
-	  U = BLOCK_NSYMS (block) - 1;
-	  while (U - i > 4)
-	    {
-	      int M = (U + i) >> 1;
-	      struct symbol *sym = BLOCK_SYM (block, M);
-	      if (DEPRECATED_SYMBOL_NAME (sym)[0] < '_')
-		i = M + 1;
-	      else if (DEPRECATED_SYMBOL_NAME (sym)[0] > '_')
-		U = M - 1;
-	      else if (strcmp (DEPRECATED_SYMBOL_NAME (sym), "_ada_") < 0)
-		i = M + 1;
-	      else
-		U = M;
-	    }
-	}
-      else
-	i = 0;
 
-      for (; i < BLOCK_BUCKETS (block); i += 1)
-	for (sym = BLOCK_BUCKET (block, i); sym != NULL; sym = sym->hash_next)
+      ALL_BLOCK_SYMBOLS (block, i, sym)
 	  {
 	    struct symbol *sym = BLOCK_SYM (block, i);
 
@@ -4104,16 +4050,8 @@ ada_add_block_symbols (struct block *blo
 		      cmp = strncmp (name, DEPRECATED_SYMBOL_NAME (sym) + 5, name_len);
 		  }
 
-		if (cmp < 0)
-		  {
-		    if (is_sorted)
-		      {
-			i = BLOCK_BUCKETS (block);
-			break;
-		      }
-		  }
-		else if (cmp == 0
-			 && is_name_suffix (DEPRECATED_SYMBOL_NAME (sym) + name_len + 5))
+		if (cmp == 0
+		    && is_name_suffix (DEPRECATED_SYMBOL_NAME (sym) + name_len + 5))
 		  {
 		    switch (SYMBOL_CLASS (sym))
 		      {
Index: block.h
===================================================================
RCS file: /cvs/src/src/gdb/block.h,v
retrieving revision 1.6
diff -u -p -r1.6 block.h
--- block.h	2 Jun 2003 18:36:33 -0000	1.6
+++ block.h	11 Jun 2003 22:16:45 -0000
@@ -162,14 +162,6 @@ struct block
 	  for ((sym) = BLOCK_BUCKET ((bl), (i)); (sym);		\
 	       (sym) = (sym)->hash_next)
 
-/* Nonzero if symbols of block BL should be sorted alphabetically.
-   Don't sort a block which corresponds to a function.  If we did the
-   sorting would have to preserve the order of the symbols for the
-   arguments.  Also don't sort any block that we chose to hash.  */
-
-#define BLOCK_SHOULD_SORT(bl) (! BLOCK_HASHTABLE (bl) \
-			       && BLOCK_FUNCTION (bl) == NULL)
-
 struct blockvector
 {
   /* Number of blocks in the list.  */
Index: coffread.c
===================================================================
RCS file: /cvs/src/src/gdb/coffread.c,v
retrieving revision 1.39
diff -u -p -r1.39 coffread.c
--- coffread.c	23 May 2003 16:16:00 -0000	1.39
+++ coffread.c	11 Jun 2003 22:16:49 -0000
@@ -605,15 +605,6 @@ coff_symfile_read (struct objfile *objfi
 
   coff_symtab_read ((long) symtab_offset, num_symbols, objfile);
 
-  /* Sort symbols alphabetically within each block.  */
-
-  {
-    struct symtab *s;
-
-    for (s = objfile->symtabs; s != NULL; s = s->next)
-      sort_symtab_syms (s);
-  }
-
   /* Install any minimal symbols that have been collected as the current
      minimal symbols for this objfile.  */
 
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.47
diff -u -p -r1.47 dbxread.c
--- dbxread.c	11 Jun 2003 13:16:27 -0000	1.47
+++ dbxread.c	11 Jun 2003 22:16:52 -0000
@@ -2484,7 +2484,6 @@ dbx_psymtab_to_symtab_1 (struct partial_
       /* Read in this file's symbols */
       bfd_seek (pst->objfile->obfd, SYMBOL_OFFSET (pst), SEEK_SET);
       read_ofile_symtab (pst);
-      sort_symtab_syms (pst->symtab);
 
       do_cleanups (old_chain);
     }
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.95
diff -u -p -r1.95 dwarf2read.c
--- dwarf2read.c	28 May 2003 20:25:10 -0000	1.95
+++ dwarf2read.c	11 Jun 2003 22:16:59 -0000
@@ -1740,7 +1740,6 @@ psymtab_to_symtab_1 (struct partial_symt
     }
   pst->symtab = symtab;
   pst->readin = 1;
-  sort_symtab_syms (pst->symtab);
 
   do_cleanups (back_to);
 }
Index: dwarfread.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarfread.c,v
retrieving revision 1.26
diff -u -p -r1.26 dwarfread.c
--- dwarfread.c	2 Jun 2003 04:16:24 -0000	1.26
+++ dwarfread.c	11 Jun 2003 22:17:03 -0000
@@ -2348,7 +2348,6 @@ psymtab_to_symtab_1 (struct partial_symt
 		  wrap_here ("");
 		  gdb_flush (gdb_stdout);
 		}
-	      sort_symtab_syms (pst->symtab);
 	      do_cleanups (old_chain);
 	    }
 	  pst->readin = 1;
Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.36
diff -u -p -r1.36 hpread.c
--- hpread.c	26 May 2003 19:34:06 -0000	1.36
+++ hpread.c	11 Jun 2003 22:17:10 -0000
@@ -2711,7 +2711,6 @@ hpread_psymtab_to_symtab_1 (struct parti
 	hpread_expand_symtab (pst->objfile, LDSYMOFF (pst), LDSYMLEN (pst),
 			      pst->textlow, pst->texthigh - pst->textlow,
 			      pst->section_offsets, pst->filename);
-      sort_symtab_syms (pst->symtab);
 
       do_cleanups (old_chain);
     }
Index: mdebugread.c
===================================================================
RCS file: /cvs/src/src/gdb/mdebugread.c,v
retrieving revision 1.45
diff -u -p -r1.45 mdebugread.c
--- mdebugread.c	14 May 2003 17:43:18 -0000	1.45
+++ mdebugread.c	11 Jun 2003 22:17:16 -0000
@@ -4008,10 +4008,6 @@ psymtab_to_symtab_1 (struct partial_symt
 	  end_stabs ();
 	}
 
-      /* Sort the symbol table now, we are done adding symbols to it.
-         We must do this before parse_procedure calls lookup_symbol.  */
-      sort_symtab_syms (st);
-
       /* There used to be a call to sort_blocks here, but this should not
          be necessary for stabs symtabs.  And as sort_blocks modifies the
          start address of the GLOBAL_BLOCK to the FIRST_LOCAL_BLOCK,
@@ -4205,9 +4201,6 @@ psymtab_to_symtab_1 (struct partial_symt
       pop_parse_stack ();
 
       st->primary = 1;
-
-      /* Sort the symbol table now, we are done adding symbols to it. */
-      sort_symtab_syms (st);
 
       sort_blocks (st);
     }
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.97
diff -u -p -r1.97 symfile.c
--- symfile.c	8 Jun 2003 18:27:14 -0000	1.97
+++ symfile.c	11 Jun 2003 22:17:20 -0000
@@ -236,38 +236,6 @@ sort_pst_symbols (struct partial_symtab 
 	 compare_psymbols);
 }
 
-/* Call sort_block_syms to sort alphabetically the symbols of one block.  */
-
-void
-sort_block_syms (register struct block *b)
-{
-  qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b),
-	 sizeof (struct symbol *), compare_symbols);
-}
-
-/* Call sort_symtab_syms to sort alphabetically
-   the symbols of each block of one symtab.  */
-
-void
-sort_symtab_syms (register struct symtab *s)
-{
-  register struct blockvector *bv;
-  int nbl;
-  int i;
-  register struct block *b;
-
-  if (s == 0)
-    return;
-  bv = BLOCKVECTOR (s);
-  nbl = BLOCKVECTOR_NBLOCKS (bv);
-  for (i = 0; i < nbl; i++)
-    {
-      b = BLOCKVECTOR_BLOCK (bv, i);
-      if (BLOCK_SHOULD_SORT (b))
-	sort_block_syms (b);
-    }
-}
-
 /* Make a null terminated copy of the string at PTR with SIZE characters in
    the obstack pointed to by OBSTACKP .  Returns the address of the copy.
    Note that the string at PTR does not have to be null terminated, I.E. it
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.23
diff -u -p -r1.23 symfile.h
--- symfile.h	7 Jun 2003 23:50:23 -0000	1.23
+++ symfile.h	11 Jun 2003 22:17:21 -0000
@@ -214,12 +214,6 @@ extern struct partial_symtab *start_psym
 						    struct partial_symbol **,
 						    struct partial_symbol **);
 
-/* Sorting your symbols for fast lookup or alphabetical printing.  */
-
-extern void sort_block_syms (struct block *);
-
-extern void sort_symtab_syms (struct symtab *);
-
 /* Make a copy of the string at PTR with SIZE characters in the symbol
    obstack (and add a null character at the end in the copy).  Returns
    the address of the copy.  */
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.109
diff -u -p -r1.109 symtab.c
--- symtab.c	20 May 2003 01:55:17 -0000	1.109
+++ symtab.c	11 Jun 2003 22:17:25 -0000
@@ -1636,7 +1636,6 @@ lookup_block_symbol (register const stru
   register int bot, top, inc;
   register struct symbol *sym;
   register struct symbol *sym_found = NULL;
-  register int do_linear_search = 1;
 
   if (BLOCK_HASHTABLE (block))
     {
@@ -1653,98 +1652,13 @@ lookup_block_symbol (register const stru
 	}
       return NULL;
     }
-
-  /* If the blocks's symbols were sorted, start with a binary search.  */
-
-  if (BLOCK_SHOULD_SORT (block))
-    {
-      /* Reset the linear search flag so if the binary search fails, we
-         won't do the linear search once unless we find some reason to
-         do so */
-
-      do_linear_search = 0;
-      top = BLOCK_NSYMS (block);
-      bot = 0;
-
-      /* Advance BOT to not far before the first symbol whose name is NAME. */
-
-      while (1)
-	{
-	  inc = (top - bot + 1);
-	  /* No need to keep binary searching for the last few bits worth.  */
-	  if (inc < 4)
-	    {
-	      break;
-	    }
-	  inc = (inc >> 1) + bot;
-	  sym = BLOCK_SYM (block, inc);
-	  if (!do_linear_search && (SYMBOL_LANGUAGE (sym) == language_java))
-	    {
-	      do_linear_search = 1;
-	    }
-	  if (SYMBOL_NATURAL_NAME (sym)[0] < name[0])
-	    {
-	      bot = inc;
-	    }
-	  else if (SYMBOL_NATURAL_NAME (sym)[0] > name[0])
-	    {
-	      top = inc;
-	    }
-	  else if (strcmp (SYMBOL_NATURAL_NAME (sym), name) < 0)
-	    {
-	      bot = inc;
-	    }
-	  else
-	    {
-	      top = inc;
-	    }
-	}
-
-      /* Now scan forward until we run out of symbols, find one whose
-         name is greater than NAME, or find one we want.  If there is
-         more than one symbol with the right name and domain, we
-         return the first one; I believe it is now impossible for us
-         to encounter two symbols with the same name and domain
-         here, because blocks containing argument symbols are no
-         longer sorted.  The exception is for C++, where multiple functions
-	 (cloned constructors / destructors, in particular) can have
-	 the same demangled name.  So if we have a particular
-	 mangled name to match, try to do so.  */
-
-      top = BLOCK_NSYMS (block);
-      while (bot < top)
-	{
-	  sym = BLOCK_SYM (block, bot);
-	  if (SYMBOL_DOMAIN (sym) == domain
-	      && (linkage_name
-		  ? strcmp (DEPRECATED_SYMBOL_NAME (sym), linkage_name) == 0
-		  : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
-	    {
-	      return sym;
-	    }
-          if (SYMBOL_PRINT_NAME (sym)[0] > name[0])
-            {
-              break;
-            }
-	  bot++;
-	}
-    }
-
-  /* Here if block isn't sorted, or we fail to find a match during the
-     binary search above.  If during the binary search above, we find a
-     symbol which is a Java symbol, then we have re-enabled the linear
-     search flag which was reset when starting the binary search.
-
-     This loop is equivalent to the loop above, but hacked greatly for speed.
-
-     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.  */
-
-  if (do_linear_search)
+  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.  */
       top = BLOCK_NSYMS (block);
       bot = 0;
       while (bot < top)
@@ -1792,8 +1706,9 @@ lookup_block_symbol (register const stru
 	    }
 	  bot++;
 	}
+
+      return (sym_found);		/* Will be NULL if not found. */
     }
-  return (sym_found);		/* Will be NULL if not found. */
 }
 
 /* Given a main symbol SYM and ADDR, search through the alias
Index: xcoffread.c
===================================================================
RCS file: /cvs/src/src/gdb/xcoffread.c,v
retrieving revision 1.29
diff -u -p -r1.29 xcoffread.c
--- xcoffread.c	6 Jun 2003 23:33:00 -0000	1.29
+++ xcoffread.c	11 Jun 2003 22:17:28 -0000
@@ -1767,7 +1767,6 @@ xcoff_psymtab_to_symtab_1 (struct partia
       old_chain = make_cleanup (really_free_pendings, 0);
 
       read_xcoff_symtab (pst);
-      sort_symtab_syms (pst->symtab);
 
       do_cleanups (old_chain);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]