Do not reopen temporary files
[deliverable/binutils-gdb.git] / gdb / coffread.c
index 0b0cbace6ba709b71fa2b70b1d6e2946b5132b9e..a473b78245e3ec038d808ed53469f5de51ea242d 100644 (file)
@@ -30,7 +30,7 @@
 #include "coff/internal.h"     /* Internal format of COFF symbols in BFD */
 #include "libcoff.h"           /* FIXME secret internal data from BFD */
 #include "objfiles.h"
-#include "buildsym.h"
+#include "buildsym-legacy.h"
 #include "gdb-stabs.h"
 #include "stabsread.h"
 #include "complaints.h"
@@ -383,6 +383,7 @@ coff_alloc_type (int index)
 static void
 coff_start_symtab (struct objfile *objfile, const char *name)
 {
+  within_function = 0;
   start_symtab (objfile,
   /* We fill in the filename later.  start_symtab puts this pointer
      into last_source_file and we put it in subfiles->name, which
@@ -564,7 +565,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   struct coff_symfile_info *info;
   bfd *abfd = objfile->obfd;
   coff_data_type *cdata = coff_data (abfd);
-  char *name = bfd_get_filename (abfd);
+  char *filename = bfd_get_filename (abfd);
   int val;
   unsigned int num_symbols;
   int symtab_offset;
@@ -636,7 +637,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
       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."), name);
+        error (_("\"%s\": error reading line numbers."), filename);
     }
 
   /* Now read the string table, all at once.  */
@@ -644,7 +645,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   make_cleanup (free_stringtab_cleanup, 0 /*ignore*/);
   val = init_stringtab (abfd, stringtab_offset);
   if (val < 0)
-    error (_("\"%s\": can't get string table"), name);
+    error (_("\"%s\": can't get string table"), filename);
 
   minimal_symbol_reader reader (objfile);
 
@@ -708,7 +709,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
        {
          error (_("The debugging information in `%s' is corrupted.\nThe "
                   "file has a `.stabs' section, but no `.stabstr' section."),
-                name);
+                filename);
        }
 
       /* FIXME: dubious.  Why can't we use something normal like
@@ -740,9 +741,9 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 
       if (!debugfile.empty ())
        {
-         gdb_bfd_ref_ptr abfd (symfile_bfd_open (debugfile.c_str ()));
+         gdb_bfd_ref_ptr debug_bfd (symfile_bfd_open (debugfile.c_str ()));
 
-         symbol_file_add_separate (abfd.get (), debugfile.c_str (),
+         symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (),
                                    symfile_flags, objfile);
        }
     }
@@ -780,7 +781,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
                  struct objfile *objfile)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
-  struct context_stack *newobj;
+  struct context_stack *newobj = nullptr;
   struct coff_symbol coff_symbol;
   struct coff_symbol *cs = &coff_symbol;
   static struct internal_syment main_sym;
@@ -803,6 +804,8 @@ coff_symtab_read (minimal_symbol_reader &reader,
   CORE_ADDR tmpaddr;
   struct minimal_symbol *msym;
 
+  scoped_free_pendings free_pending;
+
   /* Work around a stdio bug in SunOS4.1.1 (this makes me nervous....
      it's hard to know I've really worked around it.  The fix should
      be harmless, anyway).  The symptom of the bug is that the first
@@ -854,7 +857,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
             language_unknown, since such a ``file name'' is not
             recognized.  Override that with the minimal language to
             allow printing values in this symtab.  */
-         current_subfile->language = language_minimal;
+         get_current_subfile ()->language = language_minimal;
          complete_symtab ("_globals_", 0, 0);
          /* Done with all files, everything from here on out is
             globals.  */
@@ -1087,7 +1090,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
              /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno
                 contains number of lines to '}' */
 
-             if (context_stack_depth <= 0)
+             if (outermost_context_p ())
                {       /* We attempted to pop an empty context stack.  */
                  complaint (_("`.ef' symbol without matching `.bf' "
                               "symbol ignored starting at symnum %d"),
@@ -1096,9 +1099,9 @@ coff_symtab_read (minimal_symbol_reader &reader,
                  break;
                }
 
-             newobj = pop_context ();
+             struct context_stack cstk = pop_context ();
              /* Stack must be empty now.  */
-             if (context_stack_depth > 0 || newobj == NULL)
+             if (!outermost_context_p () || newobj == NULL)
                {
                  complaint (_("Unmatched .ef symbol(s) ignored "
                               "starting at symnum %d"),
@@ -1124,15 +1127,15 @@ coff_symtab_read (minimal_symbol_reader &reader,
                 of the closing '}', and for which we do not have any
                 other statement-line-number.  */
              if (fcn_last_line == 1)
-               record_line (current_subfile, fcn_first_line,
+               record_line (get_current_subfile (), fcn_first_line,
                             gdbarch_addr_bits_remove (gdbarch,
                                                       fcn_first_line_addr));
              else
                enter_linenos (fcn_line_ptr, fcn_first_line,
                               fcn_last_line, objfile);
 
-             finish_block (newobj->name, &local_symbols, newobj->old_blocks,
-                           NULL, newobj->start_addr,
+             finish_block (cstk.name, cstk.old_blocks,
+                           NULL, cstk.start_addr,
                            fcn_cs_saved.c_value
                            + fcn_aux_saved.x_sym.x_misc.x_fsize
                            + ANOFFSET (objfile->section_offsets,
@@ -1151,7 +1154,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
            }
          else if (strcmp (cs->c_name, ".eb") == 0)
            {
-             if (context_stack_depth <= 0)
+             if (outermost_context_p ())
                {       /* We attempted to pop an empty context stack.  */
                  complaint (_("`.eb' symbol without matching `.bb' "
                               "symbol ignored starting at symnum %d"),
@@ -1159,25 +1162,25 @@ coff_symtab_read (minimal_symbol_reader &reader,
                  break;
                }
 
-             newobj = pop_context ();
-             if (depth-- != newobj->depth)
+             struct context_stack cstk = pop_context ();
+             if (depth-- != cstk.depth)
                {
                  complaint (_("Mismatched .eb symbol ignored "
                               "starting at symnum %d"),
                             symnum);
                  break;
                }
-             if (local_symbols && context_stack_depth > 0)
+             if (*get_local_symbols () && !outermost_context_p ())
                {
                  tmpaddr =
                    cs->c_value + ANOFFSET (objfile->section_offsets,
                                            SECT_OFF_TEXT (objfile));
                  /* Make a block for the local symbols within.  */
-                 finish_block (0, &local_symbols, newobj->old_blocks, NULL,
-                               newobj->start_addr, tmpaddr);
+                 finish_block (0, cstk.old_blocks, NULL,
+                               cstk.start_addr, tmpaddr);
                }
              /* Now pop locals of block just finished.  */
-             local_symbols = newobj->locals;
+             *get_local_symbols () = cstk.locals;
            }
          break;
 
@@ -1500,7 +1503,7 @@ enter_linenos (long file_offset, int first_line,
          CORE_ADDR addr = lptr.l_addr.l_paddr;
          addr += ANOFFSET (objfile->section_offsets,
                            SECT_OFF_TEXT (objfile));
-         record_line (current_subfile,
+         record_line (get_current_subfile (),
                       first_line + L_LNNO32 (&lptr),
                       gdbarch_addr_bits_remove (gdbarch, addr));
        }
@@ -1623,7 +1626,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
   name = cs->c_name;
   name = EXTERNAL_NAME (name, objfile->obfd);
-  SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+  SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
                       &objfile->objfile_obstack);
   SYMBOL_SET_NAMES (sym, name, strlen (name), 1, objfile);
 
@@ -1643,10 +1646,10 @@ process_coff_symbol (struct coff_symbol *cs,
       SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
       if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
          || cs->c_sclass == C_THUMBSTATFUNC)
-       add_symbol_to_list (sym, &file_symbols);
+       add_symbol_to_list (sym, get_file_symbols ());
       else if (cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT
               || cs->c_sclass == C_THUMBEXTFUNC)
-       add_symbol_to_list (sym, &global_symbols);
+       add_symbol_to_list (sym, get_global_symbols ());
     }
   else
     {
@@ -1658,7 +1661,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
        case C_AUTO:
          SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
-         add_symbol_to_list (sym, &local_symbols);
+         add_symbol_to_list (sym, get_local_symbols ());
          break;
 
        case C_THUMBEXT:
@@ -1668,7 +1671,7 @@ process_coff_symbol (struct coff_symbol *cs,
          SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value;
          SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets,
                                                  SECT_OFF_TEXT (objfile));
-         add_symbol_to_list (sym, &global_symbols);
+         add_symbol_to_list (sym, get_global_symbols ());
          break;
 
        case C_THUMBSTAT:
@@ -1681,12 +1684,12 @@ process_coff_symbol (struct coff_symbol *cs,
          if (within_function)
            {
              /* Static symbol of local scope.  */
-             add_symbol_to_list (sym, &local_symbols);
+             add_symbol_to_list (sym, get_local_symbols ());
            }
          else
            {
              /* Static symbol at top level of file.  */
-             add_symbol_to_list (sym, &file_symbols);
+             add_symbol_to_list (sym, get_file_symbols ());
            }
          break;
 
@@ -1696,7 +1699,7 @@ process_coff_symbol (struct coff_symbol *cs,
        case C_REG:
          SYMBOL_ACLASS_INDEX (sym) = coff_register_index;
          SYMBOL_VALUE (sym) = cs->c_value;
-         add_symbol_to_list (sym, &local_symbols);
+         add_symbol_to_list (sym, get_local_symbols ());
          break;
 
        case C_THUMBLABEL:
@@ -1706,14 +1709,14 @@ process_coff_symbol (struct coff_symbol *cs,
        case C_ARG:
          SYMBOL_ACLASS_INDEX (sym) = LOC_ARG;
          SYMBOL_IS_ARGUMENT (sym) = 1;
-         add_symbol_to_list (sym, &local_symbols);
+         add_symbol_to_list (sym, get_local_symbols ());
          break;
 
        case C_REGPARM:
          SYMBOL_ACLASS_INDEX (sym) = coff_register_index;
          SYMBOL_IS_ARGUMENT (sym) = 1;
          SYMBOL_VALUE (sym) = cs->c_value;
-         add_symbol_to_list (sym, &local_symbols);
+         add_symbol_to_list (sym, get_local_symbols ());
          break;
 
        case C_TPDEF:
@@ -1767,7 +1770,7 @@ process_coff_symbol (struct coff_symbol *cs,
              SYMBOL_VALUE_CHAIN (sym) = opaque_type_chain[i];
              opaque_type_chain[i] = sym;
            }
-         add_symbol_to_list (sym, &file_symbols);
+         add_symbol_to_list (sym, get_file_symbols ());
          break;
 
        case C_STRTAG:
@@ -1786,7 +1789,7 @@ process_coff_symbol (struct coff_symbol *cs,
              TYPE_NAME (SYMBOL_TYPE (sym)) =
                concat (SYMBOL_LINKAGE_NAME (sym), (char *)NULL);
 
-         add_symbol_to_list (sym, &file_symbols);
+         add_symbol_to_list (sym, get_file_symbols ());
          break;
 
        default:
@@ -2150,9 +2153,9 @@ coff_read_enum_type (int index, int length, int lastsym,
 
   type = coff_alloc_type (index);
   if (within_function)
-    symlist = &local_symbols;
+    symlist = get_local_symbols ();
   else
-    symlist = &file_symbols;
+    symlist = get_file_symbols ();
   osyms = *symlist;
   o_nsyms = osyms ? osyms->nsyms : 0;
 
This page took 0.031058 seconds and 4 git commands to generate.