Use filtered output in some dumping commands
authorTom Tromey <tom@tromey.com>
Thu, 30 Dec 2021 19:16:58 +0000 (12:16 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 5 Jan 2022 18:36:33 +0000 (11:36 -0700)
There are several commands that may optionally send their output to a
file -- they take an optional filename argument and open a file.  This
patch changes these commands to use filtered output.  The rationale
here is that, when printing to gdb_stdout, filtering is appropriate --
it is, and should be, the default for all commands.  And, when writing
to a file, paging will not happen anyway (it only happens when the
stream==gdb_stdout), so using the _filtered form will not change
anything.

gdb/dummy-frame.c
gdb/maint-test-options.c
gdb/regcache-dump.c
gdb/regcache.c
gdb/reggroups.c

index 70c2777aa01a29ec772c5ded78896f0e6618f7cf..41c0bdeb945595c90cb4b01948ae2eff95d85cc0 100644 (file)
@@ -405,10 +405,10 @@ fprint_dummy_frames (struct ui_file *file)
   struct dummy_frame *s;
 
   for (s = dummy_frame_stack; s != NULL; s = s->next)
-    fprintf_unfiltered (file, "%s: id=%s, ptid=%s\n",
-                       host_address_to_string (s),
-                       s->id.id.to_string ().c_str (),
-                       target_pid_to_str (s->id.thread->ptid).c_str ());
+    fprintf_filtered (file, "%s: id=%s, ptid=%s\n",
+                     host_address_to_string (s),
+                     s->id.id.to_string ().c_str (),
+                     target_pid_to_str (s->id.thread->ptid).c_str ());
 }
 
 static void
index 87e810d838487b3e8dcc9b5af585ef7f8181c15a..b9b538d78bbfb87cff6444ae149f3f75bacb72bd 100644 (file)
@@ -143,22 +143,22 @@ struct test_options_opts
      arguments.  */
   void dump (ui_file *file, const char *args) const
   {
-    fprintf_unfiltered (file,
-                       _("-flag %d -xx1 %d -xx2 %d -bool %d "
-                         "-enum %s -uint %s -zuint-unl %s -string '%s' -- %s\n"),
-                       flag_opt,
-                       xx1_opt,
-                       xx2_opt,
-                       boolean_opt,
-                       enum_opt,
-                       (uint_opt == UINT_MAX
-                        ? "unlimited"
-                        : pulongest (uint_opt)),
-                       (zuint_unl_opt == -1
-                        ? "unlimited"
-                        : plongest (zuint_unl_opt)),
-                       string_opt.c_str (),
-                       args);
+    fprintf_filtered (file,
+                     _("-flag %d -xx1 %d -xx2 %d -bool %d "
+                       "-enum %s -uint %s -zuint-unl %s -string '%s' -- %s\n"),
+                     flag_opt,
+                     xx1_opt,
+                     xx2_opt,
+                     boolean_opt,
+                     enum_opt,
+                     (uint_opt == UINT_MAX
+                      ? "unlimited"
+                      : pulongest (uint_opt)),
+                     (zuint_unl_opt == -1
+                      ? "unlimited"
+                      : plongest (zuint_unl_opt)),
+                     string_opt.c_str (),
+                     args);
   }
 };
 
