diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-03-10 15:13:55 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-03-13 21:51:04 +0000 |
commit | c317ea5723689a4304760ff9f095e5f6df915f8d (patch) | |
tree | 106129b10c37c3581acd9b9879df842d7d427a14 /gdb/gdbarch.py | |
parent | 350796840f7058bd0bdb4a3be2343014c3704de1 (diff) | |
download | gdb-c317ea5723689a4304760ff9f095e5f6df915f8d.zip gdb-c317ea5723689a4304760ff9f095e5f6df915f8d.tar.gz gdb-c317ea5723689a4304760ff9f095e5f6df915f8d.tar.bz2 |
gdbarch: improve generation of validation in gdbarch getters
We currently generate some validation code within the gdbarch getter
methods.
This commit adjusts the algorithm used to generate this validation
slightly to make the gdbarch.py code (I think) clearer; there's no
significant changes to what is generated.
The validation algorithm for gdbarch values is now:
- If the Value has an 'invalid' field that is a string, use that for
validation,
- If the Value has its 'predicate' field set to true, then check the
predicate returns true, this ensures the predicate has been
called,
- If the Value has its 'invalid' field set to True, or the Value has
'postdefault' field, then check the fields has changed from its
initial value,
- Otherwise no validation is performed.
The only changes after this commit are:
- Some comments change slightly, and
- For 'gcore_bfd_target' and 'max_insn_length' we now validate by
calling the predicate rather than checking the field value
directly, the underlying check being performed is unchanged
though.
There should be no user visible changes after this commit.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/gdbarch.py')
-rwxr-xr-x | gdb/gdbarch.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py index 7ff2cab..62592c1 100755 --- a/gdb/gdbarch.py +++ b/gdb/gdbarch.py @@ -351,15 +351,13 @@ with open("gdbarch.c", "w") as f: if isinstance(c.invalid, str): print(" /* Check variable is valid. */", file=f) print(f" gdb_assert (!({c.invalid}));", file=f) - elif c.postdefault is not None and c.predefault is not None: - print(" /* Check variable changed from pre-default. */", file=f) - print(f" gdb_assert (gdbarch->{c.name} != {c.predefault});", file=f) - elif c.invalid: - if c.predefault: - print(" /* Check variable changed from pre-default. */", file=f) - print( - f" gdb_assert (gdbarch->{c.name} != {c.predefault});", file=f - ) + elif c.predicate: + print(" /* Check predicate was used. */", file=f) + print(f" gdb_assert (gdbarch_{c.name}_p (gdbarch));", file=f) + elif c.invalid or c.postdefault is not None: + init_value = c.predefault or "0" + print(" /* Check variable changed from its initial value. */", file=f) + print(f" gdb_assert (gdbarch->{c.name} != {init_value});", file=f) else: print(f" /* Skip verify of {c.name}, invalid_p == 0 */", file=f) print(" if (gdbarch_debug >= 2)", file=f) |