Eliminate PARAMS from function pointer declarations.
[deliverable/binutils-gdb.git] / gdb / dbxread.c
index 73eb3f4f4c8cbd612ad3e3d4e902603880352650..10e153544ead9bc13422bfec86f73dd7f6f5a67e 100644 (file)
@@ -265,73 +265,56 @@ static int bincls_allocated;
 
 /* Local function prototypes */
 
-extern void _initialize_dbxread PARAMS ((void));
+extern void _initialize_dbxread (void);
 
-static void
-process_now PARAMS ((struct objfile *));
+static void process_now (struct objfile *);
 
-static void
-free_header_files PARAMS ((void));
+static void free_header_files (void);
 
-static void
-init_header_files PARAMS ((void));
+static void init_header_files (void);
 
-static void
-read_ofile_symtab PARAMS ((struct partial_symtab *));
+static void read_ofile_symtab (struct partial_symtab *);
 
-static void
-dbx_psymtab_to_symtab PARAMS ((struct partial_symtab *));
+static void dbx_psymtab_to_symtab (struct partial_symtab *);
 
-static void
-dbx_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *));
+static void dbx_psymtab_to_symtab_1 (struct partial_symtab *);
 
-static void
-read_dbx_dynamic_symtab PARAMS ((struct objfile * objfile));
+static void read_dbx_dynamic_symtab (struct objfile *objfile);
 
-static void
-read_dbx_symtab PARAMS ((struct objfile *, CORE_ADDR, int));
+static void read_dbx_symtab (struct objfile *);
 
-static void
-free_bincl_list PARAMS ((struct objfile *));
+static void free_bincl_list (struct objfile *);
 
-static struct partial_symtab *
-  find_corresponding_bincl_psymtab PARAMS ((char *, int));
+static struct partial_symtab *find_corresponding_bincl_psymtab (char *, int);
 
-static void
-add_bincl_to_list PARAMS ((struct partial_symtab *, char *, int));
+static void add_bincl_to_list (struct partial_symtab *, char *, int);
 
-static void
-init_bincl_list PARAMS ((int, struct objfile *));
+static void init_bincl_list (int, struct objfile *);
 
-static char *
-  dbx_next_symbol_text PARAMS ((struct objfile *));
+static char *dbx_next_symbol_text (struct objfile *);
 
-static void
-fill_symbuf PARAMS ((bfd *));
+static void fill_symbuf (bfd *);
 
-static void
-dbx_symfile_init PARAMS ((struct objfile *));
+static void dbx_symfile_init (struct objfile *);
 
-static void
-dbx_new_init PARAMS ((struct objfile *));
+static void dbx_new_init (struct objfile *);
 
-static void
-dbx_symfile_read PARAMS ((struct objfile *, int));
+static void dbx_symfile_read (struct objfile *, int);
 
-static void
-dbx_symfile_finish PARAMS ((struct objfile *));
+static void dbx_symfile_finish (struct objfile *);
 
-static void
-record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *));
+static void record_minimal_symbol (char *, CORE_ADDR, int, struct objfile *);
 
-static void
-add_new_header_file PARAMS ((char *, int));
+static void add_new_header_file (char *, int);
 
-static void
-add_old_header_file PARAMS ((char *, int));
+static void add_old_header_file (char *, int);
 
-static void
-add_this_object_header_file PARAMS ((int));
+static void add_this_object_header_file (int);
+
+static struct partial_symtab *start_psymtab (struct objfile *, char *,
+                                            CORE_ADDR, int,
+                                            struct partial_symbol **,
+                                            struct partial_symbol **);
 
 /* Free up old header file tables */
 
