*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index 0cf709199728cb88306e0a163fbbd2ce4f89f5b9..c533eb4c290e26a85d9fd1627ba3a4b2d46cce04 100644 (file)
@@ -1,6 +1,6 @@
 /* Read dbx symbol tables and convert to internal format, for GDB.
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001, 2002
+   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003.
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -167,36 +167,27 @@ static int has_line_numbers;
 
 /* Complaints about the symbols we have encountered.  */
 
-struct deprecated_complaint lbrac_complaint =
-{"bad block start address patched", 0, 0};
-
-struct deprecated_complaint string_table_offset_complaint =
-{"bad string table offset in symbol %d", 0, 0};
-
-struct deprecated_complaint unknown_symtype_complaint =
-{"unknown symbol type %s", 0, 0};
-
-struct deprecated_complaint unknown_symchar_complaint =
-{"unknown symbol descriptor `%c'", 0, 0};
-
-struct deprecated_complaint lbrac_rbrac_complaint =
-{"block start larger than block end", 0, 0};
-
-struct deprecated_complaint lbrac_unmatched_complaint =
-{"unmatched N_LBRAC before symtab pos %d", 0, 0};
-
-struct deprecated_complaint lbrac_mismatch_complaint =
-{"N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d", 0, 0};
+static void
+unknown_symtype_complaint (const char *arg1)
+{
+  complaint (&symfile_complaints, "unknown symbol type %s", arg1);
+}
 
-struct deprecated_complaint repeated_header_complaint =
-{"\"repeated\" header file %s not previously seen, at symtab pos %d", 0, 0};
+static void
+lbrac_mismatch_complaint (int arg1)
+{
+  complaint (&symfile_complaints,
+            "N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d", arg1);
+}
 
-struct deprecated_complaint unclaimed_bincl_complaint =
-{"N_BINCL %s not in entries for any file, at symtab pos %d", 0, 0};
+static void
+repeated_header_complaint (const char *arg1, int arg2)
+{
+  complaint (&symfile_complaints,
+            "\"repeated\" header file %s not previously seen, at symtab pos %d",
+            arg1, arg2);
+}
 
-struct deprecated_complaint discarding_local_symbols_complaint =
-{"misplaced N_LBRAC entry; discarding local symbols which have no enclosing block", 0, 0};
-\f
 /* find_text_range --- find start and end of loadable code sections
 
    The find_text_range function finds the shortest address range that
@@ -266,7 +257,9 @@ static int bincls_allocated;
 
 extern void _initialize_dbxread (void);
 
-static void process_now (struct objfile *);
+#if 0 /* OBSOLETE CFront */
+// OBSOLETE static void process_now (struct objfile *);
+#endif /* OBSOLETE CFront */
 
 static void read_ofile_symtab (struct partial_symtab *);
 
@@ -367,7 +360,7 @@ add_old_header_file (char *name, int instance)
        add_this_object_header_file (i);
        return;
       }
-  complain (&repeated_header_complaint, name, symnum);
+  repeated_header_complaint (name, symnum);
 }
 
 /* Add to this file a "new" header file: definitions for its types follow.
@@ -645,7 +638,7 @@ dbx_symfile_init (struct objfile *objfile)
   /* Allocate struct to keep track of the symfile */
   objfile->sym_stab_info = (struct dbx_symfile_info *)
     xmmalloc (objfile->md, sizeof (struct dbx_symfile_info));
