From patchwork Tue Oct 29 22:16:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35462 Received: (qmail 94186 invoked by alias); 29 Oct 2019 22:16:39 -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 94173 invoked by uid 89); 29 Oct 2019 22:16:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Oct 2019 22:16:37 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 2075220D4D; Tue, 29 Oct 2019 18:16:36 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 0870320277; Tue, 29 Oct 2019 18:16:34 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id DEB7920AF6; Tue, 29 Oct 2019 18:16:34 -0400 (EDT) X-Gerrit-PatchSet: 1 Date: Tue, 29 Oct 2019 18:16:34 -0400 From: "Christian Biesinger (Code Review)" To: gdb-patches@sourceware.org Cc: Christian Biesinger Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Only clear the minsym array when necessary X-Gerrit-Change-Id: I7da994fe6747f67714e7efe9fdbb0dbc4d6ea532 X-Gerrit-Change-Number: 442 X-Gerrit-ChangeURL: X-Gerrit-Commit: cd52e118ec474b7abdc7c6b989ccb544274fd4c8 References: Reply-To: cbiesinger@google.com, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-74-g460fb0f7e9 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/442 ...................................................................... Only clear the minsym array when necessary The array starts out initialized to zero: minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE] {}; So we only need to explicitly clear it if there were previous minsyms added to it. This patch does that. gdb/ChangeLog: 2019-10-29 Christian Biesinger * minsyms.c (clear_minimal_symbol_hash_tables): New function. (build_minimal_symbol_hash_tables): Code to clear the table moved to clear_minimal_symbol_hash_tables. (minimal_symbol_reader::install): Call clear_minimal_symbol_hash_tables when needed. Change-Id: I7da994fe6747f67714e7efe9fdbb0dbc4d6ea532 --- M gdb/minsyms.c 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gdb/minsyms.c b/gdb/minsyms.c index db3e546..10f02bb 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1238,6 +1238,16 @@ return (mcount); } +static void +clear_minimal_symbol_hash_tables (struct objfile *objfile) +{ + for (size_t i = 0; i < MINIMAL_SYMBOL_HASH_SIZE; i++) + { + objfile->per_bfd->msymbol_hash[i] = 0; + objfile->per_bfd->msymbol_demangled_hash[i] = 0; + } +} + /* Build (or rebuild) the minimal symbol hash tables. This is necessary after compacting or sorting the table since the entries move around thus causing the internal minimal_symbol pointers to become jumbled. */ @@ -1248,14 +1258,7 @@ int i; struct minimal_symbol *msym; - /* Clear the hash tables. */ - for (i = 0; i < MINIMAL_SYMBOL_HASH_SIZE; i++) - { - objfile->per_bfd->msymbol_hash[i] = 0; - objfile->per_bfd->msymbol_demangled_hash[i] = 0; - } - - /* Now, (re)insert the actual entries. */ + /* (Re)insert the actual entries. */ for ((i = objfile->per_bfd->minimal_symbol_count, msym = objfile->per_bfd->msymbols.get ()); i > 0; @@ -1345,6 +1348,9 @@ The strings themselves are also located in the storage_obstack of this objfile. */ + if (m_objfile->per_bfd->minimal_symbol_count) + clear_minimal_symbol_hash_tables (m_objfile); + m_objfile->per_bfd->minimal_symbol_count = mcount; m_objfile->per_bfd->msymbols = std::move (msym_holder);