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

pfee
2011-07-30T11:44:46Z

> > So, I would think that adding something similar in

> > thread.c:switch_to_thread would do the job.
>
> It wouldn't. What he wants is the last user selected thread,
> not the thread that happens to be current when switch_to_thread
> is called.
>
> - user resumes with thread 1 selected
> - thread 2 hits breakpoint, gdb switches to thread 2
> - breakpoint doesn't cause stop, target is re-resumed
> - thread 3 hits breakpoint, gdb switches to thread 3
> - breakpoint causes stop, previous_inferior_ptid is
> thread 1, but the last switch_to_thread would have
> recorded $previous_thread as thread 2
>
> If you want a convenience variable, please model it on
> $_thread --- see end of thread.c:_initialize_thread.
>
> Note that the previously selected thread may not exist anymore,
> it may have exited meanwhile, for example, or the inferior
> exec'ed.
>
> --
> Pedro Alves
>

Hi Pedro,

I agree with your example, the previous_inferior_ptid in infrun.c, normal_stop()
has the information I need. I'll try and use that to populate the new
convenience variable.

I'll a try to construct a test program that creates a scenario where the
previous thread as died by the time normal_stop() executes.

Thanks,
Paul