From bb6648900cd3d5001b651cdbb35c7e9c43fe00d2 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 9 Dec 2025 09:37:26 -0700 Subject: [PATCH] Restore ui_file::can_page 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 --- gdb/ui-file.h | 18 ++++++++++++++++++ gdb/utils.c | 6 ++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gdb/ui-file.h b/gdb/ui-file.h index 231c32deafc..4aaf4d0e54e 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -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) diff --git a/gdb/utils.c b/gdb/utils.c index cdb167c76cd..2f8bf5551c5 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -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') -- 2.47.3