aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-05-27 11:20:14 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-27 11:20:15 -0400
commit17ee85fc2af74471e8c57502714a32bbeac5f1ae (patch)
tree45d239aad7962a2d72a1b36ce3416e0ad2311b79 /gdb/dwarf2/read.h
parent39b16f87f720b5cc454eac1e668c2ce2c60bfe15 (diff)
downloadgdb-17ee85fc2af74471e8c57502714a32bbeac5f1ae.zip
gdb-17ee85fc2af74471e8c57502714a32bbeac5f1ae.tar.gz
gdb-17ee85fc2af74471e8c57502714a32bbeac5f1ae.tar.bz2
Share DWARF partial symtabs
This changes the DWARF reader to share partial symtabs (or indices if they are available) across objfiles. This has a few parts. * If multiple objfiles backed by the same BFD can share partial symtabs (see below), a single dwarf2_per_bfd is created. It is stored in the per-bfd `dwarf2_per_bfd_bfd_data_key` registry. Multiple dwarf2_per_objfile objects will point to the same instance. The lifetime of these dwarf2_per_bfd objects is naturally handled. When all the objfiles using the BFD are destroyed, the BFD's refount drops to 0, which triggers the removal of the corresponding dwarf2_per_bfd object from the registry and its destruction. * If multiple objfiles backed by the same BFD can't share partial symtabs (see below), one dwarf2_per_bfd object is created for each objfile. Each dwarf2_per_objfile will point to their own instance of dwarf2_per_bfd. These instances of dwarf2_per_bfd are kept in a per-objfile registry, meaning that when the objfile gets destroyed, the dwarf2_per_bfd instance gets destroyed as well. * objfile::partial_symtabs is changed to be a shared_ptr again. This lets us stash a second reference in dwarf2_per_bfd; if the DWARF data is being shared, we can simply copy this value to the new objfile. * Two dwarf2_per_objfile objects backed by the same BFD may share a dwarf2_per_bfd instance if: * No other symbol reader has found symbols, and * No BFD section rqeuires relocation gdb/ChangeLog: YYYY-MM-DD Tom Tromey <tom@tromey.com> YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com> * objfiles.h (struct objfile) <partial_symtabs>: Now a shared_ptr. * dwarf2/read.h (struct dwarf2_per_objfile) <partial_symtabs>: New member. * dwarf2/read.c (dwarf2_per_bfd_bfd_data_key, dwarf2_per_bfd_objfile_data_key>: New globals. (dwarf2_has_info): Use shared dwarf2_per_bfd if possible. (dwarf2_get_section_info): Use get_dwarf2_per_objfile. (dwarf2_initialize_objfile): Consider cases where per_bfd can be shared. (dwarf2_build_psymtabs): Set objfile::partial_symtabs and short-circuit when sharing. (dwarf2_build_psymtabs): Set dwarf2_per_objfile::partial_symtabs. (dwarf2_psymtab::expand_psymtab): Use free_cached_comp_units. Change-Id: I868c64448589102ab8cbb8f06c31a8de50a14004
Diffstat (limited to 'gdb/dwarf2/read.h')
-rw-r--r--gdb/dwarf2/read.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index b53aab7..c52430a 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -251,6 +251,11 @@ public:
/* CUs that are queued to be read. */
std::queue<dwarf2_queue_item> queue;
+ /* We keep a separate reference to the partial symtabs, in case we
+ are sharing them between objfiles. This is only set after
+ partial symbols have been read the first time. */
+ std::shared_ptr<psymtab_storage> partial_symtabs;
+
private:
/* The total number of per_cu and signatured_type objects that have