Make symfile_add_flags and objfile->flags strongly typed
[deliverable/binutils-gdb.git] / gdb / coffread.c
index 9d20eebdc9a9fb9ee0c7aa7c80f826a4387b93c2..501e9011222b451c632806a336908da6652f4a5f 100644 (file)
@@ -1,5 +1,5 @@
 /* Read coff symbol tables and convert to internal format, for GDB.
-   Copyright (C) 1987-2015 Free Software Foundation, Inc.
+   Copyright (C) 1987-2016 Free Software Foundation, Inc.
    Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
 
    This file is part of GDB.
@@ -207,7 +207,8 @@ 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 coff_symtab_read (minimal_symbol_reader &,
+                             long, unsigned int, struct objfile *);
 \f
 /* We are called once per section from coff_symfile_read.  We
    need to examine each section we are passed, check to see
@@ -461,7 +462,8 @@ is_import_fixup_symbol (struct coff_symbol *cs,
 }
 
 static struct minimal_symbol *
-record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address,
+record_minimal_symbol (minimal_symbol_reader &reader,
+                      struct coff_symbol *cs, CORE_ADDR address,
                       enum minimal_symbol_type type, int section, 
                       struct objfile *objfile)
 {
@@ -479,8 +481,7 @@ record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address,
       return NULL;
     }
 
-  return prim_record_minimal_symbol_and_info (cs->c_name, address,
-                                             type, section, objfile);
+  return reader.record_with_info (cs->c_name, address, type, section);
 }
 \f
 /* coff_symfile_init ()
@@ -558,10 +559,9 @@ static bfd *symfile_bfd;
 /* Read a symbol file, after initialization by coff_symfile_init.  */
 
 static void
-coff_symfile_read (struct objfile *objfile, int symfile_flags)
+coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 {
   struct coff_symfile_info *info;
-  struct dbx_symfile_info *dbxinfo;
   bfd *abfd = objfile->obfd;
   coff_data_type *cdata = coff_data (abfd);
   char *name = bfd_get_filename (abfd);
@@ -569,11 +569,11 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
   unsigned int num_symbols;
   int symtab_offset;
   int stringtab_offset;
-  struct cleanup *back_to, *cleanup_minimal_symbols;
+  struct cleanup *back_to;
   int stabstrsize;
   
-  info = objfile_data (objfile, coff_objfile_data_key);
-  dbxinfo = DBX_SYMFILE_INFO (objfile);
+  info = (struct coff_symfile_info *) objfile_data (objfile,
+                                                   coff_objfile_data_key);
   symfile_bfd = abfd;          /* Kludge for swap routines.  */
 
 /* WARNING WILL ROBINSON!  ACCESSING BFD-PRIVATE DATA HERE!  FIXME!  */
@@ -646,18 +646,17 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
   if (val < 0)
     error (_("\"%s\": can't get string table"), name);
 
-  init_minimal_symbol_collection ();
-  cleanup_minimal_symbols = make_cleanup_discard_minimal_symbols ();
+  minimal_symbol_reader reader (objfile);
 
   /* Now that the executable file is positioned at symbol table,
      process it and define symbols accordingly.  */
 
-  coff_symtab_read ((long) symtab_offset, num_symbols, objfile);
+  coff_symtab_read (reader, (long) symtab_offset, num_symbols, objfile);
 
   /* Install any minimal symbols that have been collected as the
      current minimal symbols for this objfile.  */
 
-  install_minimal_symbols (objfile);
+  reader.install ();
 
   if (pe_file)
     {
@@ -700,9 +699,6 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
        }
     }
 
-  /* Free the installed minimal symbol data.  */
-  do_cleanups (cleanup_minimal_symbols);
-
   bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
 
   if (info->stabsects)
@@ -783,7 +779,8 @@ coff_symfile_finish (struct objfile *objfile)
    We read them one at a time using read_one_sym ().  */
 
 static void
-coff_symtab_read (long symtab_offset, unsigned int nsyms,
+coff_symtab_read (minimal_symbol_reader &reader,
+                 long symtab_offset, unsigned int nsyms,
                  struct objfile *objfile)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
@@ -881,7 +878,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
          int section = cs_to_section (cs, objfile);
 
          tmpaddr = cs->c_value;
-         record_minimal_symbol (cs, tmpaddr, mst_text,
+         record_minimal_symbol (reader, cs, tmpaddr, mst_text,
                                 section, objfile);
 
          fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
@@ -1041,7 +1038,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
                  ms_type = mst_unknown;
              }
 
-           msym = record_minimal_symbol (cs, tmpaddr, ms_type,
+           msym = record_minimal_symbol (reader, cs, tmpaddr, ms_type,
                                          sec, objfile);
            if (msym)
              gdbarch_coff_make_msymbol_special (gdbarch,
@@ -1203,7 +1200,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
     {
       /* We've got no debugging symbols, but it's a portable
         executable, so try to read the export table.  */
-      read_pe_exported_syms (objfile);
+      read_pe_exported_syms (reader, objfile);
     }
 
   if (get_last_source_file ())
This page took 0.027175 seconds and 4 git commands to generate.