#include "progspace-and-thread.h"
#include "gdbsupport/buildargv.h"
#include "cli/cli-style.h"
+#include "interps.h"
intrusive_list<inferior> inferior_list;
static int highest_inferior_num;
}
}
+/* Notify interpreters and observers that inferior INF was added. */
+
+static void
+notify_inferior_added (inferior *inf)
+{
+ interps_notify_inferior_added (inf);
+ gdb::observers::inferior_added.notify (inf);
+}
+
struct inferior *
add_inferior_silent (int pid)
{
inferior_list.push_back (*inf);
- gdb::observers::inferior_added.notify (inf);
+ notify_inferior_added (inf);
if (pid != 0)
inferior_appeared (inf, pid);
struct ui;
class completion_tracker;
struct thread_info;
+struct inferior;
typedef struct interp *(*interp_factory_func) (const char *name);
/* 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. */
+ virtual void on_inferior_added (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. */
+extern void interps_notify_inferior_added (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_added (struct inferior *inf);
static void mi_inferior_appeared (struct inferior *inf);
static void mi_inferior_exit (struct inferior *inf);
static void mi_inferior_removed (struct inferior *inf);
This is also called when additional MI interpreters are added (using
the new-ui command), when multiple inferiors possibly exist, so we need
- to use iteration to report all the inferiors. mi_inferior_added can't
- be used, because it would print the event on all the other MI UIs. */
+ to use iteration to report all the inferiors. */
for (inferior *inf : all_inferiors ())
- {
- target_terminal::scoped_restore_terminal_state term_state;
- target_terminal::ours_for_output ();
-
- gdb_printf (mi->event_channel,
- "thread-group-added,id=\"i%d\"",
- inf->num);
-
- gdb_flush (mi->event_channel);
- }
+ mi->on_inferior_added (inf);
}
}
}
}
-static void
-mi_inferior_added (struct inferior *inf)
+void
+mi_interp::on_inferior_added (inferior *inf)
{
- SWITCH_THRU_ALL_UIS ()
- {
- struct interp *interp;
- struct mi_interp *mi;
-
- /* We'll be called once for the initial inferior, before the top
- level interpreter is set. */
- interp = top_level_interpreter ();
- if (interp == NULL)
- continue;
-
- mi = as_mi_interp (interp);
- 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-added,id=\"i%d\"",
- inf->num);
- gdb_flush (mi->event_channel);
- }
+ gdb_printf (this->event_channel, "thread-group-added,id=\"i%d\"", inf->num);
+ 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_added.attach (mi_inferior_added, "mi-interp");
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");