*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / symmisc.c
index 2bf70c247d340eb0017da9850fb51fcfe97a4e19..39b10a6a02cf6afea7d08facd90abd42a8b3d4c8 100644 (file)
@@ -1,6 +1,6 @@
 /* Do various things to symbol tables (other than lookup), for GDB.
-   Copyright 1986, 87, 89, 91, 92, 93, 94, 95, 96, 1998
-   Free Software Foundation, Inc.
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -49,53 +49,50 @@ FILE *std_err;
 
 /* Prototypes for local functions */
 
-static void dump_symtab PARAMS ((struct objfile *, struct symtab *,
-                                GDB_FILE *));
+static void dump_symtab (struct objfile *, struct symtab *,
+                        struct ui_file *);
 
-static void dump_psymtab PARAMS ((struct objfile *, struct partial_symtab *,
-                                 GDB_FILE *));
+static void dump_psymtab (struct objfile *, struct partial_symtab *,
+                         struct ui_file *);
 
-static void dump_msymbols PARAMS ((struct objfile *, GDB_FILE *));
+static void dump_msymbols (struct objfile *, struct ui_file *);
 
-static void dump_objfile PARAMS ((struct objfile *));
+static void dump_objfile (struct objfile *);
 
-static int block_depth PARAMS ((struct block *));
+static int block_depth (struct block *);
 
-static void print_partial_symbols PARAMS ((struct partial_symbol **, int,
-                                          char *, GDB_FILE *));
+static void print_partial_symbols (struct partial_symbol **, int,
+                                  char *, struct ui_file *);
 
-static void free_symtab_block PARAMS ((struct objfile *, struct block *));
+static void free_symtab_block (struct objfile *, struct block *);
 
-void _initialize_symmisc PARAMS ((void));
+void _initialize_symmisc (void);
 
 struct print_symbol_args
   {
     struct symbol *symbol;
     int depth;
-    GDB_FILE *outfile;
+    struct ui_file *outfile;
   };
 
-static int print_symbol PARAMS ((PTR));
+static int print_symbol (PTR);
 
-static void
-free_symtab_block PARAMS ((struct objfile *, struct block *));
+static void free_symtab_block (struct objfile *, struct block *);
 \f
 
 /* Free a struct block <- B and all the symbols defined in that block.  */
 
 static void
-free_symtab_block (objfile, b)
-     struct objfile *objfile;
-     struct block *b;
+free_symtab_block (struct objfile *objfile, struct block *b)
 {
   register int i, n;
   n = BLOCK_NSYMS (b);
   for (i = 0; i < n; i++)
     {
-      mfree (objfile->md, SYMBOL_NAME (BLOCK_SYM (b, i)));
-      mfree (objfile->md, (PTR) BLOCK_SYM (b, i));
+      xmfree (objfile->md, SYMBOL_NAME (BLOCK_SYM (b, i)));
+      xmfree (objfile->md, (PTR) BLOCK_SYM (b, i));
     }
-  mfree (objfile->md, (PTR) b);
+  xmfree (objfile->md, (PTR) b);
 }
 
 /* Free all the storage associated with the struct symtab <- S.
@@ -107,8 +104,7 @@ free_symtab_block (objfile, b)
    It is s->free_code that says which alternative to use.  */
 
 void
-free_symtab (s)
-     register struct symtab *s;
+free_symtab (register struct symtab *s)
 {
   register int i, n;
   register struct blockvector *bv;
@@ -130,7 +126,7 @@ free_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, (PTR) bv);
       /* Also free the linetable.  */
 
     case free_linetable:
@@ -138,26 +134,26 @@ free_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, (PTR) 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, (PTR) 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, (PTR) s);
 }
 
 void
-print_symbol_bcache_statistics ()
+print_symbol_bcache_statistics (void)
 {
   struct objfile *objfile;
 
@@ -171,7 +167,7 @@ print_symbol_bcache_statistics ()
 }
 
 void
-print_objfile_statistics ()
+print_objfile_statistics (void)
 {
   struct objfile *objfile;
 
@@ -201,6 +197,8 @@ print_objfile_statistics ()
                     obstack_memory_used (&objfile->psymbol_obstack));
     printf_filtered ("  Total memory used for psymbol cache: %d\n",
                     obstack_memory_used (&objfile->psymbol_cache.cache));
