From patchwork Sun Nov 25 19:20:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 30298 Received: (qmail 29943 invoked by alias); 25 Nov 2018 19:20:56 -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 29732 invoked by uid 89); 25 Nov 2018 19:20:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 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.2 spammy=prove, decent, desirable, 906 X-HELO: gateway22.websitewelcome.com Received: from gateway22.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.46.126) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Nov 2018 19:20:51 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway22.websitewelcome.com (Postfix) with ESMTP id EDB36B7D3 for ; Sun, 25 Nov 2018 13:20:49 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id QzxZgS0sFBcCXQzxZgXuQW; Sun, 25 Nov 2018 13:20:49 -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=8qDFnZk1i1CsErq3+7xwbwg7sLSMibyDjkTIdjjerdE=; b=VzhjopQacvaH9C+emjiicnLPDd WO+BDbuumkUIarLJKoEyiMkmdGs9cVHVQ6CV4DzD55IcVNYPQLYCCzbFsXGk1oy56ZHbwPteQUc7Q +dfXYiDtKaqp+OKGWociV4ydG; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:52060 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gQzxZ-001TOx-OA; Sun, 25 Nov 2018 13:20:49 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 11/12] Make psymtab_storage::free_psymtabs private Date: Sun, 25 Nov 2018 12:20:42 -0700 Message-Id: <20181125192043.8405-12-tom@tromey.com> In-Reply-To: <20181125192043.8405-1-tom@tromey.com> References: <20181125192043.8405-1-tom@tromey.com> This adds a new psymtab allocation method to psymtab_storage and changes the free_psymtabs member to be private. While not strictly necessary, this seems like a decent cleanup, and also makes it simpler to move psymtabs off of obstacks entirely, should that prove desirable. gdb/ChangeLog 2018-11-25 Tom Tromey * psymtab.h (psymtab_storage::allocate_psymtab): New method. : Now private. * psymtab.c (psymtab_storage::allocate_psymtab): Implement. (allocate_psymtab): Use new method. --- gdb/ChangeLog | 7 +++++++ gdb/psymtab.c | 42 +++++++++++++++++++++++++----------------- gdb/psymtab.h | 14 ++++++++++---- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/gdb/psymtab.c b/gdb/psymtab.c index bd957e7b62..50236f2de3 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -78,6 +78,29 @@ psymtab_storage::~psymtab_storage () psymbol_bcache_free (psymbol_cache); } +/* See psymtab.h. */ + +struct partial_symtab * +psymtab_storage::allocate_psymtab () +{ + struct partial_symtab *psymtab; + + if (free_psymtabs != nullptr) + { + psymtab = free_psymtabs; + free_psymtabs = psymtab->next; + } + else + psymtab = XOBNEW (obstack (), struct partial_symtab); + + memset (psymtab, 0, sizeof (struct partial_symtab)); + + psymtab->next = psymtabs; + psymtabs = psymtab; + + return psymtab; +} + /* Ensure that the partial symbols for OBJFILE have been loaded. This @@ -1758,29 +1781,14 @@ init_psymbol_list (struct objfile *objfile, int total_symbols) struct partial_symtab * allocate_psymtab (const char *filename, struct objfile *objfile) { - struct partial_symtab *psymtab; + struct partial_symtab *psymtab + = objfile->partial_symtabs->allocate_psymtab (); - if (objfile->partial_symtabs->free_psymtabs) - { - psymtab = objfile->partial_symtabs->free_psymtabs; - objfile->partial_symtabs->free_psymtabs = psymtab->next; - } - else - psymtab = XOBNEW (objfile->partial_symtabs->obstack (), partial_symtab); - - memset (psymtab, 0, sizeof (struct partial_symtab)); psymtab->filename = (const char *) bcache (filename, strlen (filename) + 1, objfile->per_bfd->filename_cache); psymtab->compunit_symtab = NULL; - /* Prepend it to the psymtab list for the objfile it belongs to. - Psymtabs are searched in most recent inserted -> least recent - inserted order. */ - - psymtab->next = objfile->partial_symtabs->psymtabs; - objfile->partial_symtabs->psymtabs = psymtab; - if (symtab_create_debug) { /* Be a bit clever with debugging messages, and don't print objfile diff --git a/gdb/psymtab.h b/gdb/psymtab.h index b4cac7834e..061b63dcdf 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -70,6 +70,12 @@ public: return OBSTACK_CALLOC (obstack (), number, struct partial_symtab *); } + /* Allocate a new psymtab on the psymtab obstack. The new psymtab + will be linked in to the "psymtabs" list, but otherwise all other + fields will be zero. */ + + struct partial_symtab *allocate_psymtab (); + /* Each objfile points to a linked list of partial symtabs derived from this file, one partial symtab structure for each compilation unit @@ -84,10 +90,6 @@ public: struct addrmap *psymtabs_addrmap = nullptr; - /* List of freed partial symtabs, available for re-use. */ - - struct partial_symtab *free_psymtabs = nullptr; - /* A byte cache where we can stash arbitrary "chunks" of bytes that will not change. */ @@ -101,6 +103,10 @@ public: private: + /* List of freed partial symtabs, available for re-use. */ + + struct partial_symtab *free_psymtabs = nullptr; + /* The obstack where allocations are made. */ struct obstack *m_obstack;