interps_notify (&interp::on_user_selected_context_changed, selection);
}
+/* See interps.h. */
+
+void
+interps_notify_new_thread (thread_info *t)
+{
+ interps_notify (&interp::on_new_thread, t);
+}
+
/* This just adds the "interpreter-exec" command. */
void _initialize_interpreter ();
void
struct interp;
struct ui;
class completion_tracker;
+struct thread_info;
typedef struct interp *(*interp_factory_func) (const char *name);
virtual void on_user_selected_context_changed (user_selected_what selection)
{}
+ /* Notify the interpreter that thread T has been created. */
+ virtual void on_new_thread (thread_info *t) {}
+
private:
/* The memory for this is static, it comes from literal strings (e.g. "cli"). */
const char *m_name;
extern void interps_notify_user_selected_context_changed
(user_selected_what selection);
+/* Notify all interpreters that thread T has been created. */
+extern void interps_notify_new_thread (thread_info *t);
+
/* well-known interpreters */
#define INTERP_CONSOLE "console"
#define INTERP_MI2 "mi2"
static void mi_insert_notify_hooks (void);
static void mi_remove_notify_hooks (void);
-static void mi_new_thread (struct thread_info *t);
static void mi_thread_exit (struct thread_info *t, int silent);
static void mi_record_changed (struct inferior*, int, const char *,
const char *);
display_mi_prompt (mi);
}
-static void
-mi_new_thread (struct thread_info *t)
+void
+mi_interp::on_new_thread (thread_info *t)
{
- 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-created,id=\"%d\",group-id=\"i%d\"",
- t->global_num, t->inf->num);
- gdb_flush (mi->event_channel);
- }
+ gdb_printf (this->event_channel, "thread-created,id=\"%d\",group-id=\"i%d\"",
+ t->global_num, t->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::new_thread.attach (mi_new_thread, "mi-interp");
gdb::observers::thread_exit.attach (mi_thread_exit, "mi-interp");
gdb::observers::inferior_added.attach (mi_inferior_added, "mi-interp");
gdb::observers::inferior_appeared.attach (mi_inferior_appeared, "mi-interp");
#include "gdbsupport/gdb_optional.h"
#include "inline-frame.h"
#include "stack.h"
+#include "interps.h"
/* See gdbthread.h. */
return tp;
}
+/* Notify interpreters and observers that thread T has been created. */
+
+static void
+notify_new_thread (thread_info *t)
+{
+ interps_notify_new_thread (t);
+ gdb::observers::new_thread.notify (t);
+}
+
struct thread_info *
add_thread_silent (process_stratum_target *targ, ptid_t ptid)
{
delete_thread (tp);
tp = new_thread (inf, ptid);
- gdb::observers::new_thread.notify (tp);
+ notify_new_thread (tp);
return tp;
}