public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Add puts_unfiltered method to ui_file
@ 2022-03-29 19:42 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-03-29 19:42 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9b7167182d1f6fef32c264587bbc00c7f9bd21f2

commit 9b7167182d1f6fef32c264587bbc00c7f9bd21f2
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Dec 31 14:34:07 2021 -0700

    Add puts_unfiltered method to ui_file
    
    When the pager is rewritten as a ui_file, gdb will still need a way to
    bypass the filtering.  After examining a few approaches, I chose this
    patch, which adds a puts_unfiltered method to ui_file.  For most
    implementations of ui_file, this will just delegate to puts.  This
    patch also switches printf_unfiltered to use the new method.

Diff:
---
 gdb/ui-file.h | 14 ++++++++++++++
 gdb/utils.c   |  4 +++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gdb/ui-file.h b/gdb/ui-file.h
index 8d41f6f8300..7ae3937e41a 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -124,6 +124,14 @@ public:
      used to force out output from the wrap_buffer.  */
   void wrap_here (int indent);
 
+  /* Print STR, bypassing any paging that might be done by this
+     ui_file.  Note that nearly no code should call this -- it's
+     intended for use by printf_filtered, but nothing else.  */
+  virtual void puts_unfiltered (const char *str)
+  {
+    this->puts (str);
+  }
+
 private:
 
   /* Helper function for putstr and putstrn.  Print the character C on
@@ -342,6 +350,12 @@ public:
     return m_one->can_page () || m_two->can_page ();
   }
 
+  void puts_unfiltered (const char *str) override
+  {
+    m_one->puts_unfiltered (str);
+    m_two->puts_unfiltered (str);
+  }
+
 private:
   /* The two underlying ui_files.  */
   ui_file *m_one;
diff --git a/gdb/utils.c b/gdb/utils.c
index a0717213f0f..8f479c487d3 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2025,7 +2025,9 @@ printf_unfiltered (const char *format, ...)
   va_list args;
 
   va_start (args, format);
-  vfprintf_unfiltered (gdb_stdout, format, args);
+  string_file file (gdb_stdout->can_emit_style_escape ());
+  file.vprintf (format, args);
+  gdb_stdout->puts_unfiltered (file.string ().c_str ());
   va_end (args);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-29 19:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 19:42 [binutils-gdb] Add puts_unfiltered method to ui_file Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).