+/* Stop recording. */
+
+static void
+record_stop (struct target_ops *t)
+{
+ DEBUG ("stop %s", t->to_shortname);
+
+ if (t->to_stop_recording != NULL)
+ t->to_stop_recording ();
+}
+
+/* Unpush the record target. */
+
+static void
+record_unpush (struct target_ops *t)
+{
+ DEBUG ("unpush %s", t->to_shortname);
+
+ unpush_target (t);
+}
+
+/* See record.h. */
+
+void
+record_disconnect (struct target_ops *t, char *args, int from_tty)
+{
+ gdb_assert (t->to_stratum == record_stratum);
+
+ DEBUG ("disconnect %s", t->to_shortname);
+
+ record_stop (t);
+ record_unpush (t);
+
+ target_disconnect (args, from_tty);
+}
+
+/* See record.h. */
+
+void
+record_detach (struct target_ops *t, char *args, int from_tty)
+{
+ gdb_assert (t->to_stratum == record_stratum);
+
+ DEBUG ("detach %s", t->to_shortname);
+
+ record_stop (t);
+ record_unpush (t);
+
+ target_detach (args, from_tty);
+}
+
+/* See record.h. */
+
+void
+record_mourn_inferior (struct target_ops *t)
+{
+ gdb_assert (t->to_stratum == record_stratum);
+
+ DEBUG ("mourn inferior %s", t->to_shortname);
+
+ /* It is safer to not stop recording. Resources will be freed when
+ threads are discarded. */
+ record_unpush (t);
+
+ target_mourn_inferior ();
+}
+
+/* See record.h. */
+
+void
+record_kill (struct target_ops *t)
+{
+ gdb_assert (t->to_stratum == record_stratum);
+
+ DEBUG ("kill %s", t->to_shortname);
+
+ /* It is safer to not stop recording. Resources will be freed when
+ threads are discarded. */
+ record_unpush (t);
+
+ target_kill ();
+}
+