Re: [RFC] New threadnum command for breakpoints

Frédéric Riss
2006-08-08T19:43:12Z

Hi !

> > 1. Should it change on a user requested thread switch? That would be a
> > simple patch to thread.c:switch_to_thread. But maybe documenting it as
> > 'the id of the last stopped thread' wouldn't be a bad idea. I don't
> > think GDB provides a way for the user to get this information (I mean
> > once he has selected another thread). This way 'thread $_gdb_thread'
> > would always bring you back to the stopped thread.
>
> What worries me here is that it locks us into a one-thread-at-a-time
> model. One of the unpleasant realities of thread debugging is that
> two threads can hit breakpoints simultaneously. You can pretend to the
> user that first one happened, then the other; or you can try to expose
> both. We haven't really thought about these issues. But, hey, it's
> probably going to be a major version bump if we ever do; so let's worry
> about it later :-)

Yes, agreed :-). But the issue is quite interesting... trying to come up
with a model that would allow to test for multiple thread simultaneously
is a nice exercise.
Going slightly off-topic, do you really think that reporting
simultaneous hits would be a real gain? I don't think it's so important
as long as you don't miss any of the hits. Threading isn't totally
deterministic, thus the fact that multiple threads have hit a breakpoint
at the same time is just an 'accident' and doesn't bring any additional
information to the user. Of course this reasoning requires that targets
can guarantee that you won't miss any of the hits.

Now back to real code...

> If you want it to be the last stopped thread, which seems reasonable,
> is there a better name we could give it? Or is $_gdb_thread
> sufficiently clear?

I'm not sure. The name itself looks fine to me but, speaking as a user,
I find the leading '_' a bit strange. It seems to imply something about
the variable, but it's not clear what.
If it was a convention and all variables would share the same prefix,
then it wouldn't feel so strange. On the other side if we want to use a
common convention we've got to start somewhere.
Anyway that's just a personal feeling, and really no big deal, maybe
others could share their opinion?

Fred.