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.
This commit is contained in:
Tom Tromey 2021-12-31 14:34:07 -07:00
parent dcf1a2c8d2
commit 9b7167182d
2 changed files with 17 additions and 1 deletions

View File

@ -124,6 +124,14 @@ class ui_file
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 @@ class tee_file : public ui_file
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;

View File

@ -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);
}