public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdbarch: use predefault for more value components within gdbarch
Date: Mon, 13 Mar 2023 22:01:20 +0000 (GMT)	[thread overview]
Message-ID: <20230313220120.779113858D1E@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=350796840f7058bd0bdb4a3be2343014c3704de1

commit 350796840f7058bd0bdb4a3be2343014c3704de1
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Fri Mar 10 15:19:42 2023 +0000

    gdbarch: use predefault for more value components within gdbarch
    
    For some reason the following value components of gdbarch:
    
      bfloat16_format
      half_format
      float_format
      double_format
      long_double_format
      so_ops
    
    All use a postdefault but no predefault to set the default value for
    the component.
    
    As the postdefault values for these components are all constant
    pointers that don't depend on other fields within the gdbarch, then I
    don't see any reason why we couldn't use a predefault instead.
    
    So lets do that.
    
    Approved-By: Simon Marchi <simon.marchi@efficios.com>

Diff:
---
 gdb/gdbarch.c             | 24 ++++++------------------
 gdb/gdbarch_components.py | 12 ++++++------
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index efd111eeabc..064afd7c226 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -53,15 +53,15 @@ struct gdbarch
   int long_bit = 4*TARGET_CHAR_BIT;
   int long_long_bit = 2*4*TARGET_CHAR_BIT;
   int bfloat16_bit = 2*TARGET_CHAR_BIT;
-  const struct floatformat ** bfloat16_format = 0;
+  const struct floatformat ** bfloat16_format = floatformats_bfloat16;
   int half_bit = 2*TARGET_CHAR_BIT;
-  const struct floatformat ** half_format = 0;
+  const struct floatformat ** half_format = floatformats_ieee_half;
   int float_bit = 4*TARGET_CHAR_BIT;
-  const struct floatformat ** float_format = 0;
+  const struct floatformat ** float_format = floatformats_ieee_single;
   int double_bit = 8*TARGET_CHAR_BIT;
-  const struct floatformat ** double_format = 0;
+  const struct floatformat ** double_format = floatformats_ieee_double;
   int long_double_bit = 8*TARGET_CHAR_BIT;
-  const struct floatformat ** long_double_format = 0;
+  const struct floatformat ** long_double_format = floatformats_ieee_double;
   int wchar_bit = 4*TARGET_CHAR_BIT;
   int wchar_signed = -1;
   gdbarch_floatformat_for_type_ftype *floatformat_for_type = default_floatformat_for_type;
@@ -151,7 +151,7 @@ struct gdbarch
   gdbarch_single_step_through_delay_ftype *single_step_through_delay = nullptr;
   gdbarch_print_insn_ftype *print_insn = default_print_insn;
   gdbarch_skip_trampoline_code_ftype *skip_trampoline_code = generic_skip_trampoline_code;
-  const struct target_so_ops * so_ops = 0;
+  const struct target_so_ops * so_ops = &solib_target_so_ops;
   gdbarch_skip_solib_resolver_ftype *skip_solib_resolver = generic_skip_solib_resolver;
   gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline = generic_in_solib_return_trampoline;
   gdbarch_in_indirect_branch_thunk_ftype *in_indirect_branch_thunk = default_in_indirect_branch_thunk;
@@ -296,24 +296,14 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of long_bit, invalid_p == 0 */
   /* Skip verify of long_long_bit, invalid_p == 0 */
   /* Skip verify of bfloat16_bit, invalid_p == 0 */
-  if (gdbarch->bfloat16_format == 0)
-    gdbarch->bfloat16_format = floatformats_bfloat16;
   /* Skip verify of bfloat16_format, invalid_p == 0 */
   /* Skip verify of half_bit, invalid_p == 0 */
-  if (gdbarch->half_format == 0)
-    gdbarch->half_format = floatformats_ieee_half;
   /* Skip verify of half_format, invalid_p == 0 */
   /* Skip verify of float_bit, invalid_p == 0 */
-  if (gdbarch->float_format == 0)
-    gdbarch->float_format = floatformats_ieee_single;
   /* Skip verify of float_format, invalid_p == 0 */
   /* Skip verify of double_bit, invalid_p == 0 */
-  if (gdbarch->double_format == 0)
-    gdbarch->double_format = floatformats_ieee_double;
   /* Skip verify of double_format, invalid_p == 0 */
   /* Skip verify of long_double_bit, invalid_p == 0 */
-  if (gdbarch->long_double_format == 0)
-    gdbarch->long_double_format = floatformats_ieee_double;
   /* Skip verify of long_double_format, invalid_p == 0 */
   /* Skip verify of wchar_bit, invalid_p == 0 */
   if (gdbarch->wchar_signed == -1)
@@ -419,8 +409,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of single_step_through_delay, has predicate.  */
   /* Skip verify of print_insn, invalid_p == 0 */
   /* Skip verify of skip_trampoline_code, invalid_p == 0 */
-  if (gdbarch->so_ops == 0)
-    gdbarch->so_ops = &solib_target_so_ops;
   /* Skip verify of so_ops, invalid_p == 0 */
   /* Skip verify of skip_solib_resolver, invalid_p == 0 */
   /* Skip verify of in_solib_return_trampoline, invalid_p == 0 */
diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
index 8576ccfaf2b..2cb700309fd 100644
--- a/gdb/gdbarch_components.py
+++ b/gdb/gdbarch_components.py
@@ -199,7 +199,7 @@ useful).
 Value(
     type="const struct floatformat **",
     name="bfloat16_format",
-    postdefault="floatformats_bfloat16",
+    predefault="floatformats_bfloat16",
     printer="pformat (gdbarch, gdbarch->bfloat16_format)",
 )
 
@@ -213,7 +213,7 @@ Value(
 Value(
     type="const struct floatformat **",
     name="half_format",
-    postdefault="floatformats_ieee_half",
+    predefault="floatformats_ieee_half",
     printer="pformat (gdbarch, gdbarch->half_format)",
 )
 
@@ -227,7 +227,7 @@ Value(
 Value(
     type="const struct floatformat **",
     name="float_format",
-    postdefault="floatformats_ieee_single",
+    predefault="floatformats_ieee_single",
     printer="pformat (gdbarch, gdbarch->float_format)",
 )
 
@@ -241,7 +241,7 @@ Value(
 Value(
     type="const struct floatformat **",
     name="double_format",
-    postdefault="floatformats_ieee_double",
+    predefault="floatformats_ieee_double",
     printer="pformat (gdbarch, gdbarch->double_format)",
 )
 
@@ -255,7 +255,7 @@ Value(
 Value(
     type="const struct floatformat **",
     name="long_double_format",
-    postdefault="floatformats_ieee_double",
+    predefault="floatformats_ieee_double",
     printer="pformat (gdbarch, gdbarch->long_double_format)",
 )
 
@@ -1316,7 +1316,7 @@ Value(
     comment="Vtable of solib operations functions.",
     type="const struct target_so_ops *",
     name="so_ops",
-    postdefault="&solib_target_so_ops",
+    predefault="&solib_target_so_ops",
     printer="host_address_to_string (gdbarch->so_ops)",
 )

                 reply	other threads:[~2023-03-13 22:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230313220120.779113858D1E@sourceware.org \
    --to=aburgess@sourceware.org \
    --cc=gdb-cvs@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).