]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Restore ui_file::can_page
authorTom Tromey <tom@tromey.com>
Tue, 9 Dec 2025 16:37:26 +0000 (09:37 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 9 Feb 2026 15:09:10 +0000 (08:09 -0700)
A while back, I removed the ui_file::can_page method.  It wasn't
needed for a while, due to how output redirections were done.

With the new approach in this series, it's convenient to have this
method again, because the pipeline downstream from the pager won't
change when logging -- the logging filter will be enabled or disabled
without reconfiguring the pipeline.  This method lets the pager adapt
correctly.

Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/ui-file.h
gdb/utils.c

index 231c32deafc4843efa5fb42ec658d6eedc14ad52..4aaf4d0e54e3d34ef4759f5883d1676d2f6d6aa0 100644 (file)
@@ -101,6 +101,14 @@ public:
   virtual int fd () const
   { return -1; }
 
+  /* Return true if this object supports paging, false otherwise.  */
+  virtual bool can_page () const
+  {
+    /* Almost no file supports paging, which is why this is the
+       default.  */
+    return false;
+  }
+
   /* Indicate that if the next sequence of characters overflows the
      line, a newline should be inserted here rather than when it hits
      the end.  If INDENT is non-zero, it is a number of spaces to be
@@ -270,6 +278,11 @@ public:
   int fd () const override
   { return m_fd; }
 
+  bool can_page () const override
+  {
+    return m_file == stdout;
+  }
+
 private:
   /* Sets the internal stream to FILE, and saves the FILE's file
      descriptor in M_FD.  */
@@ -452,6 +465,11 @@ public:
   void write_async_safe (const char *buf, long length_buf) override
   { return m_stream->write_async_safe (buf, length_buf); }
 
+  bool can_page () const override
+  {
+    return m_stream->can_page ();
+  }
+
 protected:
 
   explicit wrapped_file (T stream)
index cdb167c76cd1c2f2d80627292cd6249d74136e8f..2f8bf5551c5b948442930c29106f8eaff78e476e 100644 (file)
@@ -1640,7 +1640,8 @@ pager_file::check_for_overfull_line (const unsigned int lines_allowed)
         this loop, so we must continue to check it here.  */
       if (pagination_enabled
          && !pagination_disabled_for_command
-         && lines_printed >= lines_allowed)
+         && lines_printed >= lines_allowed
+         && m_stream->can_page ())
        {
          prompt_for_continue ();
          did_paginate = true;
@@ -1713,7 +1714,8 @@ pager_file::puts (const char *linebuffer)
         it here.  */
       if (pagination_enabled
          && !pagination_disabled_for_command
-         && lines_printed >= lines_allowed)
+         && lines_printed >= lines_allowed
+         && m_stream->can_page ())
        prompt_for_continue ();
 
       while (*linebuffer != '\0' && *linebuffer != '\n')