]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove cleanups from prepare_execute_command
authorTom Tromey <tom@tromey.com>
Mon, 16 Oct 2017 23:26:09 +0000 (17:26 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 19 Oct 2017 21:58:11 +0000 (15:58 -0600)
This changes prepare_execute_command to return a scoped_value_mark
rather than a cleanup.

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

* mi/mi-main.c (mi_cmd_execute): Update.
* top.h (prepare_execute_command): Return scoped_value_mark.
* value.h (class scoped_value_mark): Use DISABLE_COPY_AND_ASSIGN.
Add move constructor.
* top.c (prepare_execute_command): Return scoped_value_mark.
(execute_command): Update.

gdb/ChangeLog
gdb/mi/mi-main.c
gdb/top.c
gdb/top.h
gdb/value.h

index aaf04850482263e9c331ddcd9ccd046abc900c74..d7f95a651194e68972b0da6549b6a6d5e0b764a2 100644 (file)
@@ -1,3 +1,12 @@
+2017-10-19  Tom Tromey  <tom@tromey.com>
+
+       * mi/mi-main.c (mi_cmd_execute): Update.
+       * top.h (prepare_execute_command): Return scoped_value_mark.
+       * value.h (class scoped_value_mark): Use DISABLE_COPY_AND_ASSIGN.
+       Add move constructor.
+       * top.c (prepare_execute_command): Return scoped_value_mark.
+       (execute_command): Update.
+
 2017-10-19  Pedro Alves  <palves@redhat.com>
 
        * xml-support.c (xml_fetch_content_from_file): Check fread's
index 8dc955da1ffebf258a76b73c521834cfac4dabcc..3caf904e28a63f4ccf50f9840f3125765d8a41cb 100644 (file)
@@ -2095,9 +2095,7 @@ mi_execute_command (const char *cmd, int from_tty)
 static void
 mi_cmd_execute (struct mi_parse *parse)
 {
-  struct cleanup *cleanup;
-
-  cleanup = prepare_execute_command ();
+  scoped_value_mark cleanup = prepare_execute_command ();
 
   if (parse->all && parse->thread_group != -1)
     error (_("Cannot specify --thread-group together with --all"));
@@ -2189,7 +2187,6 @@ mi_cmd_execute (struct mi_parse *parse)
 
       error_stream (stb);
     }
-  do_cleanups (cleanup);
 }
 
 /* FIXME: This is just a hack so we can get some extra commands going.
index 3b3bbee4ac6256df34205aca57d1867e7e7acbe6..9f5dd58d21658b279194edf50153b24f221ff270 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -438,15 +438,9 @@ do_chdir_cleanup (void *old_dir)
 }
 #endif
 
-struct cleanup *
-prepare_execute_command (void)
+scoped_value_mark
+prepare_execute_command ()
 {
-  struct value *mark;
-  struct cleanup *cleanup;
-
-  mark = value_mark ();
-  cleanup = make_cleanup_value_free_to_mark (mark);
-
   /* With multiple threads running while the one we're examining is
      stopped, the dcache can get stale without us being able to detect
      it.  For the duration of the command, though, use the dcache to
@@ -454,7 +448,7 @@ prepare_execute_command (void)
   if (non_stop)
     target_dcache_invalidate ();
 
-  return cleanup;
+  return scoped_value_mark ();
 }
 
 /* Tell the user if the language has changed (except first time) after
@@ -534,12 +528,12 @@ maybe_wait_sync_command_done (int was_sync)
 void
 execute_command (char *p, int from_tty)
 {
-  struct cleanup *cleanup_if_error, *cleanup;
+  struct cleanup *cleanup_if_error;
   struct cmd_list_element *c;
   char *line;
 
   cleanup_if_error = make_bpstat_clear_actions_cleanup ();
-  cleanup = prepare_execute_command ();
+  scoped_value_mark cleanup = prepare_execute_command ();
 
   /* Force cleanup of any alloca areas if using C alloca instead of
      a builtin alloca.  */
@@ -548,7 +542,6 @@ execute_command (char *p, int from_tty)
   /* This can happen when command_line_input hits end of file.  */
   if (p == NULL)
     {
-      do_cleanups (cleanup);
       discard_cleanups (cleanup_if_error);
       return;
     }
@@ -623,7 +616,6 @@ execute_command (char *p, int from_tty)
 
   check_frame_language_change ();
 
-  do_cleanups (cleanup);
   discard_cleanups (cleanup_if_error);
 }
 
index ab21e5e013076d2c7349e9907e723eef65bbb8a3..ab65ddb741b66dbd5106940beea9aab148a24635 100644 (file)
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -22,6 +22,7 @@
 
 #include "buffer.h"
 #include "event-loop.h"
+#include "value.h"
 
 struct tl_interp_info;
 
@@ -249,7 +250,7 @@ extern void check_frame_language_change (void);
 /* Prepare for execution of a command.
    Call this before every command, CLI or MI.
    Returns a cleanup to be run after the command is completed.  */
-extern struct cleanup *prepare_execute_command (void);
+extern scoped_value_mark prepare_execute_command (void);
 
 /* This function returns a pointer to the string that is used
    by gdb for its command prompt.  */
index bc97ec0728f34aa969320a13f7def0d28894f748..fb6f81fb120dc7d37ac3791d5381cb216d57439d 100644 (file)
@@ -730,6 +730,10 @@ class scoped_value_mark
     free_to_mark ();
   }
 
+  scoped_value_mark (scoped_value_mark &&other) = default;
+
+  DISABLE_COPY_AND_ASSIGN (scoped_value_mark);
+
   /* Free the values currently on the value stack.  */
   void free_to_mark ()
   {