Fix use-after-free in record_btrace_start_replaying
[deliverable/binutils-gdb.git] / gdb / symfile.c
index 62b38bd618251708d9d62195e6b355ad3e43fe24..8ab6a25de7c376249778d42a6fcd666a09910a02 100644 (file)
@@ -989,7 +989,7 @@ syms_from_objfile_1 (struct objfile *objfile,
      initial symbol reading for this file.  */
 
   (*objfile->sf->sym_init) (objfile);
-  clear_complaints (1);
+  clear_complaints ();
 
   (*objfile->sf->sym_offsets) (objfile, *addrs);
 
@@ -1036,7 +1036,7 @@ finish_new_objfile (struct objfile *objfile, symfile_add_flags add_flags)
     }
 
   /* We're done reading the symbol file; finish off complaints.  */
-  clear_complaints (0);
+  clear_complaints ();
 }
 
 /* Process a symbol file, as either the main file or as a dynamically
@@ -1110,11 +1110,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
       if (deprecated_pre_add_symbol_hook)
        deprecated_pre_add_symbol_hook (name);
       else
-       {
-         printf_unfiltered (_("Reading symbols from %s..."), name);
-         wrap_here ("");
-         gdb_flush (gdb_stdout);
-       }
+       printf_filtered (_("Reading symbols from %s...\n"), name);
     }
   syms_from_objfile (objfile, addrs, add_flags);
 
@@ -1126,29 +1122,24 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
   if ((flags & OBJF_READNOW))
     {
       if (should_print)
-       {
-         printf_unfiltered (_("expanding to full symbols..."));
-         wrap_here ("");
-         gdb_flush (gdb_stdout);
-       }
+       printf_filtered (_("Expanding full symbols from %s...\n"), name);
 
       if (objfile->sf)
        objfile->sf->qf->expand_all_symtabs (objfile);
     }
 
-  if (should_print && !objfile_has_symbols (objfile))
-    {
-      wrap_here ("");
-      printf_unfiltered (_("(no debugging symbols found)..."));
-      wrap_here ("");
-    }
+  /* Note that we only print a message if we have no symbols and have
+     no separate debug file.  If there is a separate debug file which
+     does not have symbols, we'll have emitted this message for that
+     file, and so printing it twice is just redundant.  */
+  if (should_print && !objfile_has_symbols (objfile)
+      && objfile->separate_debug_objfile == nullptr)
+    printf_filtered (_("(No debugging symbols found in %s)\n"), name);
 
   if (should_print)
     {
       if (deprecated_post_add_symbol_hook)
        deprecated_post_add_symbol_hook ();
-      else
-       printf_unfiltered (_("done.\n"));
     }
 
   /* We print some messages regardless of whether 'from_tty ||
@@ -1268,7 +1259,7 @@ symbol_file_clear (int from_tty)
 
   gdb_assert (symfile_objfile == NULL);
   if (from_tty)
-    printf_unfiltered (_("No symbol file now.\n"));
+    printf_filtered (_("No symbol file now.\n"));
 }
 
 /* See symfile.h.  */
@@ -1294,7 +1285,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
     return 0;
 
   if (separate_debug_file_debug)
-    printf_unfiltered (_("  Trying %s\n"), name.c_str ());
+    printf_filtered (_("  Trying %s\n"), name.c_str ());
 
   gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget, -1));
 
