]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2002-09-18 David Carlton <carlton@math.stanford.edu>
authorDavid Carlton <carlton@bactrian.org>
Fri, 20 Sep 2002 18:52:16 +0000 (18:52 +0000)
committerDavid Carlton <carlton@bactrian.org>
Fri, 20 Sep 2002 18:52:16 +0000 (18:52 +0000)
* symtab.h: Delete BLOCK_SHOULD_SORT.
* symtab.c (lookup_block_symbol): Assume non-hashed blocks aren't
sorted.
* ada-lang.c (ada_add_block_symbols): Ditto.
* symfile.h: Delete prototypes for sort_block_syms and
sort_symtab_syms.
* symfile.c: Delete functions sort_block_syms and
sort_symtab_syms.
* coffread.c (coff_symfile_read): Remove call to
sort_symtab_syms.
* xcoffread.c (xcoff_psymtab_to_symtab_1): Ditto.
* mdebugread.c (psymtab_to_symtab_1): Ditto.
* hpread.c (hpread_psymtab_to_symtab_1): Ditto.
* dwarfread.c (psymtab_to_symtab_1): Ditto.
* dwarf2read.c (psymtab_to_symtab_1): Ditto.
* dbxread.c (dbx_psymtab_to_symtab_1): Ditto.

2002-09-20  David Carlton  <carlton@math.stanford.edu>

* Makefile.in (c-lang.o): Correct dependencies.
(utils.o): Gather dependencies.
(charset.o): Move.

15 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/ada-lang.c
gdb/c-lang.c
gdb/coffread.c
gdb/dbxread.c
gdb/dwarf2read.c
gdb/dwarfread.c
gdb/hpread.c
gdb/mdebugread.c
gdb/symfile.c
gdb/symfile.h
gdb/symtab.c
gdb/symtab.h
gdb/xcoffread.c

index ec776f7ffeda122012bf578fdb562d73846b0355..6deb7ebbf7cf70e195979e2bf18533d3eee4a425 100644 (file)
@@ -1,3 +1,29 @@
+2002-09-18  David Carlton  <carlton@math.stanford.edu>
+
+       * symtab.h: Delete BLOCK_SHOULD_SORT.
+       * symtab.c (lookup_block_symbol): Assume non-hashed blocks aren't
+       sorted.
+       * ada-lang.c (ada_add_block_symbols): Ditto.
+       * symfile.h: Delete prototypes for sort_block_syms and
+       sort_symtab_syms.
+       * symfile.c: Delete functions sort_block_syms and
+       sort_symtab_syms.
+       * coffread.c (coff_symfile_read): Remove call to
+       sort_symtab_syms.
+       * xcoffread.c (xcoff_psymtab_to_symtab_1): Ditto.
+       * mdebugread.c (psymtab_to_symtab_1): Ditto.
+       * hpread.c (hpread_psymtab_to_symtab_1): Ditto.
+       * dwarfread.c (psymtab_to_symtab_1): Ditto.
+       * dwarf2read.c (psymtab_to_symtab_1): Ditto.
+       * dbxread.c (dbx_psymtab_to_symtab_1): Ditto.
+
+2002-09-20  David Carlton  <carlton@math.stanford.edu>
+
+       * Makefile.in (c-lang.o): Correct dependencies.
+       (utils.o): Gather dependencies.
+       (charset.o): Move.
+       * c-lang.c: #include "gdb_string.h"
+
 2002-09-20  Fernando Nasser  <fnasser@redhat.com>
 
        From 2002-07-02  George Helffrich <george@gly.bris.ac.uk>
index ca17a2b07a2bc8d3fbf6c07ef2e32fca83f03fa4..0eadd02419b6cf40581aabe218b31617640e86fe 100644 (file)
@@ -1560,7 +1560,7 @@ builtin-regs.o: builtin-regs.c $(defs_h) $(builtin_regs_h) $(gdbtypes_h) \
        $(gdb_string_h) $(gdb_assert_h)
 c-lang.o: c-lang.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
        $(parser_defs_h) $(language_h) $(c_lang_h) $(valprint_h) \
