aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-interp.c6
-rw-r--r--gdb/tui/tui-io.c6
-rw-r--r--gdb/tui/tui-io.h3
-rw-r--r--gdb/tui/tui-out.c143
-rw-r--r--gdb/tui/tui-out.h48
-rw-r--r--gdb/tui/tui.h2
6 files changed, 101 insertions, 107 deletions
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index 8d35124..3e8442e 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -252,10 +252,10 @@ tui_resume (void *data)
previously writing to gdb_stdout, then set it to the new
gdb_stdout afterwards. */
- stream = cli_out_set_stream (tui_old_uiout, gdb_stdout);
+ stream = tui_old_uiout->set_stream (gdb_stdout);
if (stream != gdb_stdout)
{
- cli_out_set_stream (tui_old_uiout, stream);
+ tui_old_uiout->set_stream (stream);
stream = NULL;
}
@@ -264,7 +264,7 @@ tui_resume (void *data)
ui->input_handler = command_line_handler;
if (stream != NULL)
- cli_out_set_stream (tui_old_uiout, gdb_stdout);
+ tui_old_uiout->set_stream (gdb_stdout);
if (tui_start_enabled)
tui_enable ();
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 93bed88..cde679c 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -32,6 +32,7 @@
#include "tui/tui-win.h"
#include "tui/tui-wingeneral.h"
#include "tui/tui-file.h"
+#include "tui/tui-out.h"
#include "ui-out.h"
#include "cli-out.h"
#include <fcntl.h>
@@ -114,7 +115,7 @@ struct ui_out *tui_out;
/* GDB output files in non-curses mode. */
static struct ui_file *tui_old_stdout;
static struct ui_file *tui_old_stderr;
-struct ui_out *tui_old_uiout;
+cli_ui_out *tui_old_uiout;
/* Readline previous hooks. */
static rl_getc_func_t *tui_old_rl_getc_function;
@@ -459,7 +460,8 @@ tui_setup_io (int mode)
/* Keep track of previous gdb output. */
tui_old_stdout = gdb_stdout;
tui_old_stderr = gdb_stderr;
- tui_old_uiout = current_uiout;
+ tui_old_uiout = dynamic_cast<cli_ui_out *> (current_uiout);
+ gdb_assert (tui_old_uiout != nullptr);
/* Reconfigure gdb output. */
gdb_stdout = tui_stdout;
diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h
index 67c0273..a080529 100644
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -23,6 +23,7 @@
#define TUI_IO_H
struct ui_out;
+class cli_ui_out;
/* Print the string in the curses command window. */
extern void tui_puts (const char *);
@@ -45,7 +46,7 @@ extern void tui_redisplay_readline (void);
extern char *tui_expand_tabs (const char *, int);
extern struct ui_out *tui_out;
-extern struct ui_out *tui_old_uiout;
+extern cli_ui_out *tui_old_uiout;
extern int key_is_start_sequence (int ch);
extern int key_is_end_sequence (int ch);
diff --git a/gdb/tui/tui-out.c b/gdb/tui/tui-out.c
index a5f0541..90c581c 100644
--- a/gdb/tui/tui-out.c
+++ b/gdb/tui/tui-out.c
@@ -22,156 +22,101 @@
#include "defs.h"
#include "ui-out.h"
-#include "cli-out.h"
+#include "tui-out.h"
#include "tui.h"
-struct tui_ui_out_data
- {
- struct cli_ui_out_data base;
-
- int line;
- int start_of_line;
- };
-typedef struct tui_ui_out_data tui_out_data;
-
-/* This is the TUI ui-out implementation functions vector. It is
- initialized below in _initialize_tui_out, inheriting the CLI
- version, and overriding a few methods. */
-
-static struct ui_out_impl tui_ui_out_impl;
/* Output an int field. */
-static void
-tui_field_int (struct ui_out *uiout,
- int fldno, int width,
- enum ui_align alignment,
- const char *fldname,
- int value)
+void
+tui_ui_out::do_field_int (int fldno, int width, ui_align alignment,
+ const char *fldname, int value)
{
- tui_out_data *data = (tui_out_data *) ui_out_data (uiout);
-
- if (data->base.suppress_output)
+ if (suppress_output ())
return;
/* Don't print line number, keep it for later. */
- if (data->start_of_line == 0 && strcmp (fldname, "line") == 0)
+ if (m_start_of_line == 0 && strcmp (fldname, "line") == 0)
{
- data->start_of_line ++;
- data->line = value;
+ m_start_of_line++;
+ m_line = value;
return;
}
- data->start_of_line ++;
+ m_start_of_line++;
- (*cli_ui_out_impl.field_int) (uiout, fldno,
- width, alignment, fldname, value);
+ cli_ui_out::do_field_int (fldno, width, alignment, fldname, value);
}
/* Other cli_field_* end up here so alignment and field separators are
both handled by tui_field_string. */
-static void
-tui_field_string (struct ui_out *uiout,
- int fldno, int width,
- enum ui_align align,
- const char *fldname,
- const char *string)
+void
+tui_ui_out::do_field_string (int fldno, int width, ui_align align,
+ const char *fldname, const char *string)
{
- tui_out_data *data = (tui_out_data *) ui_out_data (uiout);
-
- if (data->base.suppress_output)
+ if (suppress_output ())
return;
- if (fldname && data->line > 0 && strcmp (fldname, "fullname") == 0)
+ if (fldname && m_line > 0 && strcmp (fldname, "fullname") == 0)
{
- data->start_of_line ++;
- if (data->line > 0)
+ m_start_of_line++;
+ if (m_line > 0)
{
- tui_show_source (string, data->line);
+ tui_show_source (string, m_line);
}
return;
}
- data->start_of_line++;
+ m_start_of_line++;
- (*cli_ui_out_impl.field_string) (uiout, fldno,
- width, align,
- fldname, string);
+ cli_ui_out::do_field_string (fldno, width, align, fldname, string);
}
/* This is the only field function that does not align. */
-static void
-tui_field_fmt (struct ui_out *uiout, int fldno,
- int width, enum ui_align align,
- const char *fldname,
- const char *format,
- va_list args)
+void
+tui_ui_out::do_field_fmt (int fldno, int width, ui_align align,
+ const char *fldname, const char *format,
+ va_list args)
{
- tui_out_data *data = (tui_out_data *) ui_out_data (uiout);
-
- if (data->base.suppress_output)
+ if (suppress_output ())
return;
- data->start_of_line++;
+ m_start_of_line++;
- (*cli_ui_out_impl.field_fmt) (uiout, fldno,
- width, align,
- fldname, format, args);
+ cli_ui_out::do_field_fmt (fldno, width, align, fldname, format, args);
}
-static void
-tui_text (struct ui_out *uiout, const char *string)
+void
+tui_ui_out::do_text (const char *string)
{
- tui_out_data *data = (tui_out_data *) ui_out_data (uiout);
-
- if (data->base.suppress_output)
+ if (suppress_output ())
return;
- data->start_of_line ++;
- if (data->line > 0)
+
+ m_start_of_line++;
+ if (m_line > 0)
{
if (strchr (string, '\n') != 0)
{
- data->line = -1;
- data->start_of_line = 0;
+ m_line = -1;
+ m_start_of_line = 0;
}
return;
}
if (strchr (string, '\n'))
- data->start_of_line = 0;
+ m_start_of_line = 0;
- (*cli_ui_out_impl.text) (uiout, string);
+ cli_ui_out::do_text (string);
}
-struct ui_out *
-tui_out_new (struct ui_file *stream)
+tui_ui_out::tui_ui_out (ui_file *stream)
+: cli_ui_out (stream, 0),
+ m_line (0),
+ m_start_of_line (-1)
{
- ui_out_flags flags = 0;
-
- tui_out_data *data = new tui_out_data ();
-
- /* Initialize base "class". */
- cli_out_data_ctor (&data->base, stream);
-
- /* Initialize our fields. */
- data->line = -1;
- data->start_of_line = 0;
-
- return ui_out_new (&tui_ui_out_impl, data, flags);
}
-/* Standard gdb initialization hook. */
-
-extern void _initialize_tui_out (void);
-
-void
-_initialize_tui_out (void)
+tui_ui_out *
+tui_out_new (struct ui_file *stream)
{
- /* Inherit the CLI version. */
- tui_ui_out_impl = cli_ui_out_impl;
-
- /* Override a few methods. */
- tui_ui_out_impl.field_int = tui_field_int;
- tui_ui_out_impl.field_string = tui_field_string;
- tui_ui_out_impl.field_fmt = tui_field_fmt;
- tui_ui_out_impl.text = tui_text;
+ return new tui_ui_out (stream);
}
diff --git a/gdb/tui/tui-out.h b/gdb/tui/tui-out.h
new file mode 100644
index 0000000..da7821a
--- /dev/null
+++ b/gdb/tui/tui-out.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef TUI_OUT_H
+#define TUI_OUT_H
+
+#include "cli-out.h"
+
+class tui_ui_out : public cli_ui_out
+{
+public:
+
+ explicit tui_ui_out (ui_file *stream);
+
+protected:
+
+ void do_field_int (int fldno, int width, ui_align align, const char *fldname,
+ int value) override;
+ void do_field_string (int fldno, int width, ui_align align, const char *fldname,
+ const char *string) override;
+ void do_field_fmt (int fldno, int width, ui_align align, const char *fldname,
+ const char *format, va_list args) override
+ ATTRIBUTE_PRINTF (6,0);
+ void do_text (const char *string) override;
+
+private:
+
+ int m_line;
+ int m_start_of_line;
+};
+
+extern tui_ui_out *tui_out_new (struct ui_file *stream);
+
+#endif
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 5d56df0..aaae851 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -93,8 +93,6 @@ extern int tui_active;
extern void tui_show_source (const char *fullname, int line);
-extern struct ui_out *tui_out_new (struct ui_file *stream);
-
/* tui-layout.c */
extern enum tui_status tui_set_layout_by_name (const char *);