* coffread.c (coff_symfile_read): Clean up minimal symbols earlier.
authorDaniel Jacobowitz <drow@false.org>
Thu, 20 Feb 2003 18:31:14 +0000 (18:31 +0000)
committerDaniel Jacobowitz <drow@false.org>
Thu, 20 Feb 2003 18:31:14 +0000 (18:31 +0000)
* dbxread.c (elfstab_build_psymtabs): Don't call
install_minimal_symbols.
(stabsect_build_psymtabs): Likewise.
* elfread.c (elf_symfile_read): Call install_minimal_symbols
earlier.
* somread.c (som_symfile_read): Call install_minimal_symbols
and do_cleanups earlier.
* nlmread.c (nlm_symfile_read): Likewise.
* mdebugread.c (elfmdebug_build_psymtabs): Call
install_minimal_symbols and make appropriate cleanups.

gdb/ChangeLog
gdb/coffread.c
gdb/dbxread.c
gdb/elfread.c
gdb/mdebugread.c
gdb/nlmread.c
gdb/somread.c

index 9e9a387..226024c 100644 (file)
@@ -1,3 +1,17 @@
+2002-02-20  Daniel Jacobowitz  <drow@mvista.com>
+
+       * coffread.c (coff_symfile_read): Clean up minimal symbols earlier.
+       * dbxread.c (elfstab_build_psymtabs): Don't call
+       install_minimal_symbols.
+       (stabsect_build_psymtabs): Likewise.
+       * elfread.c (elf_symfile_read): Call install_minimal_symbols
+       earlier.
+       * somread.c (som_symfile_read): Call install_minimal_symbols
+       and do_cleanups earlier.
+       * nlmread.c (nlm_symfile_read): Likewise.
+       * mdebugread.c (elfmdebug_build_psymtabs): Call
+       install_minimal_symbols and make appropriate cleanups.
+
 2003-02-20  Kevin Buettner  <kevinb@redhat.com>
 
        * solib.c (reload_shared_libraries): New function.
