public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/8] Introduce TYPE_SPECIFIC_RUST_STUFF
Date: Tue, 22 Aug 2023 09:25:09 -0600	[thread overview]
Message-ID: <20230822-array-and-string-like-v1-3-2dcea29b0567@adacore.com> (raw)
In-Reply-To: <20230822-array-and-string-like-v1-0-2dcea29b0567@adacore.com>

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.
---
 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 f1d7bfdfdec..c9f0a18feb5 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12689,7 +12689,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 d7db7beb554..082d85bb4fc 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5403,6 +5403,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
@@ -5645,6 +5649,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 aedaf53cd5d..389cd6c5757 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,
@@ -831,7 +832,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.  */
@@ -1800,6 +1801,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 *)      \

-- 
2.40.1


  parent reply	other threads:[~2023-08-22 15:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-22 15:25 [PATCH 0/8] Handle array- and string-like types in DAP Tom Tromey
2023-08-22 15:25 ` [PATCH 1/8] Move rust_language::lookup_symbol_nonlocal Tom Tromey
2023-08-22 15:25 ` [PATCH 2/8] Refactor Rust code for slice-to-array operation Tom Tromey
2023-08-22 15:25 ` Tom Tromey [this message]
2023-08-22 15:25 ` [PATCH 4/8] Use ada_value_subscript in valpy_getitem Tom Tromey
2023-08-22 15:25 ` [PATCH 5/8] Introduce type::is_array_like and value_to_array Tom Tromey
2023-08-22 15:25 ` [PATCH 6/8] Select frame when fetching a frame variable in DAP Tom Tromey
2023-08-22 15:25 ` [PATCH 7/8] Add new Python APIs to support DAP value display Tom Tromey
2023-08-22 15:46   ` Eli Zaretskii
2023-08-22 15:25 ` [PATCH 8/8] Handle array- and string-like values in no-op pretty printers Tom Tromey
2023-09-05 17:22 ` [PATCH 0/8] Handle array- and string-like types in DAP 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=20230822-array-and-string-like-v1-3-2dcea29b0567@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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).