Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Pedro Alves <pedro@palves.net>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] Use type_instance_flags more throughout
Date: Wed, 26 Aug 2020 11:06:50 +0100	[thread overview]
Message-ID: <20200826100650.GU853475@embecosm.com> (raw)
In-Reply-To: <20200821144523.19451-3-pedro@palves.net>

* Pedro Alves <pedro@palves.net> [2020-08-21 15:45:22 +0100]:

> The next patch in this series will rewrites enum_flags fixing some API
> holes.  That would cause build failures around code using
> type_instance_flags.  Or rather, that should be using it, but wasn't.
> 
> This patch fixes it by using type_instance_flags throughout instead of
> plain integers.
> 
> Note that we can't make the seemingly obvious change to struct
> type::instance_flags:
> 
>  -  unsigned instance_flags : 9;
>  +  ENUM_BITFIELD (type_instance_flag_value) instance_flags : 9;
> 
> Because G++ complains then that 9 bits isn't sufficient for holding
> all values of type_instance_flag_value.
> 
> So the patch adds a cast to TYPE_INSTANCE_FLAGS, and adds a separate
> SET_TYPE_INSTANCE_FLAGS macro.
> 
> gdb/ChangeLog:
> 
> 	* dwarf2/read.c (read_tag_pointer_type): Use type_instance_flags.
> 	* eval.c (fake_method::fake_method): Use SET_TYPE_INSTANCE_FLAGS.
> 	* gdbarch.h, gdbarch.c: Regenerate.
> 	* gdbarch.sh (address_class_type_flags): Use type_instance_flags.
> 	(address_class_name_to_type_flags): Use type_instance_flags and
> 	bool.
> 	* gdbtypes.c (address_space_name_to_int)
> 	(address_space_int_to_name, make_qualified_type): Use
> 	type_instance_flags.
> 	(make_qualified_type): Use type_instance_flags and
> 	SET_TYPE_INSTANCE_FLAGS.
> 	(make_type_with_address_space, make_cv_type, make_vector_type)
> 	(check_typedef): Use type_instance_flags.
> 	(recursive_dump_type): Cast type_instance_flags to unsigned for
> 	printing.
> 	(copy_type_recursive): Use SET_TYPE_INSTANCE_FLAGS.
> 	* gdbtypes.h (TYPE_INSTANCE_FLAGS): Return a type_instance_flags.
> 	(SET_TYPE_INSTANCE_FLAGS): New.
> 	(address_space_name_to_int, address_space_int_to_name)
> 	(make_type_with_address_space): Pass flags using
> 	type_instance_flags instead of int.
> 	* stabsread.c (cleanup_undefined_types_noname): Use
> 	SET_TYPE_INSTANCE_FLAGS.
> 	* type-stack.c (type_stack::follow_types): Use type_instance_flags.

Pedro,

While testing this I found a few issues building with
--enable-targets=all.  The patch below fixes all of the issues I ran
into.  Feel free to merge this with your work of keep it as a separate
patch, whatever works for you.

Thanks,
Andrew

---

commit b6c8d1ca8077fa7ea2d6f6336b2115b3dcf9dfbb
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Wed Aug 26 11:02:22 2020 +0100

    gdb: additional changes to make use of type_instance_flags more
    
    Further updates to make use of type_instance_flags.
    
    gdb/ChangeLog:
    
            * avr-tdep.c (avr_address_class_type_flags): Update return type.
            (avr_address_class_type_flags_to_name): Update argument types.
            (avr_address_class_name_to_type_flags): Update return type and
            argument types.
            * ft32-tdep.c (ft32_address_class_type_flags): Update return type.
            (ft32_address_class_type_flags_to_name): Update argument types.
            (ft32_address_class_name_to_type_flags): Update return type and
            argument types.
            * gdbarch.c: Regenerate.
            * gdbarch.h: Regenerate.
            * gdbarch.sh (address_class_type_flags_to_name): Update argument
            types.
            * s390-tdep.c (s390_address_class_type_flags): Update return type.
            (s390_address_class_type_flags_to_name): Update argument types.
            (s390_address_class_name_to_type_flags): Update return type and
            argument types.

diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 74ab531711e..0148f4e4db2 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1372,7 +1372,7 @@ avr_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
    This method maps DW_AT_address_class attributes to a
    type_instance_flag_value.  */
 
