Re: Enhancement - show old and new thread info when switching during debugging

pfee
2011-07-29T16:33:44Z

> > I've copied output from GDB 7.3 before and after my patch into the bug

> > report along with some notes on the implementation.
>
> I think I understand what you are trying to say. What I am saying is
> that you can find which thread you switched from, by going up the
> debugger output until you find a "[Switching to Thread ...]" message.
> So, the information is already there. I agree it's not ultra convenient,
> but I personally think it's better than your approach (the new message
> becomes way to long, IMO).
>
> In your case, if going up the output is not good enough, I would
> suggest two alternative solutions, in order of preference:
> - Have GDB maintain variable $old_thread or $prev_thread that
> you can then use to switch to the previous thread;
>
> (gdb) thread $old_thread
>
> would return you to the previous thread before the switch.
> - At least print the new thread ID first;

Ah, I see your point now also.

The previous "Switching to" message may be lost if the terminal output buffer
isn't long enough.

I like your idea of being able to use a "thread $prev_thread" command. That's
better than my patch as I have printed out the hex target thread ID and decimal
LWP numbers but not the GDB thread ID. It's the GDB thread ID that used with the
"thread" command. Hence even with my patch, the user would still have to issue
"info threads", then match the LWP (or target ID) against GDB's ID.

However I don't currently know how to interact with GDB convenience variables.
You second suggestion is to reorder the output e.g.

[Switching to Thread 0x7ffff7fd67000 (LWP 4282) from Thread 0x7ffff7fd8740 (LWP
4279)]

That would be simple to do. Would you recommend adjusting the printf statement
or learning how to create a new convenience variable?

Thanks,
Paul