delete inf;
}
+/* Notify interpreters and observers that inferior INF disappeared. */
+
+static void
+notify_inferior_disappeared (inferior *inf)
+{
+ interps_notify_inferior_disappeared (inf);
+ gdb::observers::inferior_exit.notify (inf);
+}
+
/* If SILENT then be quiet -- don't announce a inferior exit, or the
exit of its threads. */
{
inf->clear_thread_list (silent);
- gdb::observers::inferior_exit.notify (inf);
+ notify_inferior_disappeared (inf);
inf->pid = 0;
inf->fake_pid_p = false;
/* Notify the interpreter that inferior INF was started or attached. */
virtual void on_inferior_appeared (inferior *inf) {}
+ /* Notify the interpreter that inferior INF exited or was detached. */
+ virtual void on_inferior_disappeared (inferior *inf) {}
+
private:
/* The memory for this is static, it comes from literal strings (e.g. "cli"). */
const char *m_name;
/* Notify all interpreters that inferior INF was started or attached. */
extern void interps_notify_inferior_appeared (inferior *inf);
+/* Notify all interpreters that inferior INF exited or was detached. */
+extern void interps_notify_inferior_disappeared (inferior *inf);
+
/* well-known interpreters */
#define INTERP_CONSOLE "console"
#define INTERP_MI2 "mi2"
static void mi_record_changed (struct inferior*, int, const char *,
const char *);
-static void mi_inferior_exit (struct inferior *inf);
static void mi_inferior_removed (struct inferior *inf);
static void mi_on_resume (ptid_t ptid);
static void mi_solib_loaded (struct so_list *solib);
gdb_flush (this->event_channel);
}
-static void
-mi_inferior_exit (struct inferior *inf)
+void
+mi_interp::on_inferior_disappeared (inferior *inf)
{
- SWITCH_THRU_ALL_UIS ()
- {
- struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
-
- if (mi == NULL)
- continue;
-
- target_terminal::scoped_restore_terminal_state term_state;
- target_terminal::ours_for_output ();
+ target_terminal::scoped_restore_terminal_state term_state;
+ target_terminal::ours_for_output ();
- if (inf->has_exit_code)
- gdb_printf (mi->event_channel,
- "thread-group-exited,id=\"i%d\",exit-code=\"%s\"",
- inf->num, int_string (inf->exit_code, 8, 0, 0, 1));
- else
- gdb_printf (mi->event_channel,
- "thread-group-exited,id=\"i%d\"", inf->num);
+ if (inf->has_exit_code)
+ gdb_printf (this->event_channel,
+ "thread-group-exited,id=\"i%d\",exit-code=\"%s\"",
+ inf->num, int_string (inf->exit_code, 8, 0, 0, 1));
+ else
+ gdb_printf (this->event_channel,
+ "thread-group-exited,id=\"i%d\"", inf->num);
- gdb_flush (mi->event_channel);
- }
+ gdb_flush (this->event_channel);
}
static void
interp_factory_register (INTERP_MI4, mi_interp_factory);
interp_factory_register (INTERP_MI, mi_interp_factory);
- gdb::observers::inferior_exit.attach (mi_inferior_exit, "mi-interp");
gdb::observers::inferior_removed.attach (mi_inferior_removed, "mi-interp");
gdb::observers::record_changed.attach (mi_record_changed, "mi-interp");
gdb::observers::target_resumed.attach (mi_on_resume, "mi-interp");