public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 7/7] gdb: remove TYPE_FIELD_PACKED
Date: Thu, 31 Aug 2023 11:46:28 -0400	[thread overview]
Message-ID: <20230831154727.1240363-8-simon.marchi@efficios.com> (raw)
In-Reply-To: <20230831154727.1240363-1-simon.marchi@efficios.com>

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

Replace with a new equivalent "is_packed" method on struct field.

Change-Id: I78647be3d408b40b63becb6b6f0fca211bede51c
---
 gdb/ada-valprint.c | 2 +-
 gdb/amd64-tdep.c   | 2 +-
 gdb/ax-gdb.c       | 4 ++--
 gdb/c-typeprint.c  | 2 +-
 gdb/cp-valprint.c  | 2 +-
 gdb/gdbtypes.h     | 7 +++++--
 gdb/m2-typeprint.c | 2 +-
 gdb/p-typeprint.c  | 2 +-
 gdb/p-valprint.c   | 2 +-
 gdb/typeprint.c    | 2 +-
 gdb/valops.c       | 2 +-
 11 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 9a1f3d6c9ffe..eaeca0f65161 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -615,7 +615,7 @@ print_field_values (struct value *value, struct value *outer_value,
       gdb_puts (" => ", stream);
       annotate_field_value ();
 
-      if (TYPE_FIELD_PACKED (type, i))
+      if (type->field (i).is_packed ())
 	{
 	  /* Bitfields require special handling, especially due to byte
 	     order problems.  */
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index affb775fb7e2..e6feee677b3d 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -560,7 +560,7 @@ amd64_has_unaligned_fields (struct type *type)
 	  if (type->field (i).is_static ()
 	      || (type->field (i).bitsize () == 0
 		  && subtype->length () == 0)
-	      || TYPE_FIELD_PACKED (type, i))
+	      || type->field (i).is_packed ())
 	    continue;
 
 	  int bitpos = type->field (i).loc_bitpos ();
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 068796aa9bcd..a679c8649150 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1317,7 +1317,7 @@ gen_primitive_field (struct agent_expr *ax, struct axs_value *value,
 		     int offset, int fieldno, struct type *type)
 {
   /* Is this a bitfield?  */
-  if (TYPE_FIELD_PACKED (type, fieldno))
+  if (type->field (fieldno).is_packed ())
     gen_bitfield_ref (ax, value, type->field (fieldno).type (),
 		      (offset * TARGET_CHAR_BIT
 		       + type->field (fieldno).loc_bitpos ()),
@@ -1502,7 +1502,7 @@ gen_struct_elt_for_reference (struct agent_expr *ax, struct axs_value *value,
 		       fieldname);
 	      return 1;
 	    }
-	  if (TYPE_FIELD_PACKED (t, i))
+	  if (t->field (i).is_packed ())
 	    error (_("pointers to bitfield members not allowed"));
 
 	  /* FIXME we need a way to do "want_address" equivalent */	  
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 708250c4801d..e141a62311ca 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1154,7 +1154,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 			  stream, newshow, level + 4,
 			  language, &local_flags, &local_podata);
 
-	  if (!is_static && TYPE_FIELD_PACKED (type, i))
+	  if (!is_static && type->field (i).is_packed ())
 	    {
 	      /* It is a bitfield.  This code does not attempt
 		 to look at the bitpos and reconstruct filler,
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index c73764eb5290..820a761054a8 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -259,7 +259,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	  annotate_field_value ();
 
 	  if (!type->field (i).is_static ()
-	      && TYPE_FIELD_PACKED (type, i))
+	      && type->field (i).is_packed ())
 	    {
 	      struct value *v;
 
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index d2edca51caff..f45a957f3443 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -584,6 +584,11 @@ struct field
     m_bitsize = bitsize;
   }
 
+  bool is_packed () const
+  {
+    return m_bitsize != 0;
+  }
+
   /* Return true if this field is static; false if not.  */
   bool is_static () const
   {
@@ -1933,8 +1938,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
 
-#define TYPE_FIELD_PACKED(thistype, n) (((thistype)->field (n).bitsize ())!=0)
-
 #define TYPE_FIELD_PRIVATE_BITS(thistype) \
   TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
 #define TYPE_FIELD_PROTECTED_BITS(thistype) \
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index 552c1219dbfc..9a4cb8d6b558 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -570,7 +570,7 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
 	  m2_print_type (type->field (i).type (),
 			 "",
 			 stream, 0, level + 4, flags);
-	  if (TYPE_FIELD_PACKED (type, i))
+	  if (type->field (i).is_packed ())
 	    {
 	      /* It is a bitfield.  This code does not attempt
 		 to look at the bitpos and reconstruct filler,
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 356a3a8d2355..54ff96612202 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -522,7 +522,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
 				 type->field (i).name (),
 				 stream, show - 1, level + 4, flags);
 	      if (!type->field (i).is_static ()
-		  && TYPE_FIELD_PACKED (type, i))
+		  && type->field (i).is_packed ())
 		{
 		  /* It is a bitfield.  This code does not attempt
 		     to look at the bitpos and reconstruct filler,
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index b32c0f17c6b2..fb9386293a6f 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -598,7 +598,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 	  annotate_field_value ();
 
 	  if (!type->field (i).is_static ()
-	      && TYPE_FIELD_PACKED (type, i))
+	      && type->field (i).is_packed ())
 	    {
 	      struct value *v;
 
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 4a282cbaaa29..259ff132142b 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -149,7 +149,7 @@ print_offset_data::update (struct type *type, unsigned int field_idx,
 
   maybe_print_hole (stream, bitpos, "hole");
 
-  if (TYPE_FIELD_PACKED (type, field_idx)
+  if (type->field (field_idx).is_packed ()
       || offset_bitpos % TARGET_CHAR_BIT != 0)
     {
       /* We're dealing with a bitfield.  Print the bit offset.  */
diff --git a/gdb/valops.c b/gdb/valops.c
index b007fe08d348..70851cd40b4f 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3581,7 +3581,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 		v = value_addr (v);
 	      return v;
 	    }
-	  if (TYPE_FIELD_PACKED (t, i))
+	  if (t->field (i).is_packed ())
 	    error (_("pointers to bitfield members not allowed"));
 
 	  if (want_address)
-- 
2.42.0


  parent reply	other threads:[~2023-08-31 15:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 15:46 [PATCH 0/7] Remove some more TYPE/FIELD macros Simon Marchi
2023-08-31 15:46 ` [PATCH 1/7] gdb: introduce field::is_artificial / field::set_is_artificial Simon Marchi
2023-08-31 15:46 ` [PATCH 2/7] gdb: remove FIELD_ARTIFICIAL Simon Marchi
2023-08-31 15:46 ` [PATCH 3/7] gdb: remove TYPE_FIELD_ARTIFICIAL Simon Marchi
2023-08-31 15:46 ` [PATCH 4/7] gdb: introduce field::bitsize / field::set_bitsize Simon Marchi
2023-08-31 15:46 ` [PATCH 5/7] gdb: remove FIELD_BITSIZE Simon Marchi
2023-08-31 15:46 ` [PATCH 6/7] gdb: remove TYPE_FIELD_BITSIZE Simon Marchi
2023-08-31 15:46 ` Simon Marchi [this message]
2023-08-31 17:05 ` [PATCH 0/7] Remove some more TYPE/FIELD macros Tom Tromey
2023-08-31 17:16   ` Simon Marchi

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=20230831154727.1240363-8-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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).