From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24861 invoked by alias); 23 Mar 2008 09:25:36 -0000 Received: (qmail 24851 invoked by uid 22791); 23 Mar 2008 09:25:35 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 23 Mar 2008 09:25:17 +0000 Received: (qmail 27532 invoked from network); 23 Mar 2008 09:25:15 -0000 Received: from unknown (HELO localhost) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Mar 2008 09:25:15 -0000 From: Vladimir Prus To: Nick Roberts Subject: Re: MI non-stop mode spec Date: Mon, 24 Mar 2008 05:44:00 -0000 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) Cc: gdb@sources.redhat.com References: <200803190016.02072.vladimir@codesourcery.com> <200803222033.11760.vladimir@codesourcery.com> <18405.57137.166048.407495@kahikatea.snap.net.nz> In-Reply-To: <18405.57137.166048.407495@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: <200803231225.31593.vladimir@codesourcery.com> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00197.txt.bz2 On Sunday 23 March 2008 07:40:17 Nick Roberts wrote: > =A0> > =A0> > =A0> Didn't you check in a patch to make *-varobjs be found= to a > =A0> > =A0> > =A0> thread? > =A0> > =A0> > > =A0> > =A0> > I submitted a patch earlier this year that stopped thinking= that > =A0> > =A0> > a variable object had gone out of scope if the thread chang= ed > =A0> > =A0> > but nothing happened. > =A0> > =A0> > =A0> > =A0> Can you resend the current version of that patch, and I'll ta= ke a > =A0> > =A0> look. > =A0> > > =A0> > I used pid_to_thread_id (inferior_ptid) for the thread_id, just as > =A0> > infrun.c does for *stopped. =A0I think that the thread_id problem = for > =A0> > single/multi-threaded programs should be fixed first (perhaps along > =A0> > the lines Daniel suggested). > =A0>=20 > =A0> Dan's patch is in, however, it only affects Linux. I suspect in might > =A0> be a long time till the problem is solved on all system. Until then, > =A0> we probably should assume that if thread list is empty, then the=20 > =A0> program is ST and never will become MT. > =A0>=20 > =A0> I happen to be working on variable objects for non-stop now, so I'll > =A0> play with the last version of your patch that you have posted. >=20 > I've made some changes since then so here's my latest patch updated to cu= rrent > sources. =A0I found that after all I did need thread_id =3D=3D -2 for glo= bal > variables (used in mi-cmd-var which doesn't print the thread_id field for= them > since their value is the same in all threads). I don't think we need it. A global variable has a NULL valid_block, so we c= an use that. I'll work on adjusting your patch this way. > =A0 static struct value * > =A0 c_value_of_root (struct varobj **var_handle) > =A0 { > =A0 =A0 struct value *new_val =3D NULL; > =A0 =A0 struct varobj *var =3D *var_handle; > ! =A0 struct frame_id saved_frame_id; > ! =A0 struct cleanup *old_cleanups =3D NULL; > ! =A0 int within_scope, thread_id; > ! =A0 ptid_t ptid; > =A0=20 > =A0 =A0 /* =A0Only root variables can be updated... */ > =A0 =A0 if (!is_root_p (var)) > =A0 =A0 =A0 /* Not a root var */ > =A0 =A0 =A0 return NULL; > =A0=20 > =A0 =A0 /* Determine whether the variable is still around. */ > =A0 =A0 if (var->root->valid_block =3D=3D NULL || var->root->use_selected= _frame) > =A0 =A0 =A0 within_scope =3D 1; > =A0 =A0 else > =A0 =A0 =A0 { > ! =A0 =A0 =A0 thread_id =3D var->root->thread_id; > ! =A0 =A0 =A0 ptid =3D thread_id_to_pid (thread_id); > ! =A0 =A0 =A0 if (thread_id =3D=3D 0) > ! =A0=A0=A0=A0=A0=A0/* Single-threaded application. =A0*/ > ! =A0=A0=A0=A0=A0=A0within_scope =3D check_scope (var); > ! =A0 =A0 =A0 else if (thread_id !=3D -1 && target_thread_alive (ptid)) > =A0 =A0=A0=A0=A0=A0=A0{ > !=20 > ! =A0=A0=A0=A0=A0=A0 =A0saved_frame_id =3D get_frame_id (get_selected_fra= me (NULL)); > ! =A0=A0=A0=A0=A0=A0 =A0old_cleanups =3D make_cleanup_restore_current_thr= ead (inferior_ptid, > ! =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 =A0 =A0 =A0saved_frame_id); > ! =A0=A0=A0=A0=A0=A0 =A0switch_to_thread (ptid); > ! =A0=A0=A0=A0=A0=A0 =A0within_scope =3D check_scope (var); > ! =A0=A0=A0=A0=A0=A0} > ! =A0 =A0 =A0 else > ! =A0=A0=A0=A0=A0=A0/* Mark it as dead. =A0*/ > ! =A0=A0=A0=A0=A0=A0var->root->thread_id =3D -1; > =A0 =A0 =A0 } > =A0=20 > =A0 =A0 if (within_scope) > *************** c_value_of_root (struct varobj **var_han > *** 2186,2191 **** > --- 2233,2240 ---- > =A0 =A0 =A0 =A0 return new_val; > =A0 =A0 =A0 } > =A0=20 > + =A0 do_cleanups (old_cleanups); > +=20 > =A0 =A0 return NULL; > =A0 } I think the use of cleanups above is wrong. You basically have: struct cleanups *old_cleanups =3D NULL; if (whatever) old_cleanups =3D ... do_cleanups (old_cleanups); so, if 'whatever' evaluates to false, all cleanups, including those set in parent, will be executed. That's what we get for using a language that does not have exceptions and proper destructors. I'll fix this too. - Volodya