Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 01/11] Remove make_cleanup_defer_target_commit_resume
Date: Tue, 12 Sep 2017 18:59:00 -0000	[thread overview]
Message-ID: <20170912185736.20436-2-tom@tromey.com> (raw)
In-Reply-To: <20170912185736.20436-1-tom@tromey.com>

This removes make_cleanup_defer_target_commit_resume in favor of using
scoped_restore.

ChangeLog
2017-09-12  Tom Tromey  <tom@tromey.com>

	* 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  <tom@tromey.com>
+
+	* 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  <simon.marchi@ericsson.com>
 
 	* 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<int>
+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<int> make_scoped_defer_target_commit_resume ();
 
 /* For target_read_memory see target/target.h.  */
 
-- 
2.9.4


  parent reply	other threads:[~2017-09-12 18:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 18:57 more cleanup removal, particularly in MI Tom Tromey
2017-09-12 18:57 ` [RFA 06/11] Change some gdb_* functions to use a std::string out parameter Tom Tromey
2017-09-28  9:42   ` Pedro Alves
2017-09-28 19:58     ` Tom Tromey
2017-09-12 18:57 ` [RFA 07/11] Use gdb::byte_vector in mi_cmd_data_write_memory_bytes Tom Tromey
2017-09-28  9:46   ` Pedro Alves
2017-09-12 18:57 ` [RFA 08/11] Use string and unique_xmalloc_ptr in mi-main.c Tom Tromey
2017-09-28  9:57   ` Pedro Alves
2017-09-29  1:42     ` Tom Tromey
2017-09-29 10:23       ` Pedro Alves
2017-09-12 18:57 ` [RFA 11/11] Change captured_mi_execute_command to use scoped_restore Tom Tromey
2017-09-28 10:35   ` Pedro Alves
2017-09-12 18:57 ` [RFA 09/11] Use std::set in mi-main.c Tom Tromey
2017-09-28 10:10   ` Pedro Alves
2017-10-02 13:05     ` Simon Marchi
2017-10-03 11:21   ` Simon Marchi
2017-10-03 11:39     ` Tom Tromey
2017-09-12 18:57 ` [RFA 10/11] Use a std::vector for ada_exceptions_list Tom Tromey
2017-09-28 10:20   ` Pedro Alves
2017-09-12 18:57 ` [RFA 05/11] Remove unused declaration Tom Tromey
2017-09-28  9:40   ` Pedro Alves
2017-09-12 18:57 ` [RFA 04/11] Don't copy a string in mi_cmd_disassemble Tom Tromey
2017-09-28  9:40   ` Pedro Alves
2017-09-12 18:57 ` [RFA 02/11] Remove cleanups from mi_cmd_break_insert_1 Tom Tromey
2017-09-28  9:24   ` Pedro Alves
2017-09-28 19:57     ` Tom Tromey
2017-09-29  1:40     ` Tom Tromey
2017-09-29 10:21       ` Pedro Alves
2017-09-12 18:59 ` Tom Tromey [this message]
2017-09-28  9:17   ` [RFA 01/11] Remove make_cleanup_defer_target_commit_resume Pedro Alves
2017-09-12 19:03 ` [RFA 03/11] Remove cleanups from mi-cmd-var.c Tom Tromey
2017-09-28  9:36   ` Pedro Alves
2017-09-29  1:40     ` Tom Tromey
2017-09-29 10:22       ` Pedro Alves
2017-09-23 16:15 ` more cleanup removal, particularly in MI Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170912185736.20436-2-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox