From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22892 invoked by alias); 10 Jun 2008 07:02:39 -0000 Received: (qmail 22881 invoked by uid 22791); 10 Jun 2008 07:02:38 -0000 X-Spam-Check-By: sourceware.org Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 10 Jun 2008 07:02:13 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.63) (envelope-from ) id 1K5xrr-0006Ny-BG for gdb-patches@sources.redhat.com; Tue, 10 Jun 2008 11:02:10 +0400 Received: from localhost ([127.0.0.1] helo=ip6-localhost) by zigzag.lvk.cs.msu.su with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1K5xri-0006NG-OQ; Tue, 10 Jun 2008 11:01:59 +0400 From: Vladimir Prus To: Nick Roberts Subject: Re: [patch:MI] Observer for thread-changed Date: Tue, 10 Jun 2008 08:40:00 -0000 User-Agent: KMail/1.9.9 Cc: gdb-patches@sources.redhat.com References: <18509.7945.19078.399646@kahikatea.snap.net.nz> In-Reply-To: <18509.7945.19078.399646@kahikatea.snap.net.nz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200806101057.19272.ghost@cs.msu.su> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-06/txt/msg00192.txt.bz2 On Monday 09 June 2008 16:16:09 Nick Roberts wrote: > 2008-06-09 =A0Nick Roberts =A0 >=20 > =A0=A0=A0=A0=A0=A0=A0=A0* mi/mi-interp.c (mi_thread_changed): New static = function. > =A0=A0=A0=A0=A0=A0=A0=A0(mi_interpreter_init): Register mi_thread_changed= as thread_changed > =A0=A0=A0=A0=A0=A0=A0=A0observer . > =A0=A0=A0=A0=A0=A0=A0=A0* thread.c (thread_command): Notify thread change= s using observer. > =A0=A0=A0=A0=A0=A0=A0=A0* infrun.c (normal_stop): Ditto. > =A0=A0=A0=A0=A0=A0=A0=A0* mi/mi-main.c (mi_cmd_thread_select): Ditto. > =A0=A0=A0=A0=A0=A0=A0=A0* Makefile.in (mi-main.o) : Add dependency on obs= erver.h. >=20 > 2008-06-09 =A0Nick Roberts =A0 >=20 > =A0=A0=A0=A0=A0=A0=A0=A0* observer.texi (GDB Observers): New observer for= thread_changed. >=20 >=20 > Index: thread.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/thread.c,v > retrieving revision 1.71 > diff -p -u -p -r1.71 thread.c > --- thread.c=A0=A0=A0=A06 Jun 2008 00:32:51 -0000=A0=A0=A0=A0=A0=A0=A01.71 > +++ thread.c=A0=A0=A0=A09 Jun 2008 12:13:23 -0000 > @@ -740,6 +740,7 @@ thread_command (char *tidstr, int from_t > =A0 > =A0 =A0annotate_thread_changed (); > =A0 =A0gdb_thread_select (uiout, tidstr, NULL); > + =A0observer_notify_thread_changed (); > =A0} > =A0 > =A0/* Print notices when new threads are attached and detached. =A0*/ > Index: infrun.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/infrun.c,v > retrieving revision 1.278 > diff -p -u -p -r1.278 infrun.c > --- infrun.c=A0=A0=A0=A06 Jun 2008 00:33:52 -0000=A0=A0=A0=A0=A0=A0=A01.2= 78 > +++ infrun.c=A0=A0=A0=A09 Jun 2008 12:13:25 -0000 > @@ -3605,6 +3605,7 @@ normal_stop (void) > =A0 =A0 =A0 =A0target_terminal_ours_for_output (); > =A0 =A0 =A0 =A0printf_filtered (_("[Switching to %s]\n"), > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 target_pid_t= o_str (inferior_ptid)); > + =A0 =A0 =A0observer_notify_thread_changed (); > =A0 =A0 =A0 =A0annotate_thread_changed (); > =A0 =A0 =A0 =A0previous_inferior_ptid =3D inferior_ptid; > =A0 =A0 =A0} Pedro's has asked if we'd want to call the observer only when we've selected a frame in the new thread. Have you decided if that's a good idea or not? > =A0static void * > =A0mi_interpreter_init (int top_level) > @@ -92,6 +93,7 @@ mi_interpreter_init (int top_level) > =A0 =A0 =A0{ > =A0 =A0 =A0 =A0observer_attach_new_thread (mi_new_thread); > =A0 =A0 =A0 =A0observer_attach_thread_exit (mi_thread_exit); > + =A0 =A0 =A0observer_attach_thread_changed (mi_thread_changed); > =A0 =A0 =A0} > =A0 > =A0 =A0return mi; > @@ -331,6 +333,27 @@ mi_thread_exit (struct thread_info *t) > =A0 =A0gdb_flush (mi->event_channel); > =A0} > =A0 > +static void > +mi_thread_changed () > +{ > + =A0struct mi_interp *mi =3D top_level_interpreter_data (); > + =A0struct interp *interp_to_use; > + =A0struct ui_out *old_uiout, *temp_uiout; > + =A0int version; > + > + =A0fprintf_unfiltered (mi->event_channel, "thread-changed"); > + =A0interp_to_use =3D top_level_interpreter (); > + =A0old_uiout =3D uiout; > + =A0temp_uiout =3D interp_ui_out (interp_to_use); > + =A0version =3D mi_version (temp_uiout); > + =A0temp_uiout =3D mi_out_new (version); > + =A0uiout =3D temp_uiout; > + =A0ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior= _ptid)); > + =A0mi_out_put (uiout, mi->event_channel); > + =A0uiout =3D old_uiout; > + =A0gdb_flush (mi->event_channel); > +} Since your other patches have similar code, how about introducing a helper function for creating temporary uiout, as part of this patch? > + > =A0extern initialize_file_ftype _initialize_mi_interp; /* -Wmissing-proto= types */ > =A0 > =A0void > Index: mi/mi-main.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/mi/mi-main.c,v > retrieving revision 1.115 > diff -p -u -p -r1.115 mi-main.c > --- mi/mi-main.c=A0=A0=A0=A0=A0=A0=A0=A06 May 2008 21:35:01 -0000=A0=A0= =A0=A0=A0=A0=A01.115 > +++ mi/mi-main.c=A0=A0=A0=A0=A0=A0=A0=A09 Jun 2008 12:13:28 -0000 > @@ -45,6 +45,7 @@ > =A0#include "frame.h" > =A0#include "mi-main.h" > =A0#include "language.h" > +#include "observer.h" > =A0 > =A0#include > =A0#include > @@ -241,6 +242,7 @@ mi_cmd_thread_select (char *command, cha > =A0 =A0 =A0error ("mi_cmd_thread_select: USAGE: threadnum."); > =A0 > =A0 =A0rc =3D gdb_thread_select (uiout, argv[0], &mi_error_message); > + =A0observer_notify_thread_changed (); As I've explained in the other email, I think that thread-changed notificat= ion should not be emitted for -thread-select, since the frontend does not need notification about something it just explicitly did itself. So, this call probably should disappear. OK with the above changes. Are you planning to write tests, and document the new notification? - Volodya