From patchwork Tue Nov 29 05:05:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 18027 Received: (qmail 15024 invoked by alias); 29 Nov 2016 05:06:13 -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 14800 invoked by uid 89); 29 Nov 2016 05:06:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=xfree, discarded, H*F:U*tom, H*m:10924 X-HELO: gproxy6-pub.mail.unifiedlayer.com Received: from gproxy6-pub.mail.unifiedlayer.com (HELO gproxy6-pub.mail.unifiedlayer.com) (67.222.39.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Tue, 29 Nov 2016 05:06:01 +0000 Received: (qmail 6325 invoked by uid 0); 29 Nov 2016 05:05:59 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy6.mail.unifiedlayer.com with SMTP; 29 Nov 2016 05:05:59 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id Dh5u1u00d2f2jeq01h5xc5; Mon, 28 Nov 2016 22:05:57 -0700 X-Authority-Analysis: v=2.1 cv=YNIMl32x c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=L24OOQBejmoA:10 a=zstS-IiYAAAA:8 a=Hc-ev52fSKtEDp5_eyQA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 71-218-195-233.hlrn.qwest.net ([71.218.195.233]:46172 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1cBac7-0000aB-RW; Mon, 28 Nov 2016 22:05:55 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 4/8] Remove make_cleanup_discard_psymtabs Date: Mon, 28 Nov 2016 22:05:42 -0700 Message-Id: <1480395946-10924-5-git-send-email-tom@tromey.com> In-Reply-To: <1480395946-10924-1-git-send-email-tom@tromey.com> References: <1480395946-10924-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1cBac7-0000aB-RW X-Source-Sender: 71-218-195-233.hlrn.qwest.net (bapiya.Home) [71.218.195.233]:46172 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This removes make_cleanup_discard_psymtabs in favor of a new class. 2016-11-28 Tom Tromey * dwarf2read.c (dwarf2_build_psymtabs): Use psymtab_discarder. * psympriv.h (make_cleanup_discard_psymtabs): Don't declare. * psymtab.c (discard_psymtabs_upto): Remove. (make_cleanup_discard_psymtabs): Remove. (struct psymtab_state): Remove. --- gdb/ChangeLog | 8 ++++++++ gdb/dwarf2read.c | 5 ++--- gdb/psympriv.h | 36 +++++++++++++++++++++++++++++++++++- gdb/psymtab.c | 38 -------------------------------------- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 18814d3..d00862a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2016-11-28 Tom Tromey + * dwarf2read.c (dwarf2_build_psymtabs): Use psymtab_discarder. + * psympriv.h (make_cleanup_discard_psymtabs): Don't declare. + * psymtab.c (discard_psymtabs_upto): Remove. + (make_cleanup_discard_psymtabs): Remove. + (struct psymtab_state): Remove. + +2016-11-28 Tom Tromey + * record-full.c (record_full_save_cleanups): Remove. (record_full_save): Use gdb::unlinker. * gcore.c (do_bfd_delete_cleanup): Remove. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index a021aad..0c5d374 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -4268,10 +4268,9 @@ dwarf2_build_psymtabs (struct objfile *objfile) /* This isn't really ideal: all the data we allocate on the objfile's obstack is still uselessly kept around. However, freeing it seems unsafe. */ - struct cleanup *cleanups = make_cleanup_discard_psymtabs (objfile); - + psymtab_discarder psymtabs (objfile); dwarf2_build_psymtabs_hard (objfile); - discard_cleanups (cleanups); + psymtabs.keep (); } CATCH (except, RETURN_MASK_ERROR) { diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 915208e..846e970 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -21,6 +21,7 @@ #define PSYMPRIV_H #include "psymtab.h" +#include "objfiles.h" struct psymbol_allocation_list; @@ -225,7 +226,40 @@ extern struct partial_symtab *allocate_psymtab (const char *, extern void discard_psymtab (struct objfile *, struct partial_symtab *); -extern struct cleanup *make_cleanup_discard_psymtabs (struct objfile *); +/* Used when recording partial symbol tables. On destruction, + discards any partial symbol tables that have been built. However, + the tables can be kept by calling the "keep" method. */ +class psymtab_discarder +{ + public: + + psymtab_discarder (struct objfile *objfile) + : m_objfile (objfile), + m_psymtab (objfile->psymtabs) + { + } + + ~psymtab_discarder () + { + if (m_objfile != NULL) + while (m_objfile->psymtabs != m_psymtab) + discard_psymtab (m_objfile, m_objfile->psymtabs); + } + + /* Keep any partial symbol tables that were built. */ + void keep () + { + m_objfile = NULL; + } + + private: + + /* The objfile. If NULL this serves as a sentinel to indicate that + the psymtabs should be kept. */ + struct objfile *m_objfile; + /* How far back to free. */ + struct partial_symtab *m_psymtab; +}; /* Traverse all psymtabs in one objfile. */ diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 825df77..31731ca 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1836,44 +1836,6 @@ discard_psymtab (struct objfile *objfile, struct partial_symtab *pst) objfile->free_psymtabs = pst; } -/* An object of this type is passed to discard_psymtabs_upto. */ - -struct psymtab_state -{ - /* The objfile where psymtabs are discarded. */ - - struct objfile *objfile; - - /* The first psymtab to save. */ - - struct partial_symtab *save; -}; - -/* A cleanup function used by make_cleanup_discard_psymtabs. */ - -static void -discard_psymtabs_upto (void *arg) -{ - struct psymtab_state *state = (struct psymtab_state *) arg; - - while (state->objfile->psymtabs != state->save) - discard_psymtab (state->objfile, state->objfile->psymtabs); -} - -/* Return a new cleanup that discards all psymtabs created in OBJFILE - after this function is called. */ - -struct cleanup * -make_cleanup_discard_psymtabs (struct objfile *objfile) -{ - struct psymtab_state *state = XNEW (struct psymtab_state); - - state->objfile = objfile; - state->save = objfile->psymtabs; - - return make_cleanup_dtor (discard_psymtabs_upto, state, xfree); -} - /* We need to pass a couple of items to the addrmap_foreach function,