2003-04-08 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / symmisc.c
index 198b2d632eca8a981721a23fce670595483b8e8f..f6e78ebc98ed9a6d519436cd788ac0eaf0b5aede 100644 (file)
@@ -1,8 +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, 2002 Free Software Foundation,
-   Inc.
+   1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
 #include "gdb_obstack.h"
 #include "language.h"
 #include "bcache.h"
+#include "block.h"
 
 #include "gdb_string.h"
+#include <readline/readline.h>
 
 #ifndef DEV_TTY
 #define DEV_TTY "/dev/tty"
@@ -77,7 +79,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
@@ -96,11 +98,11 @@ free_symtab_block (struct objfile *objfile, struct block *b)
       for (sym = BLOCK_BUCKET (b, i); sym; sym = next_sym)
        {
          next_sym = sym->hash_next;
-         xmfree (objfile->md, SYMBOL_NAME (sym));
-         xmfree (objfile->md, (PTR) sym);
+         xmfree (objfile->md, DEPRECATED_SYMBOL_NAME (sym));
+         xmfree (objfile->md, sym);
        }
     }
-  xmfree (objfile->md, (PTR) b);
+  xmfree (objfile->md, b);
 }
 
 /* Free all the storage associated with the struct symtab <- S.
@@ -134,7 +136,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.  */
-      xmfree (s->objfile->md, (PTR) bv);
+      xmfree (s->objfile->md, bv);
       /* Also free the linetable.  */
 
     case free_linetable:
@@ -142,7 +144,7 @@ free_symtab (register struct symtab *s)
          or by some other symtab, except for our linetable.
          Free that now.  */
       if (LINETABLE (s))
-       xmfree (s->objfile->md, (PTR) LINETABLE (s));
+       xmfree (s->objfile->md, LINETABLE (s));
       break;
     }
 
@@ -152,12 +154,12 @@ free_symtab (register struct symtab *s)
 
   /* Free source-related stuff */
   if (s->line_charpos != NULL)
-    xmfree (s->objfile->md, (PTR) s->line_charpos);
+    xmfree (s->objfile->md, s->line_charpos);
   if (s->fullname != NULL)
     xmfree (s->objfile->md, s->fullname);
   if (s->debugformat != NULL)
     xmfree (s->objfile->md, s->debugformat);
-  xmfree (s->objfile->md, (PTR) s);
+  xmfree (s->objfile->md, s);
 }
 
 void
@@ -178,6 +180,9 @@ void
 print_objfile_statistics (void)
 {
   struct objfile *objfile;
+  struct symtab *s;
+  struct partial_symtab *ps;
+  int i, linetables, blockvectors;
 
   immediate_quit++;
   ALL_OBJFILES (objfile)
@@ -198,6 +203,28 @@ print_objfile_statistics (void)
     if (OBJSTAT (objfile, n_types) > 0)
       printf_filtered ("  Number of \"types\" defined: %d\n",
                       OBJSTAT (objfile, n_types));
+    i = 0;
+    ALL_OBJFILE_PSYMTABS (objfile, ps)
+      {
+        if (ps->readin == 0)
+          i++;
+      }
+    printf_filtered ("  Number of psym tables (not yet expanded): %d\n", i);
+    i = linetables = blockvectors = 0;
+    ALL_OBJFILE_SYMTABS (objfile, s)
+      {
+        i++;
+        if (s->linetable != NULL)
+          linetables++;
+        if (s->primary == 1)
+          blockvectors++;
+      }
+    printf_filtered ("  Number of symbol tables: %d\n", i);
+    printf_filtered ("  Number of symbol tables with line tables: %d\n", 
+                     linetables);
+    printf_filtered ("  Number of symbol tables with blockvectors: %d\n", 
+                     blockvectors);
+    
     if (OBJSTAT (objfile, sz_strtab) > 0)
       printf_filtered ("  Space used by a.out string tables: %d\n",
                       OBJSTAT (objfile, sz_strtab));
@@ -285,7 +312,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
       return;
     }
   for (index = 0, msymbol = objfile->msymbols;
-       SYMBOL_NAME (msymbol) != NULL; msymbol++, index++)
+       DEPRECATED_SYMBOL_NAME (msymbol) != NULL; msymbol++, index++)
     {
       switch (msymbol->type)
        {
@@ -322,7 +349,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
        }
       fprintf_filtered (outfile, "[%2d] %c ", index, ms_type);
       print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), 1, outfile);
