public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCHv2 4/5] gdb/gdbarch: remove the 'invalid=None' state from gdbarch_components.py
Date: Mon, 6 Mar 2023 15:13:51 -0500	[thread overview]
Message-ID: <4a98e17c-7175-6127-74b2-ae41f87920d6@simark.ca> (raw)
In-Reply-To: <7452e65c89feea14efa71eb0272e00c2e68f6afd.1678116328.git.aburgess@redhat.com>



On 3/6/23 10:31, Andrew Burgess via Gdb-patches wrote:
> This commit ensures that the 'invalid' property of all components is
> either True, False, or a string.
> 
> Additionally, this commit allows a component to have both a predicate
> and for the 'invalid' property to be a string.
> 
> Removing the option for 'invalid' to be None allows us to simplify the
> algorithms in gdbarch.py a little.
> 
> Allowing a component to have both a predicate and an 'invalid' string
> means that we can validate the value that a tdep sets into a field,
> but also allow a predicate to ensure that the field has changed from
> the default.
> 
> This functionality isn't going to be used in this series, but I have
> tested it locally and believe that it would work, and this might make
> it easier for others to add new components in the future.
> 
> In gdbarch_types.py, I've updated the type annotations to show that
> the 'invalid' field should not be None, and I've changed the default
> for this field from None to False.
> 
> Additionally, in gdbarch_types.py I've removed an assert from
> Component.get_predicate.  This assert ensured that we didn't have the
> predicate field set to True and the invalid field set to a string.
> However, no component currently uses this configuration, and after
> this commit, that combination is now supported, so the assert can be
> removed.
> 
> As a consequence of the gdbarch_types.py changes we see some
> additional comments generated in gdbarch.c about verification being
> skipped due to the invalid field being False.
> 
> In gdbarch_components.py I've had to add 'invalid=True' for two
> components: gcore_bfd_target and max_insn_length, without this the
> validation in the gdbarch getter would disappear.

So, in my version of this, I gave `invalid` the default value True,
whereas you gave it the default False.  Upon further reflexion, I think
False is a good default.  It allows to set a predefault value and, if
the arch does not override it, that value is the effective value.  Seems
like a sane and simple default behavior.

This means you can remove all the `invalid=False,` from
gdbarch_components.py now (one find and replace).  I think you can tack
it as a separate patch on top to avoid noise, since you have other
changes in gdbarch_components.py already in this patch.

> @@ -1490,6 +1500,7 @@ const struct floatformat **
>  gdbarch_bfloat16_format (struct gdbarch *gdbarch)
>  {
>    gdb_assert (gdbarch != NULL);
> +  /* Skip verify of bfloat16_format, invalid_p == 0 */

I don't think the addition of these "Skip verify" comments in these
functions (that invoke the gdbarch functions and methods) make sense.

Simon

  reply	other threads:[~2023-03-06 20:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 16:51 [PATCH 0/2] Add new gdbarch::displaced_step_max_buffer_length field Andrew Burgess
2023-02-28 16:51 ` [PATCH 1/2] gdb: updates to gdbarch.py algorithm Andrew Burgess
2023-03-01  3:09   ` Simon Marchi
2023-03-02 10:13     ` Andrew Burgess
2023-03-02 16:49       ` Simon Marchi
2023-03-01 15:58   ` Tom Tromey
2023-02-28 16:51 ` [PATCH 2/2] gdb: add gdbarch::displaced_step_max_buffer_length Andrew Burgess
2023-03-02 18:28   ` Simon Marchi
2023-03-06 15:31 ` [PATCHv2 0/5] Add new gdbarch::displaced_step_buffer_length field Andrew Burgess
2023-03-06 15:31   ` [PATCHv2 1/5] gdb/gdbarch: remove unused 'invalid=True' from gdbarch_components.py Andrew Burgess
2023-03-06 15:31   ` [PATCHv2 2/5] gdb/gdbarch: remove yet more " Andrew Burgess
2023-03-06 15:31   ` [PATCHv2 3/5] gdb/gdbarch: split postdefault setup from invalid check in gdbarch.py Andrew Burgess
2023-03-06 18:26     ` Simon Marchi
2023-03-06 15:31   ` [PATCHv2 4/5] gdb/gdbarch: remove the 'invalid=None' state from gdbarch_components.py Andrew Burgess
2023-03-06 20:13     ` Simon Marchi [this message]
2023-03-07 15:17     ` Tom Tromey
2023-03-07 15:20       ` Simon Marchi
2023-03-06 15:31   ` [PATCHv2 5/5] gdb: add gdbarch::displaced_step_buffer_length Andrew Burgess
2023-03-06 21:15     ` Simon Marchi
2023-03-10 18:43   ` [PATCHv3 0/9] Add new gdbarch::displaced_step_buffer_length field Andrew Burgess
2023-03-10 18:43     ` [PATCHv3 1/9] gdb/gdbarch: remove unused 'invalid=True' from gdbarch_components.py Andrew Burgess
2023-03-10 18:43     ` [PATCHv3 2/9] gdb/gdbarch: remove yet more " Andrew Burgess
2023-03-10 18:43     ` [PATCHv3 3/9] gdb/gdbarch: split postdefault setup from invalid check in gdbarch.py Andrew Burgess
2023-03-10 18:43     ` [PATCHv3 4/9] gdb/gdbarch: remove the 'invalid=None' state from gdbarch_components.py Andrew Burgess
2023-03-10 18:43     ` [PATCHv3 5/9] gdbarch: use predefault for more value components within gdbarch Andrew Burgess
2023-03-10 18:43     ` [PATCHv3 6/9] gdbarch: improve generation of validation in gdbarch getters Andrew Burgess
2023-03-11  2:57       ` Simon Marchi
2023-03-10 18:43     ` [PATCHv3 7/9] gdbarch: remove some unneeded predefault="0" from gdbarch_components.py Andrew Burgess
2023-03-10 18:43     ` [PATCHv3 8/9] gdbarch: make invalid=True the default for all Components Andrew Burgess
2023-03-10 18:43     ` [PATCHv3 9/9] gdb: add gdbarch::displaced_step_buffer_length Andrew Burgess
2023-03-11  2:57     ` [PATCHv3 0/9] Add new gdbarch::displaced_step_buffer_length field Simon Marchi
2023-03-13 22:01       ` Andrew Burgess

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=4a98e17c-7175-6127-74b2-ae41f87920d6@simark.ca \
    --to=simark@simark.ca \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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).