Re: Fixes for a couple of infrun bugs (thread hop, revert to step thread).

Ulrich Weigand
2010-08-16T18:41:06Z

Pedro Alves wrote:

> Replacing the "next" by a "continue" should work. I've looked over the
> original description of the problem this is covering, and, that
> would still exercise the problem (which is gdb trying to step
> the other (main) thread with inferior_ptid still pointing at
> the thread that was being "next"ed, and in the process failing
> to remove breakpoints from memory because inferior_ptid pointed
> at an inferior thread.

But isn't the code your patch changes under an if that's only true
if another thread is currently being stepped or nexted? If we just
do "continue" here, that's no longer the case, and the code wouldn't
be exercised at all ...

@@ -3483,7 +3486,7 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
if (!non_stop)
{
struct thread_info *tp;
- tp = iterate_over_threads (currently_stepping_callback,
+ tp = iterate_over_threads (currently_stepping_or_nexting_callback,
ecs->event_thread);
if (tp)
{
@@ -3498,6 +3501,21 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (
return;
}

+ /* If the stepping thread exited, then don't try reverting
+ back to it, just keep going. We need to query the target
+ in case it doesn't support thread exit events. */
+ if (is_exited (tp->ptid)
+ || !target_thread_alive (tp->ptid))
+ {
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog, "\
+infrun: not switching back to stepped thread, it has vanished\n");
+
+ delete_thread (tp->ptid);
+ keep_going (ecs);
+ return;
+ }
+
/* Otherwise, we no longer expect a trap in the current thread.
Clear the trap_expected flag before switching back -- this is
what keep_going would do as well, if we called it. */

Bye,
Ulrich

--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com