+2018-04-07 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * tracepoint.c (struct current_traceframe_cleanup): Remove.
+ (do_restore_current_traceframe_cleanup): Remove.
+ (restore_current_traceframe_cleanup_dtor): Remove.
+ (make_cleanup_restore_current_traceframe): Remove.
+ (scoped_restore_current_traceframe::scoped_restore_current_traceframe):
+ New.
+ * tracepoint.h (struct scoped_restore_current_traceframe): New.
+ * infrun.c (fetch_inferior_event): Use
+ scoped_restore_current_traceframe.
+
2018-04-07 Simon Marchi <simon.marchi@polymtl.ca>
* dwarf2read.h (struct dwarf2_per_objfile) <n_type_units>:
debugging. If we're looking at traceframes while the target is
running, we're going to need to get back to that mode after
handling the event. */
+ gdb::optional<scoped_restore_current_traceframe> maybe_restore_traceframe;
if (non_stop)
{
- make_cleanup_restore_current_traceframe ();
+ maybe_restore_traceframe.emplace ();
set_current_traceframe (-1);
}
clear_traceframe_info ();
}
-/* A cleanup used when switching away and back from tfind mode. */
-
-struct current_traceframe_cleanup
-{
- /* The traceframe we were inspecting. */
- int traceframe_number;
-};
-
-static void
-do_restore_current_traceframe_cleanup (void *arg)
-{
- struct current_traceframe_cleanup *old
- = (struct current_traceframe_cleanup *) arg;
-
- set_current_traceframe (old->traceframe_number);
-}
-
-static void
-restore_current_traceframe_cleanup_dtor (void *arg)
-{
- struct current_traceframe_cleanup *old
- = (struct current_traceframe_cleanup *) arg;
-
- xfree (old);
-}
-
-struct cleanup *
-make_cleanup_restore_current_traceframe (void)
-{
- struct current_traceframe_cleanup *old =
- XNEW (struct current_traceframe_cleanup);
-
- old->traceframe_number = traceframe_number;
-
- return make_cleanup_dtor (do_restore_current_traceframe_cleanup, old,
- restore_current_traceframe_cleanup_dtor);
-}
+scoped_restore_current_traceframe::scoped_restore_current_traceframe ()
+: m_traceframe_number (traceframe_number)
+{}
/* Given a number and address, return an uploaded tracepoint with that
number, creating if necessary. */
etc.). */
extern void set_current_traceframe (int num);
-struct cleanup *make_cleanup_restore_current_traceframe (void);
+struct scoped_restore_current_traceframe
+{
+ scoped_restore_current_traceframe ();
+
+ ~scoped_restore_current_traceframe ()
+ {
+ set_current_traceframe (m_traceframe_number);
+ }
+
+ DISABLE_COPY_AND_ASSIGN (scoped_restore_current_traceframe);
+
+private:
+
+ /* The traceframe we were inspecting. */
+ int m_traceframe_number;
+};
void free_actions (struct breakpoint *);