@@ -484,17 +467,17 @@ record_minimal_symbol (name, address, type, objfile)
     {
     case N_TEXT | N_EXT:
       ms_type = mst_text;
-      section = SECT_OFF_TEXT;
+      section = SECT_OFF_TEXT (objfile);
       bfd_section = DBX_TEXT_SECTION (objfile);
       break;
     case N_DATA | N_EXT:
       ms_type = mst_data;
-      section = SECT_OFF_DATA;
+      section = SECT_OFF_DATA (objfile);
       bfd_section = DBX_DATA_SECTION (objfile);
       break;
     case N_BSS | N_EXT:
       ms_type = mst_bss;
-      section = SECT_OFF_BSS;
+      section = SECT_OFF_BSS (objfile);
       bfd_section = DBX_BSS_SECTION (objfile);
       break;
     case N_ABS | N_EXT:
@@ -505,7 +488,7 @@ record_minimal_symbol (name, address, type, objfile)
 #ifdef N_SETV
     case N_SETV | N_EXT:
       ms_type = mst_data;
-      section = SECT_OFF_DATA;
+      section = SECT_OFF_DATA (objfile);
       bfd_section = DBX_DATA_SECTION (objfile);
       break;
     case N_SETV:
@@ -513,7 +496,7 @@ record_minimal_symbol (name, address, type, objfile)
          of going over many .o files, it doesn't make sense to have one
          file local.  */
       ms_type = mst_file_data;
-      section = SECT_OFF_DATA;
+      section = SECT_OFF_DATA (objfile);
       bfd_section = DBX_DATA_SECTION (objfile);
       break;
 #endif
@@ -522,7 +505,7 @@ record_minimal_symbol (name, address, type, objfile)
     case N_FN:
     case N_FN_SEQ:
       ms_type = mst_file_text;
-      section = SECT_OFF_TEXT;
+      section = SECT_OFF_TEXT (objfile);
       bfd_section = DBX_TEXT_SECTION (objfile);
       break;
     case N_DATA:
@@ -543,12 +526,12 @@ record_minimal_symbol (name, address, type, objfile)
        if (VTBL_PREFIX_P ((tempstring)))
          ms_type = mst_data;
       }
-      section = SECT_OFF_DATA;
+      section = SECT_OFF_DATA (objfile);
       bfd_section = DBX_DATA_SECTION (objfile);
       break;
     case N_BSS:
       ms_type = mst_file_bss;
-      section = SECT_OFF_BSS;
+      section = SECT_OFF_BSS (objfile);
       bfd_section = DBX_BSS_SECTION (objfile);
       break;
     default:
@@ -571,8 +554,6 @@ record_minimal_symbol (name, address, type, objfile)
    put all the relevant info into a "struct dbx_symfile_info",
    hung off the objfile structure.
 
-   SECTION_OFFSETS contains offsets relative to which the symbols in the
-   various sections are (depending where the sections were actually loaded).
    MAINLINE is true if we are reading the main symbol
    table (as opposed to a shared lib or dynamically loaded file).  */
 
@@ -585,8 +566,6 @@ dbx_symfile_read (objfile, mainline)
   int val;
   struct cleanup *back_to;
 
-  val = strlen (objfile->name);
-
   sym_bfd = objfile->obfd;
 
   /* .o and .nlm files are relocatables with text, data and bss segs based at
@@ -604,6 +583,7 @@ dbx_symfile_read (objfile, mainline)
      || (0 == strncmp (bfd_get_target (sym_bfd), "som", 3))
      || (0 == strncmp (bfd_get_target (sym_bfd), "coff", 4))
      || (0 == strncmp (bfd_get_target (sym_bfd), "pe", 2))
+     || (0 == strncmp (bfd_get_target (sym_bfd), "epoc-pe", 7))
      || (0 == strncmp (bfd_get_target (sym_bfd), "nlm", 3)));
 
   val = bfd_seek (sym_bfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET);
@@ -623,14 +603,11 @@ dbx_symfile_read (objfile, mainline)
   back_to = make_cleanup (really_free_pendings, 0);
 
   init_minimal_symbol_collection ();
-  make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0);
+  make_cleanup_discard_minimal_symbols ();
 
-  /* Now that the symbol table data of the executable file are all in core,
-     process them and define symbols accordingly.  */
+  /* Read stabs data from executable file and define symbols. */
 
-  read_dbx_symtab (objfile,
-                  DBX_TEXT_ADDR (objfile),
-                  DBX_TEXT_SIZE (objfile));
+  read_dbx_symtab (objfile);
 
   /* Add the dynamic symbols.  */
 
@@ -832,7 +809,7 @@ struct cont_elem
     int sym_idx;
     int sym_end;
     int symnum;