index 83c277f6681963ad51d6b5b15d85bdeb7faada36..f59345032eda0a24a58c814a127cc4bd8004114f 100644 (file)
@@ -43,9 +43,9 @@ protected:
     if (regnum < 0)
       {
        if (m_dump_pseudo)
-         fprintf_unfiltered (file, "Cooked value");
+         fprintf_filtered (file, "Cooked value");
        else
-         fprintf_unfiltered (file, "Raw value");
+         fprintf_filtered (file, "Raw value");
       }
     else
       {
@@ -60,9 +60,9 @@ protected:
            auto status = m_regcache->cooked_read (regnum, buf.data ());
 
            if (status == REG_UNKNOWN)
-             fprintf_unfiltered (file, "<invalid>");
+             fprintf_filtered (file, "<invalid>");
            else if (status == REG_UNAVAILABLE)
-             fprintf_unfiltered (file, "<unavailable>");
+             fprintf_filtered (file, "<unavailable>");
            else
              {
                print_hex_chars (file, buf.data (), size,
@@ -73,7 +73,7 @@ protected:
          {
            /* Just print "<cooked>" for pseudo register when
               regcache_dump_raw.  */
-           fprintf_unfiltered (file, "<cooked>");
+           fprintf_filtered (file, "<cooked>");
          }
       }
   }
@@ -102,9 +102,9 @@ protected:
     if (regnum < 0)
       {
        if (m_has_pseudo)
-         fprintf_unfiltered (file, "Cooked value");
+         fprintf_filtered (file, "Cooked value");
        else
-         fprintf_unfiltered (file, "Raw value");
+         fprintf_filtered (file, "Raw value");
       }
     else
       {
@@ -120,15 +120,15 @@ protected:
            gdb_assert (status != REG_VALID);
 
            if (status == REG_UNKNOWN)
-             fprintf_unfiltered (file, "<invalid>");
+             fprintf_filtered (file, "<invalid>");
            else
-             fprintf_unfiltered (file, "<unavailable>");
+             fprintf_filtered (file, "<unavailable>");
          }
        else
          {
            /* Just print "<cooked>" for pseudo register when
               regcache_dump_raw.  */
-           fprintf_unfiltered (file, "<cooked>");
+           fprintf_filtered (file, "<cooked>");
          }
       }
   }
@@ -162,7 +162,7 @@ protected:
   {
     if (regnum < 0)
       {
-       fprintf_unfiltered (file, "Rmt Nr  g/G Offset");
+       fprintf_filtered (file, "Rmt Nr  g/G Offset");
       }
     else if (regnum < gdbarch_num_regs (m_gdbarch))
       {
@@ -170,7 +170,7 @@ protected:
 
        if (remote_register_number_and_offset (m_gdbarch, regnum,
                                               &pnum, &poffset))
-         fprintf_unfiltered (file, "%7d %11d", pnum, poffset);
+         fprintf_filtered (file, "%7d %11d", pnum, poffset);
       }
   }
 };
