Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [patch] regression: Quit should not ask with core (PR 12071)
Date: Wed, 29 Sep 2010 17:00:00 -0000	[thread overview]
Message-ID: <201009291604.18270.pedro@codesourcery.com> (raw)
In-Reply-To: <20100929144316.GA16519@host1.dyn.jankratochvil.net>

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


  reply	other threads:[~2010-09-29 15:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-29 16:44 Jan Kratochvil
2010-09-29 17:00 ` Pedro Alves [this message]
2010-09-30  1:56   ` Jan Kratochvil
2010-09-30 14:02     ` Pedro Alves
2010-09-30 14:43       ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201009291604.18270.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox