Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Notification for attach/detach.
@ 2008-11-12 21:07 Vladimir Prus
  2008-11-13  1:17 ` Tom Tromey
  2008-11-14 11:19 ` Joel Brobecker
  0 siblings, 2 replies; 7+ messages in thread
From: Vladimir Prus @ 2008-11-12 21:07 UTC (permalink / raw)
  To: gdb-patches


This patch introduces new =thread-group-created and =thread-group-exited notifications,
to help the frontend in multiprocess case.

I'll commit in a few days if there are no objections.

- Volodya

From c41177a84715643cdb6315256e2c5635275336ea Mon Sep 17 00:00:00 2001

	gdb/
	* Makefile.in: Update dependencies.
	* inferior.c: Call the process observers.
	* mi/mi-interp.c (mi_new_inferior, mi_inferior_exit): New.
	(mi_interpreter_init): Register the above.

	gdb/doc/
	* observer.texi (new_inferior, inferior_exit): New observers.
---
 gdb/doc/observer.texi |   10 ++++++++++
 gdb/inferior.c        |    5 +++++
 gdb/mi/mi-interp.c    |   24 ++++++++++++++++++++++++
 gdb/mi/mi-main.c      |   12 ++++++------
 4 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index f76bf9f..cc0eb06 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})
+The inferior identified by @var{pid} has either exited, or was detached
+from.
+@end deftypefun
+
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 9fec4cc..24f8fa6 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 df0d3df..3121604 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);
     }
@@ -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,
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 544fec6..43ec0b4 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -46,7 +46,7 @@
 #include "mi-main.h"
 #include "language.h"
 #include "valprint.h"
-#include "processes.h"
+#include "inferior.h"
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -250,13 +250,13 @@ mi_cmd_thread_info (char *command, char **argv, int argc)
 }
 
 static int
-print_one_process (struct process_info *process, void *arg)
+print_one_inferior (struct inferior *inferior, void *arg)
 {
   struct cleanup *back_to = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
 
-  ui_out_field_fmt (uiout, "id", "p%d", process->pid);
+  ui_out_field_fmt (uiout, "id", "%d", inferior->pid);
   ui_out_field_string (uiout, "type", "process");
-  ui_out_field_int (uiout, "pid", process->pid);
+  ui_out_field_int (uiout, "pid", inferior->pid);
   
   do_cleanups (back_to);
   return 0;
@@ -284,14 +284,14 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc)
   if (id)
     {
       int pid = atoi (id);
-      if (!in_process_list (pid))
+      if (!in_inferior_list (pid))
 	error ("Invalid thread group id '%s'", id);
       print_thread_info (uiout, -1, pid);    
     }
   else
     {
       make_cleanup_ui_out_list_begin_end (uiout, "groups");
-      iterate_over_processes (print_one_process, NULL);
+      iterate_over_inferiors (print_one_inferior, NULL);
     }
   
   do_cleanups (back_to);
-- 
1.5.3.5


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Notification for attach/detach.
  2008-11-12 21:07 [RFC] Notification for attach/detach Vladimir Prus
@ 2008-11-13  1:17 ` Tom Tromey
  2008-11-13  1:29   ` Vladimir Prus
  2008-11-14 11:19 ` Joel Brobecker
  1 sibling, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2008-11-13  1:17 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb-patches

>>>>> "Vladimir" == Vladimir Prus <vladimir@codesourcery.com> writes:

Vladimir> 	* Makefile.in: Update dependencies.

I think this text is probably not needed.
I didn't see a Makefile.in change in the patch, and, most likely, the
dependencies in question are auto-computed now anyhow.

Tom


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Notification for attach/detach.
  2008-11-13  1:17 ` Tom Tromey
@ 2008-11-13  1:29   ` Vladimir Prus
  0 siblings, 0 replies; 7+ messages in thread
From: Vladimir Prus @ 2008-11-13  1:29 UTC (permalink / raw)
  To: gdb-patches

Tom Tromey wrote:

>>>>>> "Vladimir" == Vladimir Prus <vladimir@codesourcery.com> writes:
> 
> Vladimir>     * Makefile.in: Update dependencies.
> 
> I think this text is probably not needed.
> I didn't see a Makefile.in change in the patch, and, most likely, the
> dependencies in question are auto-computed now anyhow.

You are right; that entry in changelog was stale.

- Volodya



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Notification for attach/detach.
  2008-11-12 21:07 [RFC] Notification for attach/detach Vladimir Prus
  2008-11-13  1:17 ` Tom Tromey
