* symfile.c (decrement_reading_symtab): New function.
authorPer Bothner <per@bothner.com>
Fri, 12 Jan 1996 07:16:20 +0000 (07:16 +0000)
committerPer Bothner <per@bothner.com>
Fri, 12 Jan 1996 07:16:20 +0000 (07:16 +0000)
* symfile.c, symtab.h (currently_reading_symtab):  New variable.
* symfile.c (psymtab_to_symtab):  Adjust currently_reading_symtab.
* gdbtypes.c (check_typedef):  Don't call lookup_symbol if
currently_reading_symtab (since that could infinitely recurse).
This fixes PR chill/8793.

gdb/ChangeLog
gdb/gdbtypes.c
gdb/symfile.c

index 99a3767d6a6caac6e0f210391651e851bd8998b3..83a9f26e98c03eb73012eb4265acbbaa4c871390 100644 (file)
@@ -1,3 +1,11 @@
+Thu Jan 11 23:13:24 1996  Per Bothner  <bothner@cygnus.com>
+
+       * symfile.c (decrement_reading_symtab):  New function.
+       * symfile.c, symtab.h (currently_reading_symtab):  New variable.
+       * symfile.c (psymtab_to_symtab):  Adjust currently_reading_symtab.
+       * gdbtypes.c (check_typedef):  Don't call lookup_symbol if
+       currently_reading_symtab (since that could infinitely recurse).
+
 Thu Jan 11 17:21:25 1996  Per Bothner  <bothner@kalessin.cygnus.com>
 
        * stabsread.c (read_struct_type):  Trivial simplification.
index 366ab34a713dbd198d547bf375842522234a453c..a21f9598c05cc2bf09746c904ed1bb90fc2454b6 100644 (file)
@@ -878,12 +878,19 @@ check_typedef (type)
     {
       if (!TYPE_TARGET_TYPE (type))
        {
-         char* name = type_name_no_tag (type);
+         char* name;
+         struct symbol *sym;
+
+         /* It is dangerous to call lookup_symbol if we are currently
+            reading a symtab.  Infinite recursion is one danger. */
+         if (currently_reading_symtab)
+           return type;
+
+         name = type_name_no_tag (type);
          /* FIXME: shouldn't we separately check the TYPE_NAME and the
             TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
             as appropriate?  (this code was written before TYPE_NAME and
             TYPE_TAG_NAME were separate).  */
-         struct symbol *sym;
          if (name == NULL)
            {
              complain (&stub_noname_complaint);
@@ -899,7 +906,7 @@ check_typedef (type)
       type = TYPE_TARGET_TYPE (type);
     }
 
-  if (TYPE_FLAGS(type) & TYPE_FLAG_STUB)
+  if ((TYPE_FLAGS(type) & TYPE_FLAG_STUB) && ! currently_reading_symtab)
     {
       char* name = type_name_no_tag (type);
       /* FIXME: shouldn't we separately check the TYPE_NAME and the
index dd10f5fddde813ba3b9a8cad236084711f96c918..7782a042def00d3241fb5d1740a5419dae6ea45b 100644 (file)
@@ -267,6 +267,17 @@ obconcat (obstackp, s1, s2, s3)
   return val;
 }
 
+/* True if we are nested inside psymtab_to_symtab. */
+
+int currently_reading_symtab = 0;
+
+static int
+decrement_reading_symtab (dummy)
+     void *dummy;
+{
+  currently_reading_symtab--;
+}
+
 /* Get the symbol table that corresponds to a partial_symtab.
    This is fast after the first time you do it.  In fact, there
    is an even faster macro PSYMTAB_TO_SYMTAB that does the fast
@@ -283,7 +294,10 @@ psymtab_to_symtab (pst)
   /* If it has not yet been read in, read it.  */
   if (!pst->readin)
     { 
+      struct cleanup *back_to = make_cleanup (decrement_reading_symtab, NULL);
+      currently_reading_symtab++;
       (*pst->read_symtab) (pst);
+      do_cleanups (back_to);
     }
 
   return pst->symtab;