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 B36DA395B0B1 for ; Tue, 12 May 2020 21:09:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B36DA395B0B1 X-ASG-Debug-ID: 1589317755-0c856e314b893510001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id hn73h61RWqcTfU3Y (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 82ED8441D65; 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 Cc: Tom Tromey Subject: [PATCH v2 03/42] Add dwarf2_per_cu_data::index Date: Tue, 12 May 2020 17:08:34 -0400 X-ASG-Orig-Subj: [PATCH v2 03/42] Add dwarf2_per_cu_data::index Message-Id: <20200512210913.5593-4-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: 7468 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.81805 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-31.3 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:19 -0000 From: Tom Tromey Currently, a dwarf2_per_cu_data can hold a link to the corresponding expanded compunit_symtab. However, the dwarf2_per_cu_data objects are shared across objfiles, a simple pointer won't work: each objfile sharing the dwarf2_per_cu_data instance will have a corresponding compunit_symtab. Instead, this link will be stored in the dwarf2_per_objfile object (which will contain the objfile-specific data). To enable this, we add an index to each dwarf2_per_cu_data and signatured_type. The data structure in the dwarf2_per_objfile will use this new index to map a dwarf2_per_cu_data to its corresponding compunit_symtab, for this objfile. 2020-02-21 Tom Tromey * dwarf2/read.h (struct dwarf2_per_objfile) : Declare new methods. : New member. (struct dwarf2_per_cu_data) : New member. * dwarf2/read.c (dwarf2_per_objfile::allocate_per_cu) (dwarf2_per_objfile::allocate_signatured_type): New methods. (create_cu_from_index_list): Use allocate_per_cu. (create_signatured_type_table_from_index) (create_signatured_type_table_from_debug_names) (create_debug_type_hash_table, add_type_unit) (read_comp_units_from_section): Use allocate_signatured_type. --- gdb/dwarf2/read.c | 46 +++++++++++++++++++++++++++------------------- gdb/dwarf2/read.h | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 664520fbb4c..9217f784b38 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2408,6 +2408,26 @@ dwarf2_per_objfile::get_tu (int index) return this->all_type_units[index]; } +/* See read.h. */ + +dwarf2_per_cu_data * +dwarf2_per_objfile::allocate_per_cu () +{ + dwarf2_per_cu_data *result = OBSTACK_ZALLOC (&obstack, dwarf2_per_cu_data); + result->index = m_num_psymtabs++; + return result; +} + +/* See read.h. */ + +signatured_type * +dwarf2_per_objfile::allocate_signatured_type () +{ + signatured_type *result = OBSTACK_ZALLOC (&obstack, signatured_type); + result->per_cu.index = m_num_psymtabs++; + return result; +} + /* Return a new dwarf2_per_cu_data allocated on the dwarf2_per_objfile obstack, and constructed with the specified field values. */ @@ -2417,9 +2437,7 @@ create_cu_from_index_list (struct dwarf2_per_objfile *dwarf2_per_objfile, int is_dwz, sect_offset sect_off, ULONGEST length) { - dwarf2_per_cu_data *the_cu - = OBSTACK_ZALLOC (&dwarf2_per_objfile->obstack, - struct dwarf2_per_cu_data); + dwarf2_per_cu_data *the_cu = dwarf2_per_objfile->allocate_per_cu (); the_cu->sect_off = sect_off; the_cu->length = length; the_cu->dwarf2_per_objfile = dwarf2_per_objfile; @@ -2508,8 +2526,7 @@ create_signatured_type_table_from_index signature = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE); bytes += 3 * 8; - sig_type = OBSTACK_ZALLOC (&dwarf2_per_objfile->obstack, - struct signatured_type); + sig_type = dwarf2_per_objfile->allocate_signatured_type (); sig_type->signature = signature; sig_type->type_offset_in_tu = type_offset_in_tu; sig_type->per_cu.is_debug_types = 1; @@ -2565,8 +2582,7 @@ create_signatured_type_table_from_debug_names section->buffer + to_underlying (sect_off), rcuh_kind::TYPE); - sig_type = OBSTACK_ZALLOC (&dwarf2_per_objfile->obstack, - struct signatured_type); + sig_type = dwarf2_per_objfile->allocate_signatured_type (); sig_type->signature = cu_header.signature; sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu; sig_type->per_cu.is_debug_types = 1; @@ -6206,8 +6222,7 @@ create_debug_type_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, /* N.B.: type_offset is not usable if this type uses a DWO file. The real type_offset is in the DWO file. */ dwo_tu = NULL; - sig_type = OBSTACK_ZALLOC (&dwarf2_per_objfile->obstack, - struct signatured_type); + sig_type = dwarf2_per_objfile->allocate_signatured_type (); sig_type->signature = header.signature; sig_type->type_offset_in_tu = header.type_cu_offset_in_tu; sig_type->per_cu.dwarf2_per_objfile = dwarf2_per_objfile; @@ -6322,8 +6337,7 @@ add_type_unit (struct dwarf2_per_objfile *dwarf2_per_objfile, ULONGEST sig, == dwarf2_per_objfile->all_type_units.capacity ()) ++dwarf2_per_objfile->tu_stats.nr_all_type_units_reallocs; - signatured_type *sig_type = OBSTACK_ZALLOC (&dwarf2_per_objfile->obstack, - struct signatured_type); + signatured_type *sig_type = dwarf2_per_objfile->allocate_signatured_type (); dwarf2_per_objfile->all_type_units.push_back (sig_type); sig_type->signature = sig; @@ -7928,16 +7942,10 @@ read_comp_units_from_section (struct dwarf2_per_objfile *dwarf2_per_objfile, /* Save the compilation unit for later lookup. */ if (cu_header.unit_type != DW_UT_type) - { - this_cu = XOBNEW (&dwarf2_per_objfile->obstack, - struct dwarf2_per_cu_data); - memset (this_cu, 0, sizeof (*this_cu)); - } + this_cu = dwarf2_per_objfile->allocate_per_cu (); else { - auto sig_type = XOBNEW (&dwarf2_per_objfile->obstack, - struct signatured_type); - memset (sig_type, 0, sizeof (*sig_type)); + auto sig_type = dwarf2_per_objfile->allocate_signatured_type (); sig_type->signature = cu_header.signature; sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu; this_cu = &sig_type->per_cu; diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 8dbda90aa59..bbc4f96b7cf 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -111,6 +111,16 @@ struct dwarf2_per_objfile /* Free all cached compilation units. */ void free_cached_comp_units (); + /* A convenience function to allocate a dwarf2_per_cu_data. The + returned object has its "index" field set properly. The object + is allocated on the dwarf2_per_objfile obstack. */ + dwarf2_per_cu_data *allocate_per_cu (); + + /* A convenience function to allocate a signatured_type. The + returned object has its "index" field set properly. The object + is allocated on the dwarf2_per_objfile obstack. */ + signatured_type *allocate_signatured_type (); + /* Return pointer to string at .debug_line_str offset as read from BUF. BUF is assumed to be in a compilation unit described by CU_HEADER. Return *BYTES_READ_PTR count of bytes read from BUF. */ @@ -249,6 +259,12 @@ struct dwarf2_per_objfile /* CUs that are queued to be read. */ std::queue queue; + +private: + + /* The total number of per_cu and signatured_type objects that have + been created so far for this reader. */ + size_t m_num_psymtabs = 0; }; /* Get the dwarf2_per_objfile associated to OBJFILE. */ @@ -322,6 +338,9 @@ struct dwarf2_per_cu_data This flag is only valid if is_debug_types is true. */ unsigned int tu_read : 1; + /* Our index in the unshared "symtabs" vector. */ + unsigned index; + /* The section this CU/TU lives in. If the DIE refers to a DWO file, this is always the original die, not the DWO file. */ -- 2.26.2