* 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 <vladimir@codesourcery.com>
+
+ 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 <vladimir@codesourcery.com>
Implement -list-thread-groups.
+2008-11-17 Vladimir Prus <vladimir@codesourcery.com>
+
+ * observer.texi (new_inferior, inferior_exit): New observers.
+
2008-10-27 Pedro Alves <pedro@codesourcery.com>
* gdbint.texinfo (Adding a New Target): Don't mention TDEPFILES,
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
+
#include "gdbcmd.h"
#include "gdbthread.h"
#include "ui-out.h"
+#include "observer.h"
void _initialize_inferiors (void);
{
struct inferior *inf = add_inferior_silent (pid);
+ observer_notify_new_inferior (pid);
+
if (print_inferior_events)
printf_unfiltered (_("[New inferior %d]\n"), pid);
arg.silent = silent;
iterate_over_threads (delete_thread_of_inferior, &arg);
+
+ observer_notify_inferior_exit (pid);
}
void
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 *
{
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);
}
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)
{