-    int (*func) PARAMS ((struct objfile *, struct symbol *, char *));
+    int (*func) (struct objfile *, struct symbol *, char *);
     /* other state dependancies include:
        (assumption is that these will not change since process_now FIXME!!)
        stringtab_global
@@ -851,7 +828,7 @@ void
 process_later (sym, p, f)
      struct symbol *sym;
      char *p;
-     int (*f) PARAMS ((struct objfile *, struct symbol *, char *));
+     int (*f) (struct objfile *, struct symbol *, char *);
 {
 
   /* Allocate more space for the deferred list.  */
@@ -890,7 +867,7 @@ process_now (objfile)
   struct symbol *sym;
   char *stabs;
   int err;
-  int (*func) PARAMS ((struct objfile *, struct symbol *, char *));
+  int (*func) (struct objfile *, struct symbol *, char *);
 
   /* Save the state of our caller, we'll want to restore it before
      returning.  */
@@ -1096,6 +1073,18 @@ free_bincl_list (objfile)
   bincls_allocated = 0;
 }
 
+static void
+do_free_bincl_list_cleanup (void *objfile)
+{
+  free_bincl_list (objfile);
+}
+
+static struct cleanup *
+make_cleanup_free_bincl_list (struct objfile *objfile)
+{
+  return make_cleanup (do_free_bincl_list_cleanup, objfile);
+}
+
 /* Scan a SunOs dynamic symbol table for symbols of interest and
    add them to the minimal symbol table.  */
 
@@ -1159,17 +1148,17 @@ read_dbx_dynamic_symtab (objfile)
 
          if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
            {
-             sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT);
+             sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
              type = N_TEXT;
            }
          else if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
            {
-             sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+             sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
              type = N_DATA;
            }
          else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
            {
-             sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS);
+             sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
              type = N_BSS;
            }
          else
@@ -1210,7 +1199,7 @@ read_dbx_dynamic_symtab (objfile)
     {
       arelent *rel = *relptr;
       CORE_ADDR address =
-      rel->address + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA);
+      rel->address + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
 
       switch (bfd_get_arch (abfd))
        {
@@ -1239,21 +1228,17 @@ read_dbx_dynamic_symtab (objfile)
   do_cleanups (back_to);
 }
 
-/* Given pointers to an a.out symbol table in core containing dbx
-   style data, setup partial_symtab's describing each source file for
-   which debugging information is available.
-   SYMFILE_NAME is the name of the file we are reading from
-   and SECTION_OFFSETS is the set of offsets for the various sections
-   of the file (a set of zeros if the mainline program).  */
+/* Setup partial_symtab's describing each source file for which
+   debugging information is available. */
 
 static void
-read_dbx_symtab (objfile, text_addr, text_size)
+read_dbx_symtab (objfile)
      struct objfile *objfile;
-     CORE_ADDR text_addr;
-     int text_size;
 {
   register struct external_nlist *bufp = 0;    /* =0 avoids gcc -Wall glitch */
   struct internal_nlist nlist;
+  CORE_ADDR text_addr;
+  int text_size;
 
   register char *namestring;
   int nsl;
@@ -1276,6 +1261,9 @@ read_dbx_symtab (objfile, text_addr, text_size)
   struct partial_symtab **dependency_list;
   int dependencies_used, dependencies_allocated;
 
+  text_addr = DBX_TEXT_ADDR (objfile);
+  text_size = DBX_TEXT_SIZE (objfile);
+
   /* FIXME.  We probably want to change stringtab_global rather than add this
      while processing every symbol entry.  FIXME.  */
   file_string_table_offset = 0;
@@ -1298,7 +1286,7 @@ read_dbx_symtab (objfile, text_addr, text_size)
 
   /* Init bincl list */
   init_bincl_list (20, objfile);
-  back_to = make_cleanup ((make_cleanup_func) free_bincl_list, objfile);
+  back_to = make_cleanup_free_bincl_list (objfile);
 
   last_source_file = NULL;
 
@@ -1361,8 +1349,8 @@ read_dbx_symtab (objfile, text_addr, text_size)
 #define CUR_SYMBOL_VALUE nlist.n_value
 #define CUR_SYMBOL_STRX nlist.n_strx
 #define DBXREAD_ONLY
-#define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\
-  start_psymtab(ofile, secoff, fname, low, symoff, global_syms, static_syms)
+#define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms)\
+  start_psymtab(ofile, fname, low, symoff, global_syms, static_syms)
 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set)\
   end_psymtab(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set)
 
