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 21FEF395200F for ; Tue, 12 May 2020 21:17:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 21FEF395200F X-ASG-Debug-ID: 1589318266-0c856e18f31444ed0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id TIarYoENLSthVeGs (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 May 2020 17:17:46 -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 52BCA441B21; Tue, 12 May 2020 17:17:46 -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 34/42] Move signatured_type::type to unshareable object Date: Tue, 12 May 2020 17:17:04 -0400 X-ASG-Orig-Subj: [PATCH v2 34/42] Move signatured_type::type to unshareable object Message-Id: <20200512211712.6543-35-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: 1589318266 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: 4388 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=-25.5 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:17:48 -0000 From: Tom Tromey signatured_type has a link to the "struct type". However, types are inherently objfile-specific, so once sharing is implemented, this will be incorrect. This patch moves the type to a new map in the DWARF unshareable object. YYYY-MM-DD Tom Tromey YYYY-MM-DD Simon Marchi * dwarf2/read.h (struct dwarf2_per_objfile) : New methods. : New member. (struct signatured_type) : Remove. * dwarf2/read.c (dwarf2_per_objfile::get_type_for_signatured_type, dwarf2_per_objfile::set_type_for_signatured_type): New. (get_signatured_type): Use new methods. --- gdb/dwarf2/read.c | 27 ++++++++++++++++++++++++--- gdb/dwarf2/read.h | 17 ++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9a9fd05ec26..853dd5884a4 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9592,6 +9592,25 @@ dwarf2_per_objfile::get_type_unit_group_unshareable (type_unit_group *tu_group) return result; } +struct type * +dwarf2_per_objfile::get_type_for_signatured_type + (signatured_type *sig_type) const +{ + auto iter = this->m_type_map.find (sig_type); + if (iter == this->m_type_map.end ()) + return nullptr; + + return iter->second; +} + +void dwarf2_per_objfile::set_type_for_signatured_type + (signatured_type *sig_type, struct type *type) +{ + gdb_assert (this->m_type_map.find (sig_type) == this->m_type_map.end ()); + + this->m_type_map[sig_type] = type; +} + /* A helper function for computing the list of all symbol tables included by PER_CU. */ @@ -22680,8 +22699,9 @@ get_signatured_type (struct die_info *die, ULONGEST signature, } /* If we already know the type we're done. */ - if (sig_type->type != NULL) - return sig_type->type; + type = dwarf2_per_objfile->get_type_for_signatured_type (sig_type); + if (type != nullptr) + return type; type_cu = cu; type_die = follow_die_sig_1 (die, sig_type, &type_cu); @@ -22708,7 +22728,8 @@ get_signatured_type (struct die_info *die, ULONGEST signature, objfile_name (dwarf2_per_objfile->objfile)); type = build_error_marker_type (cu, die); } - sig_type->type = type; + + dwarf2_per_objfile->set_type_for_signatured_type (sig_type, type); return type; } diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 13d31a97d3d..3500b0e7ba9 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -329,11 +329,16 @@ struct dwarf2_per_objfile /* Set the compunit_symtab associated to PER_CU. */ void set_symtab (const dwarf2_per_cu_data *per_cu, compunit_symtab *symtab); -/* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one - does not exist, create it. */ + /* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one + does not exist, create it. */ type_unit_group_unshareable *get_type_unit_group_unshareable (type_unit_group *tu_group); + struct type *get_type_for_signatured_type (signatured_type *sig_type) const; + + void set_type_for_signatured_type (signatured_type *sig_type, + struct type *type); + /* Find an integer type SIZE_IN_BYTES bytes in size and return it. UNSIGNED_P controls if the integer is unsigned or not. */ struct type *int_type (int size_in_bytes, bool unsigned_p) const; @@ -363,6 +368,9 @@ struct dwarf2_per_objfile std::unordered_map m_type_units; + + /* Map from signatured types to the corresponding struct type. */ + std::unordered_map m_type_map; }; /* Get the dwarf2_per_objfile associated to OBJFILE. */ @@ -584,11 +592,6 @@ struct signatured_type can share them. This points to the containing symtab. */ struct type_unit_group *type_unit_group; - /* The type. - The first time we encounter this type we fully read it in and install it - in the symbol tables. Subsequent times we only need the type. */ - struct type *type; - /* Containing DWO unit. This field is valid iff per_cu.reading_dwo_directly. */ struct dwo_unit *dwo_unit; -- 2.26.2