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]

Symbol table changes


No changelog, as i'm not submitting it for approval, it's a work in
progress.
There are three unrelated changes not easy to just remove from the
patch right now, just cleaning up fixmes that were in the files, and
removing #if 0 blocks.
They are 
1. symtab.h: int nsyms -> unsigned int nsyms
2. buildsym.c: Removal of the FIXME about block ordering, implementing proper
   ordering if the objfile was reordered (checking via the
   OBJF_REORDERED flag), rather than always assuming
   it is out of order. Also removed a few #if 0 blocks.

3. symtab.c: Removal of a FIXME saying "This code is never executed,
   ....", and a quick check  in find_pc_sect_symtab if the requested pc is 0,
   before reading in every single symtab to try to find the symtab
   with address 0.


In other words, it's not perfect yet.


? .gdbinit
? Makefile
? a.out
? c-exp.tab.c
? config.h
? config.log
? config.status
? f-exp.tab.c
? gdb
? gmon.out
? init.c
? jv-exp.tab.c
? logrotate.tgz
? m2-exp.tab.c
? p-exp.tab.c
? stamp-h
? symtablechanges
? symtablediffs
? test.c
? version.c
? doc/Makefile
? doc/config.status
? testsuite/Makefile
? testsuite/config.log
? testsuite/config.status
? testsuite/gdb.asm/Makefile
? testsuite/gdb.asm/config.log
? testsuite/gdb.asm/config.status
? testsuite/gdb.base/Makefile
? testsuite/gdb.base/config.log
? testsuite/gdb.base/config.status
? testsuite/gdb.c++/Makefile
? testsuite/gdb.c++/a.out
? testsuite/gdb.c++/config.log
? testsuite/gdb.c++/config.status
? testsuite/gdb.chill/Makefile
? testsuite/gdb.chill/config.log
? testsuite/gdb.chill/config.status
? testsuite/gdb.disasm/Makefile
? testsuite/gdb.disasm/config.log
? testsuite/gdb.disasm/config.status
? testsuite/gdb.gdbtk/Makefile
? testsuite/gdb.gdbtk/config.log
? testsuite/gdb.gdbtk/config.status
? testsuite/gdb.java/Makefile
? testsuite/gdb.java/config.log
? testsuite/gdb.java/config.status
? testsuite/gdb.mi/Makefile
? testsuite/gdb.mi/config.log
? testsuite/gdb.mi/config.status
? testsuite/gdb.stabs/Makefile
? testsuite/gdb.stabs/config.log
? testsuite/gdb.stabs/config.status
? testsuite/gdb.threads/Makefile
? testsuite/gdb.threads/config.h
? testsuite/gdb.threads/config.log
? testsuite/gdb.threads/config.status
? testsuite/gdb.trace/Makefile
? testsuite/gdb.trace/config.log
? testsuite/gdb.trace/config.status
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.90
diff -c -3 -p -w -B -b -r1.90 Makefile.in
*** Makefile.in	2001/06/10 00:47:02	1.90
--- Makefile.in	2001/06/26 02:28:30
*************** COMMON_OBS = version.o blockframe.o brea
*** 678,684 ****
  	expprint.o environ.o stack.o thread.o \
  	event-loop.o event-top.o inf-loop.o completer.o \
  	gdbarch.o arch-utils.o gdbtypes.o copying.o $(DEPFILES) \
! 	memattr.o mem-break.o target.o parse.o language.o $(YYOBJ) buildsym.o \
  	kod.o kod-cisco.o \
  	gdb-events.o \
  	exec.o bcache.o objfiles.o minsyms.o maint.o demangle.o \
--- 678,684 ----
  	expprint.o environ.o stack.o thread.o \
  	event-loop.o event-top.o inf-loop.o completer.o \
  	gdbarch.o arch-utils.o gdbtypes.o copying.o $(DEPFILES) \
! 	memattr.o mem-break.o target.o parse.o language.o $(YYOBJ) bitmap.o buildsym.o \
  	kod.o kod-cisco.o \
  	gdb-events.o \
  	exec.o bcache.o objfiles.o minsyms.o maint.o demangle.o \
*************** blockframe.o: blockframe.c $(defs_h) $(g
*** 1223,1228 ****
--- 1223,1230 ----
  breakpoint.o: breakpoint.c $(defs_h) $(gdbcmd_h) $(gdbcore_h) \
  	$(inferior_h) language.h target.h gdbthread.h $(gdb_string_h) \
  	gdb-events.h linespec.h $(ui_out_h)
+ 
+ bitmap.o: bitmap.c bitmap.h
  
  buildsym.o: buildsym.c $(bfd_h) buildsym.h complaints.h $(defs_h) \
  	objfiles.h symfile.h $(symtab_h) $(gdb_string_h)
Index: bcache.c
===================================================================
RCS file: /cvs/src/src/gdb/bcache.c,v
retrieving revision 1.6
diff -c -3 -p -w -B -b -r1.6 bcache.c
*** bcache.c	2001/03/06 08:21:05	1.6
--- bcache.c	2001/06/26 02:28:30
***************
*** 28,35 ****
  #include "bcache.h"
  #include "gdb_string.h"		/* For memcpy declaration */
  
! /* The old hash function was stolen from SDBM. This is what DB 3.0 uses now,
   * and is better than the old one. 
   */
  
  unsigned long
--- 28,36 ----
  #include "bcache.h"
  #include "gdb_string.h"		/* For memcpy declaration */
  
! /* The old hash function was stolen from SDBM. This is what DB 3.1 uses now,
   * and is better than the old one. 
+  * This is the FNV-1 hash.
   */
  
  unsigned long
*************** hash(void *addr, int length)
*** 40,46 ****
  		
  		k = (const unsigned char *)addr;
  		e = k+length;
! 		for (h=0; k< e;++k)
  		{
  				h *=16777619;
  				h ^= *k;
--- 41,47 ----
    
    k = (const unsigned char *)addr;
    e = k+length;
!   for (h=0x811c9dc5; k< e;++k)
      {
        h *=16777619;
        h ^= *k;
Index: bcache.h
===================================================================
RCS file: /cvs/src/src/gdb/bcache.h,v
retrieving revision 1.4
diff -c -3 -p -w -B -b -r1.4 bcache.h
*** bcache.h	2001/03/06 08:21:05	1.4
--- bcache.h	2001/06/26 02:28:31
*************** struct bstring {
*** 82,88 ****
    union
    {
      char data[1];
-     double dummy;
    }
    d;
  };
--- 82,87 ----
Index: bitmap.c
===================================================================
RCS file: bitmap.c
diff -N bitmap.c
*** /dev/null	Tue May  5 13:32:27 1998
--- bitmap.c	Mon Jun 25 19:28:31 2001
***************
*** 0 ****
--- 1,717 ----
+ /* Functions to support general ended bitmaps.
+    Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ 
+ This file is part of GNU CC.
+ 
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+ 
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING.  If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.  */
+ 
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <memory.h>
+ #include "obstack.h"
+ #include "libiberty.h"
+ #include "defs.h"
+ #include "bitmap.h"
+ #define TRUE 1
+ #define FALSE 0
+ /* Obstack to allocate bitmap elements from.  */
+ static struct obstack bitmap_obstack;
+ static int bitmap_obstack_init = FALSE;
+ 
+ #ifndef INLINE
+ #ifndef __GNUC__
+ #define INLINE
+ #else
+ #define INLINE __inline__
+ #endif
+ #endif
+ 
+ /* Global data */
+ bitmap_element bitmap_zero;		/* An element of all zero bits. */
+ bitmap_element *bitmap_free;		/* Freelist of bitmap elements. */
+ 
+ static void bitmap_element_free		PARAMS ((bitmap, bitmap_element *));
+ static bitmap_element *bitmap_element_allocate PARAMS ((void));
+ static int bitmap_element_zerop		PARAMS ((bitmap_element *));
+ static void bitmap_element_link		PARAMS ((bitmap, bitmap_element *));
+ static bitmap_element *bitmap_find_bit	PARAMS ((bitmap, unsigned int));
+ 
+ /* Free a bitmap element */
+ 
+ static INLINE void
+ bitmap_element_free (head, elt)
+      bitmap head;
+      bitmap_element *elt;
+ {
+   bitmap_element *next = elt->next;
+   bitmap_element *prev = elt->prev;
+ 
+   if (prev)
+     prev->next = next;
+ 
+   if (next)
+     next->prev = prev;
+ 
+   if (head->first == elt)
+     head->first = next;
+ 
+   /* Since the first thing we try is to insert before current,
+      make current the next entry in preference to the previous.  */
+   if (head->current == elt)
+     head->current = next != 0 ? next : prev;
+ 
+   elt->next = bitmap_free;
+   bitmap_free = elt;
+ }
+ 
+ /* Allocate a bitmap element.  The bits are cleared, but nothing else is.  */
+ 
+ static INLINE bitmap_element *
+ bitmap_element_allocate ()
+ {
+   bitmap_element *element;
+ #if BITMAP_ELEMENT_WORDS != 2
+   int i;
+ #endif
+ 
+   if (bitmap_free != 0)
+     {
+       element = bitmap_free;
+       bitmap_free = element->next;
+     }
+   else
+     {
+       /* We can't use gcc_obstack_init to initialize the obstack since
+ 	 print-rtl.c now calls bitmap functions, and bitmap is linked
+ 	 into the gen* functions.  */
+       if (!bitmap_obstack_init)
+ 	{
+ 	  bitmap_obstack_init = TRUE;
+ 
+ 	  /* Let particular systems override the size of a chunk.  */
+ #ifndef OBSTACK_CHUNK_SIZE
+ #define OBSTACK_CHUNK_SIZE 0
+ #endif
+ 	  /* Let them override the alloc and free routines too.  */
+ #ifndef OBSTACK_CHUNK_ALLOC
+ #define OBSTACK_CHUNK_ALLOC xmalloc
+ #endif
+ #ifndef OBSTACK_CHUNK_FREE
+ #define OBSTACK_CHUNK_FREE free
+ #endif
+ 
+ #if !defined(__GNUC__) || (__GNUC__ < 2)
+ #define __alignof__(type) 0
+ #endif
+ 
+ 	  obstack_specify_allocation (&bitmap_obstack, OBSTACK_CHUNK_SIZE,
+ 				      __alignof__ (bitmap_element),
+ 				      (void *(*) PARAMS ((long))) OBSTACK_CHUNK_ALLOC,
+ 				      (void (*) PARAMS ((void *))) OBSTACK_CHUNK_FREE);
+ 	}
+ 
+       element = (bitmap_element *) obstack_alloc (&bitmap_obstack,
+ 						  sizeof (bitmap_element));
+     }
+ 
+ #if BITMAP_ELEMENT_WORDS == 2
+   element->bits[0] = element->bits[1] = 0;
+ #else
+   for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
+     element->bits[i] = 0;
+ #endif
+ 
+   return element;
+ }
+ 
+ /* Return nonzero if all bits in an element are zero.  */
+ 
+ static INLINE int
+ bitmap_element_zerop (element)
+      bitmap_element *element;
+ {
+ #if BITMAP_ELEMENT_WORDS == 2
+   return (element->bits[0] | element->bits[1]) == 0;
+ #else
+   int i;
+ 
+   for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
+     if (element->bits[i] != 0)
+       return 0;
+ 
+   return 1;
+ #endif
+ }
+ 
+ /* Link the bitmap element into the current bitmap linked list.  */
+ 
+ static INLINE void
+ bitmap_element_link (head, element)
+      bitmap head;
+      bitmap_element *element;
+ {
+   unsigned int indx = element->indx;
+   bitmap_element *ptr;
+ 
+   /* If this is the first and only element, set it in.  */
+   if (head->first == 0)
+     {
+       element->next = element->prev = 0;
+       head->first = element;
+     }
+ 
+   /* If this index is less than that of the current element, it goes someplace
+      before the current element.  */
+   else if (indx < head->indx)
+     {
+       for (ptr = head->current;
+ 	   ptr->prev != 0 && ptr->prev->indx > indx;
+ 	   ptr = ptr->prev)
+ 	;
+ 
+       if (ptr->prev)
+ 	ptr->prev->next = element;
+       else
+ 	head->first = element;
+ 
+       element->prev = ptr->prev;
+       element->next = ptr;
+       ptr->prev = element;
+     }
+ 
+   /* Otherwise, it must go someplace after the current element.  */
+   else
+     {
+       for (ptr = head->current;
+ 	   ptr->next != 0 && ptr->next->indx < indx;
+ 	   ptr = ptr->next)
+ 	;
+ 
+       if (ptr->next)
+ 	ptr->next->prev = element;
+ 
+       element->next = ptr->next;
+       element->prev = ptr;
+       ptr->next = element;
+     }
+ 
+   /* Set up so this is the first element searched.  */
+   head->current = element;
+   head->indx = indx;
+ }
+ 
+ /* Clear a bitmap by freeing the linked list.  */
+ 
+ INLINE void
+ bitmap_clear (head)
+      bitmap head;
+ {
+   bitmap_element *element, *next;
+ 
+   for (element = head->first; element != 0; element = next)
+     {
+       next = element->next;
+       element->next = bitmap_free;
+       bitmap_free = element;
+     }
+ 
+   head->first = head->current =  0;
+ }
+ 
+ /* Copy a bitmap to another bitmap */
+ 
+ void
+ bitmap_copy (to, from)
+      bitmap to;
+      bitmap from;
+ {
+   bitmap_element *from_ptr, *to_ptr = 0;
+ #if BITMAP_ELEMENT_WORDS != 2
+   int i;
+ #endif
+ 
+   bitmap_clear (to);
+ 
+   /* Copy elements in forward direction one at a time */
+   for (from_ptr = from->first; from_ptr; from_ptr = from_ptr->next)
+     {
+       bitmap_element *to_elt = bitmap_element_allocate ();
+ 
+       to_elt->indx = from_ptr->indx;
+ 
+ #if BITMAP_ELEMENT_WORDS == 2
+       to_elt->bits[0] = from_ptr->bits[0];
+       to_elt->bits[1] = from_ptr->bits[1];
+ #else
+       for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
+ 	to_elt->bits[i] = from_ptr->bits[i];
+ #endif
+ 
+       /* Here we have a special case of bitmap_element_link, for the case
+ 	 where we know the links are being entered in sequence.  */
+       if (to_ptr == 0)
+ 	{
+ 	  to->first = to->current = to_elt;
+ 	  to->indx = from_ptr->indx;
+ 	  to_elt->next = to_elt->prev = 0;
+ 	}
+       else
+ 	{
+ 	  to_elt->prev = to_ptr;
+ 	  to_elt->next = 0;
+ 	  to_ptr->next = to_elt;
+ 	}
+ 
+       to_ptr = to_elt;
+     }
+ }
+ 
+ /* Find a bitmap element that would hold a bitmap's bit.
+    Update the `current' field even if we can't find an element that
+    would hold the bitmap's bit to make eventual allocation
+    faster.  */
+ 
+ static INLINE bitmap_element *
+ bitmap_find_bit (head, bit)
+      bitmap head;
+      unsigned int bit;
+ {
+   bitmap_element *element;
+   ULONGEST indx = bit / BITMAP_ELEMENT_ALL_BITS;
+ 
+   if (head->current == 0)
+     return 0;
+ 
+   if (head->indx > indx)
+     for (element = head->current;
+ 	 element->prev != 0 && element->indx > indx;
+ 	 element = element->prev)
+       ;
+ 
+   else
+     for (element = head->current;
+ 	 element->next != 0 && element->indx < indx;
+ 	 element = element->next)
+       ;
+ 
+   /* `element' is the nearest to the one we want.  If it's not the one we
+      want, the one we want doesn't exist.  */
+   head->current = element;
+   head->indx = element->indx;
+   if (element != 0 && element->indx != indx)
+     element = 0;
+ 
+   return element;
+ }
+ 
+ /* Clear a single bit in a bitmap.  */
+ 
+ void
+ bitmap_clear_bit (head, bit)
+      bitmap head;
+      int bit;
+ {
+   bitmap_element *ptr = bitmap_find_bit (head, bit);
+ 
+   if (ptr != 0)
+     {
+       unsigned bit_num  = bit % (unsigned) (sizeof(ULONGEST)*8);
+       unsigned word_num = ((bit / (unsigned) (sizeof(ULONGEST)*8))
+ 			   % BITMAP_ELEMENT_WORDS);
+       ptr->bits[word_num] &= ~ (((ULONGEST) 1) << bit_num);
+ 
+       /* If we cleared the entire word, free up the element */
+       if (bitmap_element_zerop (ptr))
+ 	bitmap_element_free (head, ptr);
+     }
+ }
+ 
+ 
+ /* Set a single bit in a bitmap.  */
+ 
+ void
+ bitmap_set_bit (head, bit)
+      bitmap head;
+      int bit;
+ {
+   bitmap_element *ptr = bitmap_find_bit (head, bit);
+   unsigned word_num
+     = ((bit / (unsigned) (sizeof(ULONGEST)*8)) % BITMAP_ELEMENT_WORDS);
+   unsigned bit_num  = bit % (unsigned) (sizeof(ULONGEST)*8);
+   ULONGEST bit_val = ((ULONGEST) 1) << bit_num;
+ 
+   if (ptr == 0)
+     {
+       ptr = bitmap_element_allocate ();
+       ptr->indx = bit / BITMAP_ELEMENT_ALL_BITS;
+       ptr->bits[word_num] = bit_val;
+       bitmap_element_link (head, ptr);
+     }
+   else
+     ptr->bits[word_num] |= bit_val;
+ }
+ 
+ /* Return whether a bit is set within a bitmap.  */
+ 
+ int
+ bitmap_bit_p (head, bit)
+      bitmap head;
+      int bit;
+ {
+   bitmap_element *ptr;
+   unsigned bit_num;
+   unsigned word_num;
+ 
+   ptr = bitmap_find_bit (head, bit);
+   if (ptr == 0)
+     return 0;
+ 
+   bit_num = bit % (unsigned) (sizeof(ULONGEST)*8);
+   word_num
+     = ((bit / (unsigned) (sizeof(ULONGEST)*8)) % BITMAP_ELEMENT_WORDS);
+ 
+   return (ptr->bits[word_num] >> bit_num) & 1;
+ }
+ 
+ /* Store in bitmap TO the result of combining bitmap FROM1 and FROM2 using
+    a specific bit manipulation.  Return true if TO changes.  */
+ 
+ int
+ bitmap_operation (to, from1, from2, operation)
+      bitmap to;
+      bitmap from1;
+      bitmap from2;
+      enum bitmap_bits operation;
+ {
+ #define HIGHEST_INDEX (unsigned int) ~0
+ 
+   bitmap_element *from1_ptr = from1->first;
+   bitmap_element *from2_ptr = from2->first;
+   unsigned int indx1 = (from1_ptr) ? from1_ptr->indx : HIGHEST_INDEX;
+   unsigned int indx2 = (from2_ptr) ? from2_ptr->indx : HIGHEST_INDEX;
+   bitmap_element *to_ptr = to->first;
+   bitmap_element *from1_tmp;
+   bitmap_element *from2_tmp;
+   bitmap_element *to_tmp;
+   unsigned int indx;
+   int changed = 0;
+ 
+ #if BITMAP_ELEMENT_WORDS == 2
+ #define DOIT(OP)					\
+   do {							\
+     ULONGEST t0, t1, f10, f11, f20, f21;	\
+     f10 = from1_tmp->bits[0];				\
+     f20 = from2_tmp->bits[0];				\
+     t0 = f10 OP f20;					\
+     changed |= (t0 != to_tmp->bits[0]);			\
+     f11 = from1_tmp->bits[1];				\
+     f21 = from2_tmp->bits[1];				\
+     t1 = f11 OP f21;					\
+     changed |= (t1 != to_tmp->bits[1]);			\
+     to_tmp->bits[0] = t0;				\
+     to_tmp->bits[1] = t1;				\
+   } while (0)
+ #else
+ #define DOIT(OP)					\
+   do {							\
+     ULONGEST t, f1, f2;			\
+     int i;						\
+     for (i = 0; i < BITMAP_ELEMENT_WORDS; ++i)		\
+       {							\
+ 	f1 = from1_tmp->bits[i];			\
+ 	f2 = from2_tmp->bits[i];			\
+ 	t = f1 OP f2;					\
+ 	changed |= (t != to_tmp->bits[i]);		\
+ 	to_tmp->bits[i] = t;				\
+       }							\
+   } while (0)
+ #endif
+ 
+   to->first = to->current = 0;
+ 
+   while (from1_ptr != 0 || from2_ptr != 0)
+     {
+       /* Figure out whether we need to substitute zero elements for
+ 	 missing links.  */
+       if (indx1 == indx2)
+ 	{
+ 	  indx = indx1;
+ 	  from1_tmp = from1_ptr;
+ 	  from2_tmp = from2_ptr;
+ 	  from1_ptr = from1_ptr->next;
+ 	  indx1 = (from1_ptr) ? from1_ptr->indx : HIGHEST_INDEX;
+ 	  from2_ptr = from2_ptr->next;
+ 	  indx2 = (from2_ptr) ? from2_ptr->indx : HIGHEST_INDEX;
+ 	}
+       else if (indx1 < indx2)
+ 	{
+ 	  indx = indx1;
+ 	  from1_tmp = from1_ptr;
+ 	  from2_tmp = &bitmap_zero;
+ 	  from1_ptr = from1_ptr->next;
+ 	  indx1 = (from1_ptr) ? from1_ptr->indx : HIGHEST_INDEX;
+ 	}
+       else
+ 	{
+ 	  indx = indx2;
+ 	  from1_tmp = &bitmap_zero;
+ 	  from2_tmp = from2_ptr;
+ 	  from2_ptr = from2_ptr->next;
+ 	  indx2 = (from2_ptr) ? from2_ptr->indx : HIGHEST_INDEX;
+ 	}
+ 
+       /* Find the appropriate element from TO.  Begin by discarding
+ 	 elements that we've skipped. */
+       while (to_ptr && to_ptr->indx < indx)
+ 	{
+ 	  changed = 1;
+ 	  to_tmp = to_ptr;
+ 	  to_ptr = to_ptr->next;
+ 	  to_tmp->next = bitmap_free;
+ 	  bitmap_free = to_tmp;
+ 	}
+       if (to_ptr && to_ptr->indx == indx)
+ 	{
+ 	  to_tmp = to_ptr;
+ 	  to_ptr = to_ptr->next;
+ 	}
+       else
+ 	to_tmp = bitmap_element_allocate ();
+ 
+       /* Do the operation, and if any bits are set, link it into the
+ 	 linked list.  */
+       switch (operation)
+ 	{
+ 	default:
+ 	  abort ();
+ 
+ 	case BITMAP_AND:
+ 	  DOIT (&);
+ 	  break;
+ 
+ 	case BITMAP_AND_COMPL:
+ 	  DOIT (&~);
+ 	  break;
+ 
+ 	case BITMAP_IOR:
+ 	  DOIT (|);
+ 	  break;
+ 	case BITMAP_IOR_COMPL:
+ 	  DOIT (|~);
+ 	  break;
+ 	case BITMAP_XOR:
+ 	  DOIT (^);
+ 	  break;
+ 	}
+ 
+       if (! bitmap_element_zerop (to_tmp))
+ 	{
+ 	  to_tmp->indx = indx;
+ 	  bitmap_element_link (to, to_tmp);
+ 	}
+       else
+ 	{
+ 	  to_tmp->next = bitmap_free;
+ 	  bitmap_free = to_tmp;
+ 	}
+     }
+ 
+   /* If we have elements of TO left over, free the lot.  */
+   if (to_ptr)
+     {
+       changed = 1;
+       for (to_tmp = to_ptr; to_tmp->next ; to_tmp = to_tmp->next)
+ 	continue;
+       to_tmp->next = bitmap_free;
+       bitmap_free = to_ptr;
+     }
+ 
+ #undef DOIT
+ 
+   return changed;
+ }
+ 
+ /* Return true if two bitmaps are identical.  */
+ 
+ int
+ bitmap_equal_p (a, b)
+      bitmap a;
+      bitmap b;
+ {
+   bitmap_head c;
+   int ret;
+ 
+   c.first = c.current = 0;
+   ret = ! bitmap_operation (&c, a, b, BITMAP_XOR);
+   bitmap_clear (&c);
+ 
+   return ret;
+ }
+ 
+ /* Or into bitmap TO bitmap FROM1 and'ed with the complement of
+    bitmap FROM2. */
+ 
+ void
+ bitmap_ior_and_compl (to, from1, from2)
+      bitmap to;
+      bitmap from1;
+      bitmap from2;
+ {
+   bitmap_head tmp;
+ 
+   tmp.first = tmp.current = 0;
+ 
+   bitmap_operation (&tmp, from1, from2, BITMAP_AND_COMPL);
+   bitmap_operation (to, to, &tmp, BITMAP_IOR);
+   bitmap_clear (&tmp);
+ }
+ 
+ /* Initialize a bitmap header.  */
+ 
+ bitmap
+ bitmap_initialize (head)
+      bitmap head;
+ {
+   head->first = head->current = 0;
+ 
+   return head;
+ }
+ 
+ /* Debugging function to print out the contents of a bitmap.  */
+ 
+ void
+ debug_bitmap_file (file, head)
+      FILE *file;
+      bitmap head;
+ {
+   bitmap_element *ptr;
+ 
+   fprintf (file, "\nfirst = ");
+   fprintf (file, "%p", (PTR) head->first);
+   fprintf (file, " current = ");
+   fprintf (file, "%p", (PTR) head->current);
+   fprintf (file, " indx = %u\n", head->indx);
+ 
+   for (ptr = head->first; ptr; ptr = ptr->next)
+     {
+       int i, j, col = 26;
+ 
+       fprintf (file, "\t");
+       fprintf (file, "%p", (PTR) ptr);
+       fprintf (file, " next = ");
+       fprintf (file, "%p", (PTR) ptr->next);
+       fprintf (file, " prev = ");
+       fprintf (file, "%p", (PTR) ptr->prev);
+       fprintf (file, " indx = %u\n\t\tbits = {", ptr->indx);
+ 
+       for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
+ 	for (j = 0; j < (sizeof(ULONGEST)*8); j++)
+ 	  if ((ptr->bits[i] >> j) & 1)
+ 	    {
+ 	      if (col > 70)
+ 		{
+ 		  fprintf (file, "\n\t\t\t");
+ 		  col = 24;
+ 		}
+ 
+ 	      fprintf (file, " %u", (ptr->indx * BITMAP_ELEMENT_ALL_BITS
+ 				     + i * (sizeof(ULONGEST)*8) + j));
+ 	      col += 4;
+ 	    }
+ 
+       fprintf (file, " }\n");
+     }
+ }
+ 
+ /* Function to be called from the debugger to print the contents
+    of a bitmap.  */
+ 
+ void
+ debug_bitmap (head)
+      bitmap head;
+ {
+   debug_bitmap_file (stdout, head);
+ }
+ 
+ /* Function to print out the contents of a bitmap.  Unlike debug_bitmap_file,
+    it does not print anything but the bits.  */
+ 
+ void
+ bitmap_print (file, head, prefix, suffix)
+      FILE *file;
+      bitmap head;
+      const char *prefix;
+      const char *suffix;
+ {
+   const char *comma = "";
+   int i;
+ 
+   fputs (prefix, file);
+   EXECUTE_IF_SET_IN_BITMAP (head, 0, i,
+ 			    {
+ 			      fprintf (file, "%s%d", comma, i);
+ 			      comma = ", ";
+ 			    });
+   fputs (suffix, file);
+ }
+ 
+ /* Release any memory allocated by bitmaps.  */
+ 
+ void
+ bitmap_release_memory ()
+ {
+   bitmap_free = 0;
+   if (bitmap_obstack_init)
+     {
+       bitmap_obstack_init = FALSE;
+       obstack_free (&bitmap_obstack, NULL);
+     }
+ }
+ 
+ int
+ bitmap_union_of_diff (dst, a, b, c)
+      bitmap dst;
+      bitmap a;
+      bitmap b;
+      bitmap c;
+ {
+   int changed = 0;
+   bitmap temp = BITMAP_ALLOCA ();
+   bitmap_operation (temp, b, c, BITMAP_AND_COMPL);
+   changed = bitmap_operation (dst, temp, a, BITMAP_IOR);
+   return changed;
+ }
+ 
+ int 
+ bitmap_first_set_bit (a)
+      bitmap a;
+ {
+   int i;
+   EXECUTE_IF_SET_IN_BITMAP (a, 0, i, return i;);
+   return -1;
+ }
+ 
+ int 
+ bitmap_last_set_bit (a)
+      bitmap a;
+ {
+   int i;
+   EXECUTE_IF_SET_IN_BITMAP (a, 0, i, );
+   if (bitmap_bit_p (a, i))
+     return i;
+   return -1;
+ }
Index: bitmap.h
===================================================================
RCS file: bitmap.h
diff -N bitmap.h
*** /dev/null	Tue May  5 13:32:27 1998
--- bitmap.h	Mon Jun 25 19:28:31 2001
***************
*** 0 ****
--- 1,350 ----
+ /* Functions to support general ended bitmaps.
+    Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ 
+ This file is part of GNU CC.
+ 
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+ 
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING.  If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.  */
+ 
+ #ifndef GCC_BITMAP_H
+ #define GCC_BITMAP_H 
+ #define PARAMS(x) x
+ /* Number of words to use for each element in the linked list.  */
+ 
+ #ifndef BITMAP_ELEMENT_WORDS
+ #define BITMAP_ELEMENT_WORDS 2
+ #endif
+ 
+ /* Number of bits in each actual element of a bitmap.  We get slightly better
+    code for bit % BITMAP_ELEMENT_ALL_BITS and bit / BITMAP_ELEMENT_ALL_BITS if
+    bits is unsigned, assuming it is a power of 2.  */
+ 
+ #define BITMAP_ELEMENT_ALL_BITS \
+   ((unsigned) (BITMAP_ELEMENT_WORDS * (sizeof(ULONGEST)*8)))
+ 
+ /* Bitmap set element.  We use a linked list to hold only the bits that
+    are set.  This allows for use to grow the bitset dynamically without
+    having to realloc and copy a giant bit array.  The `prev' field is
+    undefined for an element on the free list.  */
+ 
+ typedef struct bitmap_element_def
+ {
+   struct bitmap_element_def *next;		/* Next element. */
+   struct bitmap_element_def *prev;		/* Previous element. */
+   unsigned int indx;			/* regno/BITMAP_ELEMENT_ALL_BITS. */
+   ULONGEST bits[BITMAP_ELEMENT_WORDS]; /* Bits that are set. */
+ } bitmap_element;
+ 
+ /* Head of bitmap linked list.  */
+ typedef struct bitmap_head_def {
+   bitmap_element *first;	/* First element in linked list. */
+   bitmap_element *current;	/* Last element looked at. */
+   unsigned int indx;		/* Index of last element looked at. */
+ 
+ } bitmap_head, *bitmap;
+ 
+ /* Enumeration giving the various operations we support.  */
+ enum bitmap_bits {
+   BITMAP_AND,			/* TO = FROM1 & FROM2 */
+   BITMAP_AND_COMPL,		/* TO = FROM1 & ~ FROM2 */
+   BITMAP_IOR,			/* TO = FROM1 | FROM2 */
+   BITMAP_XOR,			/* TO = FROM1 ^ FROM2 */
+   BITMAP_IOR_COMPL			/* TO = FROM1 | ~FROM2 */
+ };
+ 
+ /* Global data */
+ extern bitmap_element *bitmap_free;	/* Freelist of bitmap elements */
+ extern bitmap_element bitmap_zero;	/* Zero bitmap element */
+ 
+ /* Clear a bitmap by freeing up the linked list.  */
+ extern void bitmap_clear PARAMS ((bitmap));
+ 
+ /* Copy a bitmap to another bitmap. */
+ extern void bitmap_copy PARAMS ((bitmap, bitmap));
+ 
+ /* True if two bitmaps are identical.  */
+ extern int bitmap_equal_p PARAMS ((bitmap, bitmap));
+ 
+ /* Perform an operation on two bitmaps, yielding a third.  */
+ extern int bitmap_operation PARAMS ((bitmap, bitmap, bitmap, enum bitmap_bits));
+ 
+ /* `or' into one bitmap the `and' of a second bitmap witih the complement
+    of a third.  */
+ extern void bitmap_ior_and_compl PARAMS ((bitmap, bitmap, bitmap));
+ 
+ /* Clear a single register in a register set.  */
+ extern void bitmap_clear_bit PARAMS ((bitmap, int));
+ 
+ /* Set a single register in a register set.  */
+ extern void bitmap_set_bit PARAMS ((bitmap, int));
+ 
+ /* Return true if a register is set in a register set.  */
+ extern int bitmap_bit_p PARAMS ((bitmap, int));
+ 
+ /* Debug functions to print a bitmap linked list.  */
+ extern void debug_bitmap PARAMS ((bitmap));
+ extern void debug_bitmap_file PARAMS ((FILE *, bitmap));
+ 
+ /* Print a bitmap */
+ extern void bitmap_print PARAMS ((FILE *, bitmap, const char *, const char *));
+ 
+ /* Initialize a bitmap header.  */
+ extern bitmap bitmap_initialize PARAMS ((bitmap));
+ 
+ /* Release all memory held by bitmaps.  */
+ extern void bitmap_release_memory PARAMS ((void));
+ 
+ /* A few compatibility/functions macros for compatibility with sbitmaps */
+ #define dump_bitmap(file, bitmap) bitmap_print (file, bitmap, "", "\n")
+ #define bitmap_zero(a) bitmap_clear (a)
+ #define bitmap_a_or_b(a,b,c) bitmap_operation (a, b, c, BITMAP_IOR)
+ #define bitmap_a_and_b(a,b,c) bitmap_operation (a, b, c, BITMAP_AND)
+ extern int bitmap_union_of_diff PARAMS((bitmap, bitmap, bitmap, bitmap));
+ extern int bitmap_first_set_bit PARAMS((bitmap));
+ extern int bitmap_last_set_bit PARAMS((bitmap));
+ 
+ /* Allocate a bitmap with oballoc.  */
+ #define BITMAP_OBSTACK_ALLOC(OBSTACK)				\
+   bitmap_initialize ((bitmap) obstack_alloc (OBSTACK, sizeof (bitmap_head)))
+ 
+ /* Allocate a bitmap with alloca.  */
+ #define BITMAP_ALLOCA()						\
+   bitmap_initialize ((bitmap) alloca (sizeof (bitmap_head)))
+ 
+ /* Allocate a bitmap with xmalloc.  */
+ #define BITMAP_XMALLOC()                                        \
+   bitmap_initialize ((bitmap) xmalloc (sizeof (bitmap_head)))
+ 
+ /* Do any cleanup needed on a bitmap when it is no longer used.  */
+ #define BITMAP_FREE(BITMAP)			\
+ do {						\
+   if (BITMAP)					\
+     {						\
+       bitmap_clear (BITMAP);			\
+       (BITMAP) = 0;				\
+     }						\
+ } while (0)
+ 
+ /* Do any cleanup needed on an xmalloced bitmap when it is no longer used.  */
+ #define BITMAP_XFREE(BITMAP)			\
+ do {						\
+   if (BITMAP)					\
+     {						\
+       bitmap_clear (BITMAP);			\
+       free (BITMAP);				\
+       (BITMAP) = 0;				\
+     }						\
+ } while (0)
+ 
+ /* Do any one-time initializations needed for bitmaps.  */
+ #define BITMAP_INIT_ONCE()
+ 
+ /* Loop over all bits in BITMAP, starting with MIN, setting BITNUM to the
+    bit number and executing CODE for all bits that are set. */
+ 
+ #define EXECUTE_IF_SET_IN_BITMAP(BITMAP, MIN, BITNUM, CODE)		\
+ do {									\
+   bitmap_element *ptr_ = (BITMAP)->first;				\
+   unsigned int indx_ = (MIN) / BITMAP_ELEMENT_ALL_BITS;			\
+   unsigned bit_num_ = (MIN) % ((unsigned) (sizeof(ULONGEST)*8));	\
+   unsigned word_num_ = (((MIN) / ((unsigned) (sizeof(ULONGEST)*8)))	\
+ 			% BITMAP_ELEMENT_WORDS);			\
+ 									\
+ 									\
+   /* Find the block the minimum bit is in.  */				\
+   while (ptr_ != 0 && ptr_->indx < indx_)				\
+     ptr_ = ptr_->next;							\
+ 									\
+   if (ptr_ != 0 && ptr_->indx != indx_)					\
+     {									\
+       bit_num_ = 0;							\
+       word_num_ = 0;							\
+     }									\
+ 									\
+   for (; ptr_ != 0; ptr_ = ptr_->next)					\
+     {									\
+       for (; word_num_ < BITMAP_ELEMENT_WORDS; word_num_++)		\
+ 	{								\
+ 	  ULONGEST word_ = ptr_->bits[word_num_];		\
+ 									\
+ 	  if (word_ != 0)						\
+ 	    {								\
+ 	      for (; bit_num_ < (sizeof(ULONGEST)*8); bit_num_++)	\
+ 		{							\
+ 		  ULONGEST mask_				\
+ 		    = ((ULONGEST) 1) << bit_num_;		\
+ 									\
+ 		  if ((word_ & mask_) != 0)				\
+ 		    {							\
+ 		      word_ &= ~ mask_;					\
+ 		      (BITNUM) = (ptr_->indx * BITMAP_ELEMENT_ALL_BITS  \
+ 				  + word_num_ * (sizeof(ULONGEST)*8)  \
+ 				  + bit_num_);				\
+ 		      CODE;						\
+ 									\
+ 		      if (word_ == 0)					\
+ 			break;						\
+ 		    }							\
+ 		}							\
+ 	    }								\
+ 									\
+ 	  bit_num_ = 0;							\
+ 	}								\
+ 									\
+       word_num_ = 0;							\
+     }									\
+ } while (0)
+ 
+ /* Loop over all bits in BITMAP1 and BITMAP2, starting with MIN, setting
+    BITNUM to the bit number and executing CODE for all bits that are set in
+    the first bitmap and not set in the second. */
+ 
+ #define EXECUTE_IF_AND_COMPL_IN_BITMAP(BITMAP1, BITMAP2, MIN, BITNUM, CODE) \
+ do {									\
+   bitmap_element *ptr1_ = (BITMAP1)->first;				\
+   bitmap_element *ptr2_ = (BITMAP2)->first;				\
+   unsigned int indx_ = (MIN) / BITMAP_ELEMENT_ALL_BITS;			\
+   unsigned bit_num_ = (MIN) % ((unsigned) (sizeof(ULONGEST)*8));	\
+   unsigned word_num_ = (((MIN) / ((unsigned) (sizeof(ULONGEST)*8)))	\
+ 			% BITMAP_ELEMENT_WORDS);			\
+ 									\
+   /* Find the block the minimum bit is in in the first bitmap.  */	\
+   while (ptr1_ != 0 && ptr1_->indx < indx_)				\
+     ptr1_ = ptr1_->next;						\
+ 									\
+   if (ptr1_ != 0 && ptr1_->indx != indx_)				\
+     {									\
+       bit_num_ = 0;							\
+       word_num_ = 0;							\
+     }									\
+ 									\
+   for (; ptr1_ != 0 ; ptr1_ = ptr1_->next)				\
+     {									\
+       /* Advance BITMAP2 to the equivalent link, using an all		\
+ 	 zero element if an equivalent link doesn't exist.  */		\
+       bitmap_element *tmp2_;						\
+ 									\
+       while (ptr2_ != 0 && ptr2_->indx < ptr1_->indx)			\
+ 	ptr2_ = ptr2_->next;						\
+ 									\
+       tmp2_ = ((ptr2_ != 0 && ptr2_->indx == ptr1_->indx)		\
+ 	       ? ptr2_ : &bitmap_zero); 				\
+ 									\
+       for (; word_num_ < BITMAP_ELEMENT_WORDS; word_num_++)		\
+ 	{								\
+ 	  ULONGEST word_ = (ptr1_->bits[word_num_]	\
+ 					  & ~ tmp2_->bits[word_num_]);	\
+ 	  if (word_ != 0)						\
+ 	    {								\
+ 	      for (; bit_num_ < (sizeof(ULONGEST)*8); bit_num_++)	\
+ 		{							\
+ 		  ULONGEST mask_				\
+ 		    = ((ULONGEST)1) << bit_num_;		\
+ 									\
+ 		  if ((word_ & mask_) != 0)				\
+ 		    {							\
+ 		      word_ &= ~ mask_;					\
+ 		      (BITNUM) = (ptr1_->indx * BITMAP_ELEMENT_ALL_BITS \
+ 				  + word_num_ * (sizeof(ULONGEST)*8)  \
+ 				  + bit_num_);				\
+ 									\
+ 		      CODE;						\
+ 		      if (word_ == 0)					\
+ 			break;						\
+ 		    }							\
+ 		}							\
+ 	    }								\
+ 									\
+ 	  bit_num_ = 0;							\
+ 	}								\
+ 									\
+       word_num_ = 0;							\
+     }									\
+ } while (0)
+ 
+ /* Loop over all bits in BITMAP1 and BITMAP2, starting with MIN, setting
+    BITNUM to the bit number and executing CODE for all bits that are set in
+    the both bitmaps. */
+ 
+ #define EXECUTE_IF_AND_IN_BITMAP(BITMAP1, BITMAP2, MIN, BITNUM, CODE)	\
+ do {									\
+   bitmap_element *ptr1_ = (BITMAP1)->first;				\
+   bitmap_element *ptr2_ = (BITMAP2)->first;				\
+   unsigned int indx_ = (MIN) / BITMAP_ELEMENT_ALL_BITS;			\
+   unsigned bit_num_ = (MIN) % ((unsigned) (sizeof(ULONGEST)*8));	\
+   unsigned word_num_ = (((MIN) / ((unsigned) (sizeof(ULONGEST)*8)))	\
+ 			% BITMAP_ELEMENT_WORDS);			\
+ 									\
+   /* Find the block the minimum bit is in in the first bitmap.  */	\
+   while (ptr1_ != 0 && ptr1_->indx < indx_)				\
+     ptr1_ = ptr1_->next;						\
+ 									\
+   if (ptr1_ != 0 && ptr1_->indx != indx_)				\
+     {									\
+       bit_num_ = 0;							\
+       word_num_ = 0;							\
+     }									\
+ 									\
+   for (; ptr1_ != 0 ; ptr1_ = ptr1_->next)				\
+     {									\
+       /* Advance BITMAP2 to the equivalent link */			\
+       while (ptr2_ != 0 && ptr2_->indx < ptr1_->indx)			\
+ 	ptr2_ = ptr2_->next;						\
+ 									\
+       if (ptr2_ == 0)							\
+ 	{								\
+ 	  /* If there are no more elements in BITMAP2, exit loop now.*/	\
+ 	  ptr1_ = (bitmap_element *)0;					\
+ 	  break;							\
+ 	}								\
+       else if (ptr2_->indx > ptr1_->indx)				\
+ 	{								\
+ 	  bit_num_ = word_num_ = 0;					\
+ 	  continue;							\
+ 	}								\
+ 									\
+       for (; word_num_ < BITMAP_ELEMENT_WORDS; word_num_++)		\
+ 	{								\
+ 	  ULONGEST word_ = (ptr1_->bits[word_num_]	\
+ 					  & ptr2_->bits[word_num_]);	\
+ 	  if (word_ != 0)						\
+ 	    {								\
+ 	      for (; bit_num_ < (sizeof(ULONGEST)*8); bit_num_++)	\
+ 		{							\
+ 		  ULONGEST mask_				\
+ 		    = ((ULONGEST)1) << bit_num_;		\
+ 									\
+ 		  if ((word_ & mask_) != 0)				\
+ 		    {							\
+ 		      word_ &= ~ mask_;					\
+ 		      (BITNUM) = (ptr1_->indx * BITMAP_ELEMENT_ALL_BITS \
+ 				  + word_num_ * (sizeof(ULONGEST)*8)  \
+ 				  + bit_num_);				\
+ 									\
+ 		      CODE;						\
+ 		      if (word_ == 0)					\
+ 			break;						\
+ 		    }							\
+ 		}							\
+ 	    }								\
+ 									\
+ 	  bit_num_ = 0;							\
+ 	}								\
+ 									\
+       word_num_ = 0;							\
+     }									\
+ } while (0)
+ 
+ #endif /* GCC_BITMAP_H */
Index: buildsym.c
===================================================================
RCS file: /cvs/src/src/gdb/buildsym.c,v
retrieving revision 1.11
diff -c -3 -p -w -B -b -r1.11 buildsym.c
*** buildsym.c	2001/04/30 10:30:27	1.11
--- buildsym.c	2001/06/26 02:28:32
***************
*** 44,50 ****
--- 44,53 ----
  /**/
  #include "buildsym.h"		/* Our own declarations */
  #undef	EXTERN
+ #include "demangle.h"
+ #include "splay-tree.h"
  
+ 
  /* For cleanup_undefined_types and finish_global_stabs (somewhat
     questionable--see comment where we call them).  */
  
***************
*** 50,59 ****
--- 53,68 ----
  
  #include "stabsread.h"
  
+ static int block_id = 0;
+ 
+ splay_tree symbolsplay = 0;
  /* List of free `struct pending' structures for reuse.  */
  
  static struct pending *free_pendings;
  
+ static int compare_blocks (const void *v1, const void *v2);
+ 
+ static int compare_names (splay_tree_key v1, splay_tree_key v2);
  /* Non-zero if symtab has line number info.  This prevents an
     otherwise empty symtab from being tossed.  */
  
*************** finish_block (struct symbol *symbol, str
*** 242,247 ****
--- 251,257 ----
    block = (struct block *) obstack_alloc (&objfile->symbol_obstack,
  	    (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *))));
  
+   BLOCK_ID (block) = block_id++;
    /* Copy the symbols into the block.  */
  
    BLOCK_NSYMS (block) = i;
*************** finish_block (struct symbol *symbol, str
*** 249,254 ****
--- 259,283 ----
      {
        for (j = next->nsyms - 1; j >= 0; j--)
  	{
+ 	  splay_tree_node result;
+ 	  struct block_splay_data *temp;
+ 	  const char *symname;
+ 	  SYMBOL_INIT_DEMANGLED_NAME (next->symbol[j], &objfile->symbol_obstack);  
+ 	  symname = SYMBOL_SOURCE_NAME (next->symbol[j]);
+ 	  result = splay_tree_lookup (symbolsplay, (splay_tree_key) symname);
+ 	  if (result != NULL)
+ 	    {
+ 	      temp = (struct block_splay_data *)result->value;
+ 	      bitmap_set_bit (temp->blocks, BLOCK_ID (block));
+ 	    }
+ 	  else
+ 	    {
+ 	      temp = xmalloc (sizeof (struct block_splay_data));
+ 	      temp->blocks = BITMAP_XMALLOC();
+ 	      bitmap_set_bit (temp->blocks, BLOCK_ID (block));
+ 	      splay_tree_insert (symbolsplay, (splay_tree_key)symname, (splay_tree_value) temp);
+ 	    }
+ 	  
  	  BLOCK_SYM (block, --i) = next->symbol[j];
  	}
      }
*************** make_blockvector (struct objfile *objfil
*** 481,520 ****
        BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
      }
  
- #if 0				/* Now we make the links in the
- 				   obstack, so don't free them.  */
-   /* Now free the links of the list, and empty the list.  */
- 
-   for (next = pending_blocks; next; next = next1)
-     {
-       next1 = next->next;
-       xfree (next);
-     }
- #endif
    pending_blocks = NULL;
  
! #if 1				/* FIXME, shut this off after a while
! 				   to speed up symbol reading.  */
!   /* Some compilers output blocks in the wrong order, but we depend on
!      their being in the right order so we can binary search. Check the
!      order and moan about it.  FIXME.  */
!   if (BLOCKVECTOR_NBLOCKS (blockvector) > 1)
!     {
!       for (i = 1; i < BLOCKVECTOR_NBLOCKS (blockvector); i++)
! 	{
! 	  if (BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i - 1))
! 	      > BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i)))
  	    {
! 	      CORE_ADDR start
! 		= BLOCK_START (BLOCKVECTOR_BLOCK (blockvector, i));
! 
! 	      complain (&blockvector_complaint,
! 			longest_local_hex_string ((LONGEST) start));
! 	    }
  	}
