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 1/8] Change setup_breakpoint_reporting to return a scoped_restore
Date: Sun, 10 Sep 2017 21:50:00 -0000	[thread overview]
Message-ID: <20170910215037.24329-2-tom@tromey.com> (raw)
In-Reply-To: <20170910215037.24329-1-tom@tromey.com>

This changes setup_breakpoint_reporting to return a scoped_restore,
allowing for some cleanup removal.

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

	* mi/mi-cmd-catch.c (mi_cmd_catch_assert)
	(mi_cmd_catch_exception, mi_catch_load_unload): Update.
	* mi/mi-cmd-break.c (setup_breakpoint_reporting): Return a
	scoped_restore.
	(mi_cmd_break_insert_1): Update.
	* mi/mi-cmd-break.h (setup_breakpoint_reporting): Return a
	scoped_restore.
---
 gdb/ChangeLog         | 10 ++++++++++
 gdb/mi/mi-cmd-break.c | 14 +++++---------
 gdb/mi/mi-cmd-break.h |  3 ++-
 gdb/mi/mi-cmd-catch.c | 10 +++-------
 4 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1781ddd..80d615b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2017-09-10  Tom Tromey  <tom@tromey.com>
+
+	* mi/mi-cmd-catch.c (mi_cmd_catch_assert)
+	(mi_cmd_catch_exception, mi_catch_load_unload): Update.
+	* mi/mi-cmd-break.c (setup_breakpoint_reporting): Return a
+	scoped_restore.
+	(mi_cmd_break_insert_1): Update.
+	* mi/mi-cmd-break.h (setup_breakpoint_reporting): Return a
+	scoped_restore.
+
 2017-09-10  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* utils.c (abort_with_message): Don't compare gdb_stderr to NULL,
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 560174e..bae8711 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -64,26 +64,22 @@ enum bp_type
   };
 
 /* Arrange for all new breakpoints and catchpoints to be reported to
-   CURRENT_UIOUT until the cleanup returned by this function is run.
+   CURRENT_UIOUT until the destructor of the returned scoped_restore
+   is run.
 
    Note that MI output will be probably invalid if more than one
    breakpoint is created inside one MI command.  */
 
-struct cleanup *
+scoped_restore_tmpl<int>
 setup_breakpoint_reporting (void)
 {
-  struct cleanup *rev_flag;
-
   if (! mi_breakpoint_observers_installed)
     {
       observer_attach_breakpoint_created (breakpoint_notify);
       mi_breakpoint_observers_installed = 1;
     }
 
-  rev_flag = make_cleanup_restore_integer (&mi_can_breakpoint_notify);
-  mi_can_breakpoint_notify = 1;
-
-  return rev_flag;
+  return make_scoped_restore (&mi_can_breakpoint_notify, 1);
 }
 
 
@@ -301,7 +297,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
     }
 
   /* Now we have what we need, let's insert the breakpoint!  */
-  setup_breakpoint_reporting ();
+  scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
 
   if (tracepoint)
     {
diff --git a/gdb/mi/mi-cmd-break.h b/gdb/mi/mi-cmd-break.h
index 6fb30c8..2394074 100644
--- a/gdb/mi/mi-cmd-break.h
+++ b/gdb/mi/mi-cmd-break.h
@@ -21,10 +21,11 @@
 #ifndef MI_CMD_BREAK_H
 #define MI_CMD_BREAK_H
 
+#include "common/scoped_restore.h"
 
 /* Setup the reporting of the insertion of a new breakpoint or
    catchpoint.  */
-struct cleanup *setup_breakpoint_reporting (void);
+scoped_restore_tmpl<int> setup_breakpoint_reporting (void);
 
 #endif
 
diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c
index a767ee7..0e1fb7e 100644
--- a/gdb/mi/mi-cmd-catch.c
+++ b/gdb/mi/mi-cmd-catch.c
@@ -79,7 +79,7 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc)
   if (oind != argc)
     error (_("Invalid argument: %s"), argv[oind]);
 
-  setup_breakpoint_reporting ();
+  scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
   /* create_ada_exception_catchpoint needs CONDITION to be xstrdup'ed,
      and will assume control of its lifetime.  */
   if (condition != NULL)
@@ -156,7 +156,7 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc)
   if (ex_kind == ada_catch_exception_unhandled && exception_name != NULL)
     error (_("\"-e\" and \"-u\" are mutually exclusive"));
 
-  setup_breakpoint_reporting ();
+  scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
   /* create_ada_exception_catchpoint needs EXCEPTION_NAME and CONDITION
      to be xstrdup'ed, and will assume control of their lifetime.  */
   if (exception_name != NULL)
@@ -173,7 +173,6 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc)
 static void
 mi_catch_load_unload (int load, char *argv[], int argc)
 {
-  struct cleanup *back_to;
   const char *actual_cmd = load ? "-catch-load" : "-catch-unload";
   int temp = 0;
   int enabled = 1;
@@ -215,11 +214,8 @@ mi_catch_load_unload (int load, char *argv[], int argc)
   if (oind < argc -1)
     error (_("-catch-load/unload: Garbage following the <library name>"));
 
-  back_to = setup_breakpoint_reporting ();
-
+  scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
   add_solib_catchpoint (argv[oind], load, temp, enabled);
-
-  do_cleanups (back_to);
 }
 
 /* Handler for the -catch-load.  */
-- 
2.9.4


  reply	other threads:[~2017-09-10 21:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-10 21:50 [RFA 0/8] various cleanup removals Tom Tromey
2017-09-10 21:50 ` Tom Tromey [this message]
2017-09-10 21:50 ` [RFA 6/8] Use std::string in ctf_start Tom Tromey
2017-09-10 21:50 ` [RFA 8/8] Remove make_show_memory_breakpoints_cleanup Tom Tromey
2017-09-11 20:34   ` Simon Marchi
2017-09-10 21:50 ` [RFA 3/8] Replace clear_hook_in_cleanup with scoped_restore_hook_in Tom Tromey
2017-09-10 21:50 ` [RFA 7/8] Use std::string in d-namespace.c Tom Tromey
2017-09-10 21:50 ` [RFA 4/8] Remove cleanups from findcmd.c Tom Tromey
2017-09-10 21:50 ` [RFA 2/8] Replace interp_set_temp with scoped_restore_interp Tom Tromey
2017-09-10 21:50 ` [RFA 5/8] Remove cleanups from find_frame_funname Tom Tromey
2017-09-11 20:25   ` Simon Marchi
2017-09-11 20:35 ` [RFA 0/8] various cleanup removals Simon Marchi
2017-09-11 22:04   ` 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=20170910215037.24329-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