]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/tui/tui.c
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / tui / tui.c
index d36ee669844637e755f9fdc8b3bb84f2dd03ec01..d609de337e2769593a4bfad68bf6dc6db0984e71 100644 (file)
@@ -1,7 +1,6 @@
 /* General functions for the WDB TUI.
 
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
-   Free Software Foundation, Inc.
+   Copyright (C) 1998-2013 Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
@@ -9,7 +8,7 @@
 
    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 2 of the License, or
+   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,
@@ -18,9 +17,7 @@
    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, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "gdbcmd.h"
@@ -243,11 +240,17 @@ tui_rl_command_key (int count, int key)
     {
       if (tui_commands[i].key == key)
         {
-          /* Must save the command because it can be modified by
-             execute_command.  */
-          char *cmd = alloca (strlen (tui_commands[i].cmd) + 1);
-          strcpy (cmd, tui_commands[i].cmd);
-          execute_command (cmd, TRUE);
+          /* Insert the command in the readline buffer.
+             Avoid calling the gdb command here since it creates
+             a possible recursion on readline if prompt_for_continue
+             is called (See PR 9584).  The command will also appear
+             in the readline history which turns out to be better.  */
+          rl_insert_text (tui_commands[i].cmd);
+          rl_newline (1, '\n');
+
+          /* Switch to gdb command mode while executing the command.
+             This way the gdb's continue prompty will be displayed.  */
+          tui_set_key_mode (TUI_ONE_COMMAND_MODE);
           return 0;
         }
     }
@@ -286,7 +289,7 @@ static int
 tui_rl_startup_hook (void)
 {
   rl_already_prompted = 1;
-  if (tui_current_key_mode != TUI_COMMAND_MODE)
+  if (tui_current_key_mode != TUI_COMMAND_MODE && immediate_quit == 0)
     tui_set_key_mode (TUI_SINGLE_KEY_MODE);
   tui_redisplay_readline ();
   return 0;
@@ -366,6 +369,9 @@ tui_initialize_readline (void)
 void
 tui_enable (void)
 {
+  if (!tui_allowed_p ())
+    error (_("TUI mode not allowed"));
+
   if (tui_active)
     return;
 
@@ -458,7 +464,8 @@ tui_disable (void)
 }
 
 void
-strcat_to_buf (char *buf, int buflen, const char *item_to_add)
+strcat_to_buf (char *buf, int buflen, 
+              const char *item_to_add)
 {
   if (item_to_add != (char *) NULL && buf != (char *) NULL)
     {
@@ -528,6 +535,7 @@ void
 tui_show_source (const char *file, int line)
 {
   struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
   /* Make sure that the source window is displayed.  */
   tui_add_win_to_layout (SRC_WIN);
 
@@ -536,10 +544,10 @@ tui_show_source (const char *file, int line)
 }
 
 void
-tui_show_assembly (CORE_ADDR addr)
+tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   tui_add_win_to_layout (DISASSEM_WIN);
-  tui_update_source_windows_with_addr (addr);
+  tui_update_source_windows_with_addr (gdbarch, addr);
 }
 
 int
@@ -555,7 +563,8 @@ tui_is_window_visible (enum tui_win_type type)
 }
 
 int
-tui_get_command_dimension (unsigned int *width, unsigned int *height)
+tui_get_command_dimension (unsigned int *width, 
+                          unsigned int *height)
 {
   if (!tui_active || (TUI_CMD_WIN == NULL))
     {