This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/2] fixed infinite recursion when printing rec. nested Fortran data types


From: Frank Penczek <frank.penczek@intel.com>

The name of a user-defined data type in Fortran is stored as
"tag_name" in the "main_type" struct. When printing out type
information via "f_type_print_base" the "show" argument passed to the
recursive call of "f_type_print_base" is correctly set 0 when
following a pointer, however, the check at the beginning of the
function only checks if "type_name" is non-NULL: in the case of a
user- defined data-type the name is stored as "tag_name" with a NULL
"type_name", which causes the check to fail. The consequence is an
infinite recursion when printing a recursively nested user-defined
type. Fixed by extending the check to also inspect "tag_name".

2013-08-05  Frank Penczek  <frank.penczek@intel.com>

	* f-typeprint.c (f_type_print_base): Include TYPE_TAG_NAME in
	  conditional that ends recursive descend.

Signed-off-by: Frank Penczek <frank.penczek@intel.com>
Change-Id: I39a003a3372093434eedc53bfd8cb16d399010b9
---
 gdb/f-typeprint.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 71fe869..3be5911 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -266,13 +266,22 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
       return;
     }
 
-  /* When SHOW is zero or less, and there is a valid type name, then always
-     just print the type name directly from the type.  */
+  /* If SHOW is zero or less, and there is a valid type name or tag name
+     (tags hold names of user-defined types), then always just print the name
+     directly without any further recursive application of this function.  */
 
-  if ((show <= 0) && (TYPE_NAME (type) != NULL))
+  if (show <= 0)
     {
-      fputs_filtered (TYPE_NAME (type), stream);
-      return;
+      const char *name_to_print = TYPE_NAME (type);
+
+      if (name_to_print == NULL)
+          name_to_print = TYPE_TAG_NAME (type);
+
+      if (name_to_print != NULL)
+        {
+          fputs_filtered (name_to_print, stream);
+          return;
+        }
     }
 
   if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
-- 
1.7.0.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]