-     }
- #endif
- 
    return (blockvector);
  }
  
--- 510,525 ----
        BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
      }
  
    pending_blocks = NULL;
  
!   if (objfile->flags & OBJF_REORDERED)
      {
!       if (BLOCKVECTOR_NBLOCKS (blockvector) > 2)
! 	qsort (&blockvector->block[2], 
! 	       BLOCKVECTOR_NBLOCKS (blockvector) - 2,
! 	       sizeof (struct block *),
! 	       compare_blocks);
      }
    return (blockvector);
  }
  
*************** record_line (register struct subfile *su
*** 730,735 ****
--- 735,764 ----
    e->pc = ADDR_BITS_REMOVE(pc);
  }
  
+ static int
+ compare_blocks (const void *v1, const void *v2)
+ {
+   const struct block *const *b1 = v1;
+   const struct block *const *b2 = v2;
+ 
+   if ((*b1)->startaddr < (*b2)->startaddr)
+     return -1;
+   else if ((*b1)->startaddr > (*b2)->startaddr)
+     return 1;
+   else if ((*b1)->endaddr < (*b2)->endaddr)
+     return 1;
+   else if ((*b1)->endaddr > (*b2)->endaddr)
+     return -1;
+   else
+     return 0;
+ }
+ static int
+ compare_names (splay_tree_key v1, splay_tree_key v2)
+ {
+   const char *b1 = (const char *)v1;
+   const char *b2 = (const char *)v2;
+   return (strcmp (b1, b2));
+ }
  /* Needed in order to sort line tables from IBM xcoff files.  Sigh!  */
  
  static int
