Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <ghost@cs.msu.su>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb@sources.redhat.com
Subject: Re: $thread convenience variable
Date: Fri, 03 Feb 2006 11:10:00 -0000	[thread overview]
Message-ID: <200602031410.42115.ghost@cs.msu.su> (raw)
In-Reply-To: <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


  reply	other threads:[~2006-02-03 11:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-30 20:19 Vladimir Prus
2006-02-03 10:58 ` Eli Zaretskii
2006-02-03 11:10   ` Vladimir Prus [this message]
2006-02-03 11:28     ` Eli Zaretskii
2006-02-03 11:59       ` Vladimir Prus
2006-02-03 15:14         ` Eli Zaretskii
2006-02-03 13:04     ` Andrew STUBBS
2006-02-03 13:10       ` Vladimir Prus
2006-02-03 13:56         ` Andrew STUBBS
2006-02-06 23:52           ` Daniel Jacobowitz
2006-02-06 23:49       ` Daniel Jacobowitz
2006-02-07 10:59         ` Andrew STUBBS
2006-02-07 19:31           ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200602031410.42115.ghost@cs.msu.su \
    --to=ghost@cs.msu.su \
    --cc=eliz@gnu.org \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox