From patchwork Thu Mar 7 20:57:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31780 Received: (qmail 53963 invoked by alias); 7 Mar 2019 20:57:18 -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 53584 invoked by uid 89); 7 Mar 2019 20:57:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.144.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Mar 2019 20:57:14 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 0DEC92F6E7 for ; Thu, 7 Mar 2019 14:57:13 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 204nhFHekdnCe204nhA1nu; Thu, 07 Mar 2019 14:57:13 -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=9HeAqRvvR/ZEzzt7KRjl+To0oUsE4lM/GPT4lDaXedI=; b=D6RC4oWptKWdFYbgianujHra5b 2gPv9VKWOn3fUwfbvCQHLEb80mSCHDmUVBOJvfQQNm6udWMNtaddrBhiBoifWMo6op26ybK1Tq7SR 5woAfwm0GeR3wqfGPiPwfhzmY; Received: from 75-166-85-218.hlrn.qwest.net ([75.166.85.218]:53182 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1h204m-002TOW-Qb; Thu, 07 Mar 2019 14:57:12 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 6/9] Use htab_up for demangled hash Date: Thu, 7 Mar 2019 13:57:06 -0700 Message-Id: <20190307205709.21919-7-tom@tromey.com> In-Reply-To: <20190307205709.21919-1-tom@tromey.com> References: <20190307205709.21919-1-tom@tromey.com> This changes objfile_per_bfd_storage::demangled_names_hash to be an htab_up. This lets us remove some manual management code from the objfile_per_bfd_storage destructor. gdb/ChangeLog 2019-03-07 Tom Tromey * symtab.c (create_demangled_names_hash): Update. (symbol_set_names): Update. * objfiles.h (struct objfile_per_bfd_storage) : Now an htab_up. * objfiles.c (objfile_per_bfd_storage): Simplify. --- gdb/ChangeLog | 8 ++++++++ gdb/objfiles.c | 2 -- gdb/objfiles.h | 2 +- gdb/symtab.c | 6 +++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index ff8b6fc72cf..7d36a2a7114 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -119,8 +119,6 @@ static const struct bfd_data *objfiles_bfd_data; objfile_per_bfd_storage::~objfile_per_bfd_storage () { - if (demangled_names_hash) - htab_delete (demangled_names_hash); } /* Create the per-BFD storage object for OBJFILE. If ABFD is not diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 9db212a1d13..709525ae5af 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -261,7 +261,7 @@ struct objfile_per_bfd_storage name, and the second is the demangled name or just a zero byte if the name doesn't demangle. */ - htab *demangled_names_hash = NULL; + htab_up demangled_names_hash; /* The per-objfile information about the entry point, the scope (file/func) containing the entry point, and the scope of the user's main() func. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 005ea23da8d..449bc4cd2b3 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -740,9 +740,9 @@ create_demangled_names_hash (struct objfile_per_bfd_storage *per_bfd) Choosing a much larger table size wastes memory, and saves only about 1% in symbol reading. */ - per_bfd->demangled_names_hash = htab_create_alloc + per_bfd->demangled_names_hash.reset (htab_create_alloc (256, hash_demangled_name_entry, eq_demangled_name_entry, - NULL, xcalloc, xfree); + NULL, xcalloc, xfree)); } /* Try to determine the demangled name for a symbol, based on the @@ -848,7 +848,7 @@ symbol_set_names (struct general_symbol_info *gsymbol, entry.mangled = linkage_name_copy; slot = ((struct demangled_name_entry **) - htab_find_slot (per_bfd->demangled_names_hash, + htab_find_slot (per_bfd->demangled_names_hash.get (), &entry, INSERT)); /* If this name is not in the hash table, add it. */