-  memset ((PTR) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
+  memset (objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
 
   DBX_TEXT_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
   DBX_DATA_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".data");
@@ -697,8 +690,8 @@ dbx_symfile_init (struct objfile *objfile)
       if (val < 0)
        perror_with_name (name);
 
-      memset ((PTR) size_temp, 0, sizeof (size_temp));
-      val = bfd_bread ((PTR) size_temp, sizeof (size_temp), sym_bfd);
+      memset (size_temp, 0, sizeof (size_temp));
+      val = bfd_bread (size_temp, sizeof (size_temp), sym_bfd);
       if (val < 0)
        {
          perror_with_name (name);
@@ -779,105 +772,106 @@ static struct external_nlist symbuf[4096];
 static int symbuf_idx;
 static int symbuf_end;
 
-/* cont_elem is used for continuing information in cfront.
-   It saves information about which types need to be fixed up and 
-   completed after all the stabs are read.  */
-struct cont_elem
-  {
-    /* sym and stabstring for continuing information in cfront */
-    struct symbol *sym;
-    char *stabs;
-    /* state dependencies (statics that must be preserved) */
-    int sym_idx;
-    int sym_end;
-    int symnum;
-    int (*func) (struct objfile *, struct symbol *, char *);
-    /* other state dependencies include:
-       (assumption is that these will not change since process_now FIXME!!)
-       stringtab_global
-       n_stabs
-       objfile
-       symfile_bfd */
-  };
-
-static struct cont_elem *cont_list = 0;
-static int cont_limit = 0;
-static int cont_count = 0;
-
-/* Arrange for function F to be called with arguments SYM and P later
-   in the stabs reading process.  */
-void
-process_later (struct symbol *sym, char *p,
-              int (*f) (struct objfile *, struct symbol *, char *))
-{
-
-  /* Allocate more space for the deferred list.  */
-  if (cont_count >= cont_limit - 1)
-    {
-      cont_limit += 32;                /* chunk size */
-
-      cont_list
-       = (struct cont_elem *) xrealloc (cont_list,
-                                        (cont_limit
-                                         * sizeof (struct cont_elem)));
-      if (!cont_list)
-       error ("Virtual memory exhausted\n");
-    }
-
-  /* Save state variables so we can process these stabs later.  */
-  cont_list[cont_count].sym_idx = symbuf_idx;
-  cont_list[cont_count].sym_end = symbuf_end;
-  cont_list[cont_count].symnum = symnum;
-  cont_list[cont_count].sym = sym;
-  cont_list[cont_count].stabs = p;
-  cont_list[cont_count].func = f;
-  cont_count++;
-}
-
-/* Call deferred funtions in CONT_LIST.  */
-
-static void
-process_now (struct objfile *objfile)
-{
-  int i;
-  int save_symbuf_idx;
-  int save_symbuf_end;
-  int save_symnum;
-  struct symbol *sym;
-  char *stabs;
-  int err;
-  int (*func) (struct objfile *, struct symbol *, char *);
-
-  /* Save the state of our caller, we'll want to restore it before
-     returning.  */
-  save_symbuf_idx = symbuf_idx;
-  save_symbuf_end = symbuf_end;
-  save_symnum = symnum;
-
-  /* Iterate over all the deferred stabs.  */
-  for (i = 0; i < cont_count; i++)
-    {
-      /* Restore the state for this deferred stab.  */
-      symbuf_idx = cont_list[i].sym_idx;
-      symbuf_end = cont_list[i].sym_end;
-      symnum = cont_list[i].symnum;
-      sym = cont_list[i].sym;
-      stabs = cont_list[i].stabs;
-      func = cont_list[i].func;
-
-      /* Call the function to handle this deferrd stab.  */
-      err = (*func) (objfile, sym, stabs);
-      if (err)
-       error ("Internal error: unable to resolve stab.\n");
-    }
-
-  /* Restore our caller's state.  */
-  symbuf_idx = save_symbuf_idx;
-  symbuf_end = save_symbuf_end;
-  symnum = save_symnum;
-  cont_count = 0;
-}
-
+#if 0 /* OBSOLETE CFront */
+// OBSOLETE  /* cont_elem is used for continuing information in cfront.
+// OBSOLETE     It saves information about which types need to be fixed up and 
+// OBSOLETE     completed after all the stabs are read.  */
+// OBSOLETE  struct cont_elem
+// OBSOLETE    {
+// OBSOLETE      /* sym and stabstring for continuing information in cfront */
+// OBSOLETE      struct symbol *sym;
+// OBSOLETE      char *stabs;
+// OBSOLETE      /* state dependencies (statics that must be preserved) */
+// OBSOLETE      int sym_idx;
+// OBSOLETE      int sym_end;
+// OBSOLETE      int symnum;
+// OBSOLETE      int (*func) (struct objfile *, struct symbol *, char *);
+// OBSOLETE      /* other state dependencies include:
+// OBSOLETE         (assumption is that these will not change since process_now FIXME!!)
+// OBSOLETE         stringtab_global
+// OBSOLETE         n_stabs
+// OBSOLETE         objfile
+// OBSOLETE         symfile_bfd */
+// OBSOLETE    };
+
+// OBSOLETE  static struct cont_elem *cont_list = 0;
+// OBSOLETE  static int cont_limit = 0;
+// OBSOLETE  static int cont_count = 0;
+
+// OBSOLETE  /* Arrange for function F to be called with arguments SYM and P later
+// OBSOLETE     in the stabs reading process.  */
+// OBSOLETE  void
+// OBSOLETE  process_later (struct symbol *sym, char *p,
+// OBSOLETE           int (*f) (struct objfile *, struct symbol *, char *))
+// OBSOLETE  {
+
+// OBSOLETE    /* Allocate more space for the deferred list.  */
+// OBSOLETE    if (cont_count >= cont_limit - 1)
+// OBSOLETE      {
+// OBSOLETE        cont_limit += 32;           /* chunk size */
+
+// OBSOLETE        cont_list
+// OBSOLETE    = (struct cont_elem *) xrealloc (cont_list,
+// OBSOLETE                                     (cont_limit
+// OBSOLETE                                      * sizeof (struct cont_elem)));
+// OBSOLETE        if (!cont_list)
+// OBSOLETE    error ("Virtual memory exhausted\n");
+// OBSOLETE      }
+
+// OBSOLETE    /* Save state variables so we can process these stabs later.  */
+// OBSOLETE    cont_list[cont_count].sym_idx = symbuf_idx;
+// OBSOLETE    cont_list[cont_count].sym_end = symbuf_end;
+// OBSOLETE    cont_list[cont_count].symnum = symnum;
+// OBSOLETE    cont_list[cont_count].sym = sym;
+// OBSOLETE    cont_list[cont_count].stabs = p;
+// OBSOLETE    cont_list[cont_count].func = f;
+// OBSOLETE    cont_count++;
+// OBSOLETE  }
+
+// OBSOLETE  /* Call deferred funtions in CONT_LIST.  */
+
+// OBSOLETE  static void
+// OBSOLETE  process_now (struct objfile *objfile)
+// OBSOLETE  {
+// OBSOLETE    int i;
+// OBSOLETE    int save_symbuf_idx;
+// OBSOLETE    int save_symbuf_end;
+// OBSOLETE    int save_symnum;
+// OBSOLETE    struct symbol *sym;
+// OBSOLETE    char *stabs;
+// OBSOLETE    int err;
+// OBSOLETE    int (*func) (struct objfile *, struct symbol *, char *);
+
+// OBSOLETE    /* Save the state of our caller, we'll want to restore it before
+// OBSOLETE       returning.  */
+// OBSOLETE    save_symbuf_idx = symbuf_idx;
+// OBSOLETE    save_symbuf_end = symbuf_end;
+// OBSOLETE    save_symnum = symnum;
+
+// OBSOLETE    /* Iterate over all the deferred stabs.  */
+// OBSOLETE    for (i = 0; i < cont_count; i++)
+// OBSOLETE      {
+// OBSOLETE        /* Restore the state for this deferred stab.  */
+// OBSOLETE        symbuf_idx = cont_list[i].sym_idx;
+// OBSOLETE        symbuf_end = cont_list[i].sym_end;
+// OBSOLETE        symnum = cont_list[i].symnum;
+// OBSOLETE        sym = cont_list[i].sym;
+// OBSOLETE        stabs = cont_list[i].stabs;
+// OBSOLETE        func = cont_list[i].func;
+
+// OBSOLETE        /* Call the function to handle this deferrd stab.  */
+// OBSOLETE        err = (*func) (objfile, sym, stabs);
+// OBSOLETE        if (err)
+// OBSOLETE    error ("Internal error: unable to resolve stab.\n");
+// OBSOLETE      }
+
+// OBSOLETE    /* Restore our caller's state.  */
+// OBSOLETE    symbuf_idx = save_symbuf_idx;
+// OBSOLETE    symbuf_end = save_symbuf_end;
+// OBSOLETE    symnum = save_symnum;
+// OBSOLETE    cont_count = 0;
+// OBSOLETE  }
+#endif /* OBSOLETE CFront */
 
 /* Name of last function encountered.  Used in Solaris to approximate
    object file boundaries.  */
@@ -930,7 +924,7 @@ fill_symbuf (bfd *sym_bfd)
        count = sizeof (symbuf);
     }
 
-  nbytes = bfd_bread ((PTR) symbuf, count, sym_bfd);
+  nbytes = bfd_bread (symbuf, count, sym_bfd);
   if (nbytes < 0)
     perror_with_name (bfd_get_filename (sym_bfd));
   else if (nbytes == 0)
@@ -1022,7 +1016,7 @@ find_corresponding_bincl_psymtab (char *name, int instance)
        && STREQ (name, bincl->name))
       return bincl->pst;
 
