Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: make all_inferiors_safe actually work
Date: Thu, 15 Jul 2021 12:15:14 +0200	[thread overview]
Message-ID: <ed20a119-b4af-0f38-8ebc-e4d7b5a6d96f@suse.de> (raw)
In-Reply-To: <20210714201541.1883926-1-simon.marchi@polymtl.ca>

On 7/14/21 10:15 PM, Simon Marchi wrote:
> The test gdb.threads/fork-plus-threads.exp fails since 08bdefb58b78
> ("gdb: make inferior_list use intrusive_list"):
> 
>     FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left
> 
> Looking at the log, we see that we are left with a bunch of inferiors in
> the detach-on-fork=off case:
> 
>     info inferiors^M
>       Num  Description       Connection           Executable        ^M
>     * 1    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       2    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       3    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       4    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       5    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       6    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       7    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       8    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       9    <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       10   <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>       11   <null>                                 /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads ^M
>     (gdb) FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left
> 
> when we expect to have just one.  The problem is prune_inferiors not
> pruning inferiors.  And this is caused by all_inferiors_safe not
> actually iterating on inferiors.  The current implementation:
> 
>   inline all_inferiors_safe_range
>   all_inferiors_safe ()
>   {
>     return {};
>   }
> 
> default-constructs an all_inferiors_safe_range, which default-constructs
> an all_inferiors_safe_iterator as its m_begin field, which
> default-constructs a all_inferiors_iterator.  A default-constructed
> all_inferiors_iterator is an end iterator, which means we have
> constructed an (end,end) all_inferiors_safe_range.
> 
> We actually need to pass down the list on which we want to iterator
> (that is the inferior_list global), so that all_inferiors_iterator's
> first constructor is chosen.  We also pass nullptr as the proc_target
> filter.  In this case, we don't do any filtering, but if in the future
> all_inferiors_safe needed to allow filtering on process target (like
> all_inferiors does), we could pass down a process target pointer.
> 
> basic_safe_iterator's constructor needs to be changed to allow
> constructing the wrapped iterator with multiple arguments, not just one.
> 
> With this, gdb.threads/fork-plus-threads.exp is passing once again for
> me.
> 

For me as well.

LGTM.

One suggestion: I'd do
s%/home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads%fork-plus-threads%
in the log message for readability.

Thanks,
- Tom

