aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-05-27 11:15:47 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-27 11:15:47 -0400
commitaf758d117e1454daebc6135cb70529b9843c3437 (patch)
tree3d7dac616c76fc95f03dc3543939476a4fbc4095 /gdb/dwarf2/read.h
parent5989a64ed5ee7a7f9c0fc284f66ef4bd414ad6c2 (diff)
downloadgdb-af758d117e1454daebc6135cb70529b9843c3437.zip
gdb-af758d117e1454daebc6135cb70529b9843c3437.tar.gz
gdb-af758d117e1454daebc6135cb70529b9843c3437.tar.bz2
Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data
The dwarf2_psymtab and dwarf2_per_cu_quick_data types contain a pointer to a compunit_symtab, which is a pointer to the corresponding full symtab. The dwarf2_psymtab and dwarf2_per_cu_quick_data objects are going to become objfile-independent, and possibly shared by multiple objfiles, whereas compunit_symtab will stay objfile-dependent. This backlink to the compunit_symtab must therefore be removed. This patch replaces them with a vector in the dwarf2_per_objfile type, that serves as a mapping from dwarf2_per_cu_data objects to compunit_symtab objects, for this particular objfile. The vector is indexed using the index assigned to the dwarf2_per_cu_data at its creation. I removed the get_compunit_symtab, as it appears to bring not much value over calling dwarf2_per_objfile::get_symtab directly. gdb/ChangeLog: YYYY-MM-DD Tom Tromey <tom@tromey.com> YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com> * dwarf2/read.h (struct dwarf2_per_bfd) <num_psymtabs>: New method. (struct dwarf2_per_objfile) <resize_symtabs, symtab_set_p, get_symtab, set_symtab>: New methods. <m_symtabs>: New field. (struct dwarf2_psymtab): Derive from partial_symtab. <readin_p, get_compunit_symtab>: Declare methods. * dwarf2/read.c (dwarf2_per_objfile::symtab_set_p, dwarf2_per_objfile::get_symtab, dwarf2_per_objfile::set_symtab): New methods. (struct dwarf2_per_cu_quick_data) <compunit_symtab>: Remove. (dw2_do_instantiate_symtab, dw2_instantiate_symtab) (dw2_map_expand_apply, dw2_map_symtabs_matching_filename) (dw2_symtab_iter_next, dw2_print_stats) (dw2_expand_symtabs_with_fullname) (dw2_expand_symtabs_matching_one) (dw_expand_symtabs_matching_file_matcher) (dw2_find_pc_sect_compunit_symtab, dw2_map_symbol_filenames) (dw2_debug_names_iterator::next) (dw2_debug_names_map_matching_symbols) (fill_in_sig_entry_from_dwo_entry, dwarf2_psymtab::read_symtab) (process_queue, dwarf2_psymtab::expand_psymtab): Update. (dwarf2_psymtab::readin_p, dwarf2_psymtab::get_compunit_symtab): New methods. (get_compunit_symtab, process_full_comp_unit) (process_full_type_unit): Update. (dwarf2_build_psymtabs, dwarf2_initialize_objfile, add_type_unit): Call Change-Id: Iec53d96e0b70a57d8b68408febdac3c6c3d4854b
Diffstat (limited to 'gdb/dwarf2/read.h')
-rw-r--r--gdb/dwarf2/read.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 4dc9496..7631938ed 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -123,6 +123,11 @@ struct dwarf2_per_bfd
is allocated on the dwarf2_per_bfd obstack. */
signatured_type *allocate_signatured_type ();
+ /* Return the number of partial symtabs allocated with allocate_per_cu
+ and allocate_signatured_type so far. */
+ int num_psymtabs () const
+ { return m_num_psymtabs; }
+
private:
/* This function is mapped across the sections and remembers the
offset and size of each of the debugging sections we are
@@ -278,12 +283,38 @@ struct dwarf2_per_objfile
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr);
+ /* Resize the M_SYMTABS vector to the needed size (the number of partial
+ symtabs allocated by the per-bfd). */
+ void resize_symtabs ()
+ {
+ /* The symtabs vector should only grow, not shrink. */
+ gdb_assert (per_bfd->num_psymtabs () >= m_symtabs.size ());
+
+ m_symtabs.resize (per_bfd->num_psymtabs ());
+ }
+
+ /* Return true if the symtab corresponding to PER_CU has been set,
+ false otherwise. */
+ bool symtab_set_p (const dwarf2_per_cu_data *per_cu) const;
+
+ /* Return the compunit_symtab associated to PER_CU, if it has been created. */
+ compunit_symtab *get_symtab (const dwarf2_per_cu_data *per_cu) const;
+
+ /* Set the compunit_symtab associated to PER_CU. */
+ void set_symtab (const dwarf2_per_cu_data *per_cu, compunit_symtab *symtab);
+
/* Back link. */
struct objfile *objfile;
/* Pointer to the data that is (possibly) shared between this objfile and
other objfiles backed by the same BFD. */
struct dwarf2_per_bfd *per_bfd;
+
+private:
+ /* Hold the corresponding compunit_symtab for each CU or TU. This
+ is indexed by dwarf2_per_cu_data::index. A NULL value means
+ that the CU/TU has not been expanded yet. */
+ std::vector<compunit_symtab *> m_symtabs;
};
/* Get the dwarf2_per_objfile associated to OBJFILE. */
@@ -291,17 +322,19 @@ struct dwarf2_per_objfile
dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
/* A partial symtab specialized for DWARF. */
-struct dwarf2_psymtab : public standard_psymtab
+struct dwarf2_psymtab : public partial_symtab
{
dwarf2_psymtab (const char *filename, struct objfile *objfile,
dwarf2_per_cu_data *per_cu)
- : standard_psymtab (filename, objfile, 0),
+ : partial_symtab (filename, objfile, 0),
per_cu_data (per_cu)
{
}
void read_symtab (struct objfile *) override;
void expand_psymtab (struct objfile *) override;
+ bool readin_p (struct objfile *) const override;
+ compunit_symtab *get_compunit_symtab (struct objfile *) const override;
struct dwarf2_per_cu_data *per_cu_data;
};