public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Lancelot SIX <Lancelot.Six@amd.com>
To: Tom Tromey <tom@tromey.com>,
	Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org>
Cc: lsix@lancelotsix.com
Subject: Re: [PATCH 3/3] gdb/selftest-arch: Make register_test_foreach_arch generate arch tests lazily
Date: Fri, 15 Apr 2022 19:10:46 +0100	[thread overview]
Message-ID: <1aa04e74-7fef-0032-5960-a3ab46b45288@amd.com> (raw)
In-Reply-To: <87o812z11i.fsf@tromey.com>



On 15/04/2022 18:52, Tom Tromey wrote:
> [CAUTION: External Email]
> 
>>>>>> "Lancelot" == Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Lancelot> To fix this, make register_test_foreach_arch register a lazy selftest
> Lancelot> generator.  This way when the test generator is eventually executed, all
> Lancelot> architectures are registered and we do not have a dependency on the
> Lancelot> order the initialize functions are executed in.
> 
> Lancelot> -void
> Lancelot> -register_test_foreach_arch (const std::string &name,
> Lancelot> -                         self_test_foreach_arch_function *function)
> Lancelot> +static std::vector<selftest>
> Lancelot> +foreach_arch_test_generator (const std::string &name,
> Lancelot> +                          self_test_foreach_arch_function *function)
> Lancelot>  {
> 
> Is there some deep reason this has to return a vector?
> It seems like the old code, just calling register_test directly here,
> would also have been fine.
> 
> Tom

Hi,

The reason I went for this is to make the interface clearer about what 
it does.

In the current implementation, I have (in selftest.h):

```
using selftests_generator = std::function<std::vector<selftest> (void)>;
extern void add_lazy_generator (selftests_generator generator);
```

My initial implementation did call `register_test` directly in the 
callback, but then selftest_generator is "just":

```
using selftest_generator = std::function<void (void)>
```

which in my opinion does not communicate much about its intent or use. 
Sure the vector is an overhead, but this machinery is really not on hot 
code path so I did not consider this an issue.

That being said, I am OK with calls `register_test` directly in the 
callback, depending on what the feedbacks are.

Best,
Lancelot.

  reply	other threads:[~2022-04-15 18:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-01 13:00 [PATCH 0/3] Fix register_test_foreach_arch 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 [this message]
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 ` [PING] [PATCH 0/3] Fix register_test_foreach_arch Lancelot SIX
2022-04-15 17:53 ` 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=1aa04e74-7fef-0032-5960-a3ab46b45288@amd.com \
    --to=lancelot.six@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    --cc=tom@tromey.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).