index 912943c..db41896 100644 (file)
@@ -518,7 +518,7 @@ coff_symfile_read (struct objfile *objfile, int 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;
@@ -598,7 +598,7 @@ coff_symfile_read (struct objfile *objfile, int 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.  */
@@ -619,6 +619,9 @@ coff_symfile_read (struct objfile *objfile, int mainline)
 
   install_minimal_symbols (objfile);
 
+  /* Free the installed minimal symbol data.  */
+  do_cleanups (cleanup_minimal_symbols);
+
   bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
 
   if (info->stabsects)
index 4d9f35d..6c90f14 100644 (file)
@@ -3556,7 +3556,6 @@ elfstab_build_psymtabs (struct objfile *objfile, int mainline,
   buildsym_new_init ();
   free_header_files ();
   init_header_files ();
-  install_minimal_symbols (objfile);
 
   processing_acc_compilation = 1;
 
@@ -3568,7 +3567,10 @@ elfstab_build_psymtabs (struct objfile *objfile, int mainline,
 
   /* In an elf file, we've already installed the minimal symbols that came
      from the elf (non-stab) symbol table, so always act like an
-     incremental load here. */
+     incremental load here.  dbx_symfile_read should not generate any new
+     minimal symbols, since we will have already read the ELF dynamic symbol
+     table and normal symbol entries won't be in the ".stab" section; but in
+     case it does, it will install them itself.  */
   dbx_symfile_read (objfile, 0);
 
   if (back_to)
@@ -3650,7 +3652,6 @@ stabsect_build_psymtabs (struct objfile *objfile, int mainline, char *stab_name,
   buildsym_new_init ();
   free_header_files ();
   init_header_files ();
-  install_minimal_symbols (objfile);
 
   /* Now, do an incremental load */
 
index b96d6e7..7aee37c 100644 (file)
@@ -542,6 +542,15 @@ elf_symfile_read (struct objfile *objfile, int mainline)
 
   elf_symtab_read (objfile, 1);
 
+  /* Install any minimal symbols that have been collected as the current
+     minimal symbols for this objfile.  The debug readers below this point
+     should not generate new minimal symbols; if they do it's their
+     responsibility to install them.  "mdebug" appears to be the only one
+     which will do this.  */
+
+  install_minimal_symbols (objfile);
+  do_cleanups (back_to);
+
   /* Now process debugging information, which is contained in
      special ELF sections. */
 
@@ -611,13 +620,6 @@ elf_symfile_read (struct objfile *objfile, int mainline)
 
   if (DWARF2_BUILD_FRAME_INFO_P ())
     DWARF2_BUILD_FRAME_INFO(objfile);
-
-  /* Install any minimal symbols that have been collected as the current
-     minimal symbols for this objfile. */
-
-  install_minimal_symbols (objfile);
-
-  do_cleanups (back_to);
 }
 
 /* This cleans up the objfile's sym_stab_info pointer, and the chain of
index ac49ca0..51536d7 100644 (file)
@@ -4809,6 +4809,14 @@ elfmdebug_build_psymtabs (struct objfile *objfile,
 {
   bfd *abfd = objfile->obfd;
   struct ecoff_debug_info *info;
+  struct cleanup *back_to;
+
+  /* FIXME: It's not clear whether we should be getting minimal symbol
+     information from .mdebug in an ELF file, or whether we will.
+     Re-initialize the minimal symbol reader in case we do.  */
+
+  init_minimal_symbol_collection ();
+  back_to = make_cleanup_discard_minimal_symbols ();
 
   info = ((struct ecoff_debug_info *)
          obstack_alloc (&objfile->psymbol_obstack,
@@ -4819,6 +4827,9 @@ elfmdebug_build_psymtabs (struct objfile *objfile,
           bfd_errmsg (bfd_get_error ()));
 
   mdebug_build_psymtabs (objfile, swap, info);
+
+  install_minimal_symbols (objfile);
+  do_cleanups (back_to);
 }
 \f
 
index 089c0f7..10af4c5 100644 (file)
@@ -191,6 +191,12 @@ nlm_symfile_read (struct objfile *objfile, int mainline)
 
   nlm_symtab_read (abfd, offset, objfile);
 
+  /* Install any minimal symbols that have been collected as the current
+     minimal symbols for this objfile. */
+
+  install_minimal_symbols (objfile);
+  do_cleanups (back_to);
+
   stabsect_build_psymtabs (objfile, mainline, ".stab",
                           ".stabstr", ".text");
 
@@ -205,13 +211,6 @@ nlm_symfile_read (struct objfile *objfile, int mainline)
 
   /* FIXME:  We could locate and read the optional native debugging format
      here and add the symbols to the minimal symbol table. */
-
-  /* Install any minimal symbols that have been collected as the current
-     minimal symbols for this objfile. */
-
-  install_minimal_symbols (objfile);
-
-  do_cleanups (back_to);
 }
 
 
index 6ba95a6..85d4f0a 100644 (file)
@@ -353,6 +353,14 @@ som_symfile_read (struct objfile *objfile, int mainline)
 
   som_symtab_read (abfd, objfile, objfile->section_offsets);
 
+  /* Install any minimal symbols that have been collected as the current
+     minimal symbols for this objfile. 
+     Further symbol-reading is done incrementally, file-by-file,
+     in a step known as "psymtab-to-symtab" expansion. hp-symtab-read.c
+     contains the code to do the actual DNTT scanning and symtab building. */
+  install_minimal_symbols (objfile);
+  do_cleanups (back_to);
+
   /* Now read information from the stabs debug sections.
      This is a no-op for SOM.
      Perhaps it is intended for some kind of mixed STABS/SOM
@@ -366,16 +374,8 @@ som_symfile_read (struct objfile *objfile, int mainline)
      together with a scan of the GNTT. See hp-psymtab-read.c. */
   hpread_build_psymtabs (objfile, mainline);
 
-  /* Install any minimal symbols that have been collected as the current
-     minimal symbols for this objfile. 
-     Further symbol-reading is done incrementally, file-by-file,
-     in a step known as "psymtab-to-symtab" expansion. hp-symtab-read.c
-     contains the code to do the actual DNTT scanning and symtab building. */
-  install_minimal_symbols (objfile);
-
   /* Force hppa-tdep.c to re-read the unwind descriptors.  */
   objfile->obj_private = NULL;
-  do_cleanups (back_to);
 }
 
 /* Initialize anything that needs initializing when a completely new symbol