Same idea as previous patches, but for inferior_appeared.
Change-Id: Ibe4feba34274549a886b1dfb5b3f8d59ae79e1b5
target_pid_to_str (ptid_t (pid)).c_str ());
}
+/* Notify interpreters and observers that inferior INF appeared. */
+
+static void
+notify_inferior_appeared (inferior *inf)
+{
+ interps_notify_inferior_appeared (inf);
+ gdb::observers::inferior_appeared.notify (inf);
+}
+
void
inferior_appeared (struct inferior *inf, int pid)
{
inf->has_exit_code = false;
inf->exit_code = 0;
- gdb::observers::inferior_appeared.notify (inf);
+ notify_inferior_appeared (inf);
}
struct inferior *
interps_notify (&interp::on_inferior_added, inf);
}
+/* See interps.h. */
+
+void
+interps_notify_inferior_appeared (inferior *inf)
+{
+ interps_notify (&interp::on_inferior_appeared, inf);
+}
+
/* This just adds the "interpreter-exec" command. */
void _initialize_interpreter ();
void
/* Notify the interpreter that thread T has exited. */
virtual void on_thread_exited (thread_info *, int silent) {}
- /* Notify the intepreter that inferior INF was added. */
+ /* Notify the interpreter that inferior INF was added. */
virtual void on_inferior_added (inferior *inf) {}
+ /* Notify the interpreter that inferior INF was started or attached. */
+ virtual void on_inferior_appeared (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 thread T has exited. */
extern void interps_notify_thread_exited (thread_info *t, int silent);
-/* Notify all intepreters that inferior INF was added. */
+/* Notify all interpreters that inferior INF was added. */
extern void interps_notify_inferior_added (inferior *inf);
+/* Notify all interpreters that inferior INF was started or attached. */
+extern void interps_notify_inferior_appeared (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_appeared (struct inferior *inf);
static void mi_inferior_exit (struct inferior *inf);
static void mi_inferior_removed (struct inferior *inf);
static void mi_on_resume (ptid_t ptid);
gdb_flush (this->event_channel);
}
-static void
-mi_inferior_appeared (struct inferior *inf)
+void
+mi_interp::on_inferior_appeared (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 ();
- gdb_printf (mi->event_channel,
- "thread-group-started,id=\"i%d\",pid=\"%d\"",
- inf->num, inf->pid);
- gdb_flush (mi->event_channel);
- }
+ gdb_printf (this->event_channel, "thread-group-started,id=\"i%d\",pid=\"%d\"",
+ inf->num, inf->pid);
+ 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_appeared.attach (mi_inferior_appeared, "mi-interp");
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");
void on_new_thread (thread_info *t) override;
void on_thread_exited (thread_info *t, int silent) override;
void on_inferior_added (inferior *inf) override;
+ void on_inferior_appeared (inferior *inf) override;
/* MI's output channels */
mi_console_file *out;