[binutils-gdb] Introduce TYPE_SPECIFIC_RUST_STUFF

Tom Tromey tromey@sourceware.org
Tue Sep 5 17:28:17 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dec28322cf6db3b2e65bb833ba825bdfc90a3bb1

commit dec28322cf6db3b2e65bb833ba825bdfc90a3bb1
Author: Tom Tromey <tromey@adacore.com>
Date:   Fri Aug 4 13:39:46 2023 -0600

    Introduce TYPE_SPECIFIC_RUST_STUFF
    
    This adds a new enum constant, TYPE_SPECIFIC_RUST_STUFF, and changes
    the DWARF reader to set this on Rust types.  This will be used as a
    flag in a later patch.
    
    Note that the size of the type_specific_field bitfield had to be
    increased.  I checked that this did not impact the size of main_type.

Diff:
---
 gdb/dwarf2/read.c |  9 ++++++++-
 gdb/gdbtypes.c    |  7 +++++++
 gdb/gdbtypes.h    | 11 ++++++++++-
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index ef7f5708213..98bedbc5d49 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12681,7 +12681,14 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
     }
 
   type = type_allocator (objfile).new_type ();
-  INIT_CPLUS_SPECIFIC (type);
+  if (cu->lang () == language_rust)
+    {
+      /* This is currently only needed for types that might be
+	 slices.  */
+      INIT_RUST_SPECIFIC (type);
+    }
+  else
+    INIT_CPLUS_SPECIFIC (type);
 
   name = dwarf2_name (die, cu);
   if (name != NULL)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 5e15ec64c41..6b2adc8fe8c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5383,6 +5383,10 @@ recursive_dump_type (struct type *type, int spaces)
       print_gnat_stuff (type, spaces);
       break;
 
+    case TYPE_SPECIFIC_RUST_STUFF:
+      gdb_printf ("%*srust\n", spaces, "");
+      break;
+
     case TYPE_SPECIFIC_FLOATFORMAT:
       gdb_printf ("%*sfloatformat ", spaces, "");
       if (TYPE_FLOATFORMAT (type) == NULL
@@ -5623,6 +5627,9 @@ copy_type_recursive (struct type *type, htab_t copied_types)
     case TYPE_SPECIFIC_GNAT_STUFF:
       INIT_GNAT_SPECIFIC (new_type);
       break;
+    case TYPE_SPECIFIC_RUST_STUFF:
+      INIT_RUST_SPECIFIC (new_type);
+      break;
     case TYPE_SPECIFIC_SELF_TYPE:
       set_type_self_type (new_type,
 			  copy_type_recursive (TYPE_SELF_TYPE (type),
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index f45a957f344..4668fba59c7 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -501,6 +501,7 @@ enum type_specific_kind
   TYPE_SPECIFIC_NONE,
   TYPE_SPECIFIC_CPLUS_STUFF,
   TYPE_SPECIFIC_GNAT_STUFF,
+  TYPE_SPECIFIC_RUST_STUFF,
   TYPE_SPECIFIC_FLOATFORMAT,
   /* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD.  */
   TYPE_SPECIFIC_FUNC,
@@ -856,7 +857,7 @@ struct main_type
   /* * A discriminant telling us which field of the type_specific
      union is being used for this type, if any.  */
 
-  ENUM_BITFIELD(type_specific_kind) type_specific_field : 3;
+  ENUM_BITFIELD(type_specific_kind) type_specific_field : 4;
 
   /* * Number of fields described for this type.  This field appears
      at this location because it packs nicely here.  */
@@ -1833,6 +1834,14 @@ extern void allocate_gnat_aux_type (struct type *);
     || (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE	\
 	&& (type)->is_fixed_instance ()))
 
+/* Currently there isn't any associated data -- this is just a
+   marker.  */
+#define INIT_RUST_SPECIFIC(type) \
+  TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_RUST_STUFF
+
+#define HAVE_RUST_SPECIFIC(type) \
+  (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_RUST_STUFF)
+
 #define INIT_FUNC_SPECIFIC(type)					       \
   (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC,			       \
    TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *)      \


More information about the Gdb-cvs mailing list