* gdbtypes.c (recursive_dump_type): Add dont_print_type_obstack
authorPeter Schauer <Peter.Schauer@mytum.de>
Sat, 19 Aug 1995 08:21:23 +0000 (08:21 +0000)
committerPeter Schauer <Peter.Schauer@mytum.de>
Sat, 19 Aug 1995 08:21:23 +0000 (08:21 +0000)
to inhibit infinite recursion when printing aggregate types.

gdb/ChangeLog
gdb/gdbtypes.c

index 86529b9b55154fca7c0c415f93e9f20df1c695ab..6ced58219189d9aaf11bbbea4c0a0e04f6c53362 100644 (file)
@@ -1,3 +1,8 @@
+Sat Aug 19 01:19:34 1995  Peter Schauer  (pes@regent.e-technik.tu-muenchen.de)
+
+       * gdbtypes.c (recursive_dump_type):  Add dont_print_type_obstack
+       to inhibit infinite recursion when printing aggregate types.
+
 Fri Aug 18 17:48:55 1995  steve chamberlain  <sac@slash.cygnus.com>
 
        * dcache.c (dcache_write_line): Write dirty lines right.
index 0fc4ec3558c6eb4a6bbd7c55ae20a3683ae4b04a..de3de3e6a196caf0acf24f8e5922af96ce62667c 100644 (file)
@@ -1,5 +1,5 @@
 /* Support routines for manipulating internal types for GDB.
-   Copyright (C) 1992 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
 This file is part of GDB.
@@ -1335,6 +1335,8 @@ print_cplus_stuff (type, spaces)
     }
 }
 
+static struct obstack dont_print_type_obstack;
+
 void
 recursive_dump_type (type, spaces)
      struct type *type;
@@ -1342,6 +1344,32 @@ recursive_dump_type (type, spaces)
 {
   int idx;
 
+  if (spaces == 0)
+    obstack_begin (&dont_print_type_obstack, 0);
+
+  if (TYPE_NFIELDS (type) > 0
+      || (TYPE_CPLUS_SPECIFIC (type) && TYPE_NFN_FIELDS (type) > 0))
+    {
+      struct type **first_dont_print
+       = (struct type **)obstack_base (&dont_print_type_obstack);
+
+      int i = (struct type **)obstack_next_free (&dont_print_type_obstack)
+       - first_dont_print;
+
+      while (--i >= 0)
+       {
+         if (type == first_dont_print[i])
+           {
+             printfi_filtered (spaces, "type node ");
+             gdb_print_address (type, gdb_stdout);
+             printf_filtered (" <same as already seen type>\n");
+             return;
+           }
+       }
+
+      obstack_ptr_grow (&dont_print_type_obstack, type);
+    }
+
   printfi_filtered (spaces, "type node ");
   gdb_print_address (type, gdb_stdout);
   printf_filtered ("\n");
@@ -1508,6 +1536,8 @@ recursive_dump_type (type, spaces)
        break;
 
     }
+  if (spaces == 0)
+    obstack_free (&dont_print_type_obstack, NULL);
 }
 
 #endif /* MAINTENANCE_CMDS */
This page took 0.030065 seconds and 4 git commands to generate.