Re-added with correct permissions
[deliverable/binutils-gdb.git] / gdb / symmisc.c
index 74e49414cbec7b5f144c2ce938fe709e272ab8de..9ce7679f978d3b5fc14a651c0f68be113521fd8f 100644 (file)
@@ -1,8 +1,7 @@
 /* Do various things to symbol tables (other than lookup), for GDB.
 
-   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2007, 2008, 2009, 2010,
-   2011 Free Software Foundation, Inc.
+   Copyright (C) 1986-2000, 2002-2004, 2007-2012 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -79,46 +78,6 @@ struct print_symbol_args
 
 static int print_symbol (void *);
 \f
-/* Free all the storage associated with the struct symtab <- S.
-   Note that some symtabs have contents that all live inside one big block of
-   memory, and some share the contents of another symbol table and so you
-   should not free the contents on their behalf (except sometimes the
-   linetable, which maybe per symtab even when the rest is not).
-   It is s->free_code that says which alternative to use.  */
-
-void
-free_symtab (struct symtab *s)
-{
-  switch (s->free_code)
-    {
-    case free_nothing:
-      /* All the contents are part of a big block of memory (an obstack),
-         and some other symtab is in charge of freeing that block.
-         Therefore, do nothing.  */
-      break;
-
-    case free_linetable:
-      /* Everything will be freed either by our `free_func'
-         or by some other symtab, except for our linetable.
-         Free that now.  */
-      if (LINETABLE (s))
-       xfree (LINETABLE (s));
-      break;
-    }
-
-  /* If there is a single block of memory to free, free it.  */
-  if (s->free_func != NULL)
-    s->free_func (s);
-
-  /* Free source-related stuff.  */
-  if (s->line_charpos != NULL)
-    xfree (s->line_charpos);
-  if (s->fullname != NULL)
-    xfree (s->fullname);
-  if (s->debugformat != NULL)
-    xfree (s->debugformat);
-  xfree (s);
-}
 
 void
 print_symbol_bcache_statistics (void)
@@ -126,17 +85,18 @@ print_symbol_bcache_statistics (void)
   struct program_space *pspace;
   struct objfile *objfile;
 
-  immediate_quit++;
   ALL_PSPACES (pspace)
     ALL_PSPACE_OBJFILES (pspace, objfile)
   {
+    QUIT;
     printf_filtered (_("Byte cache statistics for '%s':\n"), objfile->name);
     print_bcache_statistics (psymbol_bcache_get_bcache (objfile->psymbol_cache),
                              "partial symbol cache");
-    print_bcache_statistics (objfile->macro_cache, "preprocessor macro cache");
-    print_bcache_statistics (objfile->filename_cache, "file name cache");
+    print_bcache_statistics (objfile->per_bfd->macro_cache,
+                            "preprocessor macro cache");
+    print_bcache_statistics (objfile->per_bfd->filename_cache,
+                            "file name cache");
   }
-  immediate_quit--;
 }
 
 void
@@ -147,10 +107,10 @@ print_objfile_statistics (void)
   struct symtab *s;
   int i, linetables, blockvectors;
 
-  immediate_quit++;
   ALL_PSPACES (pspace)
     ALL_PSPACE_OBJFILES (pspace, objfile)
   {
+    QUIT;
     printf_filtered (_("Statistics for '%s':\n"), objfile->name);
     if (OBJSTAT (objfile, n_stabs) > 0)
       printf_filtered (_("  Number of \"stab\" symbols read: %d\n"),
@@ -189,15 +149,16 @@ print_objfile_statistics (void)
                       OBJSTAT (objfile, sz_strtab));
     printf_filtered (_("  Total memory used for objfile obstack: %d\n"),
                     obstack_memory_used (&objfile->objfile_obstack));
+    printf_filtered (_("  Total memory used for BFD obstack: %d\n"),
+                    obstack_memory_used (&objfile->per_bfd->storage_obstack));
     printf_filtered (_("  Total memory used for psymbol cache: %d\n"),
                     bcache_memory_used (psymbol_bcache_get_bcache
                                          (objfile->psymbol_cache)));
     printf_filtered (_("  Total memory used for macro cache: %d\n"),
-                    bcache_memory_used (objfile->macro_cache));
+                    bcache_memory_used (objfile->per_bfd->macro_cache));
     printf_filtered (_("  Total memory used for file name cache: %d\n"),
-                    bcache_memory_used (objfile->filename_cache));
+                    bcache_memory_used (objfile->per_bfd->filename_cache));
   }
-  immediate_quit--;
 }
 
 static void
@@ -265,6 +226,9 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
        case mst_text:
          ms_type = 'T';
          break;
+       case mst_text_gnu_ifunc:
+         ms_type = 'i';
+         break;
        case mst_solib_trampoline:
          ms_type = 'S';
          break;
