public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] gdb/remote: return early from remote_check_symbols if waiting for stop reply
Date: Fri, 29 Apr 2022 16:39:22 +0100	[thread overview]
Message-ID: <622785b8-ed10-e0d2-f24d-45990ec9ea9c@palves.net> (raw)
In-Reply-To: <2656736d-da78-ba44-3997-eaba0d07290e@polymtl.ca>

On 2022-04-29 15:53, Simon Marchi wrote:
> On 2022-04-29 08:50, Pedro Alves wrote:

> Since inferiors can share a program space, perhaps the call to
> target_has_execution here is just wrong, since it only checks one (the
> current) inferior.  What if you have two inferiors sharing a program
> space, one with execution and one without.  If remote_new_objfile gets
> called with the one without execution as the current inferior, we'll
> conclude we have no execution and won't send qSymbol.  But maybe we
> should have sent it, for the benefit of the inferior that has execution.
> 
> So maybe we need to change the question from "does the current inferior
> have execution" to "does any inferior in the affected program space have
> execution", since the current inferior is not always reliable.  And
> anyway, an objfile change is pspace-specific, not inferior-specific.

I think so, yes.

> 
> Something like that:
> 
> diff --git a/gdb/remote.c b/gdb/remote.c
> index ff98024cd78..9888aab88bd 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -5116,14 +5116,6 @@ remote_target::remote_check_symbols ()
>    char *tmp;
>    int end;
> 
> -  /* The remote side has no concept of inferiors that aren't running
> -     yet, it only knows about running processes.  If we're connected
> -     but our current inferior is not running, we should not invite the
> -     remote target to request symbol lookups related to its
> -     (unrelated) current process.  */
> -  if (!target_has_execution ())
> -    return;
> -
>    if (packet_support (PACKET_qSymbol) == PACKET_DISABLE)
>      return;
> 
> @@ -14595,6 +14587,22 @@ remote_new_objfile (struct objfile *objfile)
>    if (current_inferior ()->in_initial_library_scan)
>      return;
> 
> +  bool has_execution = false;
> +  program_space *pspace = current_program_space;
> +  for (inferior *inf : all_inferiors (remote))
> +    {
> +      if (inf->pspace != pspace)
> +       continue;
> +
> +      has_execution = remote->has_execution (inf);
> +
> +      if (has_execution)
> +       break;
> +    }
> +
> +  if (!has_execution)
> +    return;
> +
>    remote->remote_check_symbols ();
>  }
> 

remote_new_objfile has another reference to current_inferior():

 /* Function to be called whenever a new objfile (shlib) is detected.  */
 static void
 remote_new_objfile (struct objfile *objfile)
 {
 ...
   if (current_inferior ()->in_initial_library_scan)
     return;

   remote->remote_check_symbols ();
 }

so seems to me that it should be here that we'd loop over inferiors.

  reply	other threads:[~2022-04-29 15:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-24  3:20 [PATCH 0/2] Fix regressions caused by prune_threads patch Simon Marchi
2022-04-24  3:20 ` [PATCH 1/2] gdb/infrun: make fetch_inferior_event restore thread if exited or signalled Simon Marchi
2022-04-25 17:21   ` Andrew Burgess
2022-04-26 12:43     ` Simon Marchi
2022-04-29 12:37   ` Pedro Alves
2022-04-29 13:25     ` Simon Marchi
2022-04-24  3:20 ` [PATCH 2/2] gdb/remote: return early from remote_check_symbols if waiting for stop reply Simon Marchi
2022-04-26 10:27   ` Andrew Burgess
2022-04-26 14:15     ` Simon Marchi
2022-04-27 10:11       ` Andrew Burgess
2022-04-27 14:01         ` Simon Marchi
2022-04-29 12:50   ` Pedro Alves
2022-04-29 14:53     ` Simon Marchi
2022-04-29 15:39       ` Pedro Alves [this message]
2022-04-29 15:56         ` Simon Marchi
2022-04-29 15:47       ` Pedro Alves

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=622785b8-ed10-e0d2-f24d-45990ec9ea9c@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).