* gdb.base/help.exp: Allow Win32 child process.
[deliverable/binutils-gdb.git] / gdb / coffread.c
index c781a34f18fc6dab0aaeba29749f6a6fa3e08fa8..0f36b9509d1838c5cc92ea21aed10688b48cbfc6 100644 (file)
@@ -1,5 +1,6 @@
 /* Read coff symbol tables and convert to internal format, for GDB.
-   Copyright 1987, 88, 89, 90, 91, 92, 93, 94, 96, 97, 1998
+   Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 1998, 1999, 2000, 2001, 2002, 2003
    Free Software Foundation, Inc.
    Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
 
@@ -27,7 +28,7 @@
 #include "breakpoint.h"
 
 #include "bfd.h"
-#include "obstack.h"
+#include "gdb_obstack.h"
 
 #include "gdb_string.h"
 #include <ctype.h>
 #include "stabsread.h"
 #include "complaints.h"
 #include "target.h"
+#include "gdb_assert.h"
+#include "block.h"
+
+#include "coff-pe-read.h"
 
 extern void _initialize_coffread (void);
 
@@ -68,14 +73,6 @@ struct coff_symfile_info
 
 #define SDB_TYPE(type) (BTYPE(type) | (type & N_TMASK))
 
-/* Convert from an sdb register number to an internal gdb register number.
-   This should be defined in tm.h, if REGISTER_NAMES is not set up
-   to map one to one onto the sdb register numbers.  */
-
-#ifndef SDB_REG_TO_REGNUM
-#define SDB_REG_TO_REGNUM(value)     (value)
-#endif
-
 /* Core address of start and end of text of current source file.
    This comes from a ".text" symbol where x_nlinno > 0.  */
 
@@ -128,41 +125,6 @@ static int pe_file;
 
 static struct symbol *opaque_type_chain[HASHSIZE];
 
-/* Complaints about various problems in the file being read  */
-
-struct complaint ef_complaint =
-{"Unmatched .ef symbol(s) ignored starting at symnum %d", 0, 0};
-
-struct complaint ef_stack_complaint =
-{"`.ef' symbol without matching `.bf' symbol ignored starting at symnum %d", 0, 0};
-
-struct complaint eb_stack_complaint =
-{"`.eb' symbol without matching `.bb' symbol ignored starting at symnum %d", 0, 0};
-
-struct complaint bf_no_aux_complaint =
-{"`.bf' symbol %d has no aux entry", 0, 0};
-
-struct complaint ef_no_aux_complaint =
-{"`.ef' symbol %d has no aux entry", 0, 0};
-
-struct complaint lineno_complaint =
-{"Line number pointer %d lower than start of line numbers", 0, 0};
-
-struct complaint unexpected_type_complaint =
-{"Unexpected type for symbol %s", 0, 0};
-
-struct complaint bad_sclass_complaint =
-{"Bad n_sclass for symbol %s", 0, 0};
-
-struct complaint misordered_blocks_complaint =
-{"Blocks out of order at address %x", 0, 0};
-
-struct complaint tagndx_bad_complaint =
-{"Symbol table entry for %s has bad tagndx value", 0, 0};
-
-struct complaint eb_complaint =
-{"Mismatched .eb symbol ignored starting at symnum %d", 0, 0};
-
 /* Simplified internal version of coff symbol table information */
 
 struct coff_symbol
@@ -198,8 +160,6 @@ static struct symbol *process_coff_symbol (struct coff_symbol *,
 
 static void patch_opaque_types (struct symtab *);
 
-static void patch_type (struct type *, struct type *);
-
 static void enter_linenos (long, int, int, struct objfile *);
 
 static void free_linetab (void);
@@ -222,32 +182,6 @@ static void read_one_sym (struct coff_symbol *,
                          struct internal_syment *, union internal_auxent *);
 
 static void coff_symtab_read (long, unsigned int, struct objfile *);
-
-static void find_linenos (bfd *, sec_ptr, PTR);
-
-static void coff_symfile_init (struct objfile *);
-
-static void coff_new_init (struct objfile *);
-
-static void coff_symfile_read (struct objfile *, int);
-
-static void coff_symfile_finish (struct objfile *);
-
-static void record_minimal_symbol (char *, CORE_ADDR,
-                                  enum minimal_symbol_type,
-                                  struct objfile *);
-
-static void coff_end_symtab (struct objfile *);
-
-static void complete_symtab (char *, CORE_ADDR, unsigned int);
-
-static void coff_start_symtab (char *);
-
-static struct type *coff_alloc_type (int);
-
-static struct type **coff_lookup_type (int);
-
-static void coff_locate_sections (bfd *, asection *, PTR);
 \f
 /* We are called once per section from coff_symfile_read.  We
    need to examine each section we are passed, check to see
@@ -260,10 +194,7 @@ static void coff_locate_sections (bfd *, asection *, PTR);
    -kingdon).  */
 
 static void
-coff_locate_sections (abfd, sectp, csip)
-     bfd *abfd;
-     asection *sectp;
-     PTR csip;
+coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
 {
   register struct coff_symfile_info *csi;
   const char *name;
@@ -307,7 +238,7 @@ coff_locate_sections (abfd, sectp, csip)
          /* This will be run after coffstab_build_psymtabs is called
             in coff_symfile_read, at which point we no longer need
             the information.  */
-         make_cleanup (free, n);
+         make_cleanup (xfree, n);
        }
     }
 }