@@ -391,8 +355,9 @@ dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
            }
          fprintf_filtered (outfile, "\n");
          /* Now print each symbol in this block (in no particular order, if
-            we're using a hashtable).  */
-         ALL_BLOCK_SYMBOLS (b, iter, sym)
+            we're using a hashtable).  Note that we only want this
+            block, not any blocks from included symtabs.  */
+         ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
            {
              struct print_symbol_args s;
 
@@ -474,11 +439,12 @@ maintenance_print_symbols (char *args, int from_tty)
     perror_with_name (filename);
   make_cleanup_ui_file_delete (outfile);
 
-  immediate_quit++;
   ALL_SYMTABS (objfile, s)
-    if (symname == NULL || filename_cmp (symname, s->filename) == 0)
-    dump_symtab (objfile, s, outfile);
-  immediate_quit--;
+    {
+      QUIT;
+      if (symname == NULL || filename_cmp (symname, s->filename) == 0)
+       dump_symtab (objfile, s, outfile);
+    }
   do_cleanups (cleanups);
 }
 
@@ -547,9 +513,9 @@ print_symbol (void *args)
       switch (SYMBOL_CLASS (symbol))
        {
        case LOC_CONST:
-         fprintf_filtered (outfile, "const %ld (0x%lx)",
-                           SYMBOL_VALUE (symbol),
-                           SYMBOL_VALUE (symbol));
+         fprintf_filtered (outfile, "const %s (%s)",
+                           plongest (SYMBOL_VALUE (symbol)),
+                           hex_string (SYMBOL_VALUE (symbol)));
          break;
 
        case LOC_CONST_BYTES:
@@ -577,28 +543,31 @@ print_symbol (void *args)
 
        case LOC_REGISTER:
          if (SYMBOL_IS_ARGUMENT (symbol))
-           fprintf_filtered (outfile, "parameter register %ld",
-                             SYMBOL_VALUE (symbol));
+           fprintf_filtered (outfile, "parameter register %s",
+                             plongest (SYMBOL_VALUE (symbol)));
          else
-           fprintf_filtered (outfile, "register %ld", SYMBOL_VALUE (symbol));
+           fprintf_filtered (outfile, "register %s",
+                             plongest (SYMBOL_VALUE (symbol)));
          break;
 
        case LOC_ARG:
-         fprintf_filtered (outfile, "arg at offset 0x%lx",
-                           SYMBOL_VALUE (symbol));
+         fprintf_filtered (outfile, "arg at offset %s",
+                           hex_string (SYMBOL_VALUE (symbol)));
          break;
 
        case LOC_REF_ARG:
-         fprintf_filtered (outfile, "reference arg at 0x%lx", SYMBOL_VALUE (symbol));
+         fprintf_filtered (outfile, "reference arg at %s",
+                           hex_string (SYMBOL_VALUE (symbol)));
          break;
 
        case LOC_REGPARM_ADDR:
-         fprintf_filtered (outfile, "address parameter register %ld", SYMBOL_VALUE (symbol));
+         fprintf_filtered (outfile, "address parameter register %s",
+                           plongest (SYMBOL_VALUE (symbol)));
          break;
 
        case LOC_LOCAL:
-         fprintf_filtered (outfile, "local at offset 0x%lx",
-                           SYMBOL_VALUE (symbol));
+         fprintf_filtered (outfile, "local at offset %s",
+                           hex_string (SYMBOL_VALUE (symbol)));
          break;
 
        case LOC_TYPEDEF:
@@ -697,13 +666,14 @@ maintenance_print_msymbols (char *args, int from_tty)
     perror_with_name (filename);
   make_cleanup_ui_file_delete (outfile);
 
-  immediate_quit++;
   ALL_PSPACES (pspace)
     ALL_PSPACE_OBJFILES (pspace, objfile)
-      if (symname == NULL || (!stat (objfile->name, &obj_st)
-                             && sym_st.st_ino == obj_st.st_ino))
-       dump_msymbols (objfile, outfile);
-  immediate_quit--;
+      {
+       QUIT;
+       if (symname == NULL || (!stat (objfile->name, &obj_st)
+                               && sym_st.st_ino == obj_st.st_ino))
+         dump_msymbols (objfile, outfile);
+      }
   fprintf_filtered (outfile, "\n\n");
   do_cleanups (cleanups);
 }
@@ -716,11 +686,12 @@ maintenance_print_objfiles (char *ignore, int from_tty)
 
   dont_repeat ();
 
-  immediate_quit++;
   ALL_PSPACES (pspace)
     ALL_PSPACE_OBJFILES (pspace, objfile)
-      dump_objfile (objfile);
-  immediate_quit--;
+      {
+       QUIT;
+       dump_objfile (objfile);
+      }
 }
 
 
This page took 0.026968 seconds and 4 git commands to generate.