+    printf_filtered ("  Total memory used for macro cache: %d\n",
+                    obstack_memory_used (&objfile->macro_cache.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",
@@ -210,8 +208,7 @@ print_objfile_statistics ()
 }
 
 static void
-dump_objfile (objfile)
-     struct objfile *objfile;
+dump_objfile (struct objfile *objfile)
 {
   struct symtab *symtab;
   struct partial_symtab *psymtab;
@@ -267,9 +264,7 @@ dump_objfile (objfile)
 /* Print minimal symbols from this objfile.  */
 
 static void
-dump_msymbols (objfile, outfile)
-     struct objfile *objfile;
-     GDB_FILE *outfile;
+dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
 {
   struct minimal_symbol *msymbol;
   int index;
@@ -343,10 +338,8 @@ dump_msymbols (objfile, outfile)
 }
 
 static void
-dump_psymtab (objfile, psymtab, outfile)
-     struct objfile *objfile;
-     struct partial_symtab *psymtab;
-     GDB_FILE *outfile;
+dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
+             struct ui_file *outfile)
 {
   int i;
 
@@ -412,15 +405,14 @@ dump_psymtab (objfile, psymtab, outfile)
 }
 
 static void
-dump_symtab (objfile, symtab, outfile)
-     struct objfile *objfile;
-     struct symtab *symtab;
-     GDB_FILE *outfile;
+dump_symtab (struct objfile *objfile, struct symtab *symtab,
+            struct ui_file *outfile)
 {
   register int i, j;
   int len, blen;
   register struct linetable *l;
   struct blockvector *bv;
+  struct symbol *sym;
   register struct block *b;
   int depth;
 
@@ -482,11 +474,12 @@ dump_symtab (objfile, symtab, outfile)
          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 */
-         for (j = 0; j < blen; j++)
+         /* Now print each symbol in this block.  */
+         /* FIXMED: Sort?  */
+         ALL_BLOCK_SYMBOLS (b, j, sym)
            {
              struct print_symbol_args s;
-             s.symbol = BLOCK_SYM (b, j);
+             s.symbol = sym;
              s.depth = depth + 1;
              s.outfile = outfile;
              catch_errors (print_symbol, &s, "Error printing symbol:\n",
@@ -502,12 +495,10 @@ dump_symtab (objfile, symtab, outfile)
 }
 
 void
-maintenance_print_symbols (args, from_tty)
-     char *args;
-     int from_tty;
+maintenance_print_symbols (char *args, int from_tty)
 {
   char **argv;
-  GDB_FILE *outfile;
+  struct ui_file *outfile;
   struct cleanup *cleanups;
   char *symname = NULL;
   char *filename = DEV_TTY;
@@ -538,12 +529,12 @@ Arguments missing: an output file name and an optional symbol file name");
     }
 
   filename = tilde_expand (filename);
-  make_cleanup (free, filename);
+  make_cleanup (xfree, filename);
 
   outfile = gdb_fopen (filename, FOPEN_WT);
   if (outfile == 0)
     perror_with_name (filename);
-  make_cleanup ((make_cleanup_func) gdb_fclose, (char *) &outfile);
+  make_cleanup_ui_file_delete (outfile);
 
   immediate_quit++;
   ALL_SYMTABS (objfile, s)
@@ -559,12 +550,11 @@ Arguments missing: an output file name and an optional symbol file name");
    1 for success.  */
 
 static int
-print_symbol (args)
-     PTR args;
+print_symbol (PTR args)
 {
   struct symbol *symbol = ((struct print_symbol_args *) args)->symbol;
   int depth = ((struct print_symbol_args *) args)->depth;
-  GDB_FILE *outfile = ((struct print_symbol_args *) args)->outfile;
+  struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile;
 
   print_spaces (depth, outfile);
   if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE)
@@ -740,12 +730,10 @@ print_symbol (args)
 }
 
 void
-maintenance_print_psymbols (args, from_tty)
-     char *args;
-     int from_tty;
+maintenance_print_psymbols (char *args, int from_tty)
 {
   char **argv;
-  GDB_FILE *outfile;
+  struct ui_file *outfile;
   struct cleanup *cleanups;
   char *symname = NULL;
   char *filename = DEV_TTY;
@@ -775,12 +763,12 @@ maintenance_print_psymbols (args, from_tty)
     }
 
   filename = tilde_expand (filename);
-  make_cleanup (free, filename);
+  make_cleanup (xfree, filename);
 
   outfile = gdb_fopen (filename, FOPEN_WT);
   if (outfile == 0)
     perror_with_name (filename);
-  make_cleanup ((make_cleanup_func) gdb_fclose, &outfile);
+  make_cleanup_ui_file_delete (outfile);
 
   immediate_quit++;
   ALL_PSYMTABS (objfile, ps)
@@ -791,11 +779,8 @@ maintenance_print_psymbols (args, from_tty)
 }
 
 static void
-print_partial_symbols (p, count, what, outfile)
-     struct partial_symbol **p;
-     int count;
-     char *what;
-     GDB_FILE *outfile;
+print_partial_symbols (struct partial_symbol **p, int count, char *what,
+                      struct ui_file *outfile)
 {
   fprintf_filtered (outfile, "  %s partial symbols:\n", what);
   while (count-- > 0)
@@ -889,12 +874,10 @@ print_partial_symbols (p, count, what, outfile)
 }
 
 void
-maintenance_print_msymbols (args, from_tty)
-     char *args;
-     int from_tty;
+maintenance_print_msymbols (char *args, int from_tty)
 {
   char **argv;
-  GDB_FILE *outfile;
+  struct ui_file *outfile;
   struct cleanup *cleanups;
   char *filename = DEV_TTY;
   char *symname = NULL;
@@ -923,12 +906,12 @@ maintenance_print_msymbols (args, from_tty)
     }
 
   filename = tilde_expand (filename);
-  make_cleanup (free, filename);
+  make_cleanup (xfree, filename);
 
   outfile = gdb_fopen (filename, FOPEN_WT);
   if (outfile == 0)
     perror_with_name (filename);
-  make_cleanup ((make_cleanup_func) gdb_fclose, &outfile);
+  make_cleanup_ui_file_delete (outfile);
 
   immediate_quit++;
   ALL_OBJFILES (objfile)
@@ -940,9 +923,7 @@ maintenance_print_msymbols (args, from_tty)
 }
 
 void