-  complain (&repeated_header_complaint, name, symnum);
+  repeated_header_complaint (name, symnum);
   return (struct partial_symtab *) 0;
 }
 
@@ -1031,7 +1025,7 @@ find_corresponding_bincl_psymtab (char *name, int instance)
 static void
 free_bincl_list (struct objfile *objfile)
 {
-  xmfree (objfile->md, (PTR) bincl_list);
+  xmfree (objfile->md, bincl_list);
   bincls_allocated = 0;
 }
 
@@ -1059,7 +1053,8 @@ set_namestring (struct objfile *objfile, struct internal_nlist nlist)
   if (((unsigned) nlist.n_strx + file_string_table_offset) >=
       DBX_STRINGTAB_SIZE (objfile))
     {
-      complain (&string_table_offset_complaint, symnum);
+      complaint (&symfile_complaints, "bad string table offset in symbol %d",
+                symnum);
       namestring = "<bad string table offset>";
     } 
   else
@@ -1256,6 +1251,14 @@ find_stab_function_addr (char *namestring, char *filename,
 }
 #endif /* SOFUN_ADDRESS_MAYBE_MISSING */
 
+static void
+function_outside_compilation_unit_complaint (const char *arg1)
+{
+  complaint (&symfile_complaints,
+            "function `%s' appears to be defined outside of all compilation units",
+            arg1);
+}
+
 /* Setup partial_symtab's describing each source file for which
    debugging information is available. */
 
