+2019-01-23 Tom Tromey <tom@tromey.com>
+ Pedro Alves <palves@redhat.com>
+
+ * infrun.c: Include "common/scope-exit.h"
+ (delete_just_stopped_threads_infrun_breakpoints_cleanup): Remove.
+ (wait_for_inferior): Use SCOPE_EXIT.
+ (fetch_inferior_event): Use scope_exit.
+
2019-01-23 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
#include "progspace-and-thread.h"
#include "common/gdb_optional.h"
#include "arch-utils.h"
+#include "common/scope-exit.h"
/* Prototypes for local functions */
for_each_just_stopped_thread (delete_single_step_breakpoints);
}
-/* A cleanup wrapper. */
-
-static void
-delete_just_stopped_threads_infrun_breakpoints_cleanup (void *arg)
-{
- delete_just_stopped_threads_infrun_breakpoints ();
-}
-
/* See infrun.h. */
void
void
wait_for_inferior (void)
{
- struct cleanup *old_cleanups;
-
if (debug_infrun)
fprintf_unfiltered
(gdb_stdlog, "infrun: wait_for_inferior ()\n");
- old_cleanups
- = make_cleanup (delete_just_stopped_threads_infrun_breakpoints_cleanup,
- NULL);
+ SCOPE_EXIT { delete_just_stopped_threads_infrun_breakpoints (); };
/* If an error happens while handling the event, propagate GDB's
knowledge of the executing state to the frontend/user running
/* No error, don't finish the state yet. */
finish_state.release ();
-
- do_cleanups (old_cleanups);
}
/* Cleanup that reinstalls the readline callback handler, if the
still for the thread which has thrown the exception. */
struct cleanup *ts_old_chain = make_bpstat_clear_actions_cleanup ();
- make_cleanup (delete_just_stopped_threads_infrun_breakpoints_cleanup, NULL);
+ auto defer_delete_threads
+ = make_scope_exit (delete_just_stopped_threads_infrun_breakpoints);
/* Now figure out what to do with the result of the result. */
handle_inferior_event (ecs);
}
}
+ defer_delete_threads.release ();
discard_cleanups (ts_old_chain);
/* No error, don't finish the thread states yet. */