From patchwork Wed Feb 7 22:04:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 25863 Received: (qmail 3643 invoked by alias); 7 Feb 2018 22:04:43 -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 3618 invoked by uid 89); 7 Feb 2018 22:04:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.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=Hx-languages-length:3328 X-HELO: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.49.40) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Feb 2018 22:04:39 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway20.websitewelcome.com (Postfix) with ESMTP id A9F10400ED7D7 for ; Wed, 7 Feb 2018 16:04:38 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id jXpWe78wBcGlpjXpWe7FWF; Wed, 07 Feb 2018 16:04:38 -0600 Received: from 174-29-33-254.hlrn.qwest.net ([174.29.33.254]:59168 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ejXpW-002nlZ-7I; Wed, 07 Feb 2018 16:04:38 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/9] Remove make_cleanup_restore_current_thread from gdbserver Date: Wed, 7 Feb 2018 15:04:27 -0700 Message-Id: <20180207220434.6045-3-tom@tromey.com> In-Reply-To: <20180207220434.6045-1-tom@tromey.com> References: <20180207220434.6045-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1ejXpW-002nlZ-7I X-Source-Sender: 174-29-33-254.hlrn.qwest.net (pokyo.Home) [174.29.33.254]:59168 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes make_cleanup_restore_current_thread from gdbserver, replacing it with a use of scoped_restore. 2018-02-07 Tom Tromey * linux-low.c (install_software_single_step_breakpoints): Use make_scoped_restore. * inferiors.c (make_cleanup_restore_current_thread): Remove. (do_restore_current_thread_cleanup): Remove. * gdbthread.h (make_cleanup_restore_current_thread): Don't declare. --- gdb/gdbserver/ChangeLog | 9 +++++++++ gdb/gdbserver/gdbthread.h | 3 --- gdb/gdbserver/inferiors.c | 12 ------------ gdb/gdbserver/linux-low.c | 6 +++--- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 902ee7c7fd..0213edb1ee 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,14 @@ 2018-02-07 Tom Tromey + * linux-low.c (install_software_single_step_breakpoints): Use + make_scoped_restore. + * inferiors.c (make_cleanup_restore_current_thread): Remove. + (do_restore_current_thread_cleanup): Remove. + * gdbthread.h (make_cleanup_restore_current_thread): Don't + declare. + +2018-02-07 Tom Tromey + * mem-break.c (set_raw_breakpoint_at): Use gdb::unique_xmalloc_ptr. diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h index 9a8c72e780..0edf870c56 100644 --- a/gdb/gdbserver/gdbthread.h +++ b/gdb/gdbserver/gdbthread.h @@ -224,7 +224,4 @@ lwpid_of (const thread_info *thread) return thread->id.lwp (); } -/* Create a cleanup to restore current_thread. */ -struct cleanup *make_cleanup_restore_current_thread (void); - #endif /* GDB_THREAD_H */ diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index 600bf201bf..ad3df648f5 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -213,18 +213,6 @@ current_process (void) return get_thread_process (current_thread); } -static void -do_restore_current_thread_cleanup (void *arg) -{ - current_thread = (struct thread_info *) arg; -} - -struct cleanup * -make_cleanup_restore_current_thread (void) -{ - return make_cleanup (do_restore_current_thread_cleanup, current_thread); -} - /* See common/common-gdbthread.h. */ void diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 38142bba03..b6b660ea96 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -50,6 +50,7 @@ #include "common-inferior.h" #include "nat/fork-inferior.h" #include "environ.h" +#include "common/scoped_restore.h" #ifndef ELFMAG0 /* Don't include here. If it got included by gdb_proc_service.h then ELFMAG0 will have been defined. If it didn't get included by @@ -4207,15 +4208,14 @@ install_software_single_step_breakpoints (struct lwp_info *lwp) { struct thread_info *thread = get_lwp_thread (lwp); struct regcache *regcache = get_thread_regcache (thread, 1); - struct cleanup *old_chain = make_cleanup_restore_current_thread (); + + scoped_restore save_current_thread = make_scoped_restore (¤t_thread); current_thread = thread; std::vector next_pcs = the_low_target.get_next_pcs (regcache); for (CORE_ADDR pc : next_pcs) set_single_step_breakpoint (pc, current_ptid); - - do_cleanups (old_chain); } /* Single step via hardware or software single step.