From: Vladimir Prus Date: Mon, 17 Nov 2008 12:28:05 +0000 (+0000) Subject: Notification for attach/detach. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a92f99bc7076bebcee009e8b2a7fc717df03590;p=binutils-gdb.git Notification for attach/detach. * inferior.c: Call the process observers. * mi/mi-interp.c (mi_new_inferior, mi_inferior_exit): New. (mi_interpreter_init): Register the above. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 99bfda122df..a224e303e20 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2008-11-17 Vladimir Prus + + Notification for attach/detach. + + * inferior.c: Call the process observers. + * mi/mi-interp.c (mi_new_inferior, mi_inferior_exit): New. + (mi_interpreter_init): Register the above. + 2008-11-17 Vladimir Prus Implement -list-thread-groups. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 363ee18e2ec..18f665000c1 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2008-11-17 Vladimir Prus + + * observer.texi (new_inferior, inferior_exit): New observers. + 2008-10-27 Pedro Alves * gdbint.texinfo (Adding a New Target): Don't mention TDEPFILES, diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi index f76bf9ff366..636658af66b 100644 --- a/gdb/doc/observer.texi +++ b/gdb/doc/observer.texi @@ -187,3 +187,13 @@ a pointer to the new architecture. The thread's ptid has changed. The @var{old_ptid} parameter specifies the old value, and @var{new_ptid} specifies the new value. @end deftypefun + +@deftypefun void new_inferior (int @var{pid}) +@value{GDBN} has attached to a new inferior identified by @var{pid}. +@end deftypefun + +@deftypefun void inferior_exit (int @var{pid}) +Either @value{GDBN} detached from the inferior, or the inferior +exited. The argument @var{pid} identifies the inferior. +@end deftypefun + diff --git a/gdb/inferior.c b/gdb/inferior.c index 9fec4cc2887..24f8fa6b5d8 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -24,6 +24,7 @@ #include "gdbcmd.h" #include "gdbthread.h" #include "ui-out.h" +#include "observer.h" void _initialize_inferiors (void); @@ -91,6 +92,8 @@ add_inferior (int pid) { struct inferior *inf = add_inferior_silent (pid); + observer_notify_new_inferior (pid); + if (print_inferior_events) printf_unfiltered (_("[New inferior %d]\n"), pid); @@ -147,6 +150,8 @@ delete_inferior_1 (int pid, int silent) arg.silent = silent; iterate_over_threads (delete_thread_of_inferior, &arg); + + observer_notify_inferior_exit (pid); } void diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index df0d3dfdab3..31216040b04 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -69,6 +69,8 @@ static void mi_on_normal_stop (struct bpstats *bs); static void mi_new_thread (struct thread_info *t); static void mi_thread_exit (struct thread_info *t); +static void mi_new_inferior (int pid); +static void mi_inferior_exit (int pid); static void mi_on_resume (ptid_t ptid); static void * @@ -94,6 +96,8 @@ mi_interpreter_init (int top_level) { observer_attach_new_thread (mi_new_thread); observer_attach_thread_exit (mi_thread_exit); + observer_attach_new_inferior (mi_new_inferior); + observer_attach_inferior_exit (mi_inferior_exit); observer_attach_normal_stop (mi_on_normal_stop); observer_attach_target_resumed (mi_on_resume); } @@ -302,6 +306,26 @@ mi_thread_exit (struct thread_info *t) gdb_flush (mi->event_channel); } +static void +mi_new_inferior (int pid) +{ + struct mi_interp *mi = top_level_interpreter_data (); + target_terminal_ours (); + fprintf_unfiltered (mi->event_channel, "thread-group-created,id=\"%d\"", + pid); + gdb_flush (mi->event_channel); +} + +static void +mi_inferior_exit (int pid) +{ + struct mi_interp *mi = top_level_interpreter_data (); + target_terminal_ours (); + fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"%d\"", + pid); + gdb_flush (mi->event_channel); +} + static void mi_on_normal_stop (struct bpstats *bs) {