From patchwork Wed May 29 21:29:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32906 Received: (qmail 63550 invoked by alias); 29 May 2019 21:29:23 -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 63539 invoked by uid 89); 29 May 2019 21:29:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.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=sk:build_m X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.51.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 May 2019 21:29:21 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway24.websitewelcome.com (Postfix) with ESMTP id CDD7E122821 for ; Wed, 29 May 2019 16:29:19 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id W68NhwMJG4FKpW68NhHWor; Wed, 29 May 2019 16:29:19 -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=33aRG6CDUqx1PMIPX/9hbSwDGTM43gHnnf8U5yOmLyM=; b=V398DFRMfGC7nsOD58QVsbX1wT vQQLDt/OPd/CDeIZzLVNxFxZ19CocGotX2IPRez9Qte7fljh2Y6SzcTA4bH4GzGZMuIAL1ehhziLM zksQeyYWEDFHU8nePrslD46VH; Received: from 174-29-48-168.hlrn.qwest.net ([174.29.48.168]:41198 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hW68N-002qwZ-KA; Wed, 29 May 2019 16:29:19 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 1/8] Defer minimal symbol name-setting Date: Wed, 29 May 2019 15:29:09 -0600 Message-Id: <20190529212916.23721-2-tom@tromey.com> In-Reply-To: <20190529212916.23721-1-tom@tromey.com> References: <20190529212916.23721-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-05-29 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 9d29d880aab..488201a1886 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1140,7 +1140,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; @@ -1367,6 +1371,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 e4ee7271a15..cb06fe01c59 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. */