Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 1/2] [gdb] Factor out is_dynamic_type_internal_1
Date: Wed, 11 Mar 2026 12:55:05 +0100	[thread overview]
Message-ID: <20260311115506.3101288-2-tdevries@suse.de> (raw)
In-Reply-To: <20260311115506.3101288-1-tdevries@suse.de>

Simplify is_dynamic_type_internal by factoring out is_dynamic_type_internal_1,
leaving only the handling of the top_level parameter in
is_dynamic_type_internal.
---
 gdb/gdbtypes.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index f3422fe5609..00ef8122978 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1913,15 +1913,10 @@ array_type_has_dynamic_stride (struct type *type)
 /* Worker for is_dynamic_type.  */
 
 static bool
-is_dynamic_type_internal (struct type *type, bool top_level)
+is_dynamic_type_internal_1 (struct type *type)
 {
   type = check_typedef (type);
 
-  /* We only want to recognize references and pointers at the outermost
-     level.  */
-  if (top_level && type->is_pointer_or_reference ())
-    type = check_typedef (type->target_type ());
-
   /* Types that have a dynamic TYPE_DATA_LOCATION are considered
      dynamic, even if the type itself is statically defined.
      From a user's point of view, this may appear counter-intuitive;
@@ -1957,7 +1952,7 @@ is_dynamic_type_internal (struct type *type, bool top_level)
 	   of the range type are static.  It allows us to assume that
 	   the subtype of a static range type is also static.  */
 	return (!has_static_range (type->bounds ())
-		|| is_dynamic_type_internal (type->target_type (), false));
+		|| is_dynamic_type_internal_1 (type->target_type ()));
       }
 
     case TYPE_CODE_STRING:
@@ -1968,10 +1963,10 @@ is_dynamic_type_internal (struct type *type, bool top_level)
 	gdb_assert (type->num_fields () == 1);
 
 	/* The array is dynamic if either the bounds are dynamic...  */
-	if (is_dynamic_type_internal (type->index_type (), false))
+	if (is_dynamic_type_internal_1 (type->index_type ()))
 	  return true;
 	/* ... or the elements it contains have a dynamic contents...  */
-	if (is_dynamic_type_internal (type->target_type (), false))
+	if (is_dynamic_type_internal_1 (type->target_type ()))
 	  return true;
 	/* ... or if it has a dynamic stride...  */
 	if (array_type_has_dynamic_stride (type))
@@ -1992,7 +1987,7 @@ is_dynamic_type_internal (struct type *type, bool top_level)
 	    if (f.is_static ())
 	      continue;
 	    /* If the field has dynamic type, then so does TYPE.  */
-	    if (is_dynamic_type_internal (f.type (), false))
+	    if (is_dynamic_type_internal_1 (f.type ()))
 	      return true;
 	    /* If the field is at a fixed offset, then it is not
 	       dynamic.  */
@@ -2012,6 +2007,22 @@ is_dynamic_type_internal (struct type *type, bool top_level)
   return false;
 }
 
+/* Worker for is_dynamic_type.  If TOP_LEVEL and TYPE is a pointer or a
+   reference to a dynamic type, it is also considered a dynamic type.  */
+
+static bool
+is_dynamic_type_internal (struct type *type, bool top_level)
+{
+  type = check_typedef (type);
+
+  /* We only want to recognize references and pointers at the outermost
+     level.  */
+  if (top_level && type->is_pointer_or_reference ())
+    type = check_typedef (type->target_type ());
+
+  return is_dynamic_type_internal_1 (type);
+}
+
 /* See gdbtypes.h.  */
 
 bool
-- 
2.51.0


  reply	other threads:[~2026-03-11 11:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 11:55 [PATCH v2 0/2] [gdb] Enable ptype /o for some dynamic types Tom de Vries
2026-03-11 11:55 ` Tom de Vries [this message]
2026-03-11 11:55 ` [PATCH v2 2/2] " Tom de Vries
2026-03-25 12:48 ` [PING][PATCH v2 0/2] " Tom de Vries
2026-04-02 15:38 ` [PATCH " Guinevere Larsen
2026-04-03 13:20   ` Tom de Vries

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=20260311115506.3101288-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --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