From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 11/14] TUI stdout buffering cleanup
Date: Fri, 12 Aug 2022 18:54:39 -0600 [thread overview]
Message-ID: <20220813005442.4163512-12-tromey@adacore.com> (raw)
In-Reply-To: <20220813005442.4163512-1-tromey@adacore.com>
The TUI checks against gdb_stdout to decide when to buffer. It seems
much cleaner to me to simply record this as an attribute of the stream
itself.
---
gdb/tui/tui-file.c | 23 +++--------------------
gdb/tui/tui-file.h | 10 +++++++++-
gdb/tui/tui-io.c | 4 ++--
3 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c
index 49dafce112c..3cf3dbc171a 100644
--- a/gdb/tui/tui-file.c
+++ b/gdb/tui/tui-file.c
@@ -22,24 +22,11 @@
#include "tui/tui-command.h"
#include "tui.h"
-tui_file::tui_file (FILE *stream)
- : stdio_file (stream)
-{}
-
-/* All TUI I/O sent to the *_filtered and *_unfiltered functions
- eventually ends up here. The fputs_unfiltered_hook is primarily
- used by GUIs to collect all output and send it to the GUI, instead
- of the controlling terminal. Only output to gdb_stdout and
- gdb_stderr are sent to the hook. Everything else is sent on to
- fputs to allow file I/O to be handled appropriately. */
-
void
tui_file::puts (const char *linebuffer)
{
tui_puts (linebuffer);
- /* gdb_stdout is buffered, and the caller must gdb_flush it at
- appropriate times. Other streams are not so buffered. */
- if (this != gdb_stdout)
+ if (!m_buffered)
tui_refresh_cmd_win ();
}
@@ -47,18 +34,14 @@ void
tui_file::write (const char *buf, long length_buf)
{
tui_write (buf, length_buf);
- /* gdb_stdout is buffered, and the caller must gdb_flush it at
- appropriate times. Other streams are not so buffered. */
- if (this != gdb_stdout)
+ if (!m_buffered)
tui_refresh_cmd_win ();
}
void
tui_file::flush ()
{
- /* gdb_stdout is buffered. Other files are always flushed on
- every write. */
- if (this == gdb_stdout)
+ if (m_buffered)
tui_refresh_cmd_win ();
stdio_file::flush ();
}
diff --git a/gdb/tui/tui-file.h b/gdb/tui/tui-file.h
index 1b28780c51b..ff60ded71c1 100644
--- a/gdb/tui/tui-file.h
+++ b/gdb/tui/tui-file.h
@@ -26,11 +26,19 @@
class tui_file : public stdio_file
{
public:
- explicit tui_file (FILE *stream);
+ tui_file (FILE *stream, bool buffered)
+ : stdio_file (stream),
+ m_buffered (buffered)
+ {}
void write (const char *buf, long length_buf) override;
void puts (const char *) override;
void flush () override;
+
+private:
+
+ /* True if this stream is buffered. */
+ bool m_buffered;
};
#endif /* TUI_TUI_FILE_H */
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 9f27f8bcc01..0efaf69335c 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -904,8 +904,8 @@ tui_initialize_io (void)
#endif
/* Create tui output streams. */
- tui_stdout = new pager_file (new tui_file (stdout));
- tui_stderr = new tui_file (stderr);
+ tui_stdout = new pager_file (new tui_file (stdout, true));
+ tui_stderr = new tui_file (stderr, false);
tui_stdlog = new timestamped_file (tui_stderr);
tui_out = new tui_ui_out (tui_stdout);
--
2.34.1
next prev parent reply other threads:[~2022-08-13 0:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-13 0:54 [PATCH 00/14] Minor ui / interp cleanups Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 01/14] Remove some dead code Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 02/14] Free ui::line_buffer Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 03/14] Use ui_out_redirect_pop in more places Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 04/14] Remove the "for moment" comments Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 05/14] Remove obsolete filtering comment Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 06/14] Remove two unused members from mi_interp Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 07/14] Use member initialization in 'struct ui' Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 08/14] Use scoped_restore in safe_parse_type Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 09/14] Remove tui_out_new Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 10/14] Remove a ui-related memory leak Tom Tromey via Gdb-patches
2022-08-13 0:54 ` Tom Tromey via Gdb-patches [this message]
2022-08-13 0:54 ` [PATCH 12/14] Remove a call to clear_interpreter_hooks Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 13/14] Fix "source" with interpreter-exec Tom Tromey via Gdb-patches
2022-08-13 1:58 ` Enze Li via Gdb-patches
2022-08-15 17:28 ` Tom Tromey via Gdb-patches
2022-08-13 0:54 ` [PATCH 14/14] Fix interpreter-exec crash Tom Tromey via Gdb-patches
2022-08-31 17:13 ` [PATCH 00/14] Minor ui / interp cleanups 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=20220813005442.4163512-12-tromey@adacore.com \
--to=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/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