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 9A2AA395CC1D for ; Tue, 12 May 2020 21:12:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9A2AA395CC1D X-ASG-Debug-ID: 1589317944-0c856e314b893660001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id GZ5hHZw6XSLgYjBl (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 May 2020 17:12:24 -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 C70ED441B21; Tue, 12 May 2020 17:12:24 -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 11/42] Add dwarf2_per_bfd field to dwarf2_per_cu_data Date: Tue, 12 May 2020 17:11:10 -0400 X-ASG-Orig-Subj: [PATCH v2 11/42] Add dwarf2_per_bfd field to dwarf2_per_cu_data Message-Id: <20200512211141.6073-12-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: 1589317944 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: 6265 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=-29.2 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:12:27 -0000 From: Simon Marchi Some code using dwarf2_per_cu_data objects accesses the corresponding dwarf2_per_bfd using the following pattern: per_cu->dwarf2_per_objfile->per_bfd Since dwarf2_per_cu_data objects are going to become objfile-independent, the dwarf2_per_objfile link must go. To replace it, add a dwarf2_per_cu_data->per_bfd link. It makes sense to have it there because the dwarf2_per_cu_data objects belong to the dwarf2_per_bfd, so this is essentially just a backlink to their owner. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_per_cu_data) : New member. * dwarf2/read.c (dwarf2_per_bfd::allocate_per_cu): Initialize dwarf2_per_cu_data::per_bfd. (dwarf2_per_bfd::allocate_signatured_type): Likewise. (create_type_unit_group): Likewise. (queue_comp_unit): Remove reference to per_cu->dwarf2_per_objfile. (maybe_queue_comp_unit): Likewise. (fill_in_sig_entry_from_dwo_entry): Assign new field. (create_cus_hash_table): Assign new field. --- gdb/dwarf2/read.c | 21 +++++++++++++++------ gdb/dwarf2/read.h | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8b5e8800603..4817add89a7 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2447,6 +2447,7 @@ dwarf2_per_cu_data * dwarf2_per_bfd::allocate_per_cu () { dwarf2_per_cu_data *result = OBSTACK_ZALLOC (&obstack, dwarf2_per_cu_data); + result->per_bfd = this; result->index = m_num_psymtabs++; return result; } @@ -2457,6 +2458,7 @@ signatured_type * dwarf2_per_bfd::allocate_signatured_type () { signatured_type *result = OBSTACK_ZALLOC (&obstack, signatured_type); + result->per_cu.per_bfd = this; result->per_cu.index = m_num_psymtabs++; return result; } @@ -6413,10 +6415,12 @@ fill_in_sig_entry_from_dwo_entry (struct dwarf2_per_objfile *dwarf2_per_objfile, struct signatured_type *sig_entry, struct dwo_unit *dwo_entry) { + dwarf2_per_bfd *per_bfd = dwarf2_per_objfile->per_bfd; + /* Make sure we're not clobbering something we don't expect to. */ gdb_assert (! sig_entry->per_cu.queued); gdb_assert (sig_entry->per_cu.cu == NULL); - if (dwarf2_per_objfile->per_bfd->using_index) + if (per_bfd->using_index) { gdb_assert (sig_entry->per_cu.v.quick != NULL); gdb_assert (!dwarf2_per_objfile->symtab_set_p (&sig_entry->per_cu)); @@ -6433,6 +6437,7 @@ fill_in_sig_entry_from_dwo_entry (struct dwarf2_per_objfile *dwarf2_per_objfile, sig_entry->per_cu.length = dwo_entry->length; sig_entry->per_cu.reading_dwo_directly = 1; sig_entry->per_cu.dwarf2_per_objfile = dwarf2_per_objfile; + sig_entry->per_cu.per_bfd = per_bfd; sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu; sig_entry->dwo_unit = dwo_entry; } @@ -7245,6 +7250,7 @@ static struct type_unit_group * create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct) { struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile; + dwarf2_per_bfd *per_bfd = dwarf2_per_objfile->per_bfd; struct dwarf2_per_cu_data *per_cu; struct type_unit_group *tu_group; @@ -7252,10 +7258,11 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct) struct type_unit_group); per_cu = &tu_group->per_cu; per_cu->dwarf2_per_objfile = dwarf2_per_objfile; + per_cu->per_bfd = per_bfd; - if (dwarf2_per_objfile->per_bfd->using_index) + if (per_bfd->using_index) { - per_cu->v.quick = OBSTACK_ZALLOC (&dwarf2_per_objfile->per_bfd->obstack, + per_cu->v.quick = OBSTACK_ZALLOC (&per_bfd->obstack, struct dwarf2_per_cu_quick_data); } else @@ -8868,7 +8875,7 @@ queue_comp_unit (struct dwarf2_per_cu_data *per_cu, enum language pretend_language) { per_cu->queued = 1; - per_cu->dwarf2_per_objfile->per_bfd->queue.emplace (per_cu, pretend_language); + per_cu->per_bfd->queue.emplace (per_cu, pretend_language); } /* If PER_CU is not yet queued, add it to the queue. @@ -8888,7 +8895,7 @@ maybe_queue_comp_unit (struct dwarf2_cu *dependent_cu, /* We may arrive here during partial symbol reading, if we need full DIEs to process an unusual case (e.g. template arguments). Do not queue PER_CU, just tell our caller to load its DIEs. */ - if (per_cu->dwarf2_per_objfile->per_bfd->reading_partial_symbols) + if (per_cu->per_bfd->reading_partial_symbols) { if (per_cu->cu == NULL || per_cu->cu->dies == NULL) return 1; @@ -11236,6 +11243,7 @@ create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, dwarf2_section_info §ion, htab_up &cus_htab) { struct objfile *objfile = dwarf2_per_objfile->objfile; + dwarf2_per_bfd *per_bfd = dwarf2_per_objfile->per_bfd; const gdb_byte *info_ptr, *end_ptr; section.read (objfile); @@ -11262,6 +11270,7 @@ create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, memset (&per_cu, 0, sizeof (per_cu)); per_cu.dwarf2_per_objfile = dwarf2_per_objfile; + per_cu.per_bfd = per_bfd; per_cu.is_debug_types = 0; per_cu.sect_off = sect_offset (info_ptr - section.buffer); per_cu.section = §ion; @@ -11279,7 +11288,7 @@ create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, if (cus_htab == NULL) cus_htab = allocate_dwo_unit_table (); - dwo_unit = OBSTACK_ZALLOC (&dwarf2_per_objfile->per_bfd->obstack, + dwo_unit = OBSTACK_ZALLOC (&per_bfd->obstack, struct dwo_unit); *dwo_unit = read_unit; slot = htab_find_slot (cus_htab.get (), dwo_unit, INSERT); diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 2897ea6e601..02478d1aa84 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -412,6 +412,9 @@ struct dwarf2_per_cu_data /* The corresponding dwarf2_per_objfile. */ struct dwarf2_per_objfile *dwarf2_per_objfile; + /* Backlink to the owner of this. */ + dwarf2_per_bfd *per_bfd; + /* When dwarf2_per_bfd::using_index is true, the 'quick' field is active. Otherwise, the 'psymtab' field is active. */ union -- 2.26.2