public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Lancelot SIX <Lancelot.Six@amd.com>
To: gdb-patches@sourceware.org
Cc: lsix@lancelotsix.com
Subject: [PING] [PATCH 0/3] Fix register_test_foreach_arch
Date: Tue, 12 Apr 2022 09:17:08 +0100	[thread overview]
Message-ID: <e3dd574f-e33f-a5c3-c505-257f976ef589@amd.com> (raw)
In-Reply-To: <20220401130015.513187-1-lancelot.six@amd.com>

Hi,

Kindly pinging.

Best,
Lancelot.

On 01/04/2022 14:00, Lancelot SIX wrote:
> Hi,
> 
> While working on a selftest issue, I noticed that there is a silent
> problem with register_test_foreach_arch:
> 
>          $ ./gdb/gdb \
>              -data-directory ./gdb/data-directory \
>              -quiet -batch -ex "maint selftest" 2>&1 \
>              | grep -E "Ran [0-9]+ unit tests"
>          Ran 145 unit tests, 0 failed
>          $ GDB_REVERSE_INIT_FUNCTIONS=1 ./gdb/gdb \
>              -data-directory ./gdb/data-directory \
>              -quiet -batch -ex "maint selftest" 2>&1 \
>              | grep -E "Ran [0-9]+ unit tests"
>          Ran 82 unit tests, 0 failed
> 
> Notice that when the GDB_REVERSE_INIT_FUNCTIONS env variable is set, the
> number of tests registered is different compared to when this env
> variable is not set.
> 
> This is due to an issue with how register_test_foreach_arch is used and
> how it works.  This function is used to register a generic selftest and
> run it against each architecture GDB supports.  Such registration is
> typically done during GDB's initialization (in _initialize_* functions).
> At the point where this function is called, it will iterate over all the
> architectures known to GDB and create an instance of the selftest for
> it.  The problem is that at that point, because GDB's initialization
> is not done yet, the best register_test_foreach_arch can do is register
> the test for each architecture initialized so far.  All architectures
> which are initialized at a later point will not have the selftest.
> 
> To fix this, this series proposes a lazy registration mechanism so
> register_test_foreach_arch can delay the moment it iterates over the
> known architectures to a point when GDB is fully initialized.
> 
> The first patch of the series does some preparatory refactoring which
> will come in handy later.  Patch 2 introduces the lazy test generation
> mechanism in the selftest framework, and patch 3 uses this mechanism to
> fix register_test_foreach_arch.
> 
> Tested on x86_64-gnu-linux.
> 
> All feedbacks are welcome.
> 
> Best,
> Lancelot.
> 
> Lancelot SIX (3):
>    gdbsupport/selftest: Replace for_each_selftest with an iterator_range
>    gdbsupport/selftest: Allow lazy registration
>    gdb/selftest-arch: Make register_test_foreach_arch generate arch tests
>      lazily
> 
>   gdb/maint.c                        | 13 ++++-----
>   gdb/selftest-arch.c                | 29 +++++++++++++------
>   gdb/selftest-arch.h                |  3 ++
>   gdb/testsuite/gdb.gdb/unittest.exp | 25 ++++++++++++++--
>   gdbsupport/selftest.cc             | 46 +++++++++++++++++++++---------
>   gdbsupport/selftest.h              | 42 ++++++++++++++++++++++-----
>   6 files changed, 120 insertions(+), 38 deletions(-)
> 
> 
> base-commit: 5530c021ce01abf368a9cde26b22c4b34f320ee8

  parent reply	other threads:[~2022-04-12  8:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-01 13:00 Lancelot SIX
2022-04-01 13:00 ` [PATCH 1/3] gdbsupport/selftest: Replace for_each_selftest with an iterator_range Lancelot SIX
2022-04-01 13:00 ` [PATCH 2/3] gdbsupport/selftest: Allow lazy registration Lancelot SIX
2022-04-01 13:00 ` [PATCH 3/3] gdb/selftest-arch: Make register_test_foreach_arch generate arch tests lazily Lancelot SIX
2022-04-15 17:52   ` Tom Tromey
2022-04-15 18:10     ` Lancelot SIX
2022-04-15 18:50       ` Tom Tromey
2022-04-19 18:55   ` Simon Marchi
2022-04-19 21:10     ` Lancelot SIX
2022-04-12  8:17 ` Lancelot SIX [this message]
2022-04-15 17:53 ` [PATCH 0/3] Fix register_test_foreach_arch Tom Tromey
2022-04-19  8:18   ` Lancelot SIX

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=e3dd574f-e33f-a5c3-c505-257f976ef589@amd.com \
    --to=lancelot.six@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).