@ 2008-11-14 11:19 ` Joel Brobecker
  2008-11-14 19:19   ` Vladimir Prus
  1 sibling, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2008-11-14 11:19 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: gdb-patches


> index f76bf9f..cc0eb06 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})
> +The inferior identified by @var{pid} has either exited, or was detached
> +from.
> +@end deftypefun
> +

This part should be reviewed by Eli. The documentation for the first
observer looks fine to me, but I find the second one a little awkward.
Perhaps Eli will have another one of his good suggestions. In the
meantime, perhaps the following would do:

  The inferior identified by @var{pid} has exited, or @value{GDBN}
  detached from it.

> 	gdb/
> 	* Makefile.in: Update dependencies.
> 	* inferior.c: Call the process observers.
> 	* mi/mi-interp.c (mi_new_inferior, mi_inferior_exit): New.
> 	(mi_interpreter_init): Register the above.

As spotted by Tom, the Makefile.in entry needs to be removed.
The inferior.c part looks good to me. As for the mi changes,
I looked at them and I didn't see anything wrong, but you are
the maintainer and you know way more about this part than I do,
so you don't need my approval.

> 	gdb/doc/
> 	* observer.texi (new_inferior, inferior_exit): New observers.

-- 
Joel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Notification for attach/detach.
  2008-11-14 11:19 ` Joel Brobecker
@ 2008-11-14 19:19   ` Vladimir Prus
  2008-11-14 23:14     ` Eli Zaretskii
  2008-11-14 23:25     ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Vladimir Prus @ 2008-11-14 19:19 UTC (permalink / raw)
  To: Joel Brobecker, Eli Zaretskii; +Cc: gdb-patches

On Friday 14 November 2008 02:23:13 Joel Brobecker wrote:
> > index f76bf9f..cc0eb06 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})
> > +The inferior identified by @var{pid} has either exited, or was detached
> > +from.
> > +@end deftypefun
> > +
>
> This part should be reviewed by Eli. The documentation for the first
> observer looks fine to me, but I find the second one a little awkward.
> Perhaps Eli will have another one of his good suggestions. In the
> meantime, perhaps the following would do:
>
>   The inferior identified by @var{pid} has exited, or @value{GDBN}
>   detached from it.

Eli,
can you comment?

Thanks,
Volodya


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Notification for attach/detach.
  2008-11-14 19:19   ` Vladimir Prus
@ 2008-11-14 23:14     ` Eli Zaretskii
  2008-11-14 23:25     ` Eli Zaretskii
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2008-11-14 23:14 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: brobecker, gdb-patches

> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Fri, 14 Nov 2008 20:17:33 +0300
> Cc: gdb-patches@sources.redhat.com
> 
> >   The inferior identified by @var{pid} has exited, or @value{GDBN}
> >   detached from it.

This is fine.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] Notification for attach/detach.
  2008-11-14 19:19   ` Vladimir Prus
  2008-11-14 23:14     ` Eli Zaretskii
@ 2008-11-14 23:25     ` Eli Zaretskii
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2008-11-14 23:25 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: brobecker, gdb-patches

> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Fri, 14 Nov 2008 20:17:33 +0300
> Cc: gdb-patches@sources.redhat.com
> 
> > > +@deftypefun void inferior_exit (int @var{pid})
> > > +The inferior identified by @var{pid} has either exited, or was detached
> > > +from.
> > > +@end deftypefun
> > > +
> >
> > This part should be reviewed by Eli. The documentation for the first
> > observer looks fine to me, but I find the second one a little awkward.
> > Perhaps Eli will have another one of his good suggestions. In the
> > meantime, perhaps the following would do:
> >
> >   The inferior identified by @var{pid} has exited, or @value{GDBN}
> >   detached from it.
> 
> Eli,
> can you comment?

Another possible variant would be

  Either @value{GDBN} detached from the inferior, or the inferior
  exited.  The argument @var{pid} identifies the inferior.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-11-14 18:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-12 21:07 [RFC] Notification for attach/detach Vladimir Prus
2008-11-13  1:17 ` Tom Tromey
2008-11-13  1:29   ` Vladimir Prus
2008-11-14 11:19 ` Joel Brobecker
2008-11-14 19:19   ` Vladimir Prus
2008-11-14 23:14     ` Eli Zaretskii
2008-11-14 23:25     ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox