aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-08-04 13:39:46 -0600
committerTom Tromey <tromey@adacore.com>2023-09-05 11:02:34 -0600
commitdec28322cf6db3b2e65bb833ba825bdfc90a3bb1 (patch)
tree83fde1248fee247c40822a8029d545eaf8bfeb0d
parent49ed499c44d9368d2b954697f362452d1447eecf (diff)
downloadgdb-dec28322cf6db3b2e65bb833ba825bdfc90a3bb1.zip
gdb-dec28322cf6db3b2e65bb833ba825bdfc90a3bb1.tar.gz
gdb-dec28322cf6db3b2e65bb833ba825bdfc90a3bb1.tar.bz2
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.
-rw-r--r--gdb/dwarf2/read.c9
-rw-r--r--gdb/gdbtypes.c7
-rw-r--r--gdb/gdbtypes.h11
3 files changed, 25 insertions, 2 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index ef7f570..98bedbc 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 5e15ec6..6b2adc8 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 f45a957..4668fba 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 *) \