mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 04:49:54 +08:00
TUI stdout buffering cleanup
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.
This commit is contained in:
@ -22,24 +22,11 @@
|
|||||||
#include "tui/tui-command.h"
|
#include "tui/tui-command.h"
|
||||||
#include "tui.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
|
void
|
||||||
tui_file::puts (const char *linebuffer)
|
tui_file::puts (const char *linebuffer)
|
||||||
{
|
{
|
||||||
tui_puts (linebuffer);
|
tui_puts (linebuffer);
|
||||||
/* gdb_stdout is buffered, and the caller must gdb_flush it at
|
if (!m_buffered)
|
||||||
appropriate times. Other streams are not so buffered. */
|
|
||||||
if (this != gdb_stdout)
|
|
||||||
tui_refresh_cmd_win ();
|
tui_refresh_cmd_win ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,18 +34,14 @@ void
|
|||||||
tui_file::write (const char *buf, long length_buf)
|
tui_file::write (const char *buf, long length_buf)
|
||||||
{
|
{
|
||||||
tui_write (buf, length_buf);
|
tui_write (buf, length_buf);
|
||||||
/* gdb_stdout is buffered, and the caller must gdb_flush it at
|
if (!m_buffered)
|
||||||
appropriate times. Other streams are not so buffered. */
|
|
||||||
if (this != gdb_stdout)
|
|
||||||
tui_refresh_cmd_win ();
|
tui_refresh_cmd_win ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tui_file::flush ()
|
tui_file::flush ()
|
||||||
{
|
{
|
||||||
/* gdb_stdout is buffered. Other files are always flushed on
|
if (m_buffered)
|
||||||
every write. */
|
|
||||||
if (this == gdb_stdout)
|
|
||||||
tui_refresh_cmd_win ();
|
tui_refresh_cmd_win ();
|
||||||
stdio_file::flush ();
|
stdio_file::flush ();
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,19 @@
|
|||||||
class tui_file : public stdio_file
|
class tui_file : public stdio_file
|
||||||
{
|
{
|
||||||
public:
|
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 write (const char *buf, long length_buf) override;
|
||||||
void puts (const char *) override;
|
void puts (const char *) override;
|
||||||
void flush () override;
|
void flush () override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/* True if this stream is buffered. */
|
||||||
|
bool m_buffered;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TUI_TUI_FILE_H */
|
#endif /* TUI_TUI_FILE_H */
|
||||||
|
@ -904,8 +904,8 @@ tui_initialize_io (void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Create tui output streams. */
|
/* Create tui output streams. */
|
||||||
tui_stdout = new pager_file (new tui_file (stdout));
|
tui_stdout = new pager_file (new tui_file (stdout, true));
|
||||||
tui_stderr = new tui_file (stderr);
|
tui_stderr = new tui_file (stderr, false);
|
||||||
tui_stdlog = new timestamped_file (tui_stderr);
|
tui_stdlog = new timestamped_file (tui_stderr);
|
||||||
tui_out = new tui_ui_out (tui_stdout);
|
tui_out = new tui_ui_out (tui_stdout);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user