@@ -1360,9 +1363,6 @@ read_dbx_symtab (struct objfile *objfile)
 
       switch (nlist.n_type)
        {
-         static struct deprecated_complaint function_outside_compilation_unit = {
-           "function `%s' appears to be defined outside of all compilation units", 0, 0
-         };
          char *p;
          /*
           * Standard, external, non-debugger, symbols
@@ -1613,7 +1613,9 @@ read_dbx_symtab (struct objfile *objfile)
            {
              /* FIXME: we should not get here without a PST to work on.
                 Attempt to recover.  */
-             complain (&unclaimed_bincl_complaint, namestring, symnum);
+             complaint (&symfile_complaints,
+                        "N_BINCL %s not in entries for any file, at symtab pos %d",
+                        namestring, symnum);
              continue;
            }
            add_bincl_to_list (pst, namestring, nlist.n_value);
@@ -1674,7 +1676,7 @@ read_dbx_symtab (struct objfile *objfile)
              psymtab_include_list = (char **)
                alloca ((includes_allocated *= 2) *
                        sizeof (char *));
-             memcpy ((PTR) psymtab_include_list, (PTR) orig,
+             memcpy (psymtab_include_list, orig,
                      includes_used * sizeof (char *));
            }
            continue;
@@ -1776,20 +1778,22 @@ read_dbx_symtab (struct objfile *objfile)
                                         psymtab_language, objfile);
                    p += 1;
                  }
