aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
authorPeter Schauer <Peter.Schauer@mytum.de>1995-08-19 08:21:23 +0000
committerPeter Schauer <Peter.Schauer@mytum.de>1995-08-19 08:21:23 +0000
commit2447e9afab92a5700ccc6e4d90d3cef8f082c009 (patch)
treed30f9bf584acd3798691b812be0539d87e308055 /gdb/gdbtypes.c
parent69c626a9aaac3f4e435a1c514b8e05615a43fd40 (diff)
downloadgdb-2447e9afab92a5700ccc6e4d90d3cef8f082c009.zip
gdb-2447e9afab92a5700ccc6e4d90d3cef8f082c009.tar.gz
gdb-2447e9afab92a5700ccc6e4d90d3cef8f082c009.tar.bz2
* gdbtypes.c (recursive_dump_type): Add dont_print_type_obstack
to inhibit infinite recursion when printing aggregate types.
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 0fc4ec3..de3de3e 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -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 */