From db558e34b065552e67646879bd70867318a8ff5b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 14 Sep 2020 11:08:07 -0400 Subject: [PATCH] gdb: add type::endianity_is_not_default / type::set_endianity_is_not_default Add the `endianity_is_not_default` and `set_endianity_is_not_default` methods on `struct type`, in order to remove the `TYPE_ENDIANITY_NOT_DEFAULT` macro. In this patch, the macro is changed to use the getter, so all the call sites of the macro that are used as a setter are changed to use the setter method directly. The next patch will remove the macro completely. gdb/ChangeLog: * gdbtypes.h (struct type) : New methods. (TYPE_ENDIANITY_NOT_DEFAULT): Use type::endianity_is_not_default, change all write call sites to use type::set_endianity_is_not_default. Change-Id: I67acd68fcdae424d7e4a601afda78612ad5d92db --- gdb/ChangeLog | 8 ++++++++ gdb/dwarf2/read.c | 2 +- gdb/gdbtypes.c | 4 ++-- gdb/gdbtypes.h | 14 ++++++++++++-- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 78f8e7ad019..9d7661d1850 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2020-09-14 Simon Marchi + + * gdbtypes.h (struct type) : New methods. + (TYPE_ENDIANITY_NOT_DEFAULT): Use + type::endianity_is_not_default, change all write call sites to + use type::set_endianity_is_not_default. + 2020-09-14 Simon Marchi * gdbtypes.h (TYPE_FIXED_INSTANCE): Remove, replace all diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 410e4c8c677..0644a2d5f95 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -18063,7 +18063,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) maybe_set_alignment (cu, die, type); - TYPE_ENDIANITY_NOT_DEFAULT (type) = gdbarch_byte_order (arch) != byte_order; + type->set_endianity_is_not_default (gdbarch_byte_order (arch) != byte_order); return set_die_type (die, type, cu); } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 5ca4b880e22..ed548dd6bce 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -958,8 +958,8 @@ create_range_type (struct type *result_type, struct type *index_type, if (high_bound->kind () == PROP_CONST && high_bound->const_val () < 0) result_type->set_is_unsigned (false); - TYPE_ENDIANITY_NOT_DEFAULT (result_type) - = TYPE_ENDIANITY_NOT_DEFAULT (index_type); + result_type->set_endianity_is_not_default + (index_type->endianity_is_not_default ()); return result_type; } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index dcb691468d8..beff6a7466e 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -214,7 +214,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); that indicates the desired endian interpretation of the variable differs from the native endian representation. */ -#define TYPE_ENDIANITY_NOT_DEFAULT(t) (TYPE_MAIN_TYPE (t)->flag_endianity_not_default) +#define TYPE_ENDIANITY_NOT_DEFAULT(t) ((t)->endianity_is_not_default ()) /* * Not textual. By default, GDB treats all single byte integers as characters (or elements of strings) unless this flag is set. */ @@ -798,7 +798,7 @@ struct main_type unsigned int m_flag_gnu_ifunc : 1; unsigned int m_flag_fixed_instance : 1; unsigned int flag_objfile_owned : 1; - unsigned int flag_endianity_not_default : 1; + unsigned int m_flag_endianity_not_default : 1; /* * True if this type was declared with "class" rather than "struct". */ @@ -1149,6 +1149,16 @@ struct type this->main_type->m_flag_fixed_instance = is_fixed_instance; } + bool endianity_is_not_default () const + { + return this->main_type->m_flag_endianity_not_default; + } + + void set_endianity_is_not_default (bool endianity_is_not_default) + { + this->main_type->m_flag_endianity_not_default = endianity_is_not_default; + } + /* * Return the dynamic property of the requested KIND from this type's list of dynamic properties. */ dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const; -- 2.30.2