From patchwork Tue Sep 12 18:57:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 22857 Received: (qmail 6992 invoked by alias); 12 Sep 2017 18:59:01 -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 6981 invoked by uid 89); 12 Sep 2017 18:59:01 -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, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=tp, Either X-HELO: outbound-ss-1812.hostmonster.com Received: from gproxy1-pub.mail.unifiedlayer.com (HELO outbound-ss-1812.hostmonster.com) (69.89.25.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Sep 2017 18:58:59 +0000 Received: from cmgw3 (cmgw4 [10.0.90.84]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id E09FD175BA4 for ; Tue, 12 Sep 2017 12:57:43 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id 8ixg1w00X2f2jeq01ixjqv; Tue, 12 Sep 2017 12:57:43 -0600 X-Authority-Analysis: v=2.2 cv=K/VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=0FD05c-RAAAA:8 a=o7NN2xEbdeiHnO-rSBEA:9 a=4G6NA9xxw8l3yy4pmD5M:22 a=l1rpMCqCXRGZwUSuRcM3:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:46142 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1drqNQ-001eRR-DS; Tue, 12 Sep 2017 12:57:40 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 01/11] Remove make_cleanup_defer_target_commit_resume Date: Tue, 12 Sep 2017 12:57:26 -0600 Message-Id: <20170912185736.20436-2-tom@tromey.com> In-Reply-To: <20170912185736.20436-1-tom@tromey.com> References: <20170912185736.20436-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1drqNQ-001eRR-DS X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:46142 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This removes make_cleanup_defer_target_commit_resume in favor of using scoped_restore. ChangeLog 2017-09-12 Tom Tromey * target.h (make_scoped_defer_target_commit_resume): Update. * target.c (make_scoped_defer_target_commit_resume): Rename from make_cleanup_defer_target_commit_resume. Return a scoped_restore. * infrun.c (proceed): Use make_scoped_defer_target_commit_resume. --- gdb/ChangeLog | 8 ++++++++ gdb/infrun.c | 60 +++++++++++++++++++++++++++++------------------------------ gdb/target.c | 10 +++------- gdb/target.h | 6 +++--- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3905a51..b71f23b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2017-09-12 Tom Tromey + + * target.h (make_scoped_defer_target_commit_resume): Update. + * target.c (make_scoped_defer_target_commit_resume): Rename from + make_cleanup_defer_target_commit_resume. Return a + scoped_restore. + * infrun.c (proceed): Use make_scoped_defer_target_commit_resume. + 2017-09-12 Simon Marchi * probe.h (probe_ops_cp): Remove typedef. diff --git a/gdb/infrun.c b/gdb/infrun.c index 3f2ac85..e46ceab 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2990,7 +2990,6 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) struct execution_control_state ecss; struct execution_control_state *ecs = &ecss; struct cleanup *old_chain; - struct cleanup *defer_resume_cleanup; int started; /* If we're stopped at a fork/vfork, follow the branch set by the @@ -3132,26 +3131,27 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) until the target stops again. */ tp->prev_pc = regcache_read_pc (regcache); - defer_resume_cleanup = make_cleanup_defer_target_commit_resume (); + { + scoped_restore save_defer_tc = make_scoped_defer_target_commit_resume (); - started = start_step_over (); + started = start_step_over (); - if (step_over_info_valid_p ()) - { - /* Either this thread started a new in-line step over, or some - other thread was already doing one. In either case, don't - resume anything else until the step-over is finished. */ - } - else if (started && !target_is_non_stop_p ()) - { - /* A new displaced stepping sequence was started. In all-stop, - we can't talk to the target anymore until it next stops. */ - } - else if (!non_stop && target_is_non_stop_p ()) - { - /* In all-stop, but the target is always in non-stop mode. - Start all other threads that are implicitly resumed too. */ - ALL_NON_EXITED_THREADS (tp) + if (step_over_info_valid_p ()) + { + /* Either this thread started a new in-line step over, or some + other thread was already doing one. In either case, don't + resume anything else until the step-over is finished. */ + } + else if (started && !target_is_non_stop_p ()) + { + /* A new displaced stepping sequence was started. In all-stop, + we can't talk to the target anymore until it next stops. */ + } + else if (!non_stop && target_is_non_stop_p ()) + { + /* In all-stop, but the target is always in non-stop mode. + Start all other threads that are implicitly resumed too. */ + ALL_NON_EXITED_THREADS (tp) { /* Ignore threads of processes we're not resuming. */ if (!ptid_match (tp->ptid, resume_ptid)) @@ -3187,18 +3187,18 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) if (!ecs->wait_some_more) error (_("Command aborted.")); } - } - else if (!tp->resumed && !thread_is_in_step_over_chain (tp)) - { - /* The thread wasn't started, and isn't queued, run it now. */ - reset_ecs (ecs, tp); - switch_to_thread (tp->ptid); - keep_going_pass_signal (ecs); - if (!ecs->wait_some_more) - error (_("Command aborted.")); - } + } + else if (!tp->resumed && !thread_is_in_step_over_chain (tp)) + { + /* The thread wasn't started, and isn't queued, run it now. */ + reset_ecs (ecs, tp); + switch_to_thread (tp->ptid); + keep_going_pass_signal (ecs); + if (!ecs->wait_some_more) + error (_("Command aborted.")); + } + } - do_cleanups (defer_resume_cleanup); target_commit_resume (); discard_cleanups (old_chain); diff --git a/gdb/target.c b/gdb/target.c index 3e2b4d0..bcd0008 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2330,14 +2330,10 @@ target_commit_resume (void) /* See target.h. */ -struct cleanup * -make_cleanup_defer_target_commit_resume (void) +scoped_restore_tmpl +make_scoped_defer_target_commit_resume () { - struct cleanup *old_chain; - - old_chain = make_cleanup_restore_integer (&defer_target_commit_resume); - defer_target_commit_resume = 1; - return old_chain; + return make_scoped_restore (&defer_target_commit_resume, 1); } void diff --git a/gdb/target.h b/gdb/target.h index a3f00ab..5160924 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1371,10 +1371,10 @@ extern void target_resume (ptid_t ptid, int step, enum gdb_signal signal); coalesce multiple resumption requests in a single vCont packet. */ extern void target_commit_resume (); -/* Setup to defer target_commit_resume calls, and return a cleanup - that reactivates target_commit_resume, if it was previously +/* Setup to defer target_commit_resume calls, and reactivate + target_commit_resume on destruction, if it was previously active. */ -struct cleanup *make_cleanup_defer_target_commit_resume (); +extern scoped_restore_tmpl make_scoped_defer_target_commit_resume (); /* For target_read_memory see target/target.h. */