gdb: defer commit resume until all available events are consumed
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 22793e736398c0da9c7eca22ecd85007c0a81a91..2c38ce4431a6218c0f98c04e057ce0f890140183 100644 (file)
@@ -747,7 +747,9 @@ default_symfile_segments (bfd *abfd)
   symfile_segment_data_up data (new symfile_segment_data);
 
   num_sections = bfd_count_sections (abfd);
-  data->segment_info = XCNEWVEC (int, num_sections);
+
+  /* All elements are initialized to 0 (map to no segment).  */
+  data->segment_info.resize (num_sections);
 
   for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
     {
@@ -1049,6 +1051,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
   struct objfile *objfile;
   const int from_tty = add_flags & SYMFILE_VERBOSE;
   const int mainline = add_flags & SYMFILE_MAINLINE;
+  const int always_confirm = add_flags & SYMFILE_ALWAYS_CONFIRM;
   const int should_print = (print_symbol_loading_p (from_tty, mainline, 1)
                            && (readnow_symbol_files
                                || (add_flags & SYMFILE_NO_READ) == 0));
@@ -1067,12 +1070,13 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
   if ((add_flags & SYMFILE_NOT_FILENAME) != 0)
     flags |= OBJF_NOT_FILENAME;
 
-  /* Give user a chance to burp if we'd be
+  /* Give user a chance to burp if ALWAYS_CONFIRM or we'd be
      interactively wiping out any existing symbols.  */
 
-  if ((have_full_symbols () || have_partial_symbols ())
-      && mainline
-      && from_tty
+  if (from_tty
+      && (always_confirm
+         || ((have_full_symbols () || have_partial_symbols ())
+             && mainline))
       && !query (_("Load new symbol table from \"%s\"? "), name))
     error (_("Not confirmed."));
 
@@ -1273,7 +1277,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
       gdb_flush (gdb_stdout);
     }
 
-  gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget, -1));
+  gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget));
 
   if (abfd == NULL)
     {
@@ -2037,7 +2041,7 @@ generic_load (const char *args, int from_tty)
     }
 
   /* Open the file for loading.  */
-  gdb_bfd_ref_ptr loadfile_bfd (gdb_bfd_open (filename.get (), gnutarget, -1));
+  gdb_bfd_ref_ptr loadfile_bfd (gdb_bfd_open (filename.get (), gnutarget));
   if (loadfile_bfd == NULL)
     perror_with_name (filename.get ());
 
@@ -2448,7 +2452,7 @@ reread_symbols (void)
         a `shared library' on AIX is also an archive), then you should
         stat on the archive name, not member name.  */
       if (objfile->obfd->my_archive)
-       res = stat (objfile->obfd->my_archive->filename, &new_statbuf);
+       res = stat (bfd_get_filename (objfile->obfd->my_archive), &new_statbuf);
       else
        res = stat (objfile_name (objfile), &new_statbuf);
       if (res != 0)
@@ -2522,7 +2526,7 @@ reread_symbols (void)
            obfd_filename = bfd_get_filename (objfile->obfd);
            /* Open the new BFD before freeing the old one, so that
               the filename remains live.  */
-           gdb_bfd_ref_ptr temp (gdb_bfd_open (obfd_filename, gnutarget, -1));
+           gdb_bfd_ref_ptr temp (gdb_bfd_open (obfd_filename, gnutarget));
            objfile->obfd = temp.release ();
            if (objfile->obfd == NULL)
              error (_("Can't open %s to read symbols."), obfd_filename);
@@ -2541,6 +2545,11 @@ reread_symbols (void)
             will need to be called (see discussion below).  */
          obstack_free (&objfile->objfile_obstack, 0);
          objfile->sections = NULL;
+         objfile->section_offsets.clear ();
+         objfile->sect_index_bss = -1;
+         objfile->sect_index_data = -1;
+         objfile->sect_index_rodata = -1;
+         objfile->sect_index_text = -1;
          objfile->compunit_symtabs = NULL;
          objfile->template_symbols = NULL;
          objfile->static_links.reset (nullptr);
@@ -2595,6 +2604,9 @@ reread_symbols (void)
 
          objfiles_changed ();
 
+         /* Recompute section offsets and section indices.  */
+         objfile->sf->sym_offsets (objfile, {});
+
          read_symbols (objfile, 0);
 
          if (!objfile_has_symbols (objfile))
@@ -3394,8 +3406,7 @@ enum ovly_index
 static void
 simple_free_overlay_table (void)
 {
-  if (cache_ovly_table)
-    xfree (cache_ovly_table);
+  xfree (cache_ovly_table);
   cache_novlys = 0;
   cache_ovly_table = NULL;
   cache_ovly_table_base = 0;
This page took 0.026339 seconds and 4 git commands to generate.