@@ -1384,8 +1375,8 @@ find_separate_debug_file (const char *dir,
                          unsigned long crc32, struct objfile *objfile)
 {
   if (separate_debug_file_debug)
-    printf_unfiltered (_("\nLooking for separate debug info (debug link) for "
-                        "%s\n"), objfile_name (objfile));
+    printf_filtered (_("\nLooking for separate debug info (debug link) for "
+                      "%s\n"), objfile_name (objfile));
 
   /* First try in the same directory as the original file.  */
   std::string debugfile = dir;
@@ -2111,7 +2102,7 @@ set_objfile_default_section_offset (struct objfile *objf,
 
   std::vector<const struct other_sections *>::iterator addrs_sorted_iter
     = addrs_sorted.begin ();
-  for (const struct other_sections *objf_sect : objf_addrs_sorted)
+  for (const other_sections *objf_sect : objf_addrs_sorted)
     {
       const char *objf_name = addr_section_name (objf_sect->name.c_str ());
       int cmp = -1;
@@ -2259,8 +2250,8 @@ add_symbol_file_command (const char *args, int from_tty)
          index is not used for any other purpose.
       */
       section_addrs.emplace_back (addr, sec, section_addrs.size ());
-      printf_unfiltered ("\t%s_addr = %s\n", sec,
-                        paddress (gdbarch, addr));
+      printf_filtered ("\t%s_addr = %s\n", sec,
+                      paddress (gdbarch, addr));
 
       /* The object's sections are initialized when a
         call is made to build_objfile_section_table (objfile).
@@ -2398,8 +2389,8 @@ reread_symbols (void)
       if (res != 0)
        {
          /* FIXME, should use print_sys_errmsg but it's not filtered.  */
-         printf_unfiltered (_("`%s' has disappeared; keeping its symbols.\n"),
-                            objfile_name (objfile));
+         printf_filtered (_("`%s' has disappeared; keeping its symbols.\n"),
+                          objfile_name (objfile));
          continue;
        }
       new_modtime = new_statbuf.st_mtime;
@@ -2409,8 +2400,8 @@ reread_symbols (void)
          struct section_offsets *offsets;
          int num_offsets;
 
-         printf_unfiltered (_("`%s' has changed; re-reading symbols.\n"),
-                            objfile_name (objfile));
+         printf_filtered (_("`%s' has changed; re-reading symbols.\n"),
+                          objfile_name (objfile));
 
          /* There are various functions like symbol_file_add,
             symfile_bfd_open, syms_from_objfile, etc., which might
@@ -2506,6 +2497,7 @@ reread_symbols (void)
          objfile->psymtabs_addrmap = NULL;
          objfile->free_psymtabs = NULL;
          objfile->template_symbols = NULL;
+         objfile->static_links = NULL;
 
          /* obstack_init also initializes the obstack so it is
             empty.  We could use obstack_specify_allocation but
@@ -2549,7 +2541,7 @@ reread_symbols (void)
            }
 
          (*objfile->sf->sym_init) (objfile);
-         clear_complaints (1);
+         clear_complaints ();
 
          objfile->flags &= ~OBJF_PSYMTABS_READ;
 
@@ -2574,12 +2566,12 @@ reread_symbols (void)
          if (!objfile_has_symbols (objfile))
            {
              wrap_here ("");
-             printf_unfiltered (_("(no debugging symbols found)\n"));
+             printf_filtered (_("(no debugging symbols found)\n"));
              wrap_here ("");
            }
 
          /* We're done reading the symbol file; finish off complaints.  */
-         clear_complaints (0);
+         clear_complaints ();
 
          /* Getting new symbols may change our opinion about what is
             frameless.  */
@@ -2608,7 +2600,7 @@ reread_symbols (void)
         gdb::observers::new_objfile.notify (NULL) has been called by
         clear_symtab_users above.  Notify the new files now.  */
       for (auto iter : new_objfiles)
-       gdb::observers::new_objfile.notify (objfile);
+       gdb::observers::new_objfile.notify (iter);
 
       /* At least one objfile has changed, so we can consider that
          the executable we're debugging has changed too.  */
@@ -2762,13 +2754,13 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
        {
          xfree (last_objfile_name);
          last_objfile_name = xstrdup (objfile_name (objfile));
-         fprintf_unfiltered (gdb_stdlog,
-                             "Creating one or more symtabs for objfile %s ...\n",
-                             last_objfile_name);
+         fprintf_filtered (gdb_stdlog,
+                           "Creating one or more symtabs for objfile %s ...\n",
+                           last_objfile_name);
        }
-      fprintf_unfiltered (gdb_stdlog,
-                         "Created symtab %s for module %s.\n",
-                         host_address_to_string (symtab), filename);
+      fprintf_filtered (gdb_stdlog,
+                       "Created symtab %s for module %s.\n",
+                       host_address_to_string (symtab), filename);
     }
 
   /* Add it to CUST's list of symtabs.  */
@@ -2814,10 +2806,10 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
 
   if (symtab_create_debug)
     {
-      fprintf_unfiltered (gdb_stdlog,
-                         "Created compunit symtab %s for %s.\n",
-                         host_address_to_string (cu),
-                         cu->name);
+      fprintf_filtered (gdb_stdlog,
+                       "Created compunit symtab %s for %s.\n",
+                       host_address_to_string (cu),
+                       cu->name);
     }
 
   return cu;
This page took 0.039737 seconds and 4 git commands to generate.