Use filtered printing when reading symbols
authorTom Tromey <tom@tromey.com>
Thu, 17 May 2018 03:52:04 +0000 (21:52 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 4 Oct 2018 19:40:10 +0000 (13:40 -0600)
While working on this series, I found some unfiltered prints that
didn't make sense -- many things, like complaints, are filtered, while
their context (in this case the "Reading symbols ..."  messages) may
not be.

This patch changes some spots in symbol reading to use filtered
prints.  I think this is preferable overall; in fact I'd go farther
and say that unfiltered printing should just be removed.

One of these spots was not strictly related (the change to
dump_psymtab), but I left it in partly because it makes psymtab.c
"unfiltered-clean", and partly because it is an example of filtered
and unfiltered printing being mixed in the same function.

gdb/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

* symfile.c (symbol_file_add_with_addrs, symbol_file_clear)
(separate_debug_file_exists, find_separate_debug_file)
(add_symbol_file_command, reread_symbols, allocate_symtab)
(allocate_compunit_symtab): Use filtered printing, not
unfiltered.
* psymtab.c (require_partial_symbols, dump_psymtab)
(allocate_psymtab): Use filtered printing, not unfiltered.

gdb/ChangeLog
gdb/psymtab.c
gdb/symfile.c

index 14ef35f68a0f42884267b961006e21d37ebaf08c..a369d1b33c5bd2d4df7c9bd677cae0f3e797740d 100644 (file)
@@ -1,3 +1,13 @@
+2018-10-04  Tom Tromey  <tom@tromey.com>
+
+       * symfile.c (symbol_file_add_with_addrs, symbol_file_clear)
+       (separate_debug_file_exists, find_separate_debug_file)
+       (add_symbol_file_command, reread_symbols, allocate_symtab)
+       (allocate_compunit_symtab): Use filtered printing, not
+       unfiltered.
+       * psymtab.c (require_partial_symbols, dump_psymtab)
+       (allocate_psymtab): Use filtered printing, not unfiltered.
+
 2018-10-04  Tom Tromey  <tom@tromey.com>
 
        * complaints.c (complaint_internal): Correctly check complaint
index dc35ca8df2792bff0ada4823e139bce64c6a7138..219357e586bd1e441e52a32ca06145c7ad1fec82 100644 (file)
@@ -79,8 +79,8 @@ require_partial_symbols (struct objfile *objfile, int verbose)
        {
          if (verbose)
            {
-             printf_unfiltered (_("Reading symbols from %s..."),
-                                objfile_name (objfile));
+             printf_filtered (_("Reading symbols from %s..."),
+                              objfile_name (objfile));
              gdb_flush (gdb_stdout);
            }
          (*objfile->sf->sym_read_psymbols) (objfile);
@@ -95,11 +95,11 @@ require_partial_symbols (struct objfile *objfile, int verbose)
              if (!objfile_has_symbols (objfile))
                {
                  wrap_here ("");
-                 printf_unfiltered (_("(no debugging symbols found)..."));
+                 printf_filtered (_("(no debugging symbols found)..."));
                  wrap_here ("");
                }
 
-             printf_unfiltered (_("done.\n"));
+             printf_filtered (_("done.\n"));
            }
        }
     }
@@ -931,10 +931,10 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
   fprintf_filtered (outfile, "(object ");
   gdb_print_host_address (psymtab, outfile);
   fprintf_filtered (outfile, ")\n\n");
-  fprintf_unfiltered (outfile, "  Read from object file %s (",
-                     objfile_name (objfile));
+  fprintf_filtered (outfile, "  Read from object file %s (",
+                   objfile_name (objfile));
   gdb_print_host_address (objfile, outfile);
-  fprintf_unfiltered (outfile, ")\n");
+  fprintf_filtered (outfile, ")\n");
 
   if (psymtab->readin)
     {
@@ -1766,13 +1766,13 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
        {
          xfree (last_objfile_name);
          last_objfile_name = xstrdup (objfile_name (objfile));
-         fprintf_unfiltered (gdb_stdlog,
-                             "Creating one or more psymtabs for objfile %s ...\n",
-                             last_objfile_name);
+         fprintf_filtered (gdb_stdlog,
+                           "Creating one or more psymtabs for objfile %s ...\n",
+                           last_objfile_name);
        }
-      fprintf_unfiltered (gdb_stdlog,
-                         "Created psymtab %s for module %s.\n",
-                         host_address_to_string (psymtab), filename);
+      fprintf_filtered (gdb_stdlog,
+                       "Created psymtab %s for module %s.\n",
+                       host_address_to_string (psymtab), filename);
     }
 
   return psymtab;
index 20697d9dca25ca047198b16417f1ae8475807323..0767562d5ca6f60b36f18a33c52cfd0bec73094f 100644 (file)
@@ -1111,7 +1111,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
        deprecated_pre_add_symbol_hook (name);
       else
        {
-         printf_unfiltered (_("Reading symbols from %s..."), name);
+         printf_filtered (_("Reading symbols from %s..."), name);
          wrap_here ("");
          gdb_flush (gdb_stdout);
        }
@@ -1127,7 +1127,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
     {
       if (should_print)
        {
-         printf_unfiltered (_("expanding to full symbols..."));
+         printf_filtered (_("expanding to full symbols..."));
          wrap_here ("");
          gdb_flush (gdb_stdout);
        }
@@ -1139,7 +1139,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
   if (should_print && !objfile_has_symbols (objfile))
     {
       wrap_here ("");
-      printf_unfiltered (_("(no debugging symbols found)..."));
+      printf_filtered (_("(no debugging symbols found)..."));
       wrap_here ("");
     }
 
@@ -1148,7 +1148,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
       if (deprecated_post_add_symbol_hook)
        deprecated_post_add_symbol_hook ();
       else
-       printf_unfiltered (_("done.\n"));
+       printf_filtered (_("done.\n"));
     }
 
   /* We print some messages regardless of whether 'from_tty ||
@@ -1268,7 +1268,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 +1294,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 +1384,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;
@@ -2259,8 +2259,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 +2398,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 +2409,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
@@ -2574,7 +2574,7 @@ 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 ("");
            }
 
@@ -2762,13 +2762,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 +2814,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.03732 seconds and 4 git commands to generate.