aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-03-10 15:19:42 +0000
committerAndrew Burgess <aburgess@redhat.com>2023-03-13 21:51:04 +0000
commit350796840f7058bd0bdb4a3be2343014c3704de1 (patch)
tree2926c19ae46d7456294de795e7b274b91dfef2fd /gdb
parent6e2d282d74bfd961e64348199b92beb1cb648f6a (diff)
downloadgdb-350796840f7058bd0bdb4a3be2343014c3704de1.zip
gdb-350796840f7058bd0bdb4a3be2343014c3704de1.tar.gz
gdb-350796840f7058bd0bdb4a3be2343014c3704de1.tar.bz2
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>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdbarch.c24
-rw-r--r--gdb/gdbarch_components.py12
2 files changed, 12 insertions, 24 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index efd111e..064afd7 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 8576ccf..2cb7003 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)",
)