* i386.h: Correct opcode values for fsubp, fsubrp, fdivp, and
[deliverable/binutils-gdb.git] / gdb / buildsym.c
index e0b30f02c147fadb6d7084e97cc0b40a718a75dd..be8f787b47119a416f550fbef393be2ec3633c8c 100644 (file)
@@ -44,12 +44,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    questionable--see comment where we call them).  */
 #include "stabsread.h"
 
+/* Pointer to the head of a linked list of symbol blocks which have
+   already been finalized (lexical contexts already closed) and which are
+   just waiting to be built into a blockvector when finalizing the
+   associated symtab. */
+
+static struct pending_block *pending_blocks = NULL;
+
+/* List of free `struct pending' structures for reuse.  */
+
+static struct pending *free_pendings;
+
+\f
 static int
 compare_line_numbers PARAMS ((const void *, const void *));
 
-static struct blockvector *
-make_blockvector PARAMS ((struct objfile *));
-
 \f
 /* Initial sizes of data structures.  These are realloc'd larger if needed,
    and realloc'd down to the size actually used, when completed.  */
@@ -60,11 +69,17 @@ make_blockvector PARAMS ((struct objfile *));
 \f
 /* Complaints about the symbols we have encountered.  */
 
+struct complaint block_end_complaint =
+  {"block end address less than block start address in %s (patched it)", 0, 0};
+
+struct complaint anon_block_end_complaint =
+  {"block end address 0x%lx less than block start address 0x%lx (patched it)", 0, 0};
+
 struct complaint innerblock_complaint =
   {"inner block not inside outer block in %s", 0, 0};
 
 struct complaint innerblock_anon_complaint =
-  {"inner block not inside outer block", 0, 0};
+  {"inner block (0x%lx-0x%lx) not inside outer block (0x%lx-0x%lx)", 0, 0};
 
 struct complaint blockvector_complaint = 
   {"block at 0x%lx out of order", 0, 0};
@@ -140,9 +155,6 @@ really_free_pendings (foo)
      int foo;
 {
   struct pending *next, *next1;
-#if 0
-  struct pending_block *bnext, *bnext1;
-#endif
 
   for (next = free_pendings; next; next = next1)
     {
@@ -151,14 +163,7 @@ really_free_pendings (foo)
     }
   free_pendings = NULL;
 
-#if 0 /* Now we make the links in the symbol_obstack, so don't free them.  */
-  for (bnext = pending_blocks; bnext; bnext = bnext1)
-    {
-      bnext1 = bnext->next;
-      free ((PTR)bnext);
-    }
-#endif
-  pending_blocks = NULL;
+  free_pending_blocks ();
 
   for (next = file_symbols; next != NULL; next = next1)
     {
@@ -175,6 +180,23 @@ really_free_pendings (foo)
   global_symbols = NULL;
 }
 
+/* This function is called to discard any pending blocks. */
+
+void
+free_pending_blocks ()
+{
+#if 0 /* Now we make the links in the symbol_obstack, so don't free them.  */
+  struct pending_block *bnext, *bnext1;
+
+  for (bnext = pending_blocks; bnext; bnext = bnext1)
+    {
+      bnext1 = bnext->next;
+      free ((PTR)bnext);
+    }
+#endif
+  pending_blocks = NULL;
+}
+
 /* Take one of the lists of symbols and make a block from it.
    Keep the order the symbols have in the list (reversed from the input file).
    Put the block on the list of pending blocks.  */
@@ -246,6 +268,8 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile)
                case LOC_REF_ARG:
                case LOC_REGPARM:
                case LOC_REGPARM_ADDR:
+               case LOC_BASEREG_ARG:
+               case LOC_LOCAL_ARG:
                  nparams++;
                  break;
                case LOC_UNDEF:
@@ -257,9 +281,7 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile)
                case LOC_LABEL:
                case LOC_BLOCK:
                case LOC_CONST_BYTES:
-               case LOC_LOCAL_ARG:
                case LOC_BASEREG:
-               case LOC_BASEREG_ARG:
                case LOC_UNRESOLVED:
                case LOC_OPTIMIZED_OUT:
                default:
@@ -281,6 +303,8 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile)
                    case LOC_REF_ARG:
                    case LOC_REGPARM:
                    case LOC_REGPARM_ADDR:
+                   case LOC_BASEREG_ARG:
+                   case LOC_LOCAL_ARG:
                      TYPE_FIELD_TYPE (ftype, iparams) = SYMBOL_TYPE (sym);
                      iparams++;
                      break;
