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: [patch] regression: Quit should not ask with core (PR 12071)


On Wednesday 29 September 2010 15:43:16, Jan Kratochvil wrote:
> @@ -467,7 +467,7 @@ have_live_inferiors (void)
>       multiple target interfaces.  */
>    if (have_inferiors ())
>      for (t = current_target.beneath; t != NULL; t = t->beneath)
> -      if (t->to_stratum == process_stratum)
> +      if (t->to_stratum == process_stratum && t->to_has_execution (t))
>         return 1;

This is about the same as removing the loop and calling "target_has_execution".
But, that wouldn't be correct either, because the to_has_execution depends
on the inferior selected (see default_child_has_execution).  So, for example,
if you have two inferiors in your gdb session, one of them is running as
a process, while the other is still just a pseudo-inferior / file_stratum
inferior yet, and you have the latter selected as current, your patch
will make that have-live-inferiors check still return 0, while there _is_
one live inferior.

The quickest fix is to iterate over all inferiors, and in turn, switch to
the iterated inferior, and check target_has_execution.  In pseudo-C:

int
have_live_inferiors (void)
{
  struct inferior *inf;

  foreach (inf in inferiors)
    {
      thread = any_thread_of_inferior (inf);
      if (thread)
        {
          switch_to_thread (thread->ptid);
          if (target_has_execution)
            return 1;
        }
    }

  return 0;
}

Want to give that a try?

-- 
Pedro Alves


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