> Change-Id: I650552ede596e3590c4b7606ce403690a0278a01
> ---
>  gdb/inferior.h             |  2 +-
>  gdbsupport/safe-iterator.h | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/gdb/inferior.h b/gdb/inferior.h
> index 6662a3bde463..94fbac0fc571 100644
> --- a/gdb/inferior.h
> +++ b/gdb/inferior.h
> @@ -676,7 +676,7 @@ extern intrusive_list<inferior> inferior_list;
>  inline all_inferiors_safe_range
>  all_inferiors_safe ()
>  {
> -  return {};
> +  return all_inferiors_safe_range (nullptr, inferior_list);
>  }
>  
>  /* Returns a range representing all inferiors, suitable to use with
> diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
> index 5cfc5b6ee692..53868d3b3eec 100644
> --- a/gdbsupport/safe-iterator.h
> +++ b/gdbsupport/safe-iterator.h
> @@ -48,11 +48,11 @@ class basic_safe_iterator
>    typedef typename Iterator::iterator_category iterator_category;
>    typedef typename Iterator::difference_type difference_type;
>  
> -  /* Construct using the given argument; the end iterator is default
> -     constructed.  */
> -  template<typename Arg>
> -  explicit basic_safe_iterator (Arg &&arg)
> -    : m_it (std::forward<Arg> (arg)),
> +  /* Construct the begin iterator using the given arguments; the end iterator is
> +     default constructed.  */
> +  template<typename... Args>
> +  explicit basic_safe_iterator (Args &&...args)
> +    : m_it (std::forward<Args> (args)...),
>        m_next (m_it)
>    {
>      if (m_it != m_end)
> 

  reply	other threads:[~2021-07-15 10:15 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 16:56 [PATCH 00/11] Various thread lists optimizations Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 01/11] gdb: introduce iterator_range, remove next_adapter Simon Marchi via Gdb-patches
2021-07-05 15:41   ` Pedro Alves
2021-07-06 19:16     ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 02/11] gdb: introduce intrusive_list, make thread_info use it Simon Marchi via Gdb-patches
2021-06-22 23:13   ` Lancelot SIX via Gdb-patches
2021-06-23  0:48     ` Simon Marchi via Gdb-patches
2021-07-05 15:44   ` Pedro Alves
2021-07-06 19:38     ` Simon Marchi via Gdb-patches
2021-07-06 20:45       ` Simon Marchi via Gdb-patches
2021-07-06 21:04         ` Pedro Alves
2021-07-06 21:38           ` Simon Marchi via Gdb-patches
2021-07-06 21:02       ` Pedro Alves
2021-07-06 21:45         ` Simon Marchi via Gdb-patches
2021-07-07 11:46           ` Pedro Alves
2021-07-07 13:52             ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 03/11] gdb: make inferior_list use intrusive_list Simon Marchi via Gdb-patches
2021-07-05 15:44   ` Pedro Alves
2021-07-14  6:34     ` Tom de Vries
2021-07-14 16:11       ` Simon Marchi via Gdb-patches
2021-07-14 20:15         ` [PATCH] gdb: make all_inferiors_safe actually work Simon Marchi via Gdb-patches
2021-07-15 10:15           ` Tom de Vries [this message]
2021-07-17 12:54             ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 04/11] gdb: use intrusive list for step-over chain Simon Marchi via Gdb-patches
2021-07-05 15:45   ` Pedro Alves
2021-07-06 20:59     ` Simon Marchi via Gdb-patches
2021-06-22 16:56 ` [PATCH 05/11] gdb: add setter / getter for thread_info resumed state Simon Marchi via Gdb-patches
2021-07-05 15:45   ` Pedro Alves
2021-06-22 16:56 ` [PATCH 06/11] gdb: make thread_info::suspend private, add getters / setters Simon Marchi via Gdb-patches
2021-07-05 15:45   ` Pedro Alves
2021-06-22 16:57 ` [PATCH 07/11] gdb: maintain per-process-target list of resumed threads with pending wait status Simon Marchi via Gdb-patches
2021-07-05 15:51   ` Pedro Alves
2021-07-06 21:25     ` Simon Marchi via Gdb-patches
2021-07-07 12:01       ` Pedro Alves
2021-07-12 22:28         ` Simon Marchi via Gdb-patches
2021-07-12 22:34           ` Simon Marchi via Gdb-patches
2021-07-13 12:21           ` Pedro Alves
2021-06-22 16:57 ` [PATCH 08/11] gdb: optimize check for resumed threads with pending wait status in maybe_set_commit_resumed_all_targets Simon Marchi via Gdb-patches
2021-07-05 15:51   ` Pedro Alves
2021-06-22 16:57 ` [PATCH 09/11] gdb: optimize selection of resumed thread with pending event Simon Marchi via Gdb-patches
2021-07-05 15:51   ` Pedro Alves
2021-06-22 16:57 ` [PATCH 10/11] gdb: maintain ptid -> thread map, optimize find_thread_ptid Simon Marchi via Gdb-patches
2021-07-05 15:52   ` Pedro Alves
2021-07-06 21:31     ` Simon Marchi via Gdb-patches
2021-07-07 12:13       ` Pedro Alves
2021-06-22 16:57 ` [PATCH 11/11] gdb: optimize all_matching_threads_iterator Simon Marchi via Gdb-patches
2021-07-05 15:52   ` Pedro Alves
2021-07-14  9:40     ` Tom de Vries
2021-07-13  0:47 ` [PATCH 00/11] Various thread lists optimizations Simon Marchi via Gdb-patches

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=ed20a119-b4af-0f38-8ebc-e4d7b5a6d96f@suse.de \
    --to=tdevries@suse.de \
    --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