@@ -293,9 +317,7 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile)
                    case LOC_LABEL:
                    case LOC_BLOCK:
                    case LOC_CONST_BYTES:
-                   case LOC_LOCAL_ARG:
                    case LOC_BASEREG:
-                   case LOC_BASEREG_ARG:
                    case LOC_UNRESOLVED:
                    case LOC_OPTIMIZED_OUT:
                    default:
@@ -320,6 +342,25 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile)
     }
   *listhead = NULL;
 
+#if 1
+  /* Check to be sure that the blocks have an end address that is
+     greater than starting address */
+
+  if (BLOCK_END (block) < BLOCK_START (block))
+    {
+      if (symbol)
+       {
+         complain (&block_end_complaint, SYMBOL_SOURCE_NAME (symbol));
+       }
+      else
+       {
+         complain (&anon_block_end_complaint, BLOCK_END (block), BLOCK_START (block));
+       }
+      /* Better than nothing */
+      BLOCK_END (block) = BLOCK_START (block);
+    }
+#endif
+
   /* Install this block as the superblock
      of all blocks made since the start of this scope
      that don't have superblocks yet.  */
@@ -343,10 +384,14 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile)
                }
              else
                {
-                 complain (&innerblock_anon_complaint);
+                 complain (&innerblock_anon_complaint, BLOCK_START (pblock->block),
+                           BLOCK_END (pblock->block), BLOCK_START (block),
+                           BLOCK_END (block));
                }
-             BLOCK_START (pblock->block) = BLOCK_START (block);
-             BLOCK_END   (pblock->block) = BLOCK_END   (block);
+             if (BLOCK_START (pblock->block) < BLOCK_START (block))
+               BLOCK_START (pblock->block) = BLOCK_START (block);
+             if (BLOCK_END (pblock->block) > BLOCK_END (block))
+               BLOCK_END (pblock->block) = BLOCK_END (block);
            }
 #endif
          BLOCK_SUPERBLOCK (pblock->block) = block;
@@ -354,29 +399,44 @@ finish_block (symbol, listhead, old_blocks, start, end, objfile)
       opblock = pblock;
     }
 
-  /* Record this block on the list of all blocks in the file.
-     Put it after opblock, or at the beginning if opblock is 0.
-     This puts the block in the list after all its subblocks.  */
+  record_pending_block (objfile, block, opblock);
+}
+
+/* Record BLOCK on the list of all blocks in the file.  Put it after
+   OPBLOCK, or at the beginning if opblock is NULL.  This puts the block
+   in the list after all its subblocks.
+
+   Allocate the pending block struct in the symbol_obstack to save
+   time.  This wastes a little space.  FIXME: Is it worth it?  */
+
+void
+record_pending_block (objfile, block, opblock)
+     struct objfile* objfile;
+     struct block *block;
+     struct pending_block *opblock;
+{
+  register struct pending_block *pblock;
 
-  /* Allocate in the symbol_obstack to save time.
-     It wastes a little space.  */
   pblock = (struct pending_block *)
-    obstack_alloc (&objfile -> symbol_obstack,
-                  sizeof (struct pending_block));
-  pblock->block = block;
+    obstack_alloc (&objfile -> symbol_obstack, sizeof (struct pending_block));
+  pblock -> block = block;
   if (opblock)
     {
-      pblock->next = opblock->next;
-      opblock->next = pblock;
+      pblock -> next = opblock -> next;
+      opblock -> next = pblock;
     }
   else
     {
-      pblock->next = pending_blocks;
+      pblock -> next = pending_blocks;
       pending_blocks = pblock;
     }
 }
 
-static struct blockvector *
+/* Note that this is only used in this file and in dstread.c, which should be
+   fixed to not need direct access to this function.  When that is done, it can
+   be made static again. */
+
+struct blockvector *
 make_blockvector (objfile)
      struct objfile *objfile;
 {
@@ -753,8 +813,7 @@ end_symtab (end_addr, objfile, section)
 
   if (context_stack_depth > 0)
     {
-      context_stack_depth--;
-      cstk = &context_stack[context_stack_depth];
+      cstk = pop_context();
       /* Make a block for the local symbols within.  */
       finish_block (cstk->name, &local_symbols, cstk->old_blocks,
                    cstk->start_addr, end_addr, objfile);
This page took 0.026707 seconds and 4 git commands to generate.