From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 79A2C3954452 for ; Tue, 12 May 2020 21:09:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 79A2C3954452 X-ASG-Debug-ID: 1589317755-0c856e18f31444b80001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id fWHrIVpsnxS5mFj7 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 May 2020 17:09:15 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id CE192441D65; Tue, 12 May 2020 17:09:15 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 X-Barracuda-RBL-IP: 192.222.181.218 To: gdb-patches@sourceware.org Subject: [PATCH v2 06/42] Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data Date: Tue, 12 May 2020 17:08:37 -0400 X-ASG-Orig-Subj: [PATCH v2 06/42] Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data Message-Id: <20200512210913.5593-7-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512210913.5593-1-simon.marchi@efficios.com> References: <20200512210913.5593-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1589317755 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 21007 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.81805 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-Spam-Status: No, score=-29.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 May 2020 21:09:23 -0000 From: Simon Marchi 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. YYYY-MM-DD Tom Tromey YYYY-MM-DD Simon Marchi * dwarf2/read.h (struct dwarf2_per_bfd) : New method. (struct dwarf2_per_objfile) : New methods. : New field. (struct dwarf2_psymtab): Derive from partial_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) : 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 --- gdb/dwarf2/read.c | 162 +++++++++++++++++++++++++++------------------- gdb/dwarf2/read.h | 37 ++++++++++- 2 files changed, 129 insertions(+), 70 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 0b16ec127f5..4dfa85ff0c7 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1811,6 +1811,38 @@ class free_cached_comp_units dwarf2_per_objfile *m_per_objfile; }; +/* See read.h. */ + +bool +dwarf2_per_objfile::symtab_set_p (const dwarf2_per_cu_data *per_cu) const +{ + gdb_assert (per_cu->index < this->m_symtabs.size ()); + + return this->m_symtabs[per_cu->index] != nullptr; +} + +/* See read.h. */ + +compunit_symtab * +dwarf2_per_objfile::get_symtab (const dwarf2_per_cu_data *per_cu) const +{ + gdb_assert (per_cu->index < this->m_symtabs.size ()); + + return this->m_symtabs[per_cu->index]; +} + +/* See read.h. */ + +void +dwarf2_per_objfile::set_symtab (const dwarf2_per_cu_data *per_cu, + compunit_symtab *symtab) +{ + gdb_assert (per_cu->index < this->m_symtabs.size ()); + gdb_assert (this->m_symtabs[per_cu->index] == nullptr); + + this->m_symtabs[per_cu->index] = symtab; +} + /* Try to locate the sections we need for DWARF 2 debugging information and return true if we have enough to do something. NAMES points to the dwarf2 section names, or is NULL if the standard @@ -2198,10 +2230,6 @@ struct dwarf2_per_cu_quick_data NOTE: This points into dwarf2_per_objfile->per_bfd->quick_file_names_table. */ struct quick_file_names *file_names; - /* The corresponding symbol table. This is NULL if symbols for this - CU have not yet been read. */ - struct compunit_symtab *compunit_symtab; - /* A temporary mark bit used when iterating over all CUs in expand_symtabs_matching. */ unsigned int mark : 1; @@ -2325,9 +2353,7 @@ dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu, bool skip_partial) with the dwarf queue empty. */ dwarf2_queue_guard q_guard (dwarf2_per_objfile); - if (dwarf2_per_objfile->per_bfd->using_index - ? per_cu->v.quick->compunit_symtab == NULL - : (per_cu->v.psymtab == NULL || !per_cu->v.psymtab->readin)) + if (!dwarf2_per_objfile->symtab_set_p (per_cu)) { queue_comp_unit (per_cu, language_minimal); load_cu (per_cu, skip_partial); @@ -2362,7 +2388,8 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu, bool skip_partial) struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile; gdb_assert (dwarf2_per_objfile->per_bfd->using_index); - if (!per_cu->v.quick->compunit_symtab) + + if (!dwarf2_per_objfile->symtab_set_p (per_cu)) { free_cached_comp_units freer (dwarf2_per_objfile); scoped_restore decrementer = increment_reading_symtab (); @@ -2370,7 +2397,7 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu, bool skip_partial) process_cu_includes (dwarf2_per_objfile); } - return per_cu->v.quick->compunit_symtab; + return dwarf2_per_objfile->get_symtab (per_cu); } /* See declaration. */ @@ -3274,7 +3301,8 @@ dw2_map_expand_apply (struct objfile *objfile, struct compunit_symtab *last_made = objfile->compunit_symtabs; /* Don't visit already-expanded CUs. */ - if (per_cu->v.quick->compunit_symtab) + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + if (per_objfile->symtab_set_p (per_cu)) return 0; /* This may expand more than one symtab, and we want to iterate over @@ -3302,7 +3330,7 @@ dw2_map_symtabs_matching_filename for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units) { /* We only need to look at symtabs not already expanded. */ - if (per_cu->v.quick->compunit_symtab) + if (dwarf2_per_objfile->symtab_set_p (per_cu)) continue; quick_file_names *file_data = dw2_get_file_names (per_cu); @@ -3444,7 +3472,7 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter) dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->per_bfd->get_cutu (cu_index); /* Skip if already read in. */ - if (per_cu->v.quick->compunit_symtab) + if (dwarf2_per_objfile->symtab_set_p (per_cu)) continue; /* Check static vs global. */ @@ -3559,7 +3587,7 @@ dw2_print_stats (struct objfile *objfile) { dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->per_bfd->get_cutu (i); - if (!per_cu->v.quick->compunit_symtab) + if (!dwarf2_per_objfile->symtab_set_p (per_cu)) ++count; } printf_filtered (_(" Number of read CUs: %d\n"), total - count); @@ -3642,7 +3670,7 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile, for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units) { /* We only need to look at symtabs not already expanded. */ - if (per_cu->v.quick->compunit_symtab) + if (dwarf2_per_objfile->symtab_set_p (per_cu)) continue; quick_file_names *file_data = dw2_get_file_names (per_cu); @@ -4467,15 +4495,14 @@ dw2_expand_symtabs_matching_one { if (file_matcher == NULL || per_cu->v.quick->mark) { - bool symtab_was_null - = (per_cu->v.quick->compunit_symtab == NULL); + dwarf2_per_objfile *per_objfile = per_cu->dwarf2_per_objfile; + bool symtab_was_null = !per_objfile->symtab_set_p (per_cu); - dw2_instantiate_symtab (per_cu, false); + compunit_symtab *symtab = dw2_instantiate_symtab (per_cu, false); + gdb_assert (symtab != nullptr); - if (expansion_notify != NULL - && symtab_was_null - && per_cu->v.quick->compunit_symtab != NULL) - expansion_notify (per_cu->v.quick->compunit_symtab); + if (expansion_notify != NULL && symtab_was_null) + expansion_notify (symtab); } } @@ -4593,7 +4620,7 @@ dw_expand_symtabs_matching_file_matcher per_cu->v.quick->mark = 0; /* We only need to look at symtabs not already expanded. */ - if (per_cu->v.quick->compunit_symtab) + if (dwarf2_per_objfile->symtab_set_p (per_cu)) continue; quick_file_names *file_data = dw2_get_file_names (per_cu); @@ -4731,7 +4758,8 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile, if (!data) return NULL; - if (warn_if_readin && data->v.quick->compunit_symtab) + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + if (warn_if_readin && per_objfile->symtab_set_p (data)) warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"), paddress (objfile->arch (), pc)); @@ -4764,7 +4792,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun, for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units) { - if (per_cu->v.quick->compunit_symtab) + if (dwarf2_per_objfile->symtab_set_p (per_cu)) { void **slot = htab_find_slot (visited.get (), per_cu->v.quick->file_names, @@ -4777,7 +4805,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun, for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units) { /* We only need to look at symtabs not already expanded. */ - if (per_cu->v.quick->compunit_symtab) + if (dwarf2_per_objfile->symtab_set_p (per_cu)) continue; quick_file_names *file_data = dw2_get_file_names (per_cu); @@ -5448,7 +5476,7 @@ dw2_debug_names_iterator::next () } /* Skip if already read in. */ - if (per_cu->v.quick->compunit_symtab) + if (dwarf2_per_objfile->symtab_set_p (per_cu)) goto again; /* Check static vs global. */ @@ -5689,11 +5717,11 @@ dw2_debug_names_map_matching_symbols the psymtab code does. */ for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units) { - struct compunit_symtab *cust = per_cu->v.quick->compunit_symtab; - if (cust != nullptr) + compunit_symtab *symtab = dwarf2_per_objfile->get_symtab (per_cu); + if (symtab != nullptr) { const struct block *block - = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind); + = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (symtab), block_kind); if (!iterate_over_symbols_terminated (block, name, domain, callback)) break; @@ -5843,6 +5871,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) dwarf2_per_objfile->per_bfd->quick_file_names_table = create_quick_file_names_table (dwarf2_per_objfile->per_bfd->all_comp_units.size ()); + dwarf2_per_objfile->resize_symtabs (); for (int i = 0; i < (dwarf2_per_objfile->per_bfd->all_comp_units.size () + dwarf2_per_objfile->per_bfd->all_type_units.size ()); ++i) @@ -5863,6 +5892,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) if (dwarf2_read_debug_names (dwarf2_per_objfile)) { *index_kind = dw_index_kind::DEBUG_NAMES; + dwarf2_per_objfile->resize_symtabs (); return true; } @@ -5871,6 +5901,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) get_gdb_index_contents_from_section)) { *index_kind = dw_index_kind::GDB_INDEX; + dwarf2_per_objfile->resize_symtabs (); return true; } @@ -5881,6 +5912,7 @@ dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind) { global_index_cache.hit (); *index_kind = dw_index_kind::GDB_INDEX; + dwarf2_per_objfile->resize_symtabs (); return true; } @@ -5909,6 +5941,8 @@ dwarf2_build_psymtabs (struct objfile *objfile) dwarf2_build_psymtabs_hard (dwarf2_per_objfile); psymtabs.keep (); + dwarf2_per_objfile->resize_symtabs (); + /* (maybe) store an index in the cache. */ global_index_cache.store (dwarf2_per_objfile); } @@ -6339,6 +6373,8 @@ add_type_unit (struct dwarf2_per_objfile *dwarf2_per_objfile, ULONGEST sig, signatured_type *sig_type = dwarf2_per_objfile->per_bfd->allocate_signatured_type (); + dwarf2_per_objfile->resize_symtabs (); + dwarf2_per_objfile->per_bfd->all_type_units.push_back (sig_type); sig_type->signature = sig; sig_type->per_cu.is_debug_types = 1; @@ -6374,7 +6410,7 @@ fill_in_sig_entry_from_dwo_entry (struct dwarf2_per_objfile *dwarf2_per_objfile, if (dwarf2_per_objfile->per_bfd->using_index) { gdb_assert (sig_entry->per_cu.v.quick != NULL); - gdb_assert (sig_entry->per_cu.v.quick->compunit_symtab == NULL); + gdb_assert (!dwarf2_per_objfile->symtab_set_p (&sig_entry->per_cu)); } else gdb_assert (sig_entry->per_cu.v.psymtab == NULL); @@ -8801,7 +8837,8 @@ dwarf2_psymtab::read_symtab (struct objfile *objfile) struct dwarf2_per_objfile *dwarf2_per_objfile = get_dwarf2_per_objfile (objfile); - gdb_assert (!readin); + gdb_assert (!dwarf2_per_objfile->symtab_set_p (per_cu_data)); + /* If this psymtab is constructed from a debug-only objfile, the has_section_at_zero flag will not necessarily be correct. We can get the correct value for this flag by looking at the data @@ -8897,9 +8934,7 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile) { dwarf2_queue_item &item = dwarf2_per_objfile->per_bfd->queue.front (); - if ((dwarf2_per_objfile->per_bfd->using_index - ? !item.per_cu->v.quick->compunit_symtab - : (item.per_cu->v.psymtab && !item.per_cu->v.psymtab->readin)) + if (!dwarf2_per_objfile->symtab_set_p (item.per_cu) /* Skip dummy CUs. */ && item.per_cu->cu != NULL) { @@ -8954,7 +8989,7 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile) void dwarf2_psymtab::expand_psymtab (struct objfile *objfile) { - gdb_assert (!readin); + gdb_assert (!readin_p (objfile)); expand_dependencies (objfile); @@ -8962,6 +8997,24 @@ dwarf2_psymtab::expand_psymtab (struct objfile *objfile) gdb_assert (get_compunit_symtab (objfile) != nullptr); } +/* See psympriv.h. */ + +bool +dwarf2_psymtab::readin_p (struct objfile *objfile) const +{ + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + return per_objfile->symtab_set_p (per_cu_data); +} + +/* See psympriv.h. */ + +compunit_symtab * +dwarf2_psymtab::get_compunit_symtab (struct objfile *objfile) const +{ + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + return per_objfile->get_symtab (per_cu_data); +} + /* Trivial hash function for die_info: the hash value of a DIE is its offset in .debug_info for this objfile. */ @@ -9499,17 +9552,6 @@ rust_union_quirks (struct dwarf2_cu *cu) cu->rust_unions.clear (); } -/* Return the symtab for PER_CU. This works properly regardless of - whether we're using the index or psymtabs. */ - -static struct compunit_symtab * -get_compunit_symtab (struct dwarf2_per_cu_data *per_cu) -{ - return (per_cu->dwarf2_per_objfile->per_bfd->using_index - ? per_cu->v.quick->compunit_symtab - : per_cu->v.psymtab->compunit_symtab); -} - /* A helper function for computing the list of all symbol tables included by PER_CU. */ @@ -9519,10 +9561,7 @@ recursively_compute_inclusions (std::vector *result, struct dwarf2_per_cu_data *per_cu, struct compunit_symtab *immediate_parent) { - void **slot; - struct compunit_symtab *cust; - - slot = htab_find_slot (all_children, per_cu, INSERT); + void **slot = htab_find_slot (all_children, per_cu, INSERT); if (*slot != NULL) { /* This inclusion and its children have been processed. */ @@ -9530,8 +9569,9 @@ recursively_compute_inclusions (std::vector *result, } *slot = per_cu; + /* Only add a CU if it has a symbol table. */ - cust = get_compunit_symtab (per_cu); + compunit_symtab *cust = per_cu->dwarf2_per_objfile->get_symtab (per_cu); if (cust != NULL) { /* If this is a type unit only add its symbol table if we haven't @@ -9576,7 +9616,7 @@ compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu) int len; std::vector result_symtabs; htab_t all_children, all_type_symtabs; - struct compunit_symtab *cust = get_compunit_symtab (per_cu); + compunit_symtab *cust = per_cu->dwarf2_per_objfile->get_symtab (per_cu); /* If we don't have a symtab, we can just skip this case. */ if (cust == NULL) @@ -9713,14 +9753,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu, cust->call_site_htab = cu->call_site_htab; } - if (dwarf2_per_objfile->per_bfd->using_index) - per_cu->v.quick->compunit_symtab = cust; - else - { - dwarf2_psymtab *pst = per_cu->v.psymtab; - pst->compunit_symtab = cust; - pst->readin = true; - } + dwarf2_per_objfile->set_symtab (per_cu, cust); /* Push it for inclusion processing later. */ dwarf2_per_objfile->per_bfd->just_read_cus.push_back (per_cu); @@ -9793,14 +9826,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu, cust = sig_type->type_unit_group->compunit_symtab; } - if (dwarf2_per_objfile->per_bfd->using_index) - per_cu->v.quick->compunit_symtab = cust; - else - { - dwarf2_psymtab *pst = per_cu->v.psymtab; - pst->compunit_symtab = cust; - pst->readin = true; - } + dwarf2_per_objfile->set_symtab (per_cu, cust); /* Not needed any more. */ cu->reset_builder (); diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 4dc9496046f..7631938edb0 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 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; }; -- 2.26.2