From patchwork Wed May 30 14:08:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27564 Received: (qmail 125118 invoked by alias); 30 May 2018 14:08:46 -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 125103 invoked by uid 89); 30 May 2018 14:08:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=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= X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.60.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 30 May 2018 14:08:43 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway20.websitewelcome.com (Postfix) with ESMTP id C4310400C7A27 for ; Wed, 30 May 2018 09:08:41 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id O1mLf0SlAbXuJO1mLfGp8Y; Wed, 30 May 2018 09:08:41 -0500 X-Authority-Reason: nr=8 Received: from 75-166-42-107.hlrn.qwest.net ([75.166.42.107]:33592 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fO1mL-001hGU-5P; Wed, 30 May 2018 09:08:41 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove resume_section_map_updates_cleanup Date: Wed, 30 May 2018 08:08:38 -0600 Message-Id: <20180530140838.20519-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fO1mL-001hGU-5P X-Source-Sender: 75-166-42-107.hlrn.qwest.net (bapiya.Home) [75.166.42.107]:33592 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes resume_section_map_updates_cleanup, replacing it with a scoped_restore. Tested by the buildbot. gdb/ChangeLog 2018-05-30 Tom Tromey * objfiles.h (inhibit_section_map_updates): Update. (resume_section_map_updates, resume_section_map_updates_cleanup): Remove. * solib-svr4.c (svr4_handle_solib_event): Update. * objfiles.c (inhibit_section_map_updates): Return scoped_restore_tmpl. (resume_section_map_updates, resume_section_map_updates_cleanup): Remove. --- gdb/ChangeLog | 11 ++++++ gdb/objfiles.c | 21 ++-------- gdb/objfiles.h | 19 ++++----- gdb/solib-svr4.c | 117 ++++++++++++++++++++++++++++--------------------------- 4 files changed, 80 insertions(+), 88 deletions(-) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 0432ce62080..95c39cf4a95 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -1455,26 +1455,11 @@ objfiles_changed (void) /* See comments in objfiles.h. */ -void +scoped_restore_tmpl inhibit_section_map_updates (struct program_space *pspace) { - get_objfile_pspace_data (pspace)->inhibit_updates = 1; -} - -/* See comments in objfiles.h. */ - -void -resume_section_map_updates (struct program_space *pspace) -{ - get_objfile_pspace_data (pspace)->inhibit_updates = 0; -} - -/* See comments in objfiles.h. */ - -void -resume_section_map_updates_cleanup (void *arg) -{ - resume_section_map_updates ((struct program_space *) arg); + return scoped_restore_tmpl + (&get_objfile_pspace_data (pspace)->inhibit_updates, 1); } /* Return 1 if ADDR maps into one of the sections of OBJFILE and 0 diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 28e66eca362..7a9087b0158 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -551,18 +551,13 @@ DECLARE_REGISTRY(objfile); /* In normal use, the section map will be rebuilt by find_pc_section if objfiles have been added, removed or relocated since it was last called. Calling inhibit_section_map_updates will inhibit this - behavior until resume_section_map_updates is called. If you call - inhibit_section_map_updates you must ensure that every call to - find_pc_section in the inhibited region relates to a section that - is already in the section map and has not since been removed or - relocated. */ -extern void inhibit_section_map_updates (struct program_space *pspace); - -/* Resume automatically rebuilding the section map as required. */ -extern void resume_section_map_updates (struct program_space *pspace); - -/* Version of the above suitable for use as a cleanup. */ -extern void resume_section_map_updates_cleanup (void *arg); + behavior until the returned scoped_restore object is destroyed. If + you call inhibit_section_map_updates you must ensure that every + call to find_pc_section in the inhibited region relates to a + section that is already in the section map and has not since been + removed or relocated. */ +extern scoped_restore_tmpl inhibit_section_map_updates + (struct program_space *pspace); extern void default_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index f9936b36de8..3a0b3284e11 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1858,7 +1858,7 @@ svr4_handle_solib_event (void) struct svr4_info *info = get_svr4_info (); struct probe_and_action *pa; enum probe_action action; - struct cleanup *old_chain, *usm_chain; + struct cleanup *old_chain; struct value *val = NULL; CORE_ADDR pc, debug_base, lm = 0; struct frame_info *frame = get_current_frame (); @@ -1902,72 +1902,73 @@ svr4_handle_solib_event (void) so we can guarantee that the dynamic linker's sections are in the section map. We can therefore inhibit section map updates across these calls to evaluate_argument and save a lot of time. */ - inhibit_section_map_updates (current_program_space); - usm_chain = make_cleanup (resume_section_map_updates_cleanup, - current_program_space); + { + scoped_restore inhibit_updates + = inhibit_section_map_updates (current_program_space); - TRY - { - val = pa->prob->evaluate_argument (1, frame); - } - CATCH (ex, RETURN_MASK_ERROR) - { - exception_print (gdb_stderr, ex); - val = NULL; - } - END_CATCH + TRY + { + val = pa->prob->evaluate_argument (1, frame); + } + CATCH (ex, RETURN_MASK_ERROR) + { + exception_print (gdb_stderr, ex); + val = NULL; + } + END_CATCH - if (val == NULL) - { - do_cleanups (old_chain); - return; - } + if (val == NULL) + { + do_cleanups (old_chain); + return; + } - debug_base = value_as_address (val); - if (debug_base == 0) - { - do_cleanups (old_chain); - return; - } + debug_base = value_as_address (val); + if (debug_base == 0) + { + do_cleanups (old_chain); + return; + } - /* Always locate the debug struct, in case it moved. */ - info->debug_base = 0; - if (locate_base (info) == 0) - { - do_cleanups (old_chain); - return; - } + /* Always locate the debug struct, in case it moved. */ + info->debug_base = 0; + if (locate_base (info) == 0) + { + do_cleanups (old_chain); + return; + } - /* GDB does not currently support libraries loaded via dlmopen - into namespaces other than the initial one. We must ignore - any namespace other than the initial namespace here until - support for this is added to GDB. */ - if (debug_base != info->debug_base) - action = DO_NOTHING; + /* GDB does not currently support libraries loaded via dlmopen + into namespaces other than the initial one. We must ignore + any namespace other than the initial namespace here until + support for this is added to GDB. */ + if (debug_base != info->debug_base) + action = DO_NOTHING; - if (action == UPDATE_OR_RELOAD) - { - TRY - { - val = pa->prob->evaluate_argument (2, frame); - } - CATCH (ex, RETURN_MASK_ERROR) - { - exception_print (gdb_stderr, ex); - do_cleanups (old_chain); - return; - } - END_CATCH + if (action == UPDATE_OR_RELOAD) + { + TRY + { + val = pa->prob->evaluate_argument (2, frame); + } + CATCH (ex, RETURN_MASK_ERROR) + { + exception_print (gdb_stderr, ex); + do_cleanups (old_chain); + return; + } + END_CATCH - if (val != NULL) - lm = value_as_address (val); + if (val != NULL) + lm = value_as_address (val); - if (lm == 0) - action = FULL_RELOAD; - } + if (lm == 0) + action = FULL_RELOAD; + } - /* Resume section map updates. */ - do_cleanups (usm_chain); + /* Resume section map updates. Closing the scope is + sufficient. */ + } if (action == UPDATE_OR_RELOAD) {