From patchwork Tue Oct 1 20:12:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 34782 Received: (qmail 51068 invoked by alias); 1 Oct 2019 20:16:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 51054 invoked by uid 89); 1 Oct 2019 20:16:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2367 X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (50.116.125.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Oct 2019 20:16:08 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 9E82940261735 for ; Tue, 1 Oct 2019 14:19:04 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id FOVciJFFoHunhFOVci1HTm; Tue, 01 Oct 2019 15:12:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=SJbpx2t5gI5KgBT8VTxxC2uFpgZ7z63AeAt5cGNAFB0=; b=yA1mtK0eQRSKhxo8WrRV7uoeih uhu6yOFG2PTxXL1iGB/jE1sGzO3TamzpDdFOYBNzJPhOGzZrB16zrK24/ObHGRZwUsQOGZsi0IW3o 4Hm74ASKCS3YSwsrA+O0iIS0e; Received: from 75-166-72-156.hlrn.qwest.net ([75.166.72.156]:47310 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iFOVc-0023p5-FE; Tue, 01 Oct 2019 14:12:32 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v4 02/11] Defer minimal symbol name-setting Date: Tue, 1 Oct 2019 14:12:18 -0600 Message-Id: <20191001201227.8519-3-tom@tromey.com> In-Reply-To: <20191001201227.8519-1-tom@tromey.com> References: <20191001201227.8519-1-tom@tromey.com> Currently the demangled name of a minimal symbol is set when creating the symbol. However, there is no intrinsic need to do this. This patch instead arranges for the demangling to be done just before the minsym hash tables are filled. This will be useful in a later patch. gdb/ChangeLog 2019-10-01 Tom Tromey * symtab.h (struct minimal_symbol) : New member. * minsyms.c (minimal_symbol_reader::record_full): Copy name. Don't call symbol_set_names. (minimal_symbol_reader::install): Call symbol_set_names. --- gdb/ChangeLog | 7 +++++++ gdb/minsyms.c | 18 +++++++++++++++++- gdb/symtab.h | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 83f5d895779..2b259d39c11 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1106,7 +1106,11 @@ minimal_symbol_reader::record_full (const char *name, int name_len, msymbol = &m_msym_bunch->contents[m_msym_bunch_index]; symbol_set_language (msymbol, language_auto, &m_objfile->per_bfd->storage_obstack); - symbol_set_names (msymbol, name, name_len, copy_name, m_objfile->per_bfd); + + if (copy_name) + name = (char *) obstack_copy0 (&m_objfile->per_bfd->storage_obstack, + name, name_len); + msymbol->name = name; SET_MSYMBOL_VALUE_ADDRESS (msymbol, address); MSYMBOL_SECTION (msymbol) = section; @@ -1327,6 +1331,18 @@ minimal_symbol_reader::install () m_objfile->per_bfd->minimal_symbol_count = mcount; m_objfile->per_bfd->msymbols = std::move (msym_holder); + msymbols = m_objfile->per_bfd->msymbols.get (); + for (int i = 0; i < mcount; ++i) + { + if (!msymbols[i].name_set) + { + symbol_set_names (&msymbols[i], msymbols[i].name, + strlen (msymbols[i].name), 0, + m_objfile->per_bfd); + msymbols[i].name_set = 1; + } + } + build_minimal_symbol_hash_tables (m_objfile); } } diff --git a/gdb/symtab.h b/gdb/symtab.h index 1f0fc62a657..c3918a85af7 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -669,6 +669,10 @@ struct minimal_symbol : public general_symbol_info the object file format may not carry that piece of information. */ unsigned int has_size : 1; + /* Non-zero if this symbol ever had its demangled name set (even if + it was set to NULL). */ + unsigned int name_set : 1; + /* Minimal symbols with the same hash key are kept on a linked list. This is the link. */