@@ -321,13 +252,8 @@ struct find_targ_sec_arg
     asection **resultp;
   };
 
-static void find_targ_sec (bfd *, asection *, void *);
-
 static void
-find_targ_sec (abfd, sect, obj)
-     bfd *abfd;
-     asection *sect;
-     PTR obj;
+find_targ_sec (bfd *abfd, asection *sect, void *obj)
 {
   struct find_targ_sec_arg *args = (struct find_targ_sec_arg *) obj;
   if (sect->target_index == args->targ_index)
@@ -336,9 +262,7 @@ find_targ_sec (abfd, sect, obj)
 
 /* Return the section number (SECT_OFF_*) that CS points to.  */
 static int
-cs_to_section (cs, objfile)
-     struct coff_symbol *cs;
-     struct objfile *objfile;
+cs_to_section (struct coff_symbol *cs, struct objfile *objfile)
 {
   asection *sect = NULL;
   struct find_targ_sec_arg args;
@@ -355,7 +279,8 @@ cs_to_section (cs, objfile)
       else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
        off = SECT_OFF_DATA (objfile);
       else
-       off = SECT_OFF_BSS (objfile);
+       /* Just return the bfd section index. */
+       off = sect->index;
     }
   return off;
 }
@@ -365,9 +290,7 @@ cs_to_section (cs, objfile)
 static CORE_ADDR cs_section_address (struct coff_symbol *, bfd *);
 
 static CORE_ADDR
