OSDN Git Service

Notification for attach/detach.
authorvprus <vprus>
Mon, 17 Nov 2008 12:28:05 +0000 (12:28 +0000)
committervprus <vprus>
Mon, 17 Nov 2008 12:28:05 +0000 (12:28 +0000)
        * inferior.c: Call the process observers.
        * mi/mi-interp.c (mi_new_inferior, mi_inferior_exit): New.
        (mi_interpreter_init): Register the above.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/observer.texi
gdb/inferior.c
gdb/mi/mi-interp.c

index 99bfda1..a224e30 100644 (file)
@@ -1,5 +1,13 @@
 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.
 
         * thread.c (print_thread_info): New parameter pid, to print
index 363ee18..18f6650 100644 (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,
index f76bf9f..636658a 100644 (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
+
index 9fec4cc..24f8fa6 100644 (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
index df0d3df..3121604 100644 (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);
     }
@@ -303,6 +307,26 @@ mi_thread_exit (struct thread_info *t)
 }
 
 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)
 {
   /* Since this can be called when CLI command is executing,