-               /* The semantics of C++ state that "struct foo { ... }"
-                  also defines a typedef for "foo".  Unfortuantely, cfront
-                  never makes the typedef when translating from C++ to C.
-                  We make the typedef here so that "ptype foo" works as
-                  expected for cfront translated code.  */
-               else if (psymtab_language == language_cplus)
-                 {
-                   /* Also a typedef with the same name.  */
-                   add_psymbol_to_list (namestring, p - namestring,
-                                        VAR_NAMESPACE, LOC_TYPEDEF,
-                                        &objfile->static_psymbols,
-                                        nlist.n_value, 0,
-                                        psymtab_language, objfile);
-                 }
+#if 0 /* OBSOLETE CFront */
+// OBSOLETE            /* The semantics of C++ state that "struct foo { ... }"
+// OBSOLETE               also defines a typedef for "foo".  Unfortuantely, cfront
+// OBSOLETE               never makes the typedef when translating from C++ to C.
+// OBSOLETE               We make the typedef here so that "ptype foo" works as
+// OBSOLETE               expected for cfront translated code.  */
+// OBSOLETE            else if (psymtab_language == language_cplus)
+// OBSOLETE              {
+// OBSOLETE                /* Also a typedef with the same name.  */
+// OBSOLETE                add_psymbol_to_list (namestring, p - namestring,
+// OBSOLETE                                     VAR_NAMESPACE, LOC_TYPEDEF,
+// OBSOLETE                                     &objfile->static_psymbols,
+// OBSOLETE                                     nlist.n_value, 0,
+// OBSOLETE                                     psymtab_language, objfile);
+// OBSOLETE              }
+#endif /* OBSOLETE CFront */
              }
            goto check_enum;
          case 't':
@@ -1887,7 +1891,7 @@ read_dbx_symtab (struct objfile *objfile)
                char *name = xmalloc (name_len + 1);
                memcpy (name, namestring, name_len);
                name[name_len] = '\0';
-               complain (&function_outside_compilation_unit, name);
+               function_outside_compilation_unit_complaint (name);
                xfree (name);
              }
            nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
@@ -1952,7 +1956,7 @@ read_dbx_symtab (struct objfile *objfile)
                char *name = xmalloc (name_len + 1);
                memcpy (name, namestring, name_len);
                name[name_len] = '\0';
-               complain (&function_outside_compilation_unit, name);
+               function_outside_compilation_unit_complaint (name);
                xfree (name);
              }
            nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
@@ -2024,9 +2028,11 @@ read_dbx_symtab (struct objfile *objfile)
          case '9':
          case '-':
          case '#':             /* for symbol identification (used in live ranges) */
-           /* added to support cfront stabs strings */
-         case 'Z':             /* for definition continuations */
-         case 'P':             /* for prototypes */
+#if 0 /* OBSOLETE CFront */
+// OBSOLETE        /* added to support cfront stabs strings */
+// OBSOLETE      case 'Z':             /* for definition continuations */
+// OBSOLETE      case 'P':             /* for prototypes */
+#endif /* OBSOLETE CFront */
            continue;
 
          case ':':
@@ -2047,7 +2053,8 @@ read_dbx_symtab (struct objfile *objfile)
               time searching to the end of every string looking for
               a backslash.  */
 
-           complain (&unknown_symchar_complaint, p[1]);
+           complaint (&symfile_complaints, "unknown symbol descriptor `%c'",
+                      p[1]);
 
            /* Ignore it; perhaps it is an extension that we don't
               know about.  */
@@ -2093,7 +2100,7 @@ read_dbx_symtab (struct objfile *objfile)
                      (struct partial_symtab **)
                      alloca ((dependencies_allocated *= 2)
                              * sizeof (struct partial_symtab *));
