From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 04/19] Add puts_unfiltered method to ui_file
Date: Fri, 21 Jan 2022 18:37:46 -0700 [thread overview]
Message-ID: <20220122013801.666659-5-tom@tromey.com> (raw)
In-Reply-To: <20220122013801.666659-1-tom@tromey.com>
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.
---
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 1a010e55564..101769d73a2 100644
--- a/gdb/ui-file.h
+++ b/gdb/ui-file.h
@@ -109,6 +109,14 @@ class ui_file
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
@@ -317,6 +325,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;
diff --git a/gdb/utils.c b/gdb/utils.c
index 48d68c6739d..65b7668f583 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2024,7 +2024,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);
}
--
2.31.1
next prev parent reply other threads:[~2022-01-22 1:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-22 1:37 [PATCH 00/19] Simplify GDB output functions Tom Tromey
2022-01-22 1:37 ` [PATCH 01/19] Use unfiltered output in annotate.c Tom Tromey
2022-01-22 1:37 ` [PATCH 02/19] Remove some uses of printf_unfiltered Tom Tromey
2022-01-22 1:37 ` [PATCH 03/19] Only have one API for unfiltered output Tom Tromey
2022-01-22 1:37 ` Tom Tromey [this message]
2022-01-22 1:37 ` [PATCH 05/19] Add style-escape methods to ui_file Tom Tromey
2022-01-22 1:37 ` [PATCH 06/19] Remove vfprintf_styled_no_gdbfmt Tom Tromey
2022-01-22 1:37 ` [PATCH 07/19] Change the pager to a ui_file Tom Tromey
2022-01-22 1:37 ` [PATCH 08/19] Remove fputs_styled_unfiltered Tom Tromey
2022-01-22 1:37 ` [PATCH 09/19] Unify vprintf functions Tom Tromey
2022-01-22 1:37 ` [PATCH 10/19] Unify gdb puts functions Tom Tromey
2022-01-22 1:37 ` [PATCH 11/19] Unify gdb putc functions Tom Tromey
2022-01-22 1:37 ` [PATCH 13/19] Rename print_spaces_filtered Tom Tromey
2022-01-22 1:37 ` [PATCH 14/19] Rename puts_filtered_tabular Tom Tromey
2022-01-22 1:37 ` [PATCH 15/19] Rename fprintf_symbol_filtered Tom Tromey
2022-01-22 1:37 ` [PATCH 16/19] Remove ui_out_flag::unfiltered_output Tom Tromey
2022-01-22 1:37 ` [PATCH 17/19] Remove vfprintf_styled Tom Tromey
2022-01-22 1:38 ` [PATCH 18/19] Minor comment updates in utils.h Tom Tromey
2022-03-24 18:05 ` Pedro Alves
2022-03-28 20:29 ` Tom Tromey
2022-01-22 1:38 ` [PATCH 19/19] Remove unnecessary calls to wrap_here and gdb_flush Tom Tromey
2022-01-22 17:40 ` [PATCH 00/19] Simplify GDB output functions John Baldwin
2022-03-24 16:25 ` Tom Tromey
2022-03-24 18:08 ` Pedro Alves
2022-03-29 19:38 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220122013801.666659-5-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).