From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23232 invoked by alias); 3 Feb 2006 11:10:58 -0000 Received: (qmail 23218 invoked by uid 22791); 3 Feb 2006 11:10:58 -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; Fri, 03 Feb 2006 11:10:56 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1F4yq5-0007K4-LK for gdb@sources.redhat.com; Fri, 03 Feb 2006 14:10:54 +0300 Received: from zigzag.lvk.cs.msu.su ([158.250.17.23]) by zigzag.lvk.cs.msu.su with esmtp (Exim 4.50) id 1F4ypu-0007Jo-N6; Fri, 03 Feb 2006 14:10:42 +0300 From: Vladimir Prus To: Eli Zaretskii Subject: Re: $thread convenience variable Date: Fri, 03 Feb 2006 11:10:00 -0000 User-Agent: KMail/1.7.2 Cc: gdb@sources.redhat.com References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200602031410.42115.ghost@cs.msu.su> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-02/txt/msg00018.txt.bz2 On Friday 03 February 2006 13:58, Eli Zaretskii wrote: > > From: Vladimir Prus > > Date: Mon, 30 Jan 2006 16:31:34 +0300 > > > > breakpoint foo.cpp:10 if $thread==1 || $thread==2 > > > > If I understand correctly, at the moment gdb can't specify arbitrary > > condition on thread number for breakpoint. A breakpoint is either global, > > or for one thread. > > > > If such variable does not exist, does it look like a good addition? > > I'd support adding such a variable. I have it working by this patch : --- infrun.c (revision 1696) +++ infrun.c (working copy) @@ -1836,10 +1854,17 @@ /* Don't even think about breakpoints if just proceeded over a breakpoint. */ if (stop_signal == TARGET_SIGNAL_TRAP && trap_expected) bpstat_clear (&stop_bpstat); else { + + set_internalvar (lookup_internalvar ("thread"), + value_from_longest (builtin_type_int, + (LONGEST) inferior_ptid.pid)); + With it, the $thread variable will mean the last thread where we've stopped, as opposed to the current one -- that is, does not change after "thread XXX" command. This might be confusing to users, or might not. Also, I'm not sure about "inferior_ptid.pid" above. For remote target (with multiple threads) 'pid' is the only field with reasonable value. The value of 'tid' field is always zero. But for native target, I suppose 'pid' is the same for all threads in a program, but "inferior.tid" varies. I'm a bit lost on this one. - Volodya