2004-07-28 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / coffread.c
index fc6bdeb63096067272ec1dc75383f4930589b0ef..821ca44f3bf72bda266446fb9803825cb043461d 100644 (file)
@@ -1,6 +1,6 @@
 /* Read coff symbol tables and convert to internal format, for GDB.
    Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2002, 2003
+   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
 
@@ -35,8 +35,6 @@
 
 #include "coff/internal.h"     /* Internal format of COFF symbols in BFD */
 #include "libcoff.h"           /* FIXME secret internal data from BFD */
-
-#include "symfile.h"
 #include "objfiles.h"
 #include "buildsym.h"
 #include "gdb-stabs.h"
@@ -202,7 +200,7 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
 
   csi = (struct coff_symfile_info *) csip;
   name = bfd_get_section_name (abfd, sectp);
-  if (STREQ (name, ".text"))
+  if (DEPRECATED_STREQ (name, ".text"))
     {
       csi->textaddr = bfd_section_vma (abfd, sectp);
       csi->textsize += bfd_section_size (abfd, sectp);
@@ -211,7 +209,7 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
     {
       csi->textsize += bfd_section_size (abfd, sectp);
     }
-  else if (STREQ (name, ".stabstr"))
+  else if (DEPRECATED_STREQ (name, ".stabstr"))
     {
       csi->stabstrsect = sectp;
     }
@@ -387,13 +385,6 @@ complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
   last_source_file = savestring (name, strlen (name));
   current_source_start_addr = start_addr;
   current_source_end_addr = start_addr + size;
-
-  if (current_objfile->ei.entry_point >= current_source_start_addr &&
-      current_objfile->ei.entry_point < current_source_end_addr)
-    {
-      current_objfile->ei.deprecated_entry_file_lowpc = current_source_start_addr;
-      current_objfile->ei.deprecated_entry_file_highpc = current_source_end_addr;
-    }
 }
 
 /* Finish the symbol definitions for one main source file,
@@ -612,6 +603,15 @@ coff_symfile_read (struct objfile *objfile, int mainline)
   /* Free the installed minimal symbol data.  */
   do_cleanups (cleanup_minimal_symbols);
 
+  /* If we are reinitializing, or if we have not loaded syms yet,
+     empty the psymtab.  "mainline" is cleared so the *_read_psymtab
+     functions do not all re-initialize it.  */
+  if (mainline)
+    {
+      init_psymbol_list (objfile, 0);
+      mainline = 0;
+    }
+
   bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
 
   if (info->stabsects)
@@ -636,12 +636,14 @@ coff_symfile_read (struct objfile *objfile, int mainline)
                               info->stabsects,
                               info->stabstrsect->filepos, stabstrsize);
     }
-  if (dwarf2_has_info (abfd))
+  if (dwarf2_has_info (objfile))
     {
       /* DWARF2 sections.  */
       dwarf2_build_psymtabs (objfile, mainline);
     }
 
+  dwarf2_build_frame_info (objfile);
+
   do_cleanups (back_to);
 }
 
@@ -819,7 +821,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
        case C_THUMBSTATFUNC:
          if (cs->c_name[0] == '.')
            {
-             if (STREQ (cs->c_name, ".text"))
+             if (DEPRECATED_STREQ (cs->c_name, ".text"))
                {
                  /* FIXME:  don't wire in ".text" as section name
                     or symbol name! */
@@ -944,7 +946,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
          break;
 
        case C_FCN:
-         if (STREQ (cs->c_name, ".bf"))
+         if (DEPRECATED_STREQ (cs->c_name, ".bf"))
            {
              within_function = 1;
 
@@ -966,7 +968,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
              new->name =
                process_coff_symbol (&fcn_cs_saved, &fcn_aux_saved, objfile);
            }
-         else if (STREQ (cs->c_name, ".ef"))
+         else if (DEPRECATED_STREQ (cs->c_name, ".ef"))
            {
              if (!within_function)
                error ("Bad coff function information\n");
@@ -1042,13 +1044,13 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
          break;
 
        case C_BLOCK:
-         if (STREQ (cs->c_name, ".bb"))
+         if (DEPRECATED_STREQ (cs->c_name, ".bb"))
            {
              tmpaddr = cs->c_value;
              tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
              push_context (++depth, tmpaddr);
            }
-         else if (STREQ (cs->c_name, ".eb"))
+         else if (DEPRECATED_STREQ (cs->c_name, ".eb"))
            {
              if (context_stack_depth <= 0)
                {               /* We attempted to pop an empty context stack */
@@ -1364,11 +1366,15 @@ enter_linenos (long file_offset, int first_line,
   /* line numbers start at one for the first line of the function */
   first_line--;
 
-  for (;;)
+  /* If the line number table is full (e.g. 64K lines in COFF debug
+     info), the next function's L_LNNO32 might not be zero, so don't
+     overstep the table's end in any case.  */
+  while (rawptr <= &linetab[0] + linetab_size)
     {
       bfd_coff_swap_lineno_in (symfile_bfd, rawptr, &lptr);
       rawptr += local_linesz;
-      /* The next function, or the sentinel, will have L_LNNO32 zero; we exit. */
+      /* The next function, or the sentinel, will have L_LNNO32 zero;
+        we exit. */
       if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line)
        record_line (current_subfile, first_line + L_LNNO32 (&lptr),
                     lptr.l_addr.l_paddr
@@ -1468,7 +1474,7 @@ process_coff_symbol (struct coff_symbol *cs,
                     struct objfile *objfile)
 {
   struct symbol *sym
-  = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+  = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
                                     sizeof (struct symbol));
   char *name;
 
@@ -1963,7 +1969,7 @@ coff_read_struct_type (int index, int length, int lastsym)
          list->field.name =
            obsavestring (name,
                          strlen (name),
-                         &current_objfile->symbol_obstack);
+                         &current_objfile->objfile_obstack);
          FIELD_TYPE (list->field) = decode_type (ms, ms->c_type, &sub_aux);
          FIELD_BITPOS (list->field) = 8 * ms->c_value;
          FIELD_BITSIZE (list->field) = 0;
@@ -1982,7 +1988,7 @@ coff_read_struct_type (int index, int length, int lastsym)
          list->field.name =
            obsavestring (name,
                          strlen (name),
-                         &current_objfile->symbol_obstack);
+                         &current_objfile->objfile_obstack);
          FIELD_TYPE (list->field) = decode_type (ms, ms->c_type, &sub_aux);
          FIELD_BITPOS (list->field) = ms->c_value;
          FIELD_BITSIZE (list->field) = sub_aux.x_sym.x_misc.x_lnsz.x_size;
@@ -2049,13 +2055,13 @@ coff_read_enum_type (int index, int length, int lastsym)
        {
        case C_MOE:
          sym = (struct symbol *) obstack_alloc
-           (&current_objfile->symbol_obstack,
+           (&current_objfile->objfile_obstack,
             sizeof (struct symbol));
          memset (sym, 0, sizeof (struct symbol));
 
          DEPRECATED_SYMBOL_NAME (sym) =
            obsavestring (name, strlen (name),
-                         &current_objfile->symbol_obstack);
+                         &current_objfile->objfile_obstack);
          SYMBOL_CLASS (sym) = LOC_CONST;
          SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
          SYMBOL_VALUE (sym) = ms->c_value;
This page took 0.03464 seconds and 4 git commands to generate.