This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: $thread convenience variable
- From: Vladimir Prus <ghost at cs dot msu dot su>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: gdb at sources dot redhat dot com
- Date: Fri, 3 Feb 2006 14:10:41 +0300
- Subject: Re: $thread convenience variable
- References: <drl4fn$4h8$1@sea.gmane.org> <u64nwyaiv.fsf@gnu.org>
On Friday 03 February 2006 13:58, Eli Zaretskii wrote:
> > From: Vladimir Prus <ghost@cs.msu.su>
> > 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