aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2010-03-30 22:21:34 +0000
committerPedro Alves <palves@redhat.com>2010-03-30 22:21:34 +0000
commit956c2c8b9a8980a5e838f1ee3115ac96d89bea96 (patch)
tree1a8364fa6b4fd18822c3a4af03d9428033504493
parent8d9e7719110b2d06c9cadee77e19fd455b84e81c (diff)
downloadgdb-956c2c8b9a8980a5e838f1ee3115ac96d89bea96.zip
gdb-956c2c8b9a8980a5e838f1ee3115ac96d89bea96.tar.gz
gdb-956c2c8b9a8980a5e838f1ee3115ac96d89bea96.tar.bz2
* tui/tui-interp.c (tui_is_toplevel): New.
(tui_init): Set it. (tui_allowed_p): New. * tui/tui.c (tui_enable): Check if the TUI is allowed before enabling it. * tui/tui.h (tui_allowed_p): Declare.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/tui/tui-interp.c17
-rw-r--r--gdb/tui/tui.c3
-rw-r--r--gdb/tui/tui.h4
4 files changed, 33 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 17d4399..8dc87d0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2010-03-30 Pedro Alves <pedro@codesourcery.com>
+
+ * tui/tui-interp.c (tui_is_toplevel): New.
+ (tui_init): Set it.
+ (tui_allowed_p): New.
+ * tui/tui.c (tui_enable): Check if the TUI is allowed before
+ enabling it.
+ * tui/tui.h (tui_allowed_p): Declare.
+
2010-03-30 Ozkan Sezer <sezeroz@gmail.com>
* serial.h: Include winsock2.h before windows.h.
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index 3bb8246..2a6c3ce 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -45,11 +45,16 @@ tui_exit (void)
tui_disable ();
}
+/* True if TUI is the top-level interpreter. */
+static int tui_is_toplevel = 0;
+
/* These implement the TUI interpreter. */
static void *
tui_init (int top_level)
{
+ tui_is_toplevel = top_level;
+
/* Install exit handler to leave the screen in a good shape. */
atexit (tui_exit);
@@ -63,6 +68,18 @@ tui_init (int top_level)
return NULL;
}
+/* True if enabling the TUI is allowed. Example, if the top level
+ interpreter is MI, enabling curses will certainly lose. */
+
+int
+tui_allowed_p (void)
+{
+ /* Only if TUI is the top level interpreter. Also don't try to
+ setup curses (and print funny control characters) if we're not
+ outputting to a terminal. */
+ return tui_is_toplevel && ui_file_isatty (gdb_stdout);
+}
+
static int
tui_resume (void *data)
{
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 2ff5c2d..e126d81 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -364,6 +364,9 @@ tui_initialize_readline (void)
void
tui_enable (void)
{
+ if (!tui_allowed_p ())
+ error (_("TUI mode not allowed"));
+
if (tui_active)
return;
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index e9fba98..7ece1b5 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -65,6 +65,10 @@ extern int tui_get_command_dimension (unsigned int *width,
key shortcut. */
extern void tui_initialize_readline (void);
+/* True if enabling the TUI is allowed. Example, if the top level
+ interpreter is MI, enabling curses will certainly lose. */
+extern int tui_allowed_p (void);
+
/* Enter in the tui mode (curses). */
extern void tui_enable (void);