Notification for attach/detach.
authorVladimir Prus <vladimir@codesourcery.com>
Mon, 17 Nov 2008 12:28:05 +0000 (12:28 +0000)
committerVladimir Prus <vladimir@codesourcery.com>
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 99bfda122df3f8ceeabcfc7251aa4ded1ac4ee38..a224e303e204be907b14582c6da8a265b3e91520 100644 (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.
index 363ee18e2ec90804754dc450368c87b2151f3927..18f665000c175f8f783d9a21233bbba4651f44a4 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 f76bf9ff366f371cddb6f2ff0131878c7bfeacf3..636658af66b407e7183ea50b11cce1977d526193 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 9fec4cc2887e12a33864609366f574ffa153696d..24f8fa6b5d87e8abcd66ab6d9b879406b7999285 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 df0d3dfdab38cd14c0e401c20bb057b5201be6a5..31216040b043074362ff6d91a3f4f90e37c0b618 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);
     }
@@ -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)
 {
This page took 0.0373 seconds and 4 git commands to generate.