public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/testsuite: allow "require" callbacks to provide a reason
Date: Tue, 28 Mar 2023 11:51:25 -0400	[thread overview]
Message-ID: <b78f7650-e3fc-d406-553c-56ac9d232ae6@efficios.com> (raw)
In-Reply-To: <0e0254fc-5fa8-71b2-01b8-cc5742909727@suse.de>

On 3/28/23 11:44, Tom de Vries wrote:
> On 3/28/23 14:23, Simon Marchi via Gdb-patches wrote:
>> When an allow_* proc returns false, it can be a bit difficult what check
>> failed exactly, if the procedure does multiple checks.  To make
>> investigation easier, I propose to allow the "require" callbacks to be
>> able to return a list of two elements: the zero/non-zero value, and a
>> reason string.
>>
> 
> Hi,
> 
> I like the idea.
> 
> The only question I had was what the desired behaviour is for:
> ...
>   return {1 "bla"}
> ...
> 
> AFAICT, the current implementation just ignores "bla", and I wondered if perhaps we should error out to avoid the impression that something will be done with "bla".
> 
> That however will make this fail if $res == 1:
> ...
> set res [try_foo]
> return {$res "foo"}
> ...
> so probably that's just too restrictive.

I can't really think of a use case where we would return 1, with a
justification, if we always formulate our procs in the "allow" form.
That is:

  proc allow_foo_tests { } {
    if ... {
      return {0 "reason A"}
    }

    if ... {
      return {0 "reason B"}
    }

    return 1
  }

But if we have a proc in the opposite "prevent" or "skip" form (like we
had before the conversion to "allow"), it would typically written as:

  proc prevent_foo_tests { } {
    if ... {
      return {1 "reason A"}
    }

    if ... {
      return {1 "reason B"}
    }

    return 0
  }

and it could be used as:

  require !prevent_foo_tests

So that's an example where we could theoritically return 1 and use the
reason string.  It just won't happen often, because we it's better to
write things in the "allow" form, to avoid the double negative.


> LGTM as-is.

Thanks, will push.

Simon

      reply	other threads:[~2023-03-28 15:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 12:23 Simon Marchi
2023-03-28 15:44 ` Tom de Vries
2023-03-28 15:51   ` Simon Marchi [this message]

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=b78f7650-e3fc-d406-553c-56ac9d232ae6@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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).