From 6532ff3697890085456f353dd49068edfd4ed422 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 22 Aug 2012 16:12:50 +0000 Subject: [PATCH] * dwarf2read.c (macro_start_file): Update. * objfiles.c (get_objfile_bfd_data): Initialize macro_cache. (free_objfile_per_bfd_storage): Destroy macro_cache. (allocate_objfile, free_objfile): Update. * objfiles.h (struct objfile_per_bfd_storage) : New field. (struct objfile) : Remove. * symfile.c (reread_symbols): Update. * symmisc.c (print_symbol_bcache_statistics): Update. (print_objfile_statistics): Update. --- gdb/ChangeLog | 13 +++++++++++++ gdb/dwarf2read.c | 4 ++-- gdb/objfiles.c | 4 ++-- gdb/objfiles.h | 4 +++- gdb/symfile.c | 2 -- gdb/symmisc.c | 5 +++-- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3b2bc5b0c9b..571c9b6e364 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2012-08-22 Tom Tromey + + * dwarf2read.c (macro_start_file): Update. + * objfiles.c (get_objfile_bfd_data): Initialize macro_cache. + (free_objfile_per_bfd_storage): Destroy macro_cache. + (allocate_objfile, free_objfile): Update. + * objfiles.h (struct objfile_per_bfd_storage) : + New field. + (struct objfile) : Remove. + * symfile.c (reread_symbols): Update. + * symmisc.c (print_symbol_bcache_statistics): Update. + (print_objfile_statistics): Update. + 2012-08-22 Tom Tromey * elfread.c (elf_symtab_read): Update. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 099b67a00f4..682fd0fbf4d 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -17082,8 +17082,8 @@ macro_start_file (int file, int line, /* We don't create a macro table for this compilation unit at all until we actually get a filename. */ if (! pending_macros) - pending_macros = new_macro_table (&objfile->objfile_obstack, - objfile->macro_cache); + pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack, + objfile->per_bfd->macro_cache); if (! current_file) { diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 250cf3514ca..d5317a87f3f 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -141,6 +141,7 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd) obstack_init (&storage->storage_obstack); storage->filename_cache = bcache_xmalloc (NULL, NULL); + storage->macro_cache = bcache_xmalloc (NULL, NULL); } return storage; @@ -152,6 +153,7 @@ static void free_objfile_per_bfd_storage (struct objfile_per_bfd_storage *storage) { bcache_xfree (storage->filename_cache); + bcache_xfree (storage->macro_cache); obstack_free (&storage->storage_obstack, 0); } @@ -251,7 +253,6 @@ allocate_objfile (bfd *abfd, int flags) objfile = (struct objfile *) xzalloc (sizeof (struct objfile)); objfile->psymbol_cache = psymbol_bcache_init (); - objfile->macro_cache = bcache_xmalloc (NULL, NULL); /* We could use obstack_specify_allocation here instead, but gdb_obstack.h specifies the alloc/dealloc functions. */ obstack_init (&objfile->objfile_obstack); @@ -676,7 +677,6 @@ free_objfile (struct objfile *objfile) xfree (objfile->static_psymbols.list); /* Free the obstacks for non-reusable objfiles. */ psymbol_bcache_free (objfile->psymbol_cache); - bcache_xfree (objfile->macro_cache); if (objfile->demangled_names_hash) htab_delete (objfile->demangled_names_hash); obstack_free (&objfile->objfile_obstack, 0); diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 2b95ce47fc1..24124fee0fc 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -174,6 +174,9 @@ struct objfile_per_bfd_storage /* Byte cache for file names. */ struct bcache *filename_cache; + + /* Byte cache for macros. */ + struct bcache *macro_cache; }; /* Master structure for keeping track of each file from which @@ -269,7 +272,6 @@ struct objfile will not change. */ struct psymbol_bcache *psymbol_cache; /* Byte cache for partial syms. */ - struct bcache *macro_cache; /* Byte cache for macros. */ /* Hash table for mapping symbol names to demangled names. Each entry in the hash table is actually two consecutive strings, diff --git a/gdb/symfile.c b/gdb/symfile.c index 6ef1ac111ea..6c93ba6dcdb 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2548,8 +2548,6 @@ reread_symbols (void) /* Free the obstacks for non-reusable objfiles. */ psymbol_bcache_free (objfile->psymbol_cache); objfile->psymbol_cache = psymbol_bcache_init (); - bcache_xfree (objfile->macro_cache); - objfile->macro_cache = bcache_xmalloc (NULL, NULL); if (objfile->demangled_names_hash != NULL) { htab_delete (objfile->demangled_names_hash); diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 3e9ca82d7e3..9ce7679f978 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -92,7 +92,8 @@ print_symbol_bcache_statistics (void) 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->per_bfd->macro_cache, + "preprocessor macro cache"); print_bcache_statistics (objfile->per_bfd->filename_cache, "file name cache"); } @@ -154,7 +155,7 @@ print_objfile_statistics (void) 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->per_bfd->filename_cache)); } -- 2.30.2