#include "defs.h"
#include "record.h"
+#include "record-btrace.h"
#include "gdbthread.h"
#include "target.h"
#include "gdbcmd.h"
inferior_event_handler (INF_REG_EVENT, NULL);
}
+/* See record-btrace.h. */
+
+void
+record_btrace_push_target (void)
+{
+ const char *format;
+
+ record_btrace_auto_enable ();
+
+ push_target (&record_btrace_ops);
+
+ record_btrace_async_inferior_event_handler
+ = create_async_event_handler (record_btrace_handle_async_inferior_event,
+ NULL);
+ record_btrace_generating_corefile = 0;
+
+ format = btrace_format_short_string (record_btrace_conf.format);
+ observer_notify_record_changed (current_inferior (), 1, "btrace", format);
+}
+
/* The to_open method of target record-btrace. */
static void
{
struct cleanup *disable_chain;
struct thread_info *tp;
- const char *format;
DEBUG ("open");
make_cleanup (record_btrace_disable_callback, tp);
}
- record_btrace_auto_enable ();
-
- push_target (&record_btrace_ops);
-
- record_btrace_async_inferior_event_handler
- = create_async_event_handler (record_btrace_handle_async_inferior_event,
- NULL);
- record_btrace_generating_corefile = 0;
-
- format = btrace_format_short_string (record_btrace_conf.format);
- observer_notify_record_changed (current_inferior (), 1, "btrace", format);
+ record_btrace_push_target ();
discard_cleanups (disable_chain);
}
btrace_disable (tp);
}
+/* The to_disconnect method of target record-btrace. */
+
+static void
+record_btrace_disconnect (struct target_ops *self, const char *args,
+ int from_tty)
+{
+ struct target_ops *beneath = self->beneath;
+
+ /* Do not stop recording, just clean up GDB side. */
+ unpush_target (self);
+
+ /* Forward disconnect. */
+ beneath->to_disconnect (beneath, args, from_tty);
+}
+
/* The to_close method of target record-btrace. */
static void
ops->to_close = record_btrace_close;
ops->to_async = record_btrace_async;
ops->to_detach = record_detach;
- ops->to_disconnect = record_disconnect;
+ ops->to_disconnect = record_btrace_disconnect;
ops->to_mourn_inferior = record_mourn_inferior;
ops->to_kill = record_kill;
ops->to_stop_recording = record_btrace_stop_recording;