-maintenance_print_objfiles (ignore, from_tty)
-     char *ignore;
-     int from_tty;
+maintenance_print_objfiles (char *ignore, int from_tty)
 {
   struct objfile *objfile;
 
@@ -957,9 +938,7 @@ maintenance_print_objfiles (ignore, from_tty)
 /* Check consistency of psymtabs and symtabs.  */
 
 void
-maintenance_check_symtabs (ignore, from_tty)
-     char *ignore;
-     int from_tty;
+maintenance_check_symtabs (char *ignore, int from_tty)
 {
   register struct symbol *sym;
   register struct partial_symbol **psym;
@@ -982,7 +961,7 @@ maintenance_check_symtabs (ignore, 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 `");
@@ -999,7 +978,7 @@ maintenance_check_symtabs (ignore, 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 `");
@@ -1044,8 +1023,7 @@ maintenance_check_symtabs (ignore, from_tty)
 /* Return the nexting depth of a block within other blocks in its symtab.  */
 
 static int
-block_depth (block)
-     struct block *block;
+block_depth (struct block *block)
 {
   register int i = 0;
   while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
@@ -1061,9 +1039,8 @@ block_depth (block)
    be freed in free_objfile().  */
 
 void
-extend_psymbol_list (listp, objfile)
-     register struct psymbol_allocation_list *listp;
-     struct objfile *objfile;
+extend_psymbol_list (register struct psymbol_allocation_list *listp,
+                    struct objfile *objfile)
 {
   int new_size;
   if (listp->size == 0)
@@ -1088,7 +1065,7 @@ extend_psymbol_list (listp, objfile)
 
 /* Do early runtime initializations. */
 void
-_initialize_symmisc ()
+_initialize_symmisc (void)
 {
   std_in = stdin;
   std_out = stdout;
This page took 0.028293 seconds and 4 git commands to generate.