From patchwork Sat Mar 9 17:22:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31799 Received: (qmail 29356 invoked by alias); 9 Mar 2019 17:23:08 -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 29340 invoked by uid 89); 9 Mar 2019 17:23:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 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=20190303 X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.192.34) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Mar 2019 17:23:05 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 1643418412 for ; Sat, 9 Mar 2019 11:23:04 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 2fgchlfGUdnCe2fgchg3sW; Sat, 09 Mar 2019 11:23:04 -0600 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=YWede7wRvOjnlHad1JvE4dRXKGY7pbJ6varg4ErFlg4=; b=iwvqo6gqhqV89vuYWo6Tc4gRuS iEfzNNVzO4AMmq+jFGoU+anYnzFtYpxaBqxuDr0oAL0qRwS99I1zel61hobSJHOj/VX0bq7VD3pD+ LhXEo2MVQeDWg1wTu9pq/jPZd; Received: from 75-166-85-218.hlrn.qwest.net ([75.166.85.218]:56494 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1h2fgc-003et2-KA; Sat, 09 Mar 2019 11:23:02 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 1/6] Defer minimal symbol name-setting Date: Sat, 9 Mar 2019 10:22:55 -0700 Message-Id: <20190309172300.2764-2-tom@tromey.com> In-Reply-To: <20190309172300.2764-1-tom@tromey.com> References: <20190309172300.2764-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-03-03 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 1b8e67bc98b..7872b7e2588 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1145,7 +1145,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; @@ -1404,6 +1408,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; + } + } + /* Now build the hash tables; we can't do this incrementally at an earlier point since we weren't finished with the obstack yet. (And if the msymbol obstack gets moved, all the internal diff --git a/gdb/symtab.h b/gdb/symtab.h index 85dc3710483..29595685981 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. */