This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Saturday 30 July 2011 03:44:05, Joel Brobecker wrote:
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]