Replace delete_longjmp_breakpoint_cleanup with a forward_scope_exit type
authorTom Tromey <tom@tromey.com>
Wed, 23 Jan 2019 18:58:31 +0000 (18:58 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 23 Jan 2019 19:04:26 +0000 (19:04 +0000)
This removes delete_longjmp_breakpoint_cleanup in favor of forward_scope_exit.

gdb/ChangeLog:
2019-01-23  Tom Tromey  <tom@tromey.com>
    Andrew Burgess  <andrew.burgess@embecosm.com>
    Pedro Alves  <palves@redhat.com>

* breakpoint.c (until_break_command): Use
delete_longjmp_breakpoint_cleanup class.
* infcmd.c (delete_longjmp_breakpoint_cleanup): Remove function.
(until_next_command): Use delete_longjmp_breakpoint_cleanup class.
* inferior.h: Include forward-scope-exit.h.
(delete_longjmp_breakpoint_cleanup): Replace function declaration
with FORWARD_SCOPE_EXIT type.

gdb/ChangeLog
gdb/breakpoint.c
gdb/infcmd.c
gdb/inferior.h

index 63957911c8b25e62bc11ebb795da949ed46de027..55acd81042760261685b0b0881d5ee979824f8e0 100644 (file)
@@ -1,3 +1,7 @@
+2019-01-23  Tom Tromey  <tom@tromey.com>
+           Andrew Burgess  <andrew.burgess@embecosm.com>
+           Pedro Alves  <palves@redhat.com>
+
 2019-01-23  Pedro Alves  <palves@redhat.com>
 
        * gdbarch-selftests.c (struct on_exit): Use SCOPE_EXIT.
index 3166fa01296051f922b6ca9de37b0bbb2e7267ef..999809c31235dd0ef046bfe374c43343902d8e46 100644 (file)
@@ -11073,7 +11073,6 @@ until_break_command (const char *arg, int from_tty, int anywhere)
   struct gdbarch *frame_gdbarch;
   struct frame_id stack_frame_id;
   struct frame_id caller_frame_id;
-  struct cleanup *old_chain;
   int thread;
   struct thread_info *tp;
   struct until_break_fsm *sm;
@@ -11106,8 +11105,6 @@ until_break_command (const char *arg, int from_tty, int anywhere)
   tp = inferior_thread ();
   thread = tp->global_num;
 
-  old_chain = make_cleanup (null_cleanup, NULL);
-
   /* Note linespec handling above invalidates the frame chain.
      Installing a breakpoint also invalidates the frame chain (as it
      may need to switch threads), so do any frame handling before
@@ -11122,6 +11119,9 @@ until_break_command (const char *arg, int from_tty, int anywhere)
      one.  */
 
   breakpoint_up caller_breakpoint;
+
+  gdb::optional<delete_longjmp_breakpoint_cleanup> lj_deleter;
+
   if (frame_id_p (caller_frame_id))
     {
       struct symtab_and_line sal2;
@@ -11136,7 +11136,7 @@ until_break_command (const char *arg, int from_tty, int anywhere)
                                                    bp_until);
 
       set_longjmp_breakpoint (tp, caller_frame_id);
-      make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
+      lj_deleter.emplace (thread);
     }
 
   /* set_momentary_breakpoint could invalidate FRAME.  */
@@ -11159,7 +11159,8 @@ until_break_command (const char *arg, int from_tty, int anywhere)
                            std::move (caller_breakpoint));
   tp->thread_fsm = &sm->thread_fsm;
 
-  discard_cleanups (old_chain);
+  if (lj_deleter)
+    lj_deleter->release ();
 
   proceed (-1, GDB_SIGNAL_DEFAULT);
 }
index 3c3add89ab819cba614526c16b7008446071519b..fafb7e2ec468ca0c2888ed77fbb9576acf7e6465 100644 (file)
@@ -947,13 +947,6 @@ nexti_command (const char *count_string, int from_tty)
   step_1 (1, 1, count_string);
 }
 
-void
-delete_longjmp_breakpoint_cleanup (void *arg)
-{
-  int thread = * (int *) arg;
-  delete_longjmp_breakpoint (thread);
-}
-
 /* Data for the FSM that manages the step/next/stepi/nexti
    commands.  */
 
@@ -1517,7 +1510,6 @@ until_next_command (int from_tty)
   struct symtab_and_line sal;
   struct thread_info *tp = inferior_thread ();
   int thread = tp->global_num;
-  struct cleanup *old_chain;
   struct until_next_fsm *sm;
 
   clear_proceed_status (0);
@@ -1556,11 +1548,11 @@ until_next_command (int from_tty)
   tp->control.step_over_calls = STEP_OVER_ALL;
 
   set_longjmp_breakpoint (tp, get_frame_id (frame));
-  old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
+  delete_longjmp_breakpoint_cleanup lj_deleter (thread);
 
   sm = new_until_next_fsm (command_interp (), tp->global_num);
   tp->thread_fsm = &sm->thread_fsm;
-  discard_cleanups (old_chain);
+  lj_deleter.release ();
 
   proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
 }
index a82df1a52a5cd8805308035a3f59cb53166c5aec..cadaaedf22e4e7e7f34a452d608c57b179057423 100644 (file)
@@ -51,6 +51,7 @@ struct thread_info;
 
 #include "symfile-add-flags.h"
 #include "common/refcounted-object.h"
+#include "common/forward-scope-exit.h"
 
 #include "common-inferior.h"
 #include "gdbthread.h"
@@ -198,7 +199,8 @@ extern void continue_1 (int all_threads);
 
 extern void interrupt_target_1 (int all_threads);
 
-extern void delete_longjmp_breakpoint_cleanup (void *arg);
+using delete_longjmp_breakpoint_cleanup
+  = FORWARD_SCOPE_EXIT (delete_longjmp_breakpoint);
 
 extern void detach_command (const char *, int);
 
This page took 0.03366 seconds and 4 git commands to generate.