-                   memcpy ((PTR) dependency_list, (PTR) orig,
+                   memcpy (dependency_list, orig,
                            (dependencies_used
                             * sizeof (struct partial_symtab *)));
 #ifdef DEBUG_INFO
@@ -2161,8 +2168,7 @@ read_dbx_symtab (struct objfile *objfile)
          default:
          /* If we haven't found it yet, ignore it.  It's probably some
             new type we don't know about yet.  */
-         complain (&unknown_symtype_complaint,
-                   local_hex_string (nlist.n_type));
+         unknown_symtype_complaint (local_hex_string (nlist.n_type));
          continue;
        }
     }
@@ -2683,10 +2689,11 @@ read_ofile_symtab (struct partial_symtab *pst)
 
   pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
 
-  /* Process items which we had to "process_later" due to dependencies 
-     on other stabs.  */
-  process_now (objfile);
-
+#if 0 /* OBSOLETE CFront */
+// OBSOLETE    /* Process items which we had to "process_later" due to dependencies 
+// OBSOLETE       on other stabs.  */
+// OBSOLETE    process_now (objfile);
+#endif /* OBSOLETE CFront */
   end_stabs ();
 }
 \f
@@ -2774,6 +2781,13 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
        {
          /* This N_FUN marks the end of a function.  This closes off the
             current block.  */
+
+         if (context_stack_depth <= 0)
+           {
+             lbrac_mismatch_complaint (symnum);
+             break;
+           }
+
          record_line (current_subfile, 0, function_start_offset + valu);
          within_function = 0;
          new = pop_context ();
@@ -2820,7 +2834,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
       if (!SUN_FIXED_LBRAC_BUG && valu < last_pc_address)
        {
          /* Patch current LBRAC pc value to match last handy pc value */
-         complain (&lbrac_complaint);
+         complaint (&symfile_complaints, "bad block start address patched");
          valu = last_pc_address;
        }
 #endif
@@ -2843,9 +2857,15 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
           N_SO, the linker did not relocate them (sigh).  */
        valu += last_source_start_addr;
 
+      if (context_stack_depth <= 0)
+       {
+         lbrac_mismatch_complaint (symnum);
+         break;
+       }
+
       new = pop_context ();
       if (desc != new->depth)
-       complain (&lbrac_mismatch_complaint, symnum);
+       lbrac_mismatch_complaint (symnum);
 
       /* Some compilers put the variable decls inside of an
          LBRAC/RBRAC block.  This macro should be nonzero if this
@@ -2870,7 +2890,8 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
                 symbols within an LBRAC/RBRAC block; this complaint
                 might also help sort out problems in which
                 VARIABLES_INSIDE_BLOCK is incorrectly defined.  */
-             complain (&discarding_local_symbols_complaint);
+             complaint (&symfile_complaints,
+                        "misplaced N_LBRAC entry; discarding local symbols which have no enclosing block");
            }
          local_symbols = new->locals;
        }
@@ -2890,7 +2911,8 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
                 compilers?  Is this ever harmful?).  */
              if (new->start_addr > valu)
                {
-                 complain (&lbrac_rbrac_complaint);
+                 complaint (&symfile_complaints,
+                            "block start larger than block end");
                  new->start_addr = valu;
                }
              /* Make a block for the local symbols within.  */
@@ -3114,7 +3136,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
     case N_NBBSS:
     case N_NBSTS:
     case N_NBLCS:
-      complain (&unknown_symtype_complaint, local_hex_string (type));
+      unknown_symtype_complaint (local_hex_string (type));
       /* FALLTHROUGH */
 
       /* The following symbol types don't need the address field relocated,
@@ -3226,7 +3248,8 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
 
              if (context_stack_depth > 1)
                {
-                 complain (&lbrac_unmatched_complaint, symnum);
+                 complaint (&symfile_complaints,
+                            "unmatched N_LBRAC before symtab pos %d", symnum);
                  break;
                }
 
This page took 0.030969 seconds and 4 git commands to generate.