*************** void
*** 1122,1125 ****
--- 1151,1161 ----
  buildsym_new_init (void)
  {
    buildsym_init ();
+ }
+ void
+ _initialize_buildsym (void)
+ {
+   symbolsplay = splay_tree_new (compare_names, 
+ 				NULL, 
+ 				(splay_tree_delete_value_fn)free);
  }
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.41
diff -c -3 -p -w -B -b -r1.41 symtab.c
*** symtab.c	2001/06/13 18:30:07	1.41
--- symtab.c	2001/06/26 02:28:38
*************** lookup_symbol (const char *name, const s
*** 584,589 ****
--- 584,590 ----
  
    return returnval;	 
  }
+ extern splay_tree symbolsplay;
  
  static struct symbol *
  lookup_symbol_aux (const char *name, const struct block *block,
*************** lookup_symbol_aux (const char *name, con
*** 597,608 ****
    register struct objfile *objfile = NULL;
    register struct block *b;
    register struct minimal_symbol *msymbol;
  
  
    /* Search specified block and its superiors.  */
! 
    while (block != 0)
      {
        sym = lookup_block_symbol (block, name, namespace);
        if (sym)
  	{
--- 598,620 ----
    register struct objfile *objfile = NULL;
    register struct block *b;
    register struct minimal_symbol *msymbol;
+   register splay_tree_node result;
+   int skipblocksearches=0;
+   struct block_splay_data *splaydata=0;
+   result = splay_tree_lookup (symbolsplay, (splay_tree_key) name);
+   if (result == NULL)
+     skipblocksearches = 1;
+   else
+     splaydata = (struct block_splay_data *)result->value;
  
  
    /* Search specified block and its superiors.  */
!   if (!skipblocksearches)
!     {
        while (block != 0)
  	{
+ 	  if (bitmap_bit_p (splaydata->blocks, BLOCK_ID (block)))
+ 	    {
  	      sym = lookup_block_symbol (block, name, namespace);
  	      if (sym)
  		{
*************** lookup_symbol_aux (const char *name, con
*** 625,670 ****
  
  	  return fixup_symbol_section (sym, objfile);
  	}
-       block = BLOCK_SUPERBLOCK (block);
-     }
- 
-   /* FIXME: this code is never executed--block is always NULL at this
-      point.  What is it trying to do, anyway?  We already should have
-      checked the STATIC_BLOCK above (it is the superblock of top-level
-      blocks).  Why is VAR_NAMESPACE special-cased?  */
-   /* Don't need to mess with the psymtabs; if we have a block,
-      that file is read in.  If we don't, then we deal later with
-      all the psymtab stuff that needs checking.  */
-   /* Note (RT): The following never-executed code looks unnecessary to me also.
-    * If we change the code to use the original (passed-in)
-    * value of 'block', we could cause it to execute, but then what
-    * would it do? The STATIC_BLOCK of the symtab containing the passed-in
-    * 'block' was already searched by the above code. And the STATIC_BLOCK's
-    * of *other* symtabs (those files not containing 'block' lexically)
-    * should not contain 'block' address-wise. So we wouldn't expect this
-    * code to find any 'sym''s that were not found above. I vote for 
-    * deleting the following paragraph of code.
-    */
-   if (namespace == VAR_NAMESPACE && block != NULL)
-     {
-       struct block *b;
-       /* Find the right symtab.  */
-       ALL_SYMTABS (objfile, s)
-       {
- 	bv = BLOCKVECTOR (s);
- 	b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- 	if (BLOCK_START (b) <= BLOCK_START (block)
- 	    && BLOCK_END (b) > BLOCK_START (block))
- 	  {
- 	    sym = lookup_block_symbol (b, name, VAR_NAMESPACE);
- 	    if (sym)
- 	      {
- 		block_found = b;
- 		if (symtab != NULL)
- 		  *symtab = s;
- 		return fixup_symbol_section (sym, objfile);
- 	      }
  	  }
        }
      }
  
--- 637,644 ----
  		  
  		  return fixup_symbol_section (sym, objfile);
  		}
  	    }
+ 	  block = BLOCK_SUPERBLOCK (block);
  	}
      }
  
*************** lookup_symbol_aux (const char *name, con
*** 689,699 ****
       check the psymtab's. If a psymtab indicates the existence
       of the desired name as a global, then do psymtab-to-symtab
       conversion on the fly and return the found symbol. */
! 
    ALL_SYMTABS (objfile, s)
    {
      bv = BLOCKVECTOR (s);
      block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
      sym = lookup_block_symbol (block, name, namespace);
      if (sym)
        {
--- 662,675 ----
       check the psymtab's. If a psymtab indicates the existence
       of the desired name as a global, then do psymtab-to-symtab
       conversion on the fly and return the found symbol. */
!   if (!skipblocksearches)
!     {
        ALL_SYMTABS (objfile, s)
  	{
  	  bv = BLOCKVECTOR (s);
  	  block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ 	  if (bitmap_bit_p (splaydata->blocks, BLOCK_ID (block)))
+ 	    {
  	      sym = lookup_block_symbol (block, name, namespace);
  	      if (sym)
  		{
*************** lookup_symbol_aux (const char *name, con
*** 703,709 ****
  	return fixup_symbol_section (sym, objfile);
        }
    }
! 
  #ifndef HPUXHPPA
  
    /* Check for the possibility of the symbol being a function or
--- 679,686 ----
  		  return fixup_symbol_section (sym, objfile);
  		}
  	    }
! 	}
!     }
  #ifndef HPUXHPPA
  
    /* Check for the possibility of the symbol being a function or
*************** lookup_symbol_aux (const char *name, con
*** 802,812 ****
       If a psymtab indicates the existence
       of the desired name as a file-level static, then do psymtab-to-symtab
       conversion on the fly and return the found symbol. */
! 
    ALL_SYMTABS (objfile, s)
    {
      bv = BLOCKVECTOR (s);
      block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
      sym = lookup_block_symbol (block, name, namespace);
      if (sym)
        {
--- 779,792 ----
       If a psymtab indicates the existence
       of the desired name as a file-level static, then do psymtab-to-symtab
       conversion on the fly and return the found symbol. */
!   if (!skipblocksearches)
!     {
        ALL_SYMTABS (objfile, s)
  	{
  	  bv = BLOCKVECTOR (s);
  	  block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ 	  if (bitmap_bit_p (splaydata->blocks, BLOCK_ID (block)))
+ 	    {
  	      sym = lookup_block_symbol (block, name, namespace);
  	      if (sym)
  		{
*************** lookup_symbol_aux (const char *name, con
*** 816,822 ****
  	return fixup_symbol_section (sym, objfile);
        }
    }
! 
    ALL_PSYMTABS (objfile, ps)
    {
      if (!ps->readin && lookup_partial_symbol (ps, name, 0, namespace))
--- 796,803 ----
  		  return fixup_symbol_section (sym, objfile);
  		}
  	    }
! 	}
!     }
    ALL_PSYMTABS (objfile, ps)
    {
      if (!ps->readin && lookup_partial_symbol (ps, name, 0, namespace))
*************** find_pc_sect_symtab (CORE_ADDR pc, asect
*** 1374,1379 ****
--- 1355,1362 ----
    register struct objfile *objfile;
    CORE_ADDR distance = 0;
  
+   if (pc == 0)
+     return NULL;
    /* Search all symtabs for the one whose file contains our address, and which
       is the smallest of all the ones containing the address.  This is designed
       to deal with a case like symtab a is at 0x1000-0x2000 and 0x3000-0x4000
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.23
diff -c -3 -p -w -B -b -r1.23 symtab.h
*** symtab.h	2001/06/12 15:03:04	1.23
--- symtab.h	2001/06/26 02:28:39
***************
*** 41,46 ****
--- 41,49 ----
  #define	BYTE_BITFIELD		/*nothing */
  #endif
  
+ #include "bitmap.h"
+ #include "splay-tree.h"
+ 
  /* Define a structure for the information that is common to all symbol types,
     including minimal symbols, partial symbols, and full symbols.  In a
     multilanguage environment, some language specific information may need to
*************** struct blockvector
*** 416,424 ****
--- 419,433 ----
  #define	STATIC_BLOCK		1
  #define	FIRST_LOCAL_BLOCK	2
  
+ struct block_splay_data
+ {
+   bitmap blocks;
+ };
  struct block
    {
  
+     /* Unique block ID */
+     unsigned int id;
      /* Addresses in the executable code that are in this block.  */
  
      CORE_ADDR startaddr;
*************** struct block
*** 451,457 ****
  
      /* Number of local symbols.  */
  
!     int nsyms;
  
      /* The symbols.  If some of them are arguments, then they must be
         in the order in which we would like to print them.  */
--- 460,466 ----
  
      /* Number of local symbols.  */
  
!     unsigned int nsyms;
  
      /* The symbols.  If some of them are arguments, then they must be
         in the order in which we would like to print them.  */
*************** struct block
*** 466,471 ****
--- 475,481 ----
  #define BLOCK_FUNCTION(bl)	(bl)->function
  #define BLOCK_SUPERBLOCK(bl)	(bl)->superblock
  #define BLOCK_GCC_COMPILED(bl)	(bl)->gcc_compile_flag
+ #define BLOCK_ID(bl)            (bl)->id
  
  /* Nonzero if symbols of block BL should be sorted alphabetically.
     Don't sort a block which corresponds to a function.  If we did the

-- 
"I have the world's largest collection of seashells.  I keep it
on all the beaches of the world...  Perhaps you've seen it.
"-Steven Wright


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