[PATCH 07/12] gdb: remove TYPE_FIELD_LOC_KIND

Simon Marchi simon.marchi@efficios.com
Thu Oct 21 17:23:50 GMT 2021


From: Simon Marchi <simon.marchi@polymtl.ca>

Remove TYPE_FIELD_LOC_KIND, replace its uses with type::field +
field::loc_kind.

Change-Id: Ib124a26365df82ac1d23df7962d954192913bd90
---
 gdb/ax-gdb.c                      |  2 +-
 gdb/compile/compile-cplus-types.c |  4 ++--
 gdb/dwarf2/read.c                 |  4 ++--
 gdb/gdbtypes.c                    | 15 ++++++++-------
 gdb/gdbtypes.h                    |  1 -
 gdb/gnu-v3-abi.c                  |  2 +-
 gdb/python/py-type.c              |  2 +-
 gdb/riscv-tdep.c                  |  2 +-
 gdb/valops.c                      |  2 +-
 gdb/value.c                       |  2 +-
 10 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index e07ee3ab696..29d1bab8114 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1438,7 +1438,7 @@ static void
 gen_static_field (struct agent_expr *ax, struct axs_value *value,
 		  struct type *type, int fieldno)
 {
-  if (TYPE_FIELD_LOC_KIND (type, fieldno) == FIELD_LOC_KIND_PHYSADDR)
+  if (type->field (fieldno).loc_kind () == FIELD_LOC_KIND_PHYSADDR)
     {
       ax_const_l (ax, TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
       value->kind = axs_lvalue_memory;
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 8871de17f78..ef73aaabf0f 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -599,7 +599,7 @@ compile_cplus_convert_struct_or_union_members
 	{
 	  CORE_ADDR physaddr;
 
-	  switch (TYPE_FIELD_LOC_KIND (type, i))
+	  switch (type->field (i).loc_kind ())
 	    {
 	    case FIELD_LOC_KIND_PHYSADDR:
 	      {
@@ -939,7 +939,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
       gdb::unique_xmalloc_ptr<char> fname
 	= compile_cplus_instance::decl_name (type->field (i).name ());
 
-      if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL
+      if (type->field (i).loc_kind () != FIELD_LOC_KIND_ENUMVAL
 	  || fname == nullptr)
 	continue;
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a9f9ffcce6d..dc5cfbbccd2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9065,7 +9065,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 	  name = tail;
 	  if (*name != '$'
 	      || index >= field_type->num_fields ()
-	      || (TYPE_FIELD_LOC_KIND (field_type, index)
+	      || (field_type->field (index).loc_kind ()
 		  != FIELD_LOC_KIND_BITPOS))
 	    {
 	      complaint (_("Could not parse Rust enum encoding string \"%s\""
@@ -9197,7 +9197,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
       std::unordered_map<std::string, ULONGEST> discriminant_map;
       for (int i = 0; i < enum_type->num_fields (); ++i)
 	{
-	  if (TYPE_FIELD_LOC_KIND (enum_type, i) == FIELD_LOC_KIND_ENUMVAL)
+	  if (enum_type->field (i).loc_kind () == FIELD_LOC_KIND_ENUMVAL)
 	    {
 	      const char *name
 		= rust_last_path_segment (enum_type->field (i).name ());
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index c58deeab885..9f03dbf246d 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2154,7 +2154,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
 	      return 1;
 	    /* If the field is at a fixed offset, then it is not
 	       dynamic.  */
-	    if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_DWARF_BLOCK)
+	    if (type->field (i).loc_kind () != FIELD_LOC_KIND_DWARF_BLOCK)
 	      continue;
 	    /* Do not consider C++ virtual base types to be dynamic
 	       due to the field's offset being dynamic; these are
@@ -2454,7 +2454,7 @@ compute_variant_fields_inner (struct type *type,
     {
       int idx = part.discriminant_index;
 
-      if (TYPE_FIELD_LOC_KIND (type, idx) != FIELD_LOC_KIND_BITPOS)
+      if (type->field (idx).loc_kind () != FIELD_LOC_KIND_BITPOS)
 	error (_("Cannot determine struct field location"
 		 " (invalid location kind)"));
 
@@ -2586,7 +2586,7 @@ resolve_dynamic_struct (struct type *type,
       if (field_is_static (&resolved_type->field (i)))
 	continue;
 
-      if (TYPE_FIELD_LOC_KIND (resolved_type, i) == FIELD_LOC_KIND_DWARF_BLOCK)
+      if (resolved_type->field (i).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
 	{
 	  struct dwarf2_property_baton baton;
 	  baton.property_type
@@ -2610,7 +2610,7 @@ resolve_dynamic_struct (struct type *type,
 	 that verification indicates a bug in our code, the error
 	 is not severe enough to suggest to the user he stops
 	 his debugging session because of it.  */
-      if (TYPE_FIELD_LOC_KIND (resolved_type, i) != FIELD_LOC_KIND_BITPOS)
+      if (resolved_type->field (i).loc_kind () != FIELD_LOC_KIND_BITPOS)
 	error (_("Cannot determine struct field location"
 		 " (invalid location kind)"));
 
@@ -2625,7 +2625,7 @@ resolve_dynamic_struct (struct type *type,
       resolved_type->field (i).set_type
 	(resolve_dynamic_type_internal (resolved_type->field (i).type (),
 					&pinfo, 0));
-      gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
+      gdb_assert (resolved_type->field (i).loc_kind ()
 		  == FIELD_LOC_KIND_BITPOS);
 
       new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i);
@@ -5558,7 +5558,8 @@ copy_type_recursive (struct objfile *objfile,
 				    copied_types));
 	  if (type->field (i).name ())
 	    new_type->field (i).set_name (xstrdup (type->field (i).name ()));
-	  switch (TYPE_FIELD_LOC_KIND (type, i))
+
+	  switch (type->field (i).loc_kind ())
 	    {
 	    case FIELD_LOC_KIND_BITPOS:
 	      new_type->field (i).set_loc_bitpos (TYPE_FIELD_BITPOS (type, i));
@@ -5581,7 +5582,7 @@ copy_type_recursive (struct objfile *objfile,
 	    default:
 	      internal_error (__FILE__, __LINE__,
 			      _("Unexpected type field location kind: %d"),
-			      TYPE_FIELD_LOC_KIND (type, i));
+			      type->field (i).loc_kind ());
 	    }
 	}
     }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2e11e8c21b0..78aff4510e9 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2128,7 +2128,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
 
-#define TYPE_FIELD_LOC_KIND(thistype, n) ((thistype)->field (n).loc_kind ())
 #define TYPE_FIELD_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
 #define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index b82ac59fb79..22b401567e3 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -464,7 +464,7 @@ gnuv3_baseclass_offset (struct type *type, int index,
     return TYPE_BASECLASS_BITPOS (type, index) / 8;
 
   /* If we have a DWARF expression for the offset, evaluate it.  */
-  if (TYPE_FIELD_LOC_KIND (type, index) == FIELD_LOC_KIND_DWARF_BLOCK)
+  if (type->field (index).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
     {
       struct dwarf2_property_baton baton;
       baton.property_type
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index f0f83579323..7980bec1c90 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -189,7 +189,7 @@ convert_field (struct type *type, int field)
 	}
       else
 	{
-	  if (TYPE_FIELD_LOC_KIND (type, field) == FIELD_LOC_KIND_DWARF_BLOCK)
+	  if (type->field (field).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
 	    arg = gdbpy_ref<>::new_reference (Py_None);
 	  else
 	    arg = gdb_py_object_from_longest (TYPE_FIELD_BITPOS (type, field));
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 4be89022437..01fb156f5f8 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -2542,7 +2542,7 @@ riscv_struct_info::analyse_inner (struct type *type, int offset)
 
   for (i = 0; i < count; ++i)
     {
-      if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_BITPOS)
+      if (type->field (i).loc_kind () != FIELD_LOC_KIND_BITPOS)
 	continue;
 
       struct type *field_type = type->field (i).type ();
diff --git a/gdb/valops.c b/gdb/valops.c
index f65479b8117..4f26f72b0db 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3329,7 +3329,7 @@ enum_constant_from_type (struct type *type, const char *name)
       const char *fname = type->field (i).name ();
       int len;
 
-      if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL
+      if (type->field (i).loc_kind () != FIELD_LOC_KIND_ENUMVAL
 	  || fname == NULL)
 	continue;
 
diff --git a/gdb/value.c b/gdb/value.c
index bb2adae0a51..650973de63a 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2941,7 +2941,7 @@ value_static_field (struct type *type, int fieldno)
 {
   struct value *retval;
 
-  switch (TYPE_FIELD_LOC_KIND (type, fieldno))
+  switch (type->field (fieldno).loc_kind ())
     {
     case FIELD_LOC_KIND_PHYSADDR:
       retval = value_at_lazy (type->field (fieldno).type (),
-- 
2.33.0



More information about the Gdb-patches mailing list