-       $(macroscope_h) $(gdb_assert_h)
+       $(macroscope_h) $(gdb_assert_h) $(charset_h) $(gdb_string_h)
 c-typeprint.o: c-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \
        $(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(target_h) \
        $(language_h) $(demangle_h) $(c_lang_h) $(typeprint_h) $(cp_abi_h) \
@@ -1572,6 +1572,7 @@ c-valprint.o: c-valprint.c $(defs_h) $(gdb_string_h) $(symtab_h) \
 # OBSOLETE ch-lang.o: ch-lang.c
 # OBSOLETE ch-typeprint.o: ch-typeprint.c
 # OBSOLETE ch-valprint.o: ch-valprint.c
+charset.o: charset.c $(defs_h) $(charset_h) $(gdbcmd_h) gdb_assert.h
 cli-out.o: cli-out.c $(defs_h) $(ui_out_h) $(cli_out_h) $(gdb_string_h) \
        $(gdb_assert_h)
 coff-solib.o: coff-solib.c $(defs_h) $(frame_h) $(bfd_h) $(gdbcore_h) \
@@ -2242,7 +2243,7 @@ ui-out.o: ui-out.c $(defs_h) $(gdb_string_h) $(expression_h) $(language_h) \
 utils.o: utils.c $(config_h) $(defs_h) $(gdb_assert_h) $(gdb_string_h) \
        $(event_top_h) $(gdbcmd_h) $(serial_h) $(bfd_h) $(target_h) \
        $(demangle_h) $(expression_h) $(language_h) $(annotate_h) \
-       $(filenames_h) $(inferior_h) $(mmalloc_h)
+       $(filenames_h) $(inferior_h) $(mmalloc_h) $(charset_h)
 uw-thread.o: uw-thread.c $(defs_h) $(gdbthread_h) $(target_h) $(inferior_h) \
        $(regcache_h) $(gregset_h)
 v850-tdep.o: v850-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
@@ -2588,8 +2589,4 @@ xdr_rdb.o: vx-share/xdr_rdb.c $(defs_h) vx-share/vxTypes.h \
        vx-share/vxWorks.h vx-share/xdr_rdb.h
        $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/vx-share/xdr_rdb.c
 
-charset.o: charset.c $(defs_h) $(charset_h) $(gdbcmd_h) gdb_assert.h
-
-c-lang.o: $(charset_h)
-utils.o: $(charset_h)
 ### end of the gdb Makefile.in.
index 2838df7e68c667f0f2235e00df186a1d6a65f345..647f2c24487c0c23023cae9127acac4201374fe1 100644 (file)
@@ -3949,7 +3949,6 @@ ada_add_block_symbols (struct block *block, const char *name,
   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;
@@ -3985,45 +3984,14 @@ ada_add_block_symbols (struct block *block, const char *name,
     }
   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 (SYMBOL_NAME (sym)[0] < name[0])
-               i = M + 1;
-             else if (SYMBOL_NAME (sym)[0] > name[0])
-               U = M - 1;
-             else if (strcmp (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_NAMESPACE (sym) == namespace)
              {
                int cmp = strncmp (name, SYMBOL_NAME (sym), name_len);
 
-               if (cmp < 0)
-                 {
-                   if (is_sorted)
-                     {
-                       i = BLOCK_BUCKETS (block);
-                       break;
-                     }
-                 }
-               else if (cmp == 0
-                        && is_name_suffix (SYMBOL_NAME (sym) + name_len))
+               if (cmp == 0
+                   && is_name_suffix (SYMBOL_NAME (sym) + name_len))
                  {
                    switch (SYMBOL_CLASS (sym))
                      {
@@ -4059,30 +4027,8 @@ ada_add_block_symbols (struct block *block, const char *name,
     {
       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 (SYMBOL_NAME (sym)[0] < '_')
-               i = M + 1;
-             else if (SYMBOL_NAME (sym)[0] > '_')
-               U = M - 1;
-             else if (strcmp (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);
 
@@ -4098,16 +4044,8 @@ ada_add_block_symbols (struct block *block, const char *name,
                      cmp = strncmp (name, SYMBOL_NAME (sym) + 5, name_len);
                  }
 
-               if (cmp < 0)
-                 {
-                   if (is_sorted)
-                     {
-                       i = BLOCK_BUCKETS (block);
-                       break;
-                     }
-                 }
-               else if (cmp == 0
-                        && is_name_suffix (SYMBOL_NAME (sym) + name_len + 5))
+               if (cmp == 0
+                   && is_name_suffix (SYMBOL_NAME (sym) + name_len + 5))
                  {
                    switch (SYMBOL_CLASS (sym))
                      {
index 6bbd6d9829622a59a5eff3e8b64d52608be73c71..4b4af164ec5968d54bac6ef8ef957e83fcac80c4 100644 (file)
@@ -30,6 +30,7 @@
 #include "macroscope.h"
 #include "gdb_assert.h"
 #include "charset.h"
+#include "gdb_string.h"
 
 extern void _initialize_c_language (void);
 static void c_emit_char (int c, struct ui_file * stream, int quoter);
index d794a7d382a567434321511987e2d48c6771ea6b..4e71dac5549af00dfb2342f34a0b4f8578c8bbc2 100644 (file)
@@ -637,15 +637,6 @@ coff_symfile_read (struct objfile *objfile, int mainline)
 
   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 6592b74338b2764018200886cfa9213580658cc8..1991dc0bc9a28eef057e5c78ec6592d6915eb1f0 100644 (file)
@@ -2452,7 +2452,6 @@ dbx_psymtab_to_symtab_1 (struct partial_symtab *pst)
       /* 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 4ef683c13dca6cc159ef2284247173d01cd48fc2..a186a59694488335cb5643df6e7b950346855f39 100644 (file)
@@ -1606,7 +1606,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
     }
   pst->symtab = symtab;
   pst->readin = 1;
-  sort_symtab_syms (pst->symtab);
 
   do_cleanups (back_to);
 }
index 9c4201de1c3a1a4dd74371dcf5414289548b4c51..975c9af9cbf0b06e003aac75bdef65a50ff6a2b8 100644 (file)
@@ -2364,7 +2364,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
                  wrap_here ("");
                  gdb_flush (gdb_stdout);
                }
-             sort_symtab_syms (pst->symtab);
              do_cleanups (old_chain);
            }
          pst->readin = 1;
index 4cc5f18c4771e3caf4f8581ac7877786f052b4e8..793fdbd0f5f42eaf295892005d963aed041b2608 100644 (file)
@@ -2729,7 +2729,6 @@ hpread_psymtab_to_symtab_1 (struct partial_symtab *pst)
        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 1695afdf1780f1b47e60f067a22649178e95d8ce..de2c9011be00e0589e5c30f2505a5be0fadf933a 100644 (file)
@@ -3960,10 +3960,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
          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,
@@ -4158,9 +4154,6 @@ psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename)
 
       st->primary = 1;
 
-      /* Sort the symbol table now, we are done adding symbols to it. */
-      sort_symtab_syms (st);
-
       sort_blocks (st);
     }
 
index 66bbf7149844f448329f35dda9f008ad745038f6..5e154b2a6a0ee9b8b70c6a87db3d02e0341b71c6 100644 (file)
@@ -261,38 +261,6 @@ sort_pst_symbols (struct partial_symtab *pst)
         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 39eb3080f13c9522d31e2f97da660cc29016a211..8c8fae5dd15675075dbd312d7cebb502082f7f2c 100644 (file)
@@ -198,12 +198,6 @@ extern struct partial_symtab *start_psymtab_common (struct objfile *,
                                                    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 a4322926e2f8d5e6030dc3cf4d41c671049f8f57..0c299b472a6514a1d18dfd8c9508596a31228fb7 100644 (file)
@@ -1335,10 +1335,9 @@ lookup_block_symbol (register const struct block *block, const char *name,
                     const char *mangled_name,
                     const namespace_enum namespace)
 {
-  register int bot, top, inc;
+  register int bot, top;
   register struct symbol *sym;
   register struct symbol *sym_found = NULL;
-  register int do_linear_search = 1;
 
   if (BLOCK_HASHTABLE (block))
     {
@@ -1355,103 +1354,27 @@ lookup_block_symbol (register const struct block *block, const char *name,
        }
       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_SOURCE_NAME (sym)[0] < name[0])
-           {
-             bot = inc;
-           }
-         else if (SYMBOL_SOURCE_NAME (sym)[0] > name[0])
-           {
-             top = inc;
-           }
-         else if (strcmp (SYMBOL_SOURCE_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 namespace, we
-         return the first one; I believe it is now impossible for us
-         to encounter two symbols with the same name and namespace
-         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_NAMESPACE (sym) == namespace
-             && (mangled_name
-                 ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
-                 : SYMBOL_MATCHES_NAME (sym, name)))
-           {
-             return sym;
-           }
-          if (SYMBOL_SOURCE_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)
        {
          sym = BLOCK_SYM (block, bot);
+         /* If there is more than one symbol with the right name and
+            namespace, we return the first one; I believe it is now
+            impossible for us to encounter two symbols with the same
+            name and namespace 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.  */
          if (SYMBOL_NAMESPACE (sym) == namespace
              && (mangled_name
                  ? strcmp (SYMBOL_NAME (sym), mangled_name) == 0
@@ -1493,8 +1416,8 @@ lookup_block_symbol (register const struct block *block, const char *name,
            }
          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 a78607d584e6f866ecb79056e050c462f6d65939..4cbe5ceb13c15ec82a00bc5e44feae109ff5c323 100644 (file)
@@ -441,13 +441,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)
 \f
 
 /* Represent one symbol name; a variable, constant, function or typedef.  */
index 0e85125791d7439639fa06d39b20dddf2c962d2d..9618bdc290628d8bf8b9f00e0007cd4104b7e384 100644 (file)
@@ -1768,7 +1768,6 @@ xcoff_psymtab_to_symtab_1 (struct partial_symtab *pst)
       old_chain = make_cleanup (really_free_pendings, 0);
 
       read_xcoff_symtab (pst);
-      sort_symtab_syms (pst->symtab);
 
       do_cleanups (old_chain);
     }