]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* symmisc.c (print_symbol_bcache_statistics): Print filename cache
authorTom Tromey <tromey@redhat.com>
Thu, 5 Nov 2009 22:26:10 +0000 (22:26 +0000)
committerTom Tromey <tromey@redhat.com>
Thu, 5 Nov 2009 22:26:10 +0000 (22:26 +0000)
statistics.
(print_objfile_statistics): Likewise.
* symfile.c (reread_symbols): Initialize filename_cache.
(allocate_symtab): Cache the file name.
(allocate_psymtab): Likewise.
* solib-sunos.c (allocate_rt_common_objfile): Initialize
filename_cache.
* objfiles.h (struct objfile) <filename_cache>: New field.
* objfiles.c (allocate_objfile): Initialize filename_cache.
(free_objfile): Free filename_cache.

gdb/ChangeLog
gdb/objfiles.c
gdb/objfiles.h
gdb/solib-sunos.c
gdb/symfile.c
gdb/symmisc.c

index bf20ded4d378ba7da97b3d2c0192269d00349c3d..aea896e1acc84ad07e6138efaaa9b540401ade16 100644 (file)
@@ -1,3 +1,17 @@
+2009-11-05  Tom Tromey  <tromey@redhat.com>
+
+       * symmisc.c (print_symbol_bcache_statistics): Print filename cache
+       statistics.
+       (print_objfile_statistics): Likewise.
+       * symfile.c (reread_symbols): Initialize filename_cache.
+       (allocate_symtab): Cache the file name.
+       (allocate_psymtab): Likewise.
+       * solib-sunos.c (allocate_rt_common_objfile): Initialize
+       filename_cache.
+       * objfiles.h (struct objfile) <filename_cache>: New field.
+       * objfiles.c (allocate_objfile): Initialize filename_cache.
+       (free_objfile): Free filename_cache.
+
 2009-11-05  Tom Tromey  <tromey@redhat.com>
 
        * symfile.c (add_psymbol_to_bcache): Make 'psymbol' static again.
index 0425d7a281565e02f6fdec9de16202ccffb15f25..48f261362241d67aed48e75b5ca956fd75335857 100644 (file)
@@ -199,6 +199,7 @@ allocate_objfile (bfd *abfd, int flags)
   objfile = (struct objfile *) xzalloc (sizeof (struct objfile));
   objfile->psymbol_cache = bcache_xmalloc ();
   objfile->macro_cache = bcache_xmalloc ();
+  objfile->filename_cache = bcache_xmalloc ();
   /* We could use obstack_specify_allocation here instead, but
      gdb_obstack.h specifies the alloc/dealloc functions.  */
   obstack_init (&objfile->objfile_obstack);
@@ -561,6 +562,7 @@ free_objfile (struct objfile *objfile)
   /* Free the obstacks for non-reusable objfiles */
   bcache_xfree (objfile->psymbol_cache);
   bcache_xfree (objfile->macro_cache);
+  bcache_xfree (objfile->filename_cache);
   if (objfile->demangled_names_hash)
     htab_delete (objfile->demangled_names_hash);
   obstack_free (&objfile->objfile_obstack, 0);
index 97e6b5579b7e7a0a5f9e7d6ee61cce6862ee0226..d662d1253272fb592d9b29aded1aea5b8d5f4b1e 100644 (file)
@@ -251,6 +251,7 @@ struct objfile
 
     struct bcache *psymbol_cache;      /* Byte cache for partial syms */
     struct bcache *macro_cache;          /* Byte cache for macros */
+    struct bcache *filename_cache;      /* Byte cache for file names.  */
 
     /* Hash table for mapping symbol names to demangled names.  Each
        entry in the hash table is actually two consecutive strings,
index 9b2a470c3768ac36721741aa4f3526a675ffab8f..02793f1e3703384e78f89895af2bb9426cc25911 100644 (file)
@@ -191,6 +191,7 @@ allocate_rt_common_objfile (void)
   memset (objfile, 0, sizeof (struct objfile));
   objfile->psymbol_cache = bcache_xmalloc ();
   objfile->macro_cache = bcache_xmalloc ();
+  objfile->filename_cache = bcache_xmalloc ();
   obstack_init (&objfile->objfile_obstack);
   objfile->name = xstrdup ("rt_common");
 
index 117f17fb163be39c822c0d71f7698ad81e5f903e..5ce20a6e441b342fcf3cdc0fb166af0fa46ae3a7 100644 (file)
@@ -2402,6 +2402,8 @@ reread_symbols (void)
              objfile->psymbol_cache = bcache_xmalloc ();
              bcache_xfree (objfile->macro_cache);
              objfile->macro_cache = bcache_xmalloc ();
+             bcache_xfree (objfile->filename_cache);
+             objfile->filename_cache = bcache_xmalloc ();
              if (objfile->demangled_names_hash != NULL)
                {
                  htab_delete (objfile->demangled_names_hash);
@@ -2424,6 +2426,7 @@ reread_symbols (void)
 
              objfile->psymbol_cache = bcache_xmalloc ();
              objfile->macro_cache = bcache_xmalloc ();
+             objfile->filename_cache = bcache_xmalloc ();
              /* obstack_init also initializes the obstack so it is
                 empty.  We could use obstack_specify_allocation but
                 gdb_obstack.h specifies the alloc/dealloc
@@ -2746,8 +2749,8 @@ allocate_symtab (char *filename, struct objfile *objfile)
   symtab = (struct symtab *)
     obstack_alloc (&objfile->objfile_obstack, sizeof (struct symtab));
   memset (symtab, 0, sizeof (*symtab));
-  symtab->filename = obsavestring (filename, strlen (filename),
-                                  &objfile->objfile_obstack);
+  symtab->filename = (char *) bcache (filename, strlen (filename) + 1,
+                                     objfile->filename_cache);
   symtab->fullname = NULL;
   symtab->language = deduce_language_from_filename (filename);
   symtab->debugformat = "unknown";
@@ -2777,8 +2780,8 @@ allocate_psymtab (char *filename, struct objfile *objfile)
                     sizeof (struct partial_symtab));
 
   memset (psymtab, 0, sizeof (struct partial_symtab));
-  psymtab->filename = obsavestring (filename, strlen (filename),
-                                   &objfile->objfile_obstack);
+  psymtab->filename = (char *) bcache (filename, strlen (filename) + 1,
+                                      objfile->filename_cache);
   psymtab->symtab = NULL;
 
   /* Prepend it to the psymtab list for the objfile it belongs to.
index 40449811db80738d9e97a9eebe2079d0d7c4ac12..c45135ce9d4a716d86c8f44edce65d14e2310ca0 100644 (file)
@@ -140,6 +140,7 @@ print_symbol_bcache_statistics (void)
     printf_filtered (_("Byte cache statistics for '%s':\n"), objfile->name);
     print_bcache_statistics (objfile->psymbol_cache, "partial symbol cache");
     print_bcache_statistics (objfile->macro_cache, "preprocessor macro cache");
+    print_bcache_statistics (objfile->filename_cache, "file name cache");
   }
   immediate_quit--;
 }
@@ -204,6 +205,8 @@ print_objfile_statistics (void)
                     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 file name cache: %d\n"),
+                    bcache_memory_used (objfile->filename_cache));
   }
   immediate_quit--;
 }