*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / symmisc.c
index f440f07ab31e48e3454811c0fdc066b60848a386..995372d1d05242966eb4beee79c4a37282c6259c 100644 (file)
@@ -1,6 +1,8 @@
 /* Do various things to symbol tables (other than lookup), for GDB.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+   1995, 1996, 1997, 1998, 1999, 2000, 2002 Free Software Foundation,
+   Inc.
 
    This file is part of GDB.
 
 #include "objfiles.h"
 #include "breakpoint.h"
 #include "command.h"
-#include "obstack.h"
+#include "gdb_obstack.h"
 #include "language.h"
 #include "bcache.h"
 
 #include "gdb_string.h"
+#include <readline/readline.h>
 
 #ifndef DEV_TTY
 #define DEV_TTY "/dev/tty"
@@ -75,7 +78,7 @@ struct print_symbol_args
     struct ui_file *outfile;
   };
 
-static int print_symbol (PTR);
+static int print_symbol (void *);
 
 static void free_symtab_block (struct objfile *, struct block *);
 \f
@@ -86,13 +89,19 @@ static void
 free_symtab_block (struct objfile *objfile, struct block *b)
 {
   register int i, n;
-  n = BLOCK_NSYMS (b);
+  struct symbol *sym, *next_sym;
+
+  n = BLOCK_BUCKETS (b);
   for (i = 0; i < n; i++)
     {
-      mfree (objfile->md, SYMBOL_NAME (BLOCK_SYM (b, i)));
-      mfree (objfile->md, (PTR) BLOCK_SYM (b, i));
+      for (sym = BLOCK_BUCKET (b, i); sym; sym = next_sym)
+       {
+         next_sym = sym->hash_next;
+         xmfree (objfile->md, SYMBOL_NAME (sym));
+         xmfree (objfile->md, sym);
+       }
     }
-  mfree (objfile->md, (PTR) b);
+  xmfree (objfile->md, b);
 }
 
 /* Free all the storage associated with the struct symtab <- S.
@@ -126,7 +135,7 @@ free_symtab (register struct symtab *s)
       for (i = 0; i < n; i++)
        free_symtab_block (s->objfile, BLOCKVECTOR_BLOCK (bv, i));
       /* Free the blockvector itself.  */
-      mfree (s->objfile->md, (PTR) bv);
+      xmfree (s->objfile->md, bv);
       /* Also free the linetable.  */
 
     case free_linetable:
@@ -134,22 +143,22 @@ free_symtab (register struct symtab *s)
          or by some other symtab, except for our linetable.
          Free that now.  */
       if (LINETABLE (s))
-       mfree (s->objfile->md, (PTR) LINETABLE (s));
+       xmfree (s->objfile->md, LINETABLE (s));
       break;
     }
 
   /* If there is a single block of memory to free, free it.  */
   if (s->free_ptr != NULL)
-    mfree (s->objfile->md, s->free_ptr);
+    xmfree (s->objfile->md, s->free_ptr);
 
   /* Free source-related stuff */
   if (s->line_charpos != NULL)
-    mfree (s->objfile->md, (PTR) s->line_charpos);
+    xmfree (s->objfile->md, s->line_charpos);
   if (s->fullname != NULL)
-    mfree (s->objfile->md, s->fullname);
+    xmfree (s->objfile->md, s->fullname);
   if (s->debugformat != NULL)
-    mfree (s->objfile->md, s->debugformat);
-  mfree (s->objfile->md, (PTR) s);
+    xmfree (s->objfile->md, s->debugformat);
+  xmfree (s->objfile->md, s);
 }
 
 void
@@ -161,7 +170,7 @@ print_symbol_bcache_statistics (void)
   ALL_OBJFILES (objfile)
   {
     printf_filtered ("Byte cache statistics for '%s':\n", objfile->name);
-    print_bcache_statistics (&objfile->psymbol_cache, "partial symbol cache");
+    print_bcache_statistics (objfile->psymbol_cache, "partial symbol cache");
   }
   immediate_quit--;
 }
@@ -196,7 +205,9 @@ print_objfile_statistics (void)
     printf_filtered ("  Total memory used for psymbol obstack: %d\n",
                     obstack_memory_used (&objfile->psymbol_obstack));
     printf_filtered ("  Total memory used for psymbol cache: %d\n",
-                    obstack_memory_used (&objfile->psymbol_cache.cache));
+                    bcache_memory_used (objfile->psymbol_cache));
+    printf_filtered ("  Total memory used for macro cache: %d\n",
+                    bcache_memory_used (objfile->macro_cache));
     printf_filtered ("  Total memory used for symbol obstack: %d\n",
                     obstack_memory_used (&objfile->symbol_obstack));
     printf_filtered ("  Total memory used for type obstack: %d\n",
@@ -357,7 +368,7 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
                        "  Full symtab was read (at ");
       gdb_print_host_address (psymtab->symtab, outfile);
       fprintf_filtered (outfile, " by function at ");
-      gdb_print_host_address ((PTR) psymtab->read_symtab, outfile);
+      gdb_print_host_address (psymtab->read_symtab, outfile);
       fprintf_filtered (outfile, ")\n");
     }
 
@@ -455,8 +466,14 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
              fprintf_filtered (outfile, " under ");
              gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile);
            }
-         blen = BLOCK_NSYMS (b);
-         fprintf_filtered (outfile, ", %d syms in ", blen);
+         /* drow/2002-07-10: We could save the total symbols count
+            even if we're using a hashtable, but nothing else but this message
+            wants it.  */
+         blen = BLOCK_BUCKETS (b);
+         if (BLOCK_HASHTABLE (b))
+           fprintf_filtered (outfile, ", %d buckets in ", blen);
+         else
+           fprintf_filtered (outfile, ", %d syms in ", blen);
          print_address_numeric (BLOCK_START (b), 1, outfile);
          fprintf_filtered (outfile, "..");
          print_address_numeric (BLOCK_END (b), 1, outfile);
@@ -472,8 +489,8 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
          if (BLOCK_GCC_COMPILED (b))
            fprintf_filtered (outfile, ", compiled with gcc%d", BLOCK_GCC_COMPILED (b));
          fprintf_filtered (outfile, "\n");
-         /* Now print each symbol in this block.  */
-         /* FIXMED: Sort?  */
+         /* Now print each symbol in this block (in no particular order, if
+            we're using a hashtable).  */
          ALL_BLOCK_SYMBOLS (b, j, sym)
            {
              struct print_symbol_args s;
@@ -548,7 +565,7 @@ Arguments missing: an output file name and an optional symbol file name");
    1 for success.  */
 
 static int
-print_symbol (PTR args)
+print_symbol (void *args)
 {
   struct symbol *symbol = ((struct print_symbol_args *) args)->symbol;
   int depth = ((struct print_symbol_args *) args)->depth;
@@ -959,7 +976,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
     while (length--)
       {
        sym = lookup_block_symbol (b, SYMBOL_NAME (*psym),
-                                  SYMBOL_NAMESPACE (*psym));
+                                  NULL, SYMBOL_NAMESPACE (*psym));
        if (!sym)
          {
            printf_filtered ("Static symbol `");
@@ -976,7 +993,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
     while (length--)
       {
        sym = lookup_block_symbol (b, SYMBOL_NAME (*psym),
-                                  SYMBOL_NAMESPACE (*psym));
+                                  NULL, SYMBOL_NAMESPACE (*psym));
        if (!sym)
          {
            printf_filtered ("Global symbol `");
This page took 0.026159 seconds and 4 git commands to generate.