Is there a convenience variable for the current thread?

Marc Khouzam marc.khouzam@ericsson.com
Fri Feb 26 02:36:00 GMT 2010


 

> -----Original Message-----
> From: gdb-owner@sourceware.org 
> [mailto:gdb-owner@sourceware.org] On Behalf Of Vladimir Prus
> Sent: February-24-10 1:19 AM
> To: gdb@sources.redhat.com
> Subject: Re: Is there a convenience variable for the current thread?
> 
> Marc Khouzam wrote:
> 
> > Hi,
> > 
> > I would like to disable a breakpoint for a single thread.
> > I don't believe there is a way to do that directly in GDB, 
> so someone 
> > suggested I use a breakpoint condition:
> > 
> >> break myMultiThreadProg:10
> >> cond $threadId != 2
> > 
> > Is there a way to access the threadId in such a condition
> > 
> > Thanks
> > 
> > Marc
> > 
> > P.S. This is different than setting thread-specific 
> breakpoints on all 
> > threads except thread 2, because I need the breakpoint to work on 
> > threads that are not yet created.
> 
> Like proposed here:
> 
> 	http://sourceware.org/ml/gdb/2006-01/msg00330.html

That's exacly it.
Too bad there is nothing we can do about older versions of GDB.

Thanks
 
> ? Here's a patch, but I have no idea if it still applies.
> 
> - Volodya
> 
> Set the $thread variable when stopping.
> 
>         * infrun.c (handle_inferior_event): The change.
> 
> Index: gdb/infrun.c
> ===================================================================
> --- gdb/infrun.c        (revision 10998)
> +++ gdb/infrun.c        (revision 10999)
> @@ -1993,6 +1993,10 @@
>         }
>        else
>         {
> +         set_internalvar (lookup_internalvar ("thread"),
> +                          value_from_longest (builtin_type_int,
> +                                              (LONGEST) 
> + inferior_ptid.pid));
> +
>           /* See if there is a breakpoint at the current PC.  */
>           stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
> 
> 
> 
> 
> 



More information about the Gdb mailing list