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.
This commit is contained in:
Vladimir Prus 2008-11-17 12:28:05 +00:00
parent 3ee1c036ac
commit 4a92f99bc7
5 changed files with 51 additions and 0 deletions

View file

@ -1,3 +1,11 @@
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.

View file

@ -1,3 +1,7 @@
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,

View file

@ -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

View file

@ -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

View file

@ -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)
{