@@ -188,7 +188,7 @@ protected:
   void dump_reg (ui_file *file, int regnum) override
   {
     if (regnum < 0)
-      fprintf_unfiltered (file, "Groups");
+      fprintf_filtered (file, "Groups");
     else
       {
        const char *sep = "";
@@ -200,8 +200,8 @@ protected:
          {
            if (gdbarch_register_reggroup_p (m_gdbarch, regnum, group))
              {
-               fprintf_unfiltered (file,
-                                   "%s%s", sep, reggroup_name (group));
+               fprintf_filtered (file,
+                                 "%s%s", sep, reggroup_name (group));
                sep = ",";
              }
          }
index f6e2cdda27aab98d278c68925ebf32c283b376bd..ab45277e3b6b31a343dd5517f99c49e5fd79f557 100644 (file)
@@ -1436,7 +1436,7 @@ register_dump::dump (ui_file *file)
     {
       /* Name.  */
       if (regnum < 0)
-       fprintf_unfiltered (file, " %-10s", "Name");
+       fprintf_filtered (file, " %-10s", "Name");
       else
        {
          const char *p = gdbarch_register_name (m_gdbarch, regnum);
@@ -1445,31 +1445,31 @@ register_dump::dump (ui_file *file)
            p = "";
          else if (p[0] == '\0')
            p = "''";
-         fprintf_unfiltered (file, " %-10s", p);
+         fprintf_filtered (file, " %-10s", p);
        }
 
       /* Number.  */
       if (regnum < 0)
-       fprintf_unfiltered (file, " %4s", "Nr");
+       fprintf_filtered (file, " %4s", "Nr");
       else
-       fprintf_unfiltered (file, " %4d", regnum);
+       fprintf_filtered (file, " %4d", regnum);
 
       /* Relative number.  */
       if (regnum < 0)
-       fprintf_unfiltered (file, " %4s", "Rel");
+       fprintf_filtered (file, " %4s", "Rel");
       else if (regnum < gdbarch_num_regs (m_gdbarch))
-       fprintf_unfiltered (file, " %4d", regnum);
+       fprintf_filtered (file, " %4d", regnum);
       else
-       fprintf_unfiltered (file, " %4d",
-                           (regnum - gdbarch_num_regs (m_gdbarch)));
+       fprintf_filtered (file, " %4d",
+                         (regnum - gdbarch_num_regs (m_gdbarch)));
 
       /* Offset.  */
       if (regnum < 0)
-       fprintf_unfiltered (file, " %6s  ", "Offset");
+       fprintf_filtered (file, " %6s  ", "Offset");
       else
        {
-         fprintf_unfiltered (file, " %6ld",
-                             descr->register_offset[regnum]);
+         fprintf_filtered (file, " %6ld",
+                           descr->register_offset[regnum]);
          if (register_offset != descr->register_offset[regnum]
              || (regnum > 0
                  && (descr->register_offset[regnum]
@@ -1479,19 +1479,19 @@ register_dump::dump (ui_file *file)
            {
              if (!footnote_register_offset)
                footnote_register_offset = ++footnote_nr;
-             fprintf_unfiltered (file, "*%d", footnote_register_offset);
+             fprintf_filtered (file, "*%d", footnote_register_offset);
            }
          else
-           fprintf_unfiltered (file, "  ");
+           fprintf_filtered (file, "  ");
          register_offset = (descr->register_offset[regnum]
                             + descr->sizeof_register[regnum]);
        }
 
       /* Size.  */
       if (regnum < 0)
-       fprintf_unfiltered (file, " %5s ", "Size");
+       fprintf_filtered (file, " %5s ", "Size");
       else
-       fprintf_unfiltered (file, " %5ld", descr->sizeof_register[regnum]);
+       fprintf_filtered (file, " %5ld", descr->sizeof_register[regnum]);
 
       /* Type.  */
       {
@@ -1517,24 +1517,24 @@ register_dump::dump (ui_file *file)
            if (startswith (t, blt))
              t += strlen (blt);
          }
-       fprintf_unfiltered (file, " %-15s", t);
+       fprintf_filtered (file, " %-15s", t);
       }
 
       /* Leading space always present.  */
-      fprintf_unfiltered (file, " ");
+      fprintf_filtered (file, " ");
 
       dump_reg (file, regnum);
 
-      fprintf_unfiltered (file, "\n");
+      fprintf_filtered (file, "\n");
     }
 
   if (footnote_register_offset)
-    fprintf_unfiltered (file, "*%d: Inconsistent register offsets.\n",
-                       footnote_register_offset);
+    fprintf_filtered (file, "*%d: Inconsistent register offsets.\n",
+                     footnote_register_offset);
   if (footnote_register_type_name_null)
-    fprintf_unfiltered (file,
-                       "*%d: Register type's name NULL.\n",
-                       footnote_register_type_name_null);
+    fprintf_filtered (file,
+                     "*%d: Register type's name NULL.\n",
+                     footnote_register_type_name_null);
 }
 
 #if GDB_SELF_TEST
index 38861c9a6752660e72684f43338f83e323d828b2..2b612fbd0402ad5530c44cb160a9c26a96b5eba9 100644 (file)
@@ -251,7 +251,7 @@ reggroups_dump (struct gdbarch *gdbarch, struct ui_file *file)
          name = "Group";
        else
          name = reggroup_name (group);
-       fprintf_unfiltered (file, " %-10s", name);
+       fprintf_filtered (file, " %-10s", name);
       }
       
       /* Group type.  */
@@ -274,13 +274,13 @@ reggroups_dump (struct gdbarch *gdbarch, struct ui_file *file)
                internal_error (__FILE__, __LINE__, _("bad switch"));
              }
          }
-       fprintf_unfiltered (file, " %-10s", type);
+       fprintf_filtered (file, " %-10s", type);
       }
 
       /* Note: If you change this, be sure to also update the
         documentation.  */
       
-      fprintf_unfiltered (file, "\n");
+      fprintf_filtered (file, "\n");
 
       group = reggroup_next (gdbarch, group);
     }