-static int
+static type_instance_flags
 avr_address_class_type_flags (int byte_size, int dwarf2_addr_class)
 {
   /* The value 1 of the DW_AT_address_class attribute corresponds to the
@@ -1389,7 +1389,8 @@ avr_address_class_type_flags (int byte_size, int dwarf2_addr_class)
    Convert a type_instance_flag_value to an address space qualifier.  */
 
 static const char*
-avr_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+avr_address_class_type_flags_to_name (struct gdbarch *gdbarch,
+				      type_instance_flags type_flags)
 {
   if (type_flags & AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH)
     return "flash";
@@ -1401,18 +1402,18 @@ avr_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
 
    Convert an address space qualifier to a type_instance_flag_value.  */
 
-static int
+static bool
 avr_address_class_name_to_type_flags (struct gdbarch *gdbarch,
                                       const char* name,
-                                      int *type_flags_ptr)
+                                      type_instance_flags *type_flags_ptr)
 {
   if (strcmp (name, "flash") == 0)
     {
       *type_flags_ptr = AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH;
-      return 1;
+      return true;
     }
   else
-    return 0;
+    return false;
 }
 
 /* Initialize the gdbarch structure for the AVR's.  */
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 99ef69de770..8ce16c06505 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -341,7 +341,7 @@ ft32_pointer_to_address (struct gdbarch *gdbarch,
    This method maps DW_AT_address_class attributes to a
    type_instance_flag_value.  */
 
-static int
+static type_instance_flags
 ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class)
 {
   /* The value 1 of the DW_AT_address_class attribute corresponds to the
@@ -357,7 +357,8 @@ ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class)
    Convert a type_instance_flag_value to an address space qualifier.  */
 
 static const char*
-ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch,
+				       type_instance_flags type_flags)
 {
   if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
     return "flash";
@@ -369,18 +370,18 @@ ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
 
    Convert an address space qualifier to a type_instance_flag_value.  */
 
-static int
+static bool
 ft32_address_class_name_to_type_flags (struct gdbarch *gdbarch,
 				       const char* name,
-				       int *type_flags_ptr)
+				       type_instance_flags *type_flags_ptr)
 {
   if (strcmp (name, "flash") == 0)
     {
       *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
-      return 1;
+      return true;
     }
   else
-    return 0;
+    return false;
 }
 
 /* Given a return value in `regbuf' with a type `valtype',
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 2be959ecfc9..a3a67020078 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -3526,7 +3526,7 @@ gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch)
 }
 
 const char *
-gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->address_class_type_flags_to_name != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 8a4a384fda9..5ac4f5495c4 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -854,8 +854,8 @@ extern void set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, gdbar
 
 extern int gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch);
 
-typedef const char * (gdbarch_address_class_type_flags_to_name_ftype) (struct gdbarch *gdbarch, int type_flags);
-extern const char * gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags);
+typedef const char * (gdbarch_address_class_type_flags_to_name_ftype) (struct gdbarch *gdbarch, type_instance_flags type_flags);
+extern const char * gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags);
 extern void set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name);
 
 /* Execute vendor-specific DWARF Call Frame Instruction.  OP is the instruction.
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 7e9204119bd..a64afb5a3d2 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -690,7 +690,7 @@ v;int;cannot_step_breakpoint;;;0;0;;0
 # non-steppable watchpoints.
 v;int;have_nonsteppable_watchpoint;;;0;0;;0
 F;type_instance_flags;address_class_type_flags;int byte_size, int dwarf2_addr_class;byte_size, dwarf2_addr_class
-M;const char *;address_class_type_flags_to_name;int type_flags;type_flags
+M;const char *;address_class_type_flags_to_name;type_instance_flags type_flags;type_flags
 # Execute vendor-specific DWARF Call Frame Instruction.  OP is the instruction.
 # FS are passed from the generic execute_cfa_program function.
 m;bool;execute_dwarf_cfa_vendor_op;gdb_byte op, struct dwarf2_frame_state *fs;op, fs;;default_execute_dwarf_cfa_vendor_op;;0
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 65cb23705d2..49a507f7c2d 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1583,7 +1583,7 @@ s390_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 /* Implement addr_class_type_flags gdbarch method.
    Only used for ABI_LINUX_ZSERIES.  */
 
-static int
+static type_instance_flags
 s390_address_class_type_flags (int byte_size, int dwarf2_addr_class)
 {
   if (byte_size == 4)
@@ -1596,7 +1596,8 @@ s390_address_class_type_flags (int byte_size, int dwarf2_addr_class)
    Only used for ABI_LINUX_ZSERIES.  */
 
 static const char *
-s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+s390_address_class_type_flags_to_name (struct gdbarch *gdbarch,
+				       type_instance_flags type_flags)
 {
   if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
     return "mode32";
@@ -1607,18 +1608,18 @@ s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
 /* Implement addr_class_name_to_type_flags gdbarch method.
    Only used for ABI_LINUX_ZSERIES.  */
 
-static int
+static bool
 s390_address_class_name_to_type_flags (struct gdbarch *gdbarch,
 				       const char *name,
-				       int *type_flags_ptr)
+				       type_instance_flags *type_flags_ptr)
 {
   if (strcmp (name, "mode32") == 0)
     {
       *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
-      return 1;
+      return true;
     }
   else
-    return 0;
+    return false;
 }
 
 /* Inferior function calls.  */


  parent reply	other threads:[~2020-08-26 10:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 14:45 [PATCH 0/3] Rewrite enum_flags, add unit tests, fix problems Pedro Alves
2020-08-21 14:45 ` [PATCH 1/3] Rewrite valid-expr.h's internals in terms of the detection idiom (C++17/N4502) Pedro Alves
2020-09-28 18:59   ` Tom Tromey
2020-09-28 19:58     ` Luis Machado via Gdb-patches
2020-09-28 20:00       ` Tom Tromey
2020-09-29 13:04         ` Tom Tromey
2020-09-29 19:24           ` Pedro Alves
2020-09-29 22:50             ` [pushed] Tweak gdbsupport/valid-expr.h for GCC 6, fix build (Re: [PATCH 1/3] Rewrite valid-expr.h's internals in terms of the detection idiom (C++17/N4502)) Pedro Alves
2020-08-21 14:45 ` [PATCH 2/3] Use type_instance_flags more throughout Pedro Alves
2020-08-25 11:36   ` Luis Machado
2020-09-14 11:56     ` Pedro Alves
2020-08-26 10:06   ` Andrew Burgess [this message]
2020-09-14 12:54     ` Pedro Alves
2020-08-26 15:21   ` Andrew Burgess
2020-09-14 13:53     ` Pedro Alves
2020-09-11 20:21   ` Tom Tromey
2020-09-14 19:26     ` Pedro Alves
2020-08-21 14:45 ` [PATCH 3/3] Rewrite enum_flags, add unit tests, fix problems Pedro Alves
2020-08-21 15:51 ` [PATCH 0/3] " Andrew Burgess
2020-09-11 20:26   ` Tom Tromey

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=20200826100650.GU853475@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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