-cs_section_address (cs, abfd)
-     struct coff_symbol *cs;
-     bfd *abfd;
+cs_section_address (struct coff_symbol *cs, bfd *abfd)
 {
   asection *sect = NULL;
   struct find_targ_sec_arg args;
@@ -389,8 +312,7 @@ cs_section_address (cs, abfd)
    or for associating a new type with the index.  */
 
 static struct type **
-coff_lookup_type (index)
-     register int index;
+coff_lookup_type (register int index)
 {
   if (index >= type_vector_length)
     {
@@ -414,8 +336,7 @@ coff_lookup_type (index)
    This can create an empty (zeroed) type object.  */
 
 static struct type *
-coff_alloc_type (index)
-     int index;
+coff_alloc_type (int index)
 {
   register struct type **type_addr = coff_lookup_type (index);
   register struct type *type = *type_addr;
@@ -436,8 +357,7 @@ coff_alloc_type (index)
    it indicates the start of data for one original source file.  */
 
 static void
-coff_start_symtab (name)
-     char *name;
+coff_start_symtab (char *name)
 {
   start_symtab (
   /* We fill in the filename later.  start_symtab puts
@@ -459,13 +379,10 @@ coff_start_symtab (name)
    text address for the file, and SIZE is the number of bytes of text.  */
 
 static void
-complete_symtab (name, start_addr, size)
-     char *name;
-     CORE_ADDR start_addr;
-     unsigned int size;
+complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
 {
   if (last_source_file != NULL)
-    free (last_source_file);
+    xfree (last_source_file);
   last_source_file = savestring (name, strlen (name));
   current_source_start_addr = start_addr;
   current_source_end_addr = start_addr + size;
@@ -484,14 +401,13 @@ complete_symtab (name, start_addr, size)
    struct symtab for that file and put it in the list of all such. */
 
 static void
-coff_end_symtab (objfile)
-     struct objfile *objfile;
+coff_end_symtab (struct objfile *objfile)
 {
   struct symtab *symtab;
 
   last_source_start_addr = current_source_start_addr;
 
-  symtab = end_symtab (current_source_end_addr, objfile, 0);
+  symtab = end_symtab (current_source_end_addr, objfile, SECT_OFF_TEXT (objfile));
 
   if (symtab != NULL)
     free_named_symtabs (symtab->filename);
@@ -501,11 +417,8 @@ coff_end_symtab (objfile)
 }
 \f
 static void
-record_minimal_symbol (name, address, type, objfile)
-     char *name;
-     CORE_ADDR address;
-     enum minimal_symbol_type type;
-     struct objfile *objfile;
+record_minimal_symbol (char *name, CORE_ADDR address,
+                      enum minimal_symbol_type type, struct objfile *objfile)
 {
   /* We don't want TDESC entry points in the minimal symbol table */
   if (name[0] == '@')
@@ -528,14 +441,14 @@ record_minimal_symbol (name, address, type, objfile)
    The ultimate result is a new symtab (or, FIXME, eventually a psymtab).  */
 
 static void
-coff_symfile_init (objfile)
-     struct objfile *objfile;
+coff_symfile_init (struct objfile *objfile)
 {
   /* Allocate struct to keep track of stab reading. */
   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));
 
   /* Allocate struct to keep track of the symfile */
   objfile->sym_private = xmmalloc (objfile->md,
@@ -557,10 +470,7 @@ coff_symfile_init (objfile)
 
 /* ARGSUSED */
 static void
-find_linenos (abfd, asect, vpinfo)
-     bfd *abfd;
-     sec_ptr asect;
-     PTR vpinfo;
+find_linenos (bfd *abfd, sec_ptr asect, void *vpinfo)
 {
   struct coff_symfile_info *info;
   int size, count;
@@ -597,9 +507,7 @@ static bfd *symfile_bfd;
 
 /* ARGSUSED */
 static void
-coff_symfile_read (objfile, mainline)
-     struct objfile *objfile;
-     int mainline;
+coff_symfile_read (struct objfile *objfile, int mainline)
 {
   struct coff_symfile_info *info;
   struct dbx_symfile_info *dbxinfo;
@@ -610,7 +518,7 @@ coff_symfile_read (objfile, mainline)
   unsigned int num_symbols;
   int symtab_offset;
   int stringtab_offset;
-  struct cleanup *back_to;
+  struct cleanup *back_to, *cleanup_minimal_symbols;
   int stabstrsize;
   int len;
   char * target;
@@ -653,16 +561,34 @@ coff_symfile_read (objfile, mainline)
 
 /* End of warning */
 
-  /* Read the line number table, all at once.  */
   info->min_lineno_offset = 0;
   info->max_lineno_offset = 0;
-  bfd_map_over_sections (abfd, find_linenos, (PTR) info);
 
-  make_cleanup (free_linetab_cleanup, 0 /*ignore*/);
-  val = init_lineno (abfd, info->min_lineno_offset,
-                    info->max_lineno_offset - info->min_lineno_offset);
-  if (val < 0)
-    error ("\"%s\": error reading line numbers\n", name);
+  /* Only read line number information if we have symbols.
+
+     On Windows NT, some of the system's DLL's have sections with
+     PointerToLinenumbers fields that are non-zero, but point at
+     random places within the image file.  (In the case I found,
+     KERNEL32.DLL's .text section has a line number info pointer that
+     points into the middle of the string `lib\\i386\kernel32.dll'.)
+
+     However, these DLL's also have no symbols.  The line number
+     tables are meaningless without symbols.  And in fact, GDB never
+     uses the line number information unless there are symbols.  So we
+     can avoid spurious error messages (and maybe run a little
+     faster!) by not even reading the line number table unless we have
+     symbols.  */
+  if (num_symbols > 0)
+    {
+      /* Read the line number table, all at once.  */
+      bfd_map_over_sections (abfd, find_linenos, (void *) info);
+
+      make_cleanup (free_linetab_cleanup, 0 /*ignore*/);
+      val = init_lineno (abfd, info->min_lineno_offset,
+                         info->max_lineno_offset - info->min_lineno_offset);
+      if (val < 0)
+        error ("\"%s\": error reading line numbers\n", name);
+    }
 
   /* Now read the string table, all at once.  */
 
@@ -672,7 +598,7 @@ coff_symfile_read (objfile, mainline)
     error ("\"%s\": can't get string table", name);
 
   init_minimal_symbol_collection ();
-  make_cleanup_discard_minimal_symbols ();
+  cleanup_minimal_symbols = make_cleanup_discard_minimal_symbols ();
 
   /* Now that the executable file is positioned at symbol table,
      process it and define symbols accordingly.  */
@@ -693,19 +619,19 @@ coff_symfile_read (objfile, mainline)
 
   install_minimal_symbols (objfile);
 
-  bfd_map_over_sections (abfd, coff_locate_sections, (PTR) info);
+  /* Free the installed minimal symbol data.  */
+  do_cleanups (cleanup_minimal_symbols);
+
+  bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
 
   if (info->stabsects)
     {
       if (!info->stabstrsect)
        {
-         error_begin ();
-         fprintf_filtered
-           (gdb_stderr,
-            ("The debugging information in `%s' is corrupted.\n"
-          "The file has a `.stabs' section, but no `.stabstr' section.\n"),
-            name);
-         return_to_top_level (RETURN_ERROR);
+         error (("The debugging information in `%s' is corrupted.\n"
+                 "The file has a `.stabs' section, but no `.stabstr' "
+                 "section."),
+                name);
        }
 
       /* FIXME: dubious.  Why can't we use something normal like
@@ -720,13 +646,17 @@ coff_symfile_read (objfile, mainline)
                               info->stabsects,
                               info->stabstrsect->filepos, stabstrsize);
     }
+  if (dwarf2_has_info (abfd))
+    {
+      /* DWARF2 sections.  */
+      dwarf2_build_psymtabs (objfile, mainline);
+    }
 
   do_cleanups (back_to);
 }
 
 static void
-coff_new_init (ignore)
-     struct objfile *ignore;
+coff_new_init (struct objfile *ignore)
 {
 }
 
@@ -736,12 +666,11 @@ coff_new_init (ignore)
    objfile struct from the global list of known objfiles. */
 
 static void
-coff_symfile_finish (objfile)
-     struct objfile *objfile;
+coff_symfile_finish (struct objfile *objfile)
 {
   if (objfile->sym_private != NULL)
     {
-      mfree (objfile->md, objfile->sym_private);
+      xmfree (objfile->md, objfile->sym_private);
     }
 
   /* Let stabs reader clean up */
@@ -755,10 +684,8 @@ coff_symfile_finish (objfile)
    We read them one at a time using read_one_sym ().  */
 
 static void
-coff_symtab_read (symtab_offset, nsyms, objfile)
-     long symtab_offset;
-     unsigned int nsyms;
-     struct objfile *objfile;
+coff_symtab_read (long symtab_offset, unsigned int nsyms,
+                 struct objfile *objfile)
 {
   register struct context_stack *new;
   struct coff_symbol coff_symbol;
@@ -776,7 +703,7 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
   char *filestring = "";
   int depth = 0;
   int fcn_first_line = 0;
-  CORE_ADDR fcn_first_line_addr;
+  CORE_ADDR fcn_first_line_addr = 0;
   int fcn_last_line = 0;
   int fcn_start_addr = 0;
   long fcn_line_ptr = 0;
@@ -811,7 +738,7 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
   memset (opaque_type_chain, 0, sizeof opaque_type_chain);
 
   if (type_vector)             /* Get rid of previous one */
-    free ((PTR) type_vector);
+    xfree (type_vector);
   type_vector_length = 160;
   type_vector = (struct type **)
     xmalloc (type_vector_length * sizeof (struct type *));
@@ -865,7 +792,8 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
        case C_LINE:
        case C_ALIAS:
        case C_HIDDEN:
-         complain (&bad_sclass_complaint, cs->c_name);
+         complaint (&symfile_complaints, "Bad n_sclass for symbol %s",
+                    cs->c_name);
          break;
 
        case C_FILE:
@@ -977,10 +905,7 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
                      cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXTFUNC
                      || cs->c_sclass == C_THUMBEXT ?
                      mst_text : mst_file_text;
-#ifdef SMASH_TEXT_ADDRESS
-                   if (tmpaddr & 1)    /* FIXME: delete this line */
-                     SMASH_TEXT_ADDRESS (tmpaddr);
-#endif
+                   tmpaddr = SMASH_TEXT_ADDRESS (tmpaddr);
                  }
                else if (sec == SECT_OFF_DATA (objfile))
                  {
@@ -1002,13 +927,17 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
              {
                struct minimal_symbol *msym;
 
+               /* FIXME: cagney/2001-02-01: The nasty (int) -> (long)
+                   -> (void*) cast is to ensure that that the value of
+                   cs->c_sclass can be correctly stored in a void
+                   pointer in MSYMBOL_INFO.  Better solutions
+                   welcome. */
+               gdb_assert (sizeof (void *) >= sizeof (cs->c_sclass));
                msym = prim_record_minimal_symbol_and_info
-                 (cs->c_name, tmpaddr, ms_type, (char *) cs->c_sclass, sec,
-                  NULL, objfile);
-#ifdef COFF_MAKE_MSYMBOL_SPECIAL
+                 (cs->c_name, tmpaddr, ms_type, (void *) (long) cs->c_sclass,
+                  sec, NULL, objfile);
                if (msym)
                  COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym);
-#endif
              }
            if (SDB_TYPE (cs->c_type))
              {
@@ -1030,7 +959,8 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
              /* main_aux.x_sym.x_misc.x_lnsz.x_lnno
                 contains line number of '{' } */
              if (cs->c_naux != 1)
-               complain (&bf_no_aux_complaint, cs->c_symnum);
+               complaint (&symfile_complaints,
+                          "`.bf' symbol %d has no aux entry", cs->c_symnum);
              fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
              fcn_first_line_addr = cs->c_value;
 
@@ -1045,6 +975,8 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
            }
          else if (STREQ (cs->c_name, ".ef"))
            {
+             if (!within_function)
+               error ("Bad coff function information\n");
              /* the value of .ef is the address of epilogue code;
                 not useful for gdb.  */
              /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
@@ -1052,7 +984,9 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
 
              if (context_stack_depth <= 0)
                {               /* We attempted to pop an empty context stack */
-                 complain (&ef_stack_complaint, cs->c_symnum);
+                 complaint (&symfile_complaints,
+                            "`.ef' symbol without matching `.bf' symbol ignored starting at symnum %d",
+                            cs->c_symnum);
                  within_function = 0;
                  break;
                }
@@ -1061,13 +995,16 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
              /* Stack must be empty now.  */
              if (context_stack_depth > 0 || new == NULL)
                {
-                 complain (&ef_complaint, cs->c_symnum);
+                 complaint (&symfile_complaints,
+                            "Unmatched .ef symbol(s) ignored starting at symnum %d",
+                            cs->c_symnum);
                  within_function = 0;
                  break;
                }
              if (cs->c_naux != 1)
                {
-                 complain (&ef_no_aux_complaint, cs->c_symnum);
+                 complaint (&symfile_complaints,
+                            "`.ef' symbol %d has no aux entry", cs->c_symnum);
                  fcn_last_line = 0x7FFFFFFF;
                }
              else
@@ -1122,14 +1059,18 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
            {
              if (context_stack_depth <= 0)
                {               /* We attempted to pop an empty context stack */
-                 complain (&eb_stack_complaint, cs->c_symnum);
+                 complaint (&symfile_complaints,
+                            "`.eb' symbol without matching `.bb' symbol ignored starting at symnum %d",
+                            cs->c_symnum);
                  break;
                }
 
              new = pop_context ();
              if (depth-- != new->depth)
                {
-                 complain (&eb_complaint, symnum);
+                 complaint (&symfile_complaints,
+                            "Mismatched .eb symbol ignored starting at symnum %d",
+                            symnum);
                  break;
                }
              if (local_symbols && context_stack_depth > 0)
@@ -1151,6 +1092,13 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
        }
     }
 
+  if ((nsyms == 0) && (pe_file))
+    {
+      /* We've got no debugging symbols, but it's is a portable
+        executable, so try to read the export table */
+      read_pe_exported_syms (objfile);
+    }
+
   if (last_source_file)
     coff_end_symtab (objfile);
 
@@ -1169,26 +1117,25 @@ coff_symtab_read (symtab_offset, nsyms, objfile)
    in internal_auxent form, and skip any other auxents.  */
 
 static void
-read_one_sym (cs, sym, aux)
-     register struct coff_symbol *cs;
-     register struct internal_syment *sym;
-     register union internal_auxent *aux;
+read_one_sym (register struct coff_symbol *cs,
+             register struct internal_syment *sym,
+             register union internal_auxent *aux)
 {
   int i;
 
   cs->c_symnum = symnum;
-  bfd_read (temp_sym, local_symesz, 1, nlist_bfd_global);
+  bfd_bread (temp_sym, local_symesz, nlist_bfd_global);
   bfd_coff_swap_sym_in (symfile_bfd, temp_sym, (char *) sym);
   cs->c_naux = sym->n_numaux & 0xff;
   if (cs->c_naux >= 1)
     {
-      bfd_read (temp_aux, local_auxesz, 1, nlist_bfd_global);
+      bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
       bfd_coff_swap_aux_in (symfile_bfd, temp_aux, sym->n_type, sym->n_sclass,
                            0, cs->c_naux, (char *) aux);
       /* If more than one aux entry, read past it (only the first aux
          is important). */
       for (i = 1; i < cs->c_naux; i++)
-       bfd_read (temp_aux, local_auxesz, 1, nlist_bfd_global);
+       bfd_bread (temp_aux, local_auxesz, nlist_bfd_global);
     }
   cs->c_name = getsymname (sym);
   cs->c_value = sym->n_value;
@@ -1239,9 +1186,7 @@ read_one_sym (cs, sym, aux)
 static char *stringtab = NULL;
 
 static int
-init_stringtab (abfd, offset)
-     bfd *abfd;
-     long offset;
+init_stringtab (bfd *abfd, long offset)
 {
   long length;
   int val;
@@ -1257,7 +1202,7 @@ init_stringtab (abfd, offset)
   if (bfd_seek (abfd, offset, 0) < 0)
     return -1;
 
-  val = bfd_read ((char *) lengthbuf, sizeof lengthbuf, 1, abfd);
+  val = bfd_bread ((char *) lengthbuf, sizeof lengthbuf, abfd);
   length = bfd_h_get_32 (symfile_bfd, lengthbuf);
 
   /* If no string table is needed, then the file may end immediately
@@ -1272,7 +1217,8 @@ init_stringtab (abfd, offset)
   if (length == sizeof length) /* Empty table -- just the count */
     return 0;
 
-  val = bfd_read (stringtab + sizeof lengthbuf, length - sizeof lengthbuf, 1, abfd);
+  val = bfd_bread (stringtab + sizeof lengthbuf, length - sizeof lengthbuf,
+                  abfd);
   if (val != length - sizeof lengthbuf || stringtab[length - 1] != '\0')
     return -1;
 
@@ -1280,10 +1226,10 @@ init_stringtab (abfd, offset)
 }
 
 static void
-free_stringtab ()
+free_stringtab (void)
 {
   if (stringtab)
-    free (stringtab);
+    xfree (stringtab);
   stringtab = NULL;
 }
 
@@ -1294,8 +1240,7 @@ free_stringtab_cleanup (void *ignore)
 }
 
 static char *
-getsymname (symbol_entry)
-     struct internal_syment *symbol_entry;
+getsymname (struct internal_syment *symbol_entry)
 {
   static char buffer[SYMNMLEN + 1];
   char *result;
@@ -1320,8 +1265,7 @@ getsymname (symbol_entry)
    is only good for temporary use.  */
 
 static char *
-coff_getfilename (aux_entry)
-     union internal_auxent *aux_entry;
+coff_getfilename (union internal_auxent *aux_entry)
 {
   static char buffer[BUFSIZ];
   register char *temp;
@@ -1355,10 +1299,7 @@ static unsigned long linetab_size;
    them into GDB's data structures.  */
 
 static int
-init_lineno (abfd, offset, size)
-     bfd *abfd;
-     long offset;
-     int size;
+init_lineno (bfd *abfd, long offset, int size)
 {
   int val;
 
@@ -1376,7 +1317,7 @@ init_lineno (abfd, offset, size)
   /* Allocate the desired table, plus a sentinel */
   linetab = (char *) xmalloc (size + local_linesz);
 
-  val = bfd_read (linetab, size, 1, abfd);
+  val = bfd_bread (linetab, size, abfd);
   if (val != size)
     return -1;
 
@@ -1387,10 +1328,10 @@ init_lineno (abfd, offset, size)
 }
 
 static void
-free_linetab ()
+free_linetab (void)
 {
   if (linetab)
-    free (linetab);
+    xfree (linetab);
   linetab = NULL;
 }
 
@@ -1405,11 +1346,8 @@ free_linetab_cleanup (void *ignore)
 #endif
 
 static void
-enter_linenos (file_offset, first_line, last_line, objfile)
-     long file_offset;
-     register int first_line;
-     register int last_line;
-     struct objfile *objfile;
+enter_linenos (long file_offset, register int first_line,
+              register int last_line, struct objfile *objfile)
 {
   register char *rawptr;
   struct internal_lineno lptr;
@@ -1418,7 +1356,9 @@ enter_linenos (file_offset, first_line, last_line, objfile)
     return;
   if (file_offset < linetab_offset)
     {
-      complain (&lineno_complaint, file_offset);
+      complaint (&symfile_complaints,
+                "Line number pointer %ld lower than start of line numbers",
+                file_offset);
       if (file_offset > linetab_size)  /* Too big to be an offset? */
        return;
       file_offset += linetab_offset;   /* Try reading at that linetab offset */
@@ -1446,9 +1386,7 @@ enter_linenos (file_offset, first_line, last_line, objfile)
 }
 \f
 static void
-patch_type (type, real_type)
-     struct type *type;
-     struct type *real_type;
+patch_type (struct type *type, struct type *real_type)
 {
   register struct type *target = TYPE_TARGET_TYPE (type);
   register struct type *real_target = TYPE_TARGET_TYPE (real_type);
@@ -1463,7 +1401,7 @@ patch_type (type, real_type)
   if (TYPE_NAME (real_target))
     {
       if (TYPE_NAME (target))
-       free (TYPE_NAME (target));
+       xfree (TYPE_NAME (target));
       TYPE_NAME (target) = concat (TYPE_NAME (real_target), NULL);
     }
 }
@@ -1472,8 +1410,7 @@ patch_type (type, real_type)
    so that they can be used to print out opaque data structures properly.  */
 
 static void
-patch_opaque_types (s)
-     struct symtab *s;
+patch_opaque_types (struct symtab *s)
 {
   register struct block *b;
   register int i;
@@ -1481,27 +1418,26 @@ patch_opaque_types (s)
 
   /* Go through the per-file symbols only */
   b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
-  for (i = BLOCK_NSYMS (b) - 1; i >= 0; i--)
+  ALL_BLOCK_SYMBOLS (b, i, real_sym)
     {
       /* Find completed typedefs to use to fix opaque ones.
          Remove syms from the chain when their types are stored,
          but search the whole chain, as there may be several syms
          from different files with the same name.  */
-      real_sym = BLOCK_SYM (b, i);
       if (SYMBOL_CLASS (real_sym) == LOC_TYPEDEF &&
          SYMBOL_NAMESPACE (real_sym) == VAR_NAMESPACE &&
          TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR &&
          TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
        {
-         register char *name = SYMBOL_NAME (real_sym);
+         register char *name = DEPRECATED_SYMBOL_NAME (real_sym);
          register int hash = hashname (name);
          register struct symbol *sym, *prev;
 
          prev = 0;
          for (sym = opaque_type_chain[hash]; sym;)
            {
-             if (name[0] == SYMBOL_NAME (sym)[0] &&
-                 STREQ (name + 1, SYMBOL_NAME (sym) + 1))
+             if (name[0] == DEPRECATED_SYMBOL_NAME (sym)[0] &&
+                 STREQ (name + 1, DEPRECATED_SYMBOL_NAME (sym) + 1))
                {
                  if (prev)
                    {
@@ -1534,10 +1470,9 @@ patch_opaque_types (s)
 }
 \f
 static struct symbol *
-process_coff_symbol (cs, aux, objfile)
-     register struct coff_symbol *cs;
-     register union internal_auxent *aux;
-     struct objfile *objfile;
+process_coff_symbol (register struct coff_symbol *cs,
+                    register union internal_auxent *aux,
+                    struct objfile *objfile)
 {
   register struct symbol *sym
   = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
@@ -1547,10 +1482,8 @@ process_coff_symbol (cs, aux, objfile)
   memset (sym, 0, sizeof (struct symbol));
   name = cs->c_name;
   name = EXTERNAL_NAME (name, objfile->obfd);
-  SYMBOL_NAME (sym) = obsavestring (name, strlen (name),
-                                   &objfile->symbol_obstack);
   SYMBOL_LANGUAGE (sym) = language_auto;
-  SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
+  SYMBOL_SET_NAMES (sym, name, strlen (name), objfile);
 
   /* default assumptions */
   SYMBOL_VALUE (sym) = cs->c_value;
@@ -1628,7 +1561,7 @@ process_coff_symbol (cs, aux, objfile)
          SYMBOL_CLASS (sym) = LOC_ARG;
          add_symbol_to_list (sym, &local_symbols);
 #if !defined (BELIEVE_PCC_PROMOTION)
-         if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+         if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
            {
              /* If PCC says a parameter is a short or a char,
                 aligned on an int boundary, realign it to the
@@ -1706,7 +1639,7 @@ process_coff_symbol (cs, aux, objfile)
                }
              else
                TYPE_NAME (SYMBOL_TYPE (sym)) =
-                 concat (SYMBOL_NAME (sym), NULL);
+                 concat (DEPRECATED_SYMBOL_NAME (sym), NULL);
            }
 #ifdef CXUX_TARGET
          /* Ignore vendor section for Harris CX/UX targets. */
@@ -1724,7 +1657,7 @@ process_coff_symbol (cs, aux, objfile)
              TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (sym))) !=
              TYPE_CODE_UNDEF)
            {
-             register int i = hashname (SYMBOL_NAME (sym));
+             register int i = hashname (DEPRECATED_SYMBOL_NAME (sym));
 
              SYMBOL_VALUE_CHAIN (sym) = opaque_type_chain[i];
              opaque_type_chain[i] = sym;
@@ -1742,11 +1675,11 @@ process_coff_symbol (cs, aux, objfile)
             names for anonymous enums, structures, and unions, like
             "~0fake" or ".0fake".  Thanks, but no thanks... */
          if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0)
-           if (SYMBOL_NAME (sym) != NULL
-               && *SYMBOL_NAME (sym) != '~'
-               && *SYMBOL_NAME (sym) != '.')
+           if (DEPRECATED_SYMBOL_NAME (sym) != NULL
+               && *DEPRECATED_SYMBOL_NAME (sym) != '~'
+               && *DEPRECATED_SYMBOL_NAME (sym) != '.')
              TYPE_TAG_NAME (SYMBOL_TYPE (sym)) =
-               concat (SYMBOL_NAME (sym), NULL);
+               concat (DEPRECATED_SYMBOL_NAME (sym), NULL);
 
          add_symbol_to_list (sym, &file_symbols);
          break;
@@ -1761,10 +1694,8 @@ process_coff_symbol (cs, aux, objfile)
 /* Decode a coff type specifier;  return the type that is meant.  */
 
 static struct type *
-decode_type (cs, c_type, aux)
-     register struct coff_symbol *cs;
-     unsigned int c_type;
-     register union internal_auxent *aux;
+decode_type (register struct coff_symbol *cs, unsigned int c_type,
+            register union internal_auxent *aux)
 {
   register struct type *type = 0;
   unsigned int new_c_type;
@@ -1830,7 +1761,9 @@ decode_type (cs, c_type, aux)
        }
       else
        {
-         complain (&tagndx_bad_complaint, cs->c_name);
+         complaint (&symfile_complaints,
+                    "Symbol table entry for %s has bad tagndx value",
+                    cs->c_name);
          /* And fall through to decode_base_type... */
        }
     }
@@ -1842,10 +1775,8 @@ decode_type (cs, c_type, aux)
    return the type that the function returns.  */
 
 static struct type *
-decode_function_type (cs, c_type, aux)
-     register struct coff_symbol *cs;
-     unsigned int c_type;
-     register union internal_auxent *aux;
+decode_function_type (register struct coff_symbol *cs, unsigned int c_type,
+                     register union internal_auxent *aux)
 {
   if (aux->x_sym.x_tagndx.l == 0)
     cs->c_naux = 0;            /* auxent refers to function, not base type */
@@ -1856,10 +1787,8 @@ decode_function_type (cs, c_type, aux)
 /* basic C types */
 
 static struct type *
-decode_base_type (cs, c_type, aux)
-     register struct coff_symbol *cs;
-     unsigned int c_type;
-     register union internal_auxent *aux;
+decode_base_type (register struct coff_symbol *cs, unsigned int c_type,
+                 register union internal_auxent *aux)
 {
   struct type *type;
 
@@ -2000,7 +1929,7 @@ decode_base_type (cs, c_type, aux)
       else
        return lookup_fundamental_type (current_objfile, FT_UNSIGNED_LONG);
     }
-  complain (&unexpected_type_complaint, cs->c_name);
+  complaint (&symfile_complaints, "Unexpected type for symbol %s", cs->c_name);
   return lookup_fundamental_type (current_objfile, FT_VOID);
 }
 \f
@@ -2010,10 +1939,7 @@ decode_base_type (cs, c_type, aux)
    object describing the type.  */
 
 static struct type *
-coff_read_struct_type (index, length, lastsym)
-     int index;
-     int length;
-     int lastsym;
+coff_read_struct_type (int index, int length, int lastsym)
 {
   struct nextfield
     {
@@ -2062,6 +1988,7 @@ coff_read_struct_type (index, length, lastsym)
          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;
+         FIELD_STATIC_KIND (list->field) = 0;
          nfields++;
          break;
 
@@ -2080,6 +2007,7 @@ coff_read_struct_type (index, length, lastsym)
          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;
+         FIELD_STATIC_KIND (list->field) = 0;
          nfields++;
          break;
 
@@ -2108,10 +2036,7 @@ coff_read_struct_type (index, length, lastsym)
 
 /* ARGSUSED */
 static struct type *
-coff_read_enum_type (index, length, lastsym)
-     int index;
-     int length;
-     int lastsym;
+coff_read_enum_type (int index, int length, int lastsym)
 {
   register struct symbol *sym;
   register struct type *type;
@@ -2150,7 +2075,7 @@ coff_read_enum_type (index, length, lastsym)
             sizeof (struct symbol));
          memset (sym, 0, sizeof (struct symbol));
 
-         SYMBOL_NAME (sym) =
+         DEPRECATED_SYMBOL_NAME (sym) =
            obsavestring (name, strlen (name),
                          &current_objfile->symbol_obstack);
          SYMBOL_CLASS (sym) = LOC_CONST;
@@ -2198,11 +2123,12 @@ coff_read_enum_type (index, length, lastsym)
        {
          struct symbol *xsym = syms->symbol[j];
          SYMBOL_TYPE (xsym) = type;
-         TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
+         TYPE_FIELD_NAME (type, n) = DEPRECATED_SYMBOL_NAME (xsym);
          TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
          if (SYMBOL_VALUE (xsym) < 0)
            unsigned_enum = 0;
          TYPE_FIELD_BITSIZE (type, n) = 0;
+         TYPE_FIELD_STATIC_KIND (type, n) = 0;
        }
       if (syms == osyms)
        break;
@@ -2228,7 +2154,7 @@ static struct sym_fns coff_sym_fns =
 };
 
 void
-_initialize_coffread ()
+_initialize_coffread (void)
 {
   add_symtab_fns (&coff_sym_fns);
 }
This page took 0.03763 seconds and 4 git commands to generate.