gdb/tui: Fix 'layout asm' before the inferior has started
[deliverable/binutils-gdb.git] / gdb / tui / tui.c
index a0d2e4c791329f4fc875091e59297a3b7ca3d167..99d30a55a153338e64399410da7461a11633f3ae 100644 (file)
@@ -1,6 +1,6 @@
 /* General functions for the WDB TUI.
 
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
 
    Contributed by Hewlett-Packard Company.
 
@@ -44,9 +44,6 @@
 #include <ctype.h>
 #include <signal.h>
 #include <fcntl.h>
-#if 0
-#include <termio.h>
-#endif
 #include <setjmp.h>
 
 #include "gdb_curses.h"
@@ -58,8 +55,8 @@
 #include "readline/readline.h"
 
 /* Tells whether the TUI is active or not.  */
-int tui_active = 0;
-static int tui_finish_init = 1;
+bool tui_active = false;
+static bool tui_finish_init = true;
 
 enum tui_key_mode tui_current_key_mode = TUI_COMMAND_MODE;
 
@@ -482,7 +479,7 @@ tui_enable (void)
       tui_set_win_focus_to (TUI_SRC_WIN);
       keypad (TUI_CMD_WIN->handle.get (), TRUE);
       wrefresh (TUI_CMD_WIN->handle.get ());
-      tui_finish_init = 0;
+      tui_finish_init = false;
     }
   else
     {
@@ -492,16 +489,12 @@ tui_enable (void)
      clearok (stdscr, TRUE);
    }
 
-  /* Install the TUI specific hooks.  */
-  tui_install_hooks ();
-  rl_startup_hook = tui_rl_startup_hook;
-
   if (tui_update_variables ())
     tui_rehighlight_all ();
 
   tui_setup_io (1);
 
-  tui_active = 1;
+  tui_active = true;
 
   /* Resize windows before anything might display/refresh a
      window.  */
@@ -513,6 +506,14 @@ tui_enable (void)
 
   if (deprecated_safe_get_selected_frame ())
     tui_show_frame_info (deprecated_safe_get_selected_frame ());
+  else
+    tui_display_main ();
+
+  /* Install the TUI specific hooks.  This must be done after the call to
+     tui_display_main so that we don't detect the symtab changed event it
+     can cause.  */
+  tui_install_hooks ();
+  rl_startup_hook = tui_rl_startup_hook;
 
   /* Restore TUI keymap.  */
   tui_set_key_mode (tui_current_key_mode);
@@ -553,7 +554,7 @@ tui_disable (void)
   /* Update gdb's knowledge of its terminal.  */
   gdb_save_tty_state ();
 
-  tui_active = 0;
+  tui_active = false;
   tui_update_gdb_sizes ();
 }
 
@@ -573,71 +574,6 @@ tui_disable_command (const char *args, int from_tty)
   tui_disable ();
 }
 
-#if 0
-/* Solaris <sys/termios.h> defines CTRL.  */
-#ifndef CTRL
-#define CTRL(x)         (x & ~0140)
-#endif
-
-#define FILEDES         2
-#define CHK(val, dft)   (val<=0 ? dft : val)
-
-static void
-tui_reset (void)
-{
-  struct termio mode;
-
-  /* Reset the teletype mode bits to a sensible state.
-     Copied tset.c.  */
-#if defined (TIOCGETC)
-  struct tchars tbuf;
-#endif /* TIOCGETC */
-#ifdef UCB_NTTY
-  struct ltchars ltc;
-
-  if (ldisc == NTTYDISC)
-    {
-      ioctl (FILEDES, TIOCGLTC, &ltc);
-      ltc.t_suspc = CHK (ltc.t_suspc, CTRL ('Z'));
-      ltc.t_dsuspc = CHK (ltc.t_dsuspc, CTRL ('Y'));
-      ltc.t_rprntc = CHK (ltc.t_rprntc, CTRL ('R'));
-      ltc.t_flushc = CHK (ltc.t_flushc, CTRL ('O'));
-      ltc.t_werasc = CHK (ltc.t_werasc, CTRL ('W'));
-      ltc.t_lnextc = CHK (ltc.t_lnextc, CTRL ('V'));
-      ioctl (FILEDES, TIOCSLTC, &ltc);
-    }
-#endif /* UCB_NTTY */
-#ifdef TIOCGETC
-  ioctl (FILEDES, TIOCGETC, &tbuf);
-  tbuf.t_intrc = CHK (tbuf.t_intrc, CTRL ('?'));
-  tbuf.t_quitc = CHK (tbuf.t_quitc, CTRL ('\\'));
-  tbuf.t_startc = CHK (tbuf.t_startc, CTRL ('Q'));
-  tbuf.t_stopc = CHK (tbuf.t_stopc, CTRL ('S'));
-  tbuf.t_eofc = CHK (tbuf.t_eofc, CTRL ('D'));
-  /* brkc is left alone.  */
-  ioctl (FILEDES, TIOCSETC, &tbuf);
-#endif /* TIOCGETC */
-  mode.sg_flags &= ~(RAW
-#ifdef CBREAK
-                    | CBREAK
-#endif /* CBREAK */
-                    | VTDELAY | ALLDELAY);
-  mode.sg_flags |= XTABS | ECHO | CRMOD | ANYP;
-}
-#endif
-
-void
-tui_show_source ()
-{
-  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);
-
-  tui_update_source_windows_with_line (cursal);
-  tui_update_locator_fullname (cursal.symtab);
-}
-
 void
 tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
@@ -648,7 +584,7 @@ tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr)
 bool
 tui_is_window_visible (enum tui_win_type type)
 {
-  if (tui_active == 0)
+  if (!tui_active)
     return false;
 
   if (tui_win_list[type] == 0)
@@ -657,18 +593,16 @@ tui_is_window_visible (enum tui_win_type type)
   return tui_win_list[type]->is_visible ();
 }
 
-int
+bool
 tui_get_command_dimension (unsigned int *width, 
                           unsigned int *height)
 {
   if (!tui_active || (TUI_CMD_WIN == NULL))
-    {
-      return 0;
-    }
+    return false;
   
   *width = TUI_CMD_WIN->width;
   *height = TUI_CMD_WIN->height;
-  return 1;
+  return true;
 }
 
 void
This page took 0.025254 seconds and 4 git commands to generate.