aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-03-10 15:13:55 +0000
committerAndrew Burgess <aburgess@redhat.com>2023-03-13 21:51:04 +0000
commitc317ea5723689a4304760ff9f095e5f6df915f8d (patch)
tree106129b10c37c3581acd9b9879df842d7d427a14 /gdb/gdbarch.c
parent350796840f7058bd0bdb4a3be2343014c3704de1 (diff)
downloadgdb-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.c')
-rw-r--r--gdb/gdbarch.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 064afd7..6018c63 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -1658,7 +1658,7 @@ int
gdbarch_wchar_signed (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Check variable changed from pre-default. */
+ /* Check variable changed from its initial value. */
gdb_assert (gdbarch->wchar_signed != -1);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_wchar_signed called\n");
@@ -1710,7 +1710,7 @@ int
gdbarch_addr_bit (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Check variable changed from pre-default. */
+ /* Check variable changed from its initial value. */
gdb_assert (gdbarch->addr_bit != 0);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_addr_bit called\n");
@@ -1728,7 +1728,7 @@ int
gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Check variable changed from pre-default. */
+ /* Check variable changed from its initial value. */
gdb_assert (gdbarch->dwarf2_addr_size != 0);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_dwarf2_addr_size called\n");
@@ -1746,7 +1746,7 @@ int
gdbarch_char_signed (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Check variable changed from pre-default. */
+ /* Check variable changed from its initial value. */
gdb_assert (gdbarch->char_signed != -1);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_char_signed called\n");
@@ -1901,7 +1901,7 @@ int
gdbarch_num_regs (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Check variable changed from pre-default. */
+ /* Check variable changed from its initial value. */
gdb_assert (gdbarch->num_regs != -1);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_num_regs called\n");
@@ -3919,8 +3919,8 @@ const char *
gdbarch_gcore_bfd_target (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Check variable changed from pre-default. */
- gdb_assert (gdbarch->gcore_bfd_target != 0);
+ /* Check predicate was used. */
+ gdb_assert (gdbarch_gcore_bfd_target_p (gdbarch));
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_gcore_bfd_target called\n");
return gdbarch->gcore_bfd_target;
@@ -3995,8 +3995,8 @@ ULONGEST
gdbarch_max_insn_length (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Check variable changed from pre-default. */
- gdb_assert (gdbarch->max_insn_length != 0);
+ /* Check predicate was used. */
+ gdb_assert (gdbarch_max_insn_length_p (gdbarch));
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_max_insn_length called\n");
return gdbarch->max_insn_length;