-      fprintf_filtered (outfile, " %s", SYMBOL_NAME (msymbol));
+      fprintf_filtered (outfile, " %s", DEPRECATED_SYMBOL_NAME (msymbol));
       if (SYMBOL_BFD_SECTION (msymbol))
        fprintf_filtered (outfile, " section %s",
                          bfd_section_name (objfile->obfd,
@@ -367,7 +394,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");
     }
 
@@ -478,7 +505,7 @@ dump_symtab (struct objfile *objfile, struct symtab *symtab,
          print_address_numeric (BLOCK_END (b), 1, outfile);
          if (BLOCK_FUNCTION (b))
            {
-             fprintf_filtered (outfile, ", function %s", SYMBOL_NAME (BLOCK_FUNCTION (b)));
+             fprintf_filtered (outfile, ", function %s", DEPRECATED_SYMBOL_NAME (BLOCK_FUNCTION (b)));
              if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL)
                {
                  fprintf_filtered (outfile, ", %s",
@@ -564,7 +591,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;
@@ -573,7 +600,7 @@ print_symbol (PTR args)
   print_spaces (depth, outfile);
   if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE)
     {
-      fprintf_filtered (outfile, "label %s at ", SYMBOL_SOURCE_NAME (symbol));
+      fprintf_filtered (outfile, "label %s at ", SYMBOL_PRINT_NAME (symbol));
       print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile);
       if (SYMBOL_BFD_SECTION (symbol))
        fprintf_filtered (outfile, " section %s\n",
@@ -596,7 +623,7 @@ print_symbol (PTR args)
                          ? "enum"
                     : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT
                        ? "struct" : "union")),
-                           SYMBOL_NAME (symbol));
+                           DEPRECATED_SYMBOL_NAME (symbol));
          LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth);
        }
       fprintf_filtered (outfile, ";\n");
@@ -608,14 +635,14 @@ print_symbol (PTR args)
       if (SYMBOL_TYPE (symbol))
        {
          /* Print details of types, except for enums where it's clutter.  */
-         LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_SOURCE_NAME (symbol),
+         LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_PRINT_NAME (symbol),
                         outfile,
                         TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM,
                         depth);
          fprintf_filtered (outfile, "; ");
        }
       else
-       fprintf_filtered (outfile, "%s ", SYMBOL_SOURCE_NAME (symbol));
+       fprintf_filtered (outfile, "%s ", SYMBOL_PRINT_NAME (symbol));
 
       switch (SYMBOL_CLASS (symbol))
        {
@@ -725,6 +752,11 @@ print_symbol (PTR args)
                               SYMBOL_BFD_SECTION (symbol)));
          break;
 
+       case LOC_COMPUTED:
+       case LOC_COMPUTED_ARG:
+         fprintf_filtered (outfile, "computed at runtime");
+         break;
+
        case LOC_UNRESOLVED:
          fprintf_filtered (outfile, "unresolved");
          break;
@@ -799,7 +831,7 @@ print_partial_symbols (struct partial_symbol **p, int count, char *what,
   fprintf_filtered (outfile, "  %s partial symbols:\n", what);
   while (count-- > 0)
     {
-      fprintf_filtered (outfile, "    `%s'", SYMBOL_NAME (*p));
+      fprintf_filtered (outfile, "    `%s'", DEPRECATED_SYMBOL_NAME (*p));
       if (SYMBOL_DEMANGLED_NAME (*p) != NULL)
        {
          fprintf_filtered (outfile, "  `%s'", SYMBOL_DEMANGLED_NAME (*p));
@@ -876,6 +908,10 @@ print_partial_symbols (struct partial_symbol **p, int count, char *what,
        case LOC_OPTIMIZED_OUT:
          fputs_filtered ("optimized out", outfile);
          break;
+       case LOC_COMPUTED:
+       case LOC_COMPUTED_ARG:
+         fputs_filtered ("computed at runtime", outfile);
+         break;
        default:
          fputs_filtered ("<invalid location>", outfile);
          break;
@@ -974,12 +1010,12 @@ maintenance_check_symtabs (char *ignore, int from_tty)
     length = ps->n_static_syms;
     while (length--)
       {
-       sym = lookup_block_symbol (b, SYMBOL_NAME (*psym),
+       sym = lookup_block_symbol (b, DEPRECATED_SYMBOL_NAME (*psym),
                                   NULL, SYMBOL_NAMESPACE (*psym));
        if (!sym)
          {
            printf_filtered ("Static symbol `");
-           puts_filtered (SYMBOL_NAME (*psym));
+           puts_filtered (DEPRECATED_SYMBOL_NAME (*psym));
            printf_filtered ("' only found in ");
            puts_filtered (ps->filename);
            printf_filtered (" psymtab\n");
@@ -991,12 +1027,12 @@ maintenance_check_symtabs (char *ignore, int from_tty)
     length = ps->n_global_syms;
     while (length--)
       {
-       sym = lookup_block_symbol (b, SYMBOL_NAME (*psym),
+       sym = lookup_block_symbol (b, DEPRECATED_SYMBOL_NAME (*psym),
                                   NULL, SYMBOL_NAMESPACE (*psym));
        if (!sym)
          {
            printf_filtered ("Global symbol `");
-           puts_filtered (SYMBOL_NAME (*psym));
+           puts_filtered (DEPRECATED_SYMBOL_NAME (*psym));
            printf_filtered ("' only found in ");
            puts_filtered (ps->filename);
            printf_filtered (" psymtab\n");
This page took 0.032081 seconds and 4 git commands to generate.