From patchwork Thu May 10 22:23:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27219 Received: (qmail 47356 invoked by alias); 10 May 2018 22:24:42 -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 42168 invoked by uid 89); 10 May 2018 22:24:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 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=clever X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.149.105) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 May 2018 22:24:23 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 17243261A60A for ; Thu, 10 May 2018 17:24:09 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GtyrfFDiSbXuJGtyrfZ3w7; Thu, 10 May 2018 17:24:09 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:54520 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fGtyr-001ijL-Fd; Thu, 10 May 2018 17:24:09 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 14/15] Make psymtab_storage::free_psymtabs private Date: Thu, 10 May 2018 16:23:56 -0600 Message-Id: <20180510222357.27332-15-tom@tromey.com> In-Reply-To: <20180510222357.27332-1-tom@tromey.com> References: <20180510222357.27332-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fGtyr-001ijL-Fd X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:54520 X-Source-Auth: tom+tromey.com X-Email-Count: 15 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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. 2018-05-10 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 | 44 +++++++++++++++++++++++++------------------- gdb/psymtab.h | 14 ++++++++++---- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/gdb/psymtab.c b/gdb/psymtab.c index d121eace54..f109e9f1ee 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) + { + 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 @@ -1775,30 +1798,13 @@ 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 = (struct partial_symtab *) - obstack_alloc (objfile->partial_symtabs->obstack (), - sizeof (struct partial_symtab)); - - memset (psymtab, 0, sizeof (struct partial_symtab)); psymtab->filename = (const char *) bcache (filename, strlen (filename) + 1, objfile->per_bfd->filename_cache); - /* 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 8aacc30e38..c4b6f3b9ad 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -66,6 +66,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 @@ -80,10 +86,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. */ @@ -97,6 +99,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;