* buildsym.c (end_symtab): If we ignore the subfiles, then
authorJoel Brobecker <brobecker@gnat.com>
Tue, 24 Mar 2009 01:32:46 +0000 (01:32 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Tue, 24 Mar 2009 01:32:46 +0000 (01:32 +0000)
        unlink the associated symtabs if they were already allocated.

gdb/ChangeLog
gdb/buildsym.c

index cf0b12365e656fcfc85f56272f1cbc1d03d3bfac..1a34fb2a88e59de33736b53030f55438ccdef534 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-23  Joel Brobecker  <brobecker@adacore.com>
+
+       * buildsym.c (end_symtab): If we ignore the subfiles, then
+       unlink the associated symtabs if they were already allocated.
+
 2009-03-23  Jerome Guitton  <guitton@adacore.com>
 
        Provide a way to force building of GDB with libcurses.
index 55ace15cc29ab340b8fb664052173f2c13136b5f..6de817f8b9f0cf40b901ae9a37d4b871d4e86f74 100644 (file)
@@ -1118,6 +1118,32 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
 
          symtab->primary = 0;
        }
+      else
+        {
+          if (subfile->symtab)
+            {
+              /* Since we are ignoring that subfile, we also need
+                 to unlink the associated empty symtab that we created.
+                 Otherwise, we can into trouble because various parts
+                 such as the block-vector are uninitialized whereas
+                 the rest of the code assumes that they are.
+                 
+                 We can only unlink the symtab because it was allocated
+                 on the objfile obstack.  */
+              struct symtab *s;
+
+              if (objfile->symtabs == subfile->symtab)
+                objfile->symtabs = objfile->symtabs->next;
+              else
+                ALL_OBJFILE_SYMTABS (objfile, s)
+                  if (s->next == subfile->symtab)
+                    {
+                      s->next = s->next->next;
+                      break;
+                    }
+              subfile->symtab = NULL;
+            }
+        }
       if (subfile->name != NULL)
        {
          xfree ((void *) subfile->name);