diff options
author | Tom Tromey <tom@tromey.com> | 2020-03-04 16:34:49 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-03-04 16:34:49 -0700 |
commit | be1e3d3eab0af2a140463757a1ba3977167551af (patch) | |
tree | 585dd9c3355bd4af81c0aa4a4439450ed3932a44 /gdb/objfiles.h | |
parent | 4e7625fde223fd0c98f09f41fe924e7317a82e1a (diff) | |
download | gdb-be1e3d3eab0af2a140463757a1ba3977167551af.zip gdb-be1e3d3eab0af2a140463757a1ba3977167551af.tar.gz gdb-be1e3d3eab0af2a140463757a1ba3977167551af.tar.bz2 |
Introduce objfile::intern
This introduces a string cache on the per-BFD object, replacing the
macro and filename caches. Both of these caches just store strings,
so this consolidation by itself saves a little memory (about the size
of a bcache per objfile).
Then this patch switches some allocations on the objfile obstack to
use this bcache instead. This saves more space; and turns out to be a
bit faster as well.
Here are the before and after "maint time" + "maint space" results of
"file ./gdb":
Command execution time: 4.664021 (cpu), 4.728518 (wall)
Space used: 39190528 (+29212672 for this command)
Command execution time: 4.216209 (cpu), 4.107023 (wall)
Space used: 36667392 (+26689536 for this command)
The main interface to the string cache is a new pair of overloaded
methods, objfile::intern.
gdb/ChangeLog
2020-03-04 Tom Tromey <tom@tromey.com>
* symmisc.c (print_symbol_bcache_statistics)
(print_objfile_statistics): Update.
* symfile.c (allocate_symtab): Use intern.
* psymtab.c (partial_symtab::partial_symtab): Use intern.
* objfiles.h (struct objfile_per_bfd_storage) <filename_cache,
macro_cache>: Remove.
<string_cache>: New member.
(struct objfile) <intern>: New methods.
* elfread.c (elf_symtab_read): Use intern.
* dwarf2/read.c (fixup_go_packaging): Intern package name.
(dwarf2_compute_name, dwarf2_physname)
(create_dwo_unit_in_dwp_v1, create_dwo_unit_in_dwp_v2): Intern
names.
(guess_partial_die_structure_name): Update.
(partial_die_info::fixup): Intern name.
(dwarf2_canonicalize_name): Change parameter to objfile. Intern
name.
(dwarf2_name): Intern name. Update.
* buildsym.c (buildsym_compunit::get_macro_table): Use
string_cache.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r-- | gdb/objfiles.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h index b71a8a9..a568fa4 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -275,13 +275,9 @@ struct objfile_per_bfd_storage auto_obstack storage_obstack; - /* Byte cache for file names. */ + /* String cache. */ - gdb::bcache filename_cache; - - /* Byte cache for macros. */ - - gdb::bcache macro_cache; + gdb::bcache string_cache; /* The gdbarch associated with the BFD. Note that this gdbarch is determined solely from BFD information, without looking at target @@ -533,6 +529,22 @@ public: return section_offsets[SECT_OFF_DATA (this)]; } + /* Intern STRING and return the unique copy. The copy has the same + lifetime as the per-BFD object. */ + const char *intern (const char *str) + { + return (const char *) per_bfd->string_cache.insert (str, strlen (str) + 1); + } + + /* Intern STRING and return the unique copy. The copy has the same + lifetime as the per-BFD object. */ + const char *intern (const std::string &str) + { + return (const char *) per_bfd->string_cache.insert (str.c_str (), + str.size () + 1); + } + + /* The object file's original name as specified by the user, made absolute, and tilde-expanded. However, it is not canonicalized (i.e., it has not been passed through gdb_realpath). |