gdb: add interp::on_thread_exited method
Same idea as previous patches, but for thread_exited. Change-Id: I4be974cbe58cf635453fef503c2d77c82522cbd9
This commit is contained in:
parent
30e7e0a917
commit
8e7af84345
5 changed files with 32 additions and 19 deletions
|
@ -454,6 +454,14 @@ interps_notify_new_thread (thread_info *t)
|
||||||
interps_notify (&interp::on_new_thread, t);
|
interps_notify (&interp::on_new_thread, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See interps.h. */
|
||||||
|
|
||||||
|
void
|
||||||
|
interps_notify_thread_exited (thread_info *t, int silent)
|
||||||
|
{
|
||||||
|
interps_notify (&interp::on_thread_exited, t, silent);
|
||||||
|
}
|
||||||
|
|
||||||
/* This just adds the "interpreter-exec" command. */
|
/* This just adds the "interpreter-exec" command. */
|
||||||
void _initialize_interpreter ();
|
void _initialize_interpreter ();
|
||||||
void
|
void
|
||||||
|
|
|
@ -118,6 +118,9 @@ public:
|
||||||
/* Notify the interpreter that thread T has been created. */
|
/* Notify the interpreter that thread T has been created. */
|
||||||
virtual void on_new_thread (thread_info *t) {}
|
virtual void on_new_thread (thread_info *t) {}
|
||||||
|
|
||||||
|
/* Notify the interpreter that thread T has exited. */
|
||||||
|
virtual void on_thread_exited (thread_info *, int silent) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* The memory for this is static, it comes from literal strings (e.g. "cli"). */
|
/* The memory for this is static, it comes from literal strings (e.g. "cli"). */
|
||||||
const char *m_name;
|
const char *m_name;
|
||||||
|
@ -232,6 +235,9 @@ extern void interps_notify_user_selected_context_changed
|
||||||
/* Notify all interpreters that thread T has been created. */
|
/* Notify all interpreters that thread T has been created. */
|
||||||
extern void interps_notify_new_thread (thread_info *t);
|
extern void interps_notify_new_thread (thread_info *t);
|
||||||
|
|
||||||
|
/* Notify all interpreters that thread T has exited. */
|
||||||
|
extern void interps_notify_thread_exited (thread_info *t, int silent);
|
||||||
|
|
||||||
/* well-known interpreters */
|
/* well-known interpreters */
|
||||||
#define INTERP_CONSOLE "console"
|
#define INTERP_CONSOLE "console"
|
||||||
#define INTERP_MI2 "mi2"
|
#define INTERP_MI2 "mi2"
|
||||||
|
|
|
@ -60,7 +60,6 @@ static int mi_interp_query_hook (const char *ctlstr, va_list ap)
|
||||||
static void mi_insert_notify_hooks (void);
|
static void mi_insert_notify_hooks (void);
|
||||||
static void mi_remove_notify_hooks (void);
|
static void mi_remove_notify_hooks (void);
|
||||||
|
|
||||||
static void mi_thread_exit (struct thread_info *t, int silent);
|
|
||||||
static void mi_record_changed (struct inferior*, int, const char *,
|
static void mi_record_changed (struct inferior*, int, const char *,
|
||||||
const char *);
|
const char *);
|
||||||
static void mi_inferior_added (struct inferior *inf);
|
static void mi_inferior_added (struct inferior *inf);
|
||||||
|
@ -317,23 +316,14 @@ mi_interp::on_new_thread (thread_info *t)
|
||||||
gdb_flush (this->event_channel);
|
gdb_flush (this->event_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
mi_thread_exit (struct thread_info *t, int silent)
|
mi_interp::on_thread_exited (thread_info *t, int silent)
|
||||||
{
|
{
|
||||||
SWITCH_THRU_ALL_UIS ()
|
target_terminal::scoped_restore_terminal_state term_state;
|
||||||
{
|
target_terminal::ours_for_output ();
|
||||||
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
|
gdb_printf (this->event_channel, "thread-exited,id=\"%d\",group-id=\"i%d\"",
|
||||||
|
t->global_num, t->inf->num);
|
||||||
if (mi == NULL)
|
gdb_flush (this->event_channel);
|
||||||
continue;
|
|
||||||
|
|
||||||
target_terminal::scoped_restore_terminal_state term_state;
|
|
||||||
target_terminal::ours_for_output ();
|
|
||||||
gdb_printf (mi->event_channel,
|
|
||||||
"thread-exited,id=\"%d\",group-id=\"i%d\"",
|
|
||||||
t->global_num, t->inf->num);
|
|
||||||
gdb_flush (mi->event_channel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit notification on changing the state of record. */
|
/* Emit notification on changing the state of record. */
|
||||||
|
@ -1179,7 +1169,6 @@ _initialize_mi_interp ()
|
||||||
interp_factory_register (INTERP_MI4, mi_interp_factory);
|
interp_factory_register (INTERP_MI4, mi_interp_factory);
|
||||||
interp_factory_register (INTERP_MI, mi_interp_factory);
|
interp_factory_register (INTERP_MI, mi_interp_factory);
|
||||||
|
|
||||||
gdb::observers::thread_exit.attach (mi_thread_exit, "mi-interp");
|
|
||||||
gdb::observers::inferior_added.attach (mi_inferior_added, "mi-interp");
|
gdb::observers::inferior_added.attach (mi_inferior_added, "mi-interp");
|
||||||
gdb::observers::inferior_appeared.attach (mi_inferior_appeared, "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_exit.attach (mi_inferior_exit, "mi-interp");
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
void on_command_error () override;
|
void on_command_error () override;
|
||||||
void on_user_selected_context_changed (user_selected_what selection) override;
|
void on_user_selected_context_changed (user_selected_what selection) override;
|
||||||
void on_new_thread (thread_info *t) override;
|
void on_new_thread (thread_info *t) override;
|
||||||
|
void on_thread_exited (thread_info *t, int silent) override;
|
||||||
|
|
||||||
/* MI's output channels */
|
/* MI's output channels */
|
||||||
mi_console_file *out;
|
mi_console_file *out;
|
||||||
|
|
11
gdb/thread.c
11
gdb/thread.c
|
@ -191,6 +191,15 @@ clear_thread_inferior_resources (struct thread_info *tp)
|
||||||
clear_inline_frame_state (tp);
|
clear_inline_frame_state (tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Notify interpreters and observers that thread T has exited. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
notify_thread_exited (thread_info *t, int silent)
|
||||||
|
{
|
||||||
|
interps_notify_thread_exited (t, silent);
|
||||||
|
gdb::observers::thread_exit.notify (t, silent);
|
||||||
|
}
|
||||||
|
|
||||||
/* See gdbthread.h. */
|
/* See gdbthread.h. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -213,7 +222,7 @@ set_thread_exited (thread_info *tp, bool silent)
|
||||||
if (proc_target != nullptr)
|
if (proc_target != nullptr)
|
||||||
proc_target->maybe_remove_resumed_with_pending_wait_status (tp);
|
proc_target->maybe_remove_resumed_with_pending_wait_status (tp);
|
||||||
|
|
||||||
gdb::observers::thread_exit.notify (tp, silent);
|
notify_thread_exited (tp, silent);
|
||||||
|
|
||||||
/* Tag it as exited. */
|
/* Tag it as exited. */
|
||||||
tp->state = THREAD_EXITED;
|
tp->state = THREAD_EXITED;
|
||||||
|
|
Loading…
Add table
Reference in a new issue