@@ -1385,7 +1373,7 @@ read_dbx_symtab (objfile, text_addr, text_size)
       /* Don't set pst->texthigh lower than it already is.  */
       CORE_ADDR text_end =
       (lowest_text_address == (CORE_ADDR) -1
-       ? (text_addr + objfile->section_offsets->offsets[SECT_OFF_TEXT])
+       ? (text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)))
        : lowest_text_address)
       + text_size;
 
@@ -1406,11 +1394,9 @@ read_dbx_symtab (objfile, text_addr, text_size)
    (normal). */
 
 
-struct partial_symtab *
-start_psymtab (objfile, section_offsets,
-              filename, textlow, ldsymoff, global_syms, static_syms)
+static struct partial_symtab *
+start_psymtab (objfile, filename, textlow, ldsymoff, global_syms, static_syms)
      struct objfile *objfile;
-     struct section_offsets *section_offsets;
      char *filename;
      CORE_ADDR textlow;
      int ldsymoff;
@@ -1418,7 +1404,7 @@ start_psymtab (objfile, section_offsets,
      struct partial_symbol **static_syms;
 {
   struct partial_symtab *result =
-  start_psymtab_common (objfile, section_offsets,
+  start_psymtab_common (objfile, objfile->section_offsets,
                        filename, textlow, global_syms, static_syms);
 
   result->read_symtab_private = (char *)
@@ -1563,6 +1549,7 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset,
       struct partial_symtab *subpst =
       allocate_psymtab (include_list[i], objfile);
 
+      /* Copy the sesction_offsets array from the main psymtab. */
       subpst->section_offsets = pst->section_offsets;
       subpst->read_symtab_private =
        (char *) obstack_alloc (&objfile->psymbol_obstack,
@@ -1743,6 +1730,10 @@ read_ofile_symtab (pst)
   sym_size = LDSYMLEN (pst);
   text_offset = pst->textlow;
   text_size = pst->texthigh - pst->textlow;
+  /* This cannot be simply objfile->section_offsets because of
+     elfstab_offset_sections() which initializes the psymtab section
+     offsets information in a special way, and that is different from
+     objfile->section_offsets. */ 
   section_offsets = pst->section_offsets;
 
   current_objfile = objfile;
@@ -1885,7 +1876,7 @@ read_ofile_symtab (pst)
   if (last_source_start_addr > text_offset)
     last_source_start_addr = text_offset;
 
-  pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT);
+  pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
 
   /* Process items which we had to "process_later" due to dependancies 
      on other stabs.  */
@@ -1904,6 +1895,8 @@ read_ofile_symtab (pst)
    NAME is the symbol name, in our address space.
    SECTION_OFFSETS is a set of amounts by which the sections of this object
    file were relocated when it was loaded into memory.
+   Note that these section_offsets are not the 
+   objfile->section_offsets but the pst->section_offsets.
    All symbols that refer
    to memory locations need to be offset by these amounts.
    OBJFILE is the object file from which we are reading symbols.
@@ -1947,7 +1940,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
   if (!block_address_function_relative)
     /* N_LBRAC, N_RBRAC and N_SLINE entries are not relative to the
        function start address, so just use the text offset.  */
-    function_start_offset = ANOFFSET (section_offsets, SECT_OFF_TEXT);
+    function_start_offset = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
 
   /* Something is wrong if we see real data before
      seeing a source file name.  */
@@ -1987,7 +1980,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
        }
 
       /* Relocate for dynamic loading */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
 #ifdef SMASH_TEXT_ADDRESS
       SMASH_TEXT_ADDRESS (valu);
 #endif
@@ -2095,7 +2088,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
     case N_FN_SEQ:
       /* This kind of symbol indicates the start of an object file.  */
       /* Relocate for dynamic loading */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
       break;
 
     case N_SO:
@@ -2104,7 +2097,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
          Finish the symbol table of the previous source file
          (if any) and start accumulating a new symbol table.  */
       /* Relocate for dynamic loading */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
 
       n_opt_found = 0;
 
@@ -2131,7 +2124,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
              patch_subfile_names (current_subfile, name);
              break;            /* Ignore repeated SOs */
            }
-         end_symtab (valu, objfile, SECT_OFF_TEXT);
+         end_symtab (valu, objfile, SECT_OFF_TEXT (objfile));
          end_stabs ();
        }
 
@@ -2154,7 +2147,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
          included in the compilation of the main source file
          (whose name was given in the N_SO symbol.)  */
       /* Relocate for dynamic loading */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
       start_subfile (name, current_subfile->dirname);
       break;
 
@@ -2232,7 +2225,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
                   elfstab_offset_sections ever starts dealing with the
                   text offset, and we still need to do this, we need to
                   invent a SECT_OFF_ADDR_KLUDGE or something.  */
-               valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+               valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
                goto define_a_symbol;
              }
          }
@@ -2252,22 +2245,22 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
 
     case_N_STSYM:              /* Static symbol in data seg */
     case N_DSLINE:             /* Source line number, data seg */
-      valu += ANOFFSET (section_offsets, SECT_OFF_DATA);
+      valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile));
       goto define_a_symbol;
 
     case_N_LCSYM:              /* Static symbol in BSS seg */
     case N_BSLINE:             /* Source line number, bss seg */
       /*   N_BROWS:       overlaps with N_BSLINE */
-      valu += ANOFFSET (section_offsets, SECT_OFF_BSS);
+      valu += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile));
       goto define_a_symbol;
 
     case_N_ROSYM:              /* Static symbol in Read-only data seg */
-      valu += ANOFFSET (section_offsets, SECT_OFF_RODATA);
+      valu += ANOFFSET (section_offsets, SECT_OFF_RODATA (objfile));
       goto define_a_symbol;
 
     case N_ENTRY:              /* Alternate entry point */
       /* Relocate for dynamic loading */
-      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
+      valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
       goto define_a_symbol;
 
       /* The following symbol types we don't know how to process.  Handle
@@ -2319,35 +2312,9 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
              /* Deal with the SunPRO 3.0 compiler which omits the address
                 from N_FUN symbols.  */
              if (type == N_FUN
-                 && valu == ANOFFSET (section_offsets, SECT_OFF_TEXT))
-               {
-                 struct minimal_symbol *msym;
-                 char *p;
-                 int n;
-
-                 p = strchr (name, ':');
-                 if (p == NULL)
-                   p = name;
-                 n = p - name;
-                 p = alloca (n + 2);
-                 strncpy (p, name, n);
-                 p[n] = 0;
-
-                 msym = lookup_minimal_symbol (p, last_source_file,
-                                               objfile);
-                 if (msym == NULL)
-                   {
-                     /* Sun Fortran appends an underscore to the minimal
-                        symbol name, try again with an appended underscore
-                        if the minimal symbol was not found.  */
-                     p[n] = '_';
-                     p[n + 1] = 0;
-                     msym = lookup_minimal_symbol (p, last_source_file,
-                                                   objfile);
-                   }
-                 if (msym)
-                   valu = SYMBOL_VALUE_ADDRESS (msym);
-               }
+                 && valu == ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)))
+               valu = 
+                 find_stab_function_addr (name, last_source_file, objfile);
 #endif
 
 #ifdef SUN_FIXED_LBRAC_BUG
@@ -2410,6 +2377,13 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
                function_start_offset = valu;
 
              within_function = 1;
+
+             if (context_stack_depth > 1)
+               {
+                 complain (&lbrac_unmatched_complaint, symnum);
+                 break;
+               }
+
              if (context_stack_depth > 0)
                {
                  new = pop_context ();
@@ -2417,9 +2391,6 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile)
                  finish_block (new->name, &local_symbols, new->old_blocks,
                                new->start_addr, valu, objfile);
                }
-             /* Stack must be empty now.  */
-             if (context_stack_depth != 0)
-               complain (&lbrac_unmatched_complaint, symnum);
 
              new = push_context (0, valu);
              new->name = define_symbol (valu, name, desc, type, objfile);
@@ -2635,7 +2606,6 @@ elfstab_build_psymtabs (objfile, mainline,
   bfd *sym_bfd = objfile->obfd;
   char *name = bfd_get_filename (sym_bfd);
   struct dbx_symfile_info *info;
-  asection *text_sect;
 
   /* There is already a dbx_symfile_info allocated by our caller.
      It might even contain some info from the ELF symtab to help us.  */
This page took 0.031258 seconds and 4 git commands to generate.