This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[RFA]: Fix TUI to build and run


Hi!

The following patch fixes the build and several runtime problems
with TUI.  I checked it for i386-linux and m6811-elf targets.
I checked on xterm and linux consoles. It works reasonably well
although this is not perfect.

 - This fix the hppa specific register management.  This is now
   more generic.  This is not perfect because the current gdb
   register interface does not allow to retrieve the type of
   registers (If I remember, Nick's patch about registers would
   be very useful here).

 - The TUI no longer relies on undocumented readline variables
   (term_*).  It obtains the termcap capabilities it needs.

 - It fixes the cooperation between TUI and readline as well as
   the sharing of the tty between readline output and curses.

 - It fixes many crashes.

This patch is not perfect.  It repairs TUI to put it in a
usable shape.

I'm going to submit other patches to cleanup the TUI, put it
in ANSI-C, and do some improvements.

Can you approve this patch?

	Stephane

2001-03-25  Stephane Carrez  <Stephane.Carrez@worldnet.fr>

	* tuiGeneralWin.c (boxWin): Use XSI Curses standard characters
	for the border.
	* tuiDisassem.c (tuiSetDisassemContent): Use tm_print_insn_info
	to configure the disassembler for curses.
	* tuiData.c (partialWinByName): Fix crash when winList[i] is null.
	(tuiNextWin): Likewise.
	* tuiGeneralWin.c (refreshAll): Fix crash when list[type] is null.
	* tuiWin.c (tuiRefreshAll): Fix crash when winList[type] or
	dataWin are null.
	(_makeVisibleWithNewHeight): Fix call to find_line_pc.
	* tuiStack.c (tuiShowFrameInfo): Fix crash when find_pc_symtab
	returns a null symtab.
	* tuiSourceWin.c (tuiUpdateSourceWindowsWithLine): Fix calls to
	find_line_pc.
	(tuiSetHasBreakAt): Fix crash when a breakpoint without a source
	file is installed.
	* tuiSource.c (_hasBreak): Fix crash when a breakpoint without
	a source file is installed.
	* tuiRegs.c (_tuiRegisterName): Use REGISTER_NAME.
	(_tuiRegisterFormat): If the register exist, get and format
	its value in a generic way.
	(START_SPECIAL_REGS): Define.
	(_tuiGetRegisterRawValue): Use get_saved_register.
	* tuiLayout.c (_initAndMakeWin): Don't turn echo mode.
	(_tuiSetLayoutTo): Fix crash when dataWin == 0.
	(_extractDisplayStartAddr): Fix call to find_line_pc.
	* tui.h (tui_term_rc, tui_term_sc, tui_cursor_move): Declare.
	(tui_scroll_region, tui_memory_lock): Declare.
	(tui_memory_unlock, tui_term_se): Declare.
	* tui.c: Define the above global.
	* tuiIO.c (tuiPuts_unfiltered): #if 0 this function.
	(tui_tputs): Likewise.
	(tuiGetc): Update to conform to readline getc prototype;
	Use TUI_ENTER_SCREEN_OK and TUI_LEAVE; Identify KEY_BACKSPACE
	and return \b for readline.
	(_tuiHandleResizeDuringIO): Don't call rl_reset.
	(tuiTermSetup): Turn off NL+CR mapping; Use 'sc' terminal capability
	to save the current cursor location; Move cursor to where curses
	think it should be; Redraw the window;
	(tuiTermUnsetup): Turn on NL+CR mapping for gdb output; Use 'rc'
	to restore the cursor for readline.
	* tuiIO.h (tuiGetc): Fix prototype.
	* tui.h (TUI_ENTER_FIRST, TUI_ENTER_SCREEN_OK): New defines.
	(TUI_ENTER_SCREEN_BAD, TUI_LEAVE_TEMPORARY, TUI_LEAVE): Likewise.
	(subsetCompare): Define.
	* tui.c (prep_terminal, deprep_terminal): New functions to override
	readline terminal setting.
	(tuiInit): Initialize readline before curses; override readline
	terminal setting; get 'cm', 'cs', 'se', 'rc', 'sc' terminal
	capabilities; install tui getc function for readline
	(tuiInitWindows): Don't use echo, crmode or nl.
	(tuiCleanUp): Use TUI_ENTER_SCREEN_OK to setup terminal.
	(tuiDo): Cleanup.
	(va_catch_errors): Use catch_errors.
	(_tui_vDo): Use TUI_ENTER_SCREEN_OK and TUI_LEAVE.
	(_tuiReset): Do nothing;
	(tuiResetScreen): #if 0 this function.
	* tui-file.c (tui_file_fputs): Indicate to tuiTermUnsetup and
	tuiTermSetup that we leave temporarily the TUI.
Index: tui-file.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-file.c,v
retrieving revision 1.6
diff -u -p -r1.6 tui-file.c
--- tui-file.c	2001/02/08 06:03:54	1.6
+++ tui-file.c	2001/03/25 16:55:29
@@ -205,9 +205,10 @@ tui_file_fputs (const char *linebuffer, 
 	    }
 	  else
 	    {
-	      tuiTermUnsetup (0, (tui_version) ? cmdWin->detail.commandInfo.curch : 0);
+	      tuiTermUnsetup (TUI_LEAVE_TEMPORARY, 
+                              (tui_version) ? cmdWin->detail.commandInfo.curch : 0);
 	      fputs (linebuffer, stream->ts_filestream);
-	      tuiTermSetup (0);
+	      tuiTermSetup (TUI_ENTER_SCREEN_OK);
 	      if (linebuffer[strlen (linebuffer) - 1] == '\n')
 		tuiClearCommandCharCount ();
 	      else
Index: tui.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui.c,v
retrieving revision 1.5
diff -u -p -r1.5 tui.c
--- tui.c	2000/12/15 01:01:51	1.5
+++ tui.c	2001/03/25 16:55:30
@@ -22,12 +22,15 @@
 #include "tuiIO.h"
 #include "tuiRegs.h"
 #include "tuiWin.h"
+#include "readline/readline.h"
 
 /* The Solaris header files seem to provide no declaration for this at
    all when __STDC__ is defined.  This shouldn't conflict with
    anything.  */
 extern char *tgoto ();
 
+extern Function *old_rl_getc_function;
+
 /***********************
 ** Local Definitions
 ************************/
@@ -49,12 +52,44 @@ static void _toggle_command (char *, int
 static void _tui_vToggle_command (va_list);
 static Opaque _tui_vDo (TuiOpaqueFuncPtr, va_list);
 
+extern int tui_owns_terminal;
 
 
 /***********************
 ** Public Functions
 ************************/
 
+#ifndef __MSDOS__
+static char *term_buffer = (char *)NULL;
+static char *term_string_buffer = (char *)NULL;
+
+/* Non-zero means this terminal can't really do anything. */
+static int dumb_term;
+#endif /* !__MSDOS__ */
+
+char *tui_cursor_move;
+char *tui_memory_lock;
+char *tui_memory_unlock;
+char *tui_scroll_region;
+char *tui_term_se;
+char *tui_term_rc;
+char *tui_term_sc;
+static char *tui_term_buffer;
+static char *tui_term_string_buffer;
+
+VFunction *old_rl_prep_terminal;
+VFunction *old_rl_deprep_terminal;
+
+static void
+prep_terminal ()
+{
+}
+
+static void
+deprep_terminal ()
+{
+}
+
 /*
    ** tuiInit().
  */
@@ -66,28 +101,72 @@ tuiInit (argv0)
      char *argv0;
 #endif
 {
+  WINDOW *w;
+  char *term;
+  char *buffer;
   extern void init_page_info ();
-extern void initialize_tui_files (void);
+  extern int readline_echoing_p;
 
-  initialize_tui_files ();
   initializeStaticData ();
-  initscr ();
+
+  rl_initialize ();		/* need readline initialization to
+				   * create termcap sequences
+
+                                  */
+  old_rl_deprep_terminal = rl_deprep_term_function;
+  old_rl_prep_terminal = rl_prep_term_function;
+  rl_deprep_term_function = deprep_terminal;
+  rl_prep_term_function = prep_terminal;
+  
+  readline_echoing_p = 1;
+  w = initscr ();
+  cbreak();
+  noecho();
+  nodelay (w, TRUE);
+  nl();
   refresh ();
   setTermHeightTo (LINES);
   setTermWidthTo (COLS);
   tuiInitWindows ();
   wrefresh (cmdWin->generic.handle);
   init_page_info ();
+
+  term = termname ();
+  
+  if (tui_term_string_buffer == 0)
+    tui_term_string_buffer = xmalloc(2032);
+
+  if (tui_term_buffer == 0)
+    tui_term_buffer = xmalloc(4080);
+
+  buffer = term_string_buffer;
+
+  if (tgetent (tui_term_buffer, term) == 1)
+    {
+      tui_cursor_move = tgetstr ("cm", &buffer);
+      tui_memory_lock = 0; /* ? which capability is it.  */
+      tui_memory_unlock = 0; /* ? which capability is it.  */
+      tui_scroll_region = tgetstr ("cs", &buffer);
+      tui_term_se = tgetstr ("se", &buffer);
+      tui_term_rc = tgetstr ("rc", &buffer);
+      tui_term_sc = tgetstr ("sc", &buffer);
+    }
+  
   /* Don't hook debugger output if doing command-window
      * the XDB way. However, one thing we do want to do in
      * XDB style is set up the scrolling region to be
      * the bottom of the screen (tuiTermUnsetup()).
    */
-  fputs_unfiltered_hook = NULL;
-  rl_initialize ();		/* need readline initialization to
-				   * create termcap sequences
-				 */
-  tuiTermUnsetup (1, cmdWin->detail.commandInfo.curch);
+  tui_owns_terminal = 0;
+  if (old_rl_getc_function == 0)
+    {
+      old_rl_getc_function = rl_getc_function;
+      rl_getc_function = tuiGetc;
+    }
+#if 0
+  tuiTermSetup (TUI_ENTER_FIRST);
+#endif
+  tuiTermUnsetup (TUI_LEAVE, cmdWin->detail.commandInfo.curch);
 
   return;
 }				/* tuiInit */
@@ -108,15 +187,12 @@ tuiInitWindows ()
   tuiSetLocatorContent (0);
   showLayout (SRC_COMMAND);
   keypad (cmdWin->generic.handle, TRUE);
-  echo ();
-  crmode ();
-  nl ();
   tuiSetWinFocusTo (srcWin);
 
   return;
 }				/* tuiInitWindows */
 
-
+#if 0
 /*
    ** tuiCleanUp().
    **        Kill signal handler and cleanup termination method
@@ -147,6 +223,7 @@ tuiResetScreen ()
 
   return;
 }				/* tuiResetScreen */
+#endif
 
 
 /*
@@ -161,21 +238,20 @@ tuiCleanUp ()
 #endif
 {
   char *buffer;
-  extern char *term_cursor_move;
 
   signal (SIGINT, SIG_IGN);
-  tuiTermSetup (0);		/* Restore scrolling region to whole screen */
+  /* Restore scrolling region to whole screen */
+  tuiTermSetup (TUI_ENTER_SCREEN_OK);
   keypad (cmdWin->generic.handle, FALSE);
   freeAllWindows ();
   endwin ();
-  buffer = tgoto (term_cursor_move, 0, termHeight ());
+  buffer = tgoto (tui_cursor_move, 0, termHeight ());
   tputs (buffer, 1, putchar);
   _tuiReset ();
 
   return;
 }				/* tuiCleanUp */
 
-
 /*
    ** tuiError().
  */
@@ -328,14 +404,7 @@ tui_vGetLowDisassemblyAddress (args)
    **       be replaced by judicious use of QUIT.
  */
 Opaque
-#ifdef __STDC__
-tuiDo (
-	TuiOpaqueFuncPtr func,...)
-#else
-tuiDo (func, va_alist)
-     TuiOpaqueFuncPtr func;
-     va_dcl
-#endif
+tuiDo (TuiOpaqueFuncPtr func, ...)
 {
   extern int terminal_is_ours;
 
@@ -494,43 +563,8 @@ va_catch_errors (func, args)
 #endif
 {
   Opaque ret = (Opaque) NULL;
-
-  /*
-     ** We could have used catch_errors(), but it doesn't handle variable args.
-     ** Also, for the tui, we always want to catch all errors, so we don't
-     ** need to pass a mask, or an error string.
-   */
-  jmp_buf saved_error;
-  jmp_buf saved_quit;
-  jmp_buf tmp_jmp;
-  struct cleanup *saved_cleanup_chain;
-  char *saved_error_pre_print;
-  char *saved_quit_pre_print;
-  extern jmp_buf error_return;
-  extern jmp_buf quit_return;
-
-  saved_cleanup_chain = save_cleanups ();
-  saved_error_pre_print = error_pre_print;
-  saved_quit_pre_print = quit_pre_print;
-
-  memcpy ((char *) saved_error, (char *) error_return, sizeof (jmp_buf));
-  error_pre_print = "";
-  memcpy (saved_quit, quit_return, sizeof (jmp_buf));
-  quit_pre_print = "";
-
-  if (setjmp (tmp_jmp) == 0)
-    {
-      va_list argList = args;
-      memcpy (error_return, tmp_jmp, sizeof (jmp_buf));
-      memcpy (quit_return, tmp_jmp, sizeof (jmp_buf));
-      ret = func (argList);
-    }
-  restore_cleanups (saved_cleanup_chain);
-  memcpy (error_return, saved_error, sizeof (jmp_buf));
-  error_pre_print = saved_error_pre_print;
-  memcpy (quit_return, saved_quit, sizeof (jmp_buf));
-  quit_pre_print = saved_quit_pre_print;
 
+  ret = catch_errors ((catch_errors_ftype*) func, args, "", RETURN_MASK_ERROR);
   return ret;
 }
 
@@ -683,12 +717,12 @@ _tui_vDo (func, args)
          * is unmanaged by curses...
        */
       /* Set up terminal for TUI */
-      tuiTermSetup (1);
+      tuiTermSetup (TUI_ENTER_SCREEN_OK);
 
       ret = va_catch_errors (func, args);
 
       /* Set up terminal for command window */
-      tuiTermUnsetup (1, cmdWin->detail.commandInfo.curch);
+      tuiTermUnsetup (TUI_LEAVE, cmdWin->detail.commandInfo.curch);
     }
 
   return ret;
@@ -761,6 +795,7 @@ _tuiReset (void)
 _tuiReset ()
 #endif
 {
+#if 0
   struct termio mode;
 
   /*
@@ -823,6 +858,6 @@ _tuiReset ()
   mode.c_lflag |= (ISIG | ICANON | ECHO | ECHOK);
   ioctl (FILEDES, TCSETAW, &mode);
 #endif /* USG */
-
+#endif
   return;
 }				/* _tuiReset */
Index: tui.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui.h,v
retrieving revision 1.4
diff -u -p -r1.4 tui.h
--- tui.h	2000/06/04 00:41:10	1.4
+++ tui.h	2001/03/25 16:55:39
@@ -22,7 +22,14 @@
 #if defined(chtype)
 #undef chtype
 #endif
+#define subsetCompare(S1,S2) strcmp (S1,S2) == 0
 
+#define TUI_ENTER_FIRST      3
+#define TUI_ENTER_SCREEN_OK  0
+#define TUI_ENTER_SCREEN_BAD 1
+#define TUI_LEAVE_TEMPORARY  2
+#define TUI_LEAVE            0
+
 /* Opaque data type */
 typedef char *Opaque;
 typedef
@@ -130,4 +137,14 @@ extern void tui_vUpdateSourceWindowsWith
 /* tuiStack.c */
 extern void tui_vShowFrameInfo (va_list);
 extern void tui_vUpdateLocatorFilename (va_list);
+
+/* Tui internal global variables.  */
+extern char *tui_term_rc;
+extern char *tui_term_sc;
+extern char *tui_cursor_move;
+extern char *tui_scroll_region;
+extern char *tui_memory_lock;
+extern char *tui_memory_unlock;
+extern char *tui_term_se;
+
 #endif /* TUI_H */
Index: tuiData.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiData.c,v
retrieving revision 1.3
diff -u -p -r1.3 tuiData.c
--- tuiData.c	2000/12/15 01:01:51	1.3
+++ tuiData.c	2001/03/25 16:55:40
@@ -615,7 +615,7 @@ tuiNextWin (curWin)
     type = curWin->generic.type + 1;
   while (type != curWin->generic.type && m_winPtrIsNull (nextWin))
     {
-      if (winList[type]->generic.isVisible)
+      if (winList[type] && winList[type]->generic.isVisible)
 	nextWin = winList[type];
       else
 	{
@@ -901,10 +901,13 @@ partialWinByName (name)
 
       while (i < MAX_MAJOR_WINDOWS && m_winPtrIsNull (winInfo))
 	{
-	  char *curName = winName (&winList[i]->generic);
-	  if (strlen (name) <= strlen (curName) &&
-	      strncmp (name, curName, strlen (name)) == 0)
-	    winInfo = winList[i];
+          if (winList[i] != 0)
+            {
+              char *curName = winName (&winList[i]->generic);
+              if (strlen (name) <= strlen (curName) &&
+                  strncmp (name, curName, strlen (name)) == 0)
+                winInfo = winList[i];
+            }
 	  i++;
 	}
     }
Index: tuiDisassem.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiDisassem.c,v
retrieving revision 1.2
diff -u -p -r1.2 tuiDisassem.c
--- tuiDisassem.c	2000/05/28 01:12:42	1.2
+++ tuiDisassem.c	2001/03/25 16:55:43
@@ -14,8 +14,8 @@
 #include "tuiLayout.h"
 #include "tuiSourceWin.h"
 #include "tuiStack.h"
+#include "tui-file.h"
 
-
 /*****************************************
 ** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
 ******************************************/
@@ -68,9 +68,8 @@ extern void strcat_address_numeric (CORE
 	  /* now init the ui_file structure */
 	  gdb_dis_out = tui_sfileopen (threshold);
 
-	  INIT_DISASSEMBLE_INFO_NO_ARCH (asmInfo, gdb_dis_out, (fprintf_ftype) fprintf_filtered);
-	  asmInfo.read_memory_func = dis_asm_read_memory;
-	  asmInfo.memory_error_func = dis_asm_memory_error;
+          asmInfo = tm_print_insn_info;
+          asmInfo.stream = gdb_dis_out;
 
 	  disassemWin->detail.sourceInfo.startLineOrAddr.addr = startAddr;
 
Index: tuiGeneralWin.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiGeneralWin.c,v
retrieving revision 1.3
diff -u -p -r1.3 tuiGeneralWin.c
--- tuiGeneralWin.c	2000/05/28 01:12:42	1.3
+++ tuiGeneralWin.c	2001/03/25 16:55:43
@@ -80,34 +80,33 @@ tuiDelwin (window)
 }				/* tuiDelwin */
 
 
-/*
-   ** boxWin().
- */
+/* boxWin().  */
 void
-#ifdef __STDC__
-boxWin (
-	 TuiGenWinInfoPtr winInfo,
-	 int highlightFlag)
-#else
-boxWin (winInfo, highlightFlag)
-     TuiGenWinInfoPtr winInfo;
-     int highlightFlag;
-#endif
+boxWin (TuiGenWinInfoPtr winInfo, int highlightFlag)
 {
+  WINDOW *win;
+  
   if (m_genWinPtrNotNull (winInfo) && winInfo->handle != (WINDOW *) NULL)
     {
+      win = winInfo->handle;
       if (highlightFlag == HILITE)
-	box (winInfo->handle, '|', '-');
+        {
+          wattron(win, A_BOLD);
+          wborder (win, ACS_VLINE, ACS_VLINE, ACS_HLINE,
+                   ACS_HLINE,  ACS_ULCORNER,  ACS_URCORNER,
+                   ACS_LLCORNER, ACS_LRCORNER);
+          wattroff (win, A_BOLD);
+        }
       else
 	{
-/*            wattron(winInfo->handle, A_DIM); */
-	  box (winInfo->handle, ':', '.');
-/*            wattroff(winInfo->handle, A_DIM); */
+          wattron (win, A_DIM);
+          wborder (win, ACS_VLINE, ACS_VLINE, ACS_HLINE,
+                   ACS_HLINE,  ACS_ULCORNER,  ACS_URCORNER,
+                   ACS_LLCORNER, ACS_LRCORNER);
+          wattroff (win, A_DIM);
 	}
     }
-
-  return;
-}				/* boxWin */
+}
 
 
 /*
@@ -442,7 +441,7 @@ refreshAll (list)
 
   for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
     {
-      if (list[type]->generic.isVisible)
+      if (list[type] && list[type]->generic.isVisible)
 	{
 	  if (type == SRC_WIN || type == DISASSEM_WIN)
 	    {
Index: tuiIO.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiIO.c,v
retrieving revision 1.4
diff -u -p -r1.4 tuiIO.c
--- tuiIO.c	2000/06/18 00:23:24	1.4
+++ tuiIO.c	2001/03/25 16:55:45
@@ -12,6 +12,7 @@
 #include "tuiIO.h"
 #include "tuiCommand.h"
 #include "tuiWin.h"
+#include "readline/readline.h"
 
 #ifdef ANSI_PROTOTYPES
 #include <stdarg.h>
@@ -36,7 +37,7 @@ static unsigned int _tuiHandleResizeDuri
 /*********************************************************************************
 **                              PUBLIC FUNCTIONS                                **
 *********************************************************************************/
-
+#if 0
 /*
    ** tuiPuts_unfiltered().
    **        Function to put a string to the command window
@@ -255,7 +256,7 @@ tui_tputs (str, affcnt, putfunc)
       tputs (str, affcnt, putfunc);
     }
 }				/* tui_tputs */
-
+#endif
 
 /*
    ** tui_vwgetch()
@@ -325,6 +326,7 @@ tuiRead (filedes, buf, nbytes)
   return result;
 }				/* tuiRead */
 
+Function *old_rl_getc_function = 0;
 
 /*
    ** tuiGetc().
@@ -337,9 +339,10 @@ tuiRead (filedes, buf, nbytes)
  */
 unsigned int
 #ifdef __STDC__
-tuiGetc (void)
+tuiGetc (FILE *fp)
 #else
-tuiGetc ()
+tuiGetc (fp)
+     FILE* fp;
 #endif
 {
   unsigned int ch;
@@ -358,16 +361,19 @@ tuiGetc ()
 
   if (m_isCommandChar (ch))
     {				/* Handle prev/next/up/down here */
-      tuiTermSetup (0);
+      tuiTermSetup (TUI_ENTER_SCREEN_OK);
       ch = tuiDispatchCtrlChar (ch);
       cmdWin->detail.commandInfo.curch = strlen (rl_prompt) + rl_point;
-      tuiTermUnsetup (0, cmdWin->detail.commandInfo.curch);
+      tuiTermUnsetup (TUI_LEAVE, cmdWin->detail.commandInfo.curch);
     }
   if (ch == '\n' || ch == '\r' || ch == '\f')
     cmdWin->detail.commandInfo.curch = 0;
   else
     tuiIncrCommandCharCountBy (1);
 
+  if (ch == KEY_BACKSPACE)
+    return '\b';
+  
   return ch;
 }				/* tuiGetc */
 
@@ -509,7 +515,9 @@ _tuiHandleResizeDuringIO (originalCh)
       tuiDo ((TuiOpaqueFuncPtr) tuiRefreshAll);
       dont_repeat ();
       tuiSetWinResizedTo (FALSE);
+#if 0
       rl_reset ();
+#endif
       return '\n';
     }
   else
@@ -558,70 +566,64 @@ int tui_owns_terminal = 0;
  */
 
 void
-#ifdef __STDC__
-tuiTermSetup (
-	       int turn_off_echo)
-#else
-tuiTermSetup (turn_off_echo)
-     int turn_off_echo;
-#endif
+tuiTermSetup (int mode)
 {
   char *buffer;
   int start;
   int end;
   int endcol;
-  extern char *term_scroll_region;
-  extern char *term_cursor_move;
-  extern char *term_memory_lock;
-  extern char *term_memory_unlock;
 
-  /* Turn off echoing, since the TUI does not
-     * expect echoing. Below I only put in the TERMIOS
-     * case, since that is what applies on HP-UX. turn_off_echo
-     * is 1 except for the case where we're being called
-     * on a "quit", in which case we want to leave echo on.
-   */
-  if (turn_off_echo)
-    {
+  /* Turn off NL+CR mapping while in TUI.  */
 #ifdef HAVE_TERMIOS
-      struct termios tio;
-      tcgetattr (0, &tio);
-      tio.c_lflag &= ~(ECHO);
-      tcsetattr (0, TCSANOW, &tio);
+  struct termios tio;
+
+  tcgetattr (0, &tio);
+  tio.c_oflag &= ~ONLCR;
+  tcsetattr (0, TCSANOW, &tio);
 #endif
-    }
 
   /* Compute the start and end lines of the command
-     * region. (Actually we only use end here)
-   */
+     region. (Actually we only use end here).  */
   start = winList[CMD_WIN]->generic.origin.y;
   end = start + winList[CMD_WIN]->generic.height - 1;
   endcol = winList[CMD_WIN]->generic.width - 1;
 
-  if (term_memory_unlock)
+  if (mode == TUI_ENTER_FIRST)
     {
+      buffer = tgoto (tui_cursor_move, 0, end+1);
+      tputs (buffer, 1, (int (*) (int)) putchar);
+    }
+  
+  /* Save cursor position.  */
+  if (tui_term_sc && tui_owns_terminal == 0)
+    tputs (tui_term_sc, 1, (int (*) (int)) putchar);
 
-      /* Un-do the effect of the memory lock in terminal_inferior() */
-      tputs (term_memory_unlock, 1, (int (*) (int)) putchar);
+  tui_owns_terminal = 1;
+  
+  if (tui_memory_unlock)
+    {
+      /* Un-do the effect of the memory lock in terminal_inferior().  */
+      tputs (tui_memory_unlock, 1, (int (*) (int)) putchar);
       fflush (stdout);
 
     }
-  else if (term_scroll_region)
+  else if (tui_scroll_region)
     {
 
-      /* Un-do the effect of setting scroll region in terminal_inferior() */
-      /* I'm actually not sure how to do this (we don't know for
-       * sure what the scroll region was *before* we changed it),
-       * but I'll guess that setting it to the whole screen is
-       * the right thing. So, ...
-       */
+      /* Un-do the effect of setting scroll region in terminal_inferior()
+         I'm actually not sure how to do this (we don't know for
+         sure what the scroll region was *before* we changed it),
+         but I'll guess that setting it to the whole screen is
+         the right thing. So, ...  */
 
       /* Set scroll region to be 0..end */
-      buffer = (char *) tgoto (term_scroll_region, end, 0);
+      buffer = (char *) tgoto (tui_scroll_region, end, 0);
       tputs (buffer, 1, (int (*) (int)) putchar);
 
     }				/* else we're out of luck */
-
+  if (mode == TUI_ENTER_SCREEN_OK)
+    return;
+  
   /* This is an attempt to keep the logical & physical
      * cursor in synch, going into curses. Without this,
      * curses seems to be confused by the fact that
@@ -639,13 +641,22 @@ tuiTermSetup (turn_off_echo)
      * only writing what changed (the space),
      * not the whole screen.
    */
+
+  {
+    int x,y;
+    getsyx (y, x);
+    buffer = (char *) tgoto (tui_cursor_move, x, y);
+    tputs (buffer, 1, (int (*) (int)) putchar);
+  }
+  
   standend ();
   move (end, endcol - 1);
   addch (' ');
   refresh ();
+  tuiRefreshAll ();
 
-  tui_owns_terminal = 1;
-}				/* tuiTermSetup */
+  fflush (stdout);
+}
 
 
 /* Called to set up the terminal for target program I/O, meaning I/O
@@ -653,82 +664,63 @@ tuiTermSetup (turn_off_echo)
  * way out of tuiDo, thus setting up the terminal this way for
  * debugger command I/O.  */
 void
-#ifdef __STDC__
-tuiTermUnsetup (
-		 int turn_on_echo,
-		 int to_column)
-#else
-tuiTermUnsetup (turn_on_echo, to_column)
-     int turn_on_echo;
-     int to_column;
-#endif
+tuiTermUnsetup (int mode, int to_column)
 {
   int start;
   int end;
   int curline;
   char *buffer;
-  /* The next bunch of things are from readline */
-  extern char *term_scroll_region;
-  extern char *term_cursor_move;
-  extern char *term_memory_lock;
-  extern char *term_memory_unlock;
-  extern char *term_se;
 
-  /* We need to turn on echoing, since the TUI turns it off */
-  /* Below I only put in the TERMIOS case, since that
-     * is what applies on HP-UX.
-   */
-  if (turn_on_echo)
-    {
+  /* Turn on NL+CR mapping for gdb and program.  */
 #ifdef HAVE_TERMIOS
-      struct termios tio;
-      tcgetattr (0, &tio);
-      tio.c_lflag |= (ECHO);
-      tcsetattr (0, TCSANOW, &tio);
+  struct termios tio;
+  tcgetattr (0, &tio);
+  tio.c_oflag |= ONLCR;
+  tcsetattr (0, TCSANOW, &tio);
 #endif
-    }
 
   /* Compute the start and end lines of the command
-     * region, as well as the last "real" line of
-     * the region (normally same as end, except when
-     * we're first populating the region)
-   */
+     region, as well as the last "real" line of
+     the region (normally same as end, except when
+     we're first populating the region).  */
   start = winList[CMD_WIN]->generic.origin.y;
   end = start + winList[CMD_WIN]->generic.height - 1;
   curline = start + winList[CMD_WIN]->detail.commandInfo.curLine;
 
+  refresh ();
+
   /* We want to confine target I/O to the command region.
-     * In order to do so, we must either have "memory lock"
-     * (hpterm's) or "scroll regions" (xterm's).
-   */
-  if (term_cursor_move && term_memory_lock)
+     In order to do so, we must either have "memory lock"
+     (hpterm's) or "scroll regions" (xterm's).  */
+  if (tui_cursor_move && tui_memory_lock)
     {
-
       /* Memory lock means lock region above cursor.
-       * So first position the cursor, then call memory lock.
-       */
-      buffer = tgoto (term_cursor_move, 0, start);
+         So first position the cursor, then call memory lock.  */
+      buffer = tgoto (tui_cursor_move, 0, start);
       tputs (buffer, 1, (int (*) (int)) putchar);
-      tputs (term_memory_lock, 1, (int (*) (int)) putchar);
-
+      tputs (tui_memory_lock, 1, (int (*) (int)) putchar);
     }
-  else if (term_scroll_region)
+  else if (tui_scroll_region)
     {
-
-      /* Set the scroll region to the command window */
-      buffer = tgoto (term_scroll_region, end, start);
+      /* Set the scroll region to the command window.  */
+      buffer = tgoto (tui_scroll_region, end, start);
       tputs (buffer, 1, (int (*) (int)) putchar);
+    }
+  /* else we can't do anything about target I/O */
 
-    }				/* else we can't do anything about target I/O */
+  /* Also turn off standout mode, in case it is on.  */
+  if (tui_term_se != NULL)
+    tputs (tui_term_se, 1, (int (*) (int)) putchar);
+
+  /* Now go to the appropriate spot on the end line.  */
+  if (tui_term_rc && tui_owns_terminal == 1)
+    tputs (tui_term_rc, 1, (int (*) (int)) putchar);
+  else
+    {
+      buffer = tgoto (tui_cursor_move, to_column, end);
+      tputs (buffer, 1, (int (*) (int)) putchar);
+    }
 
-  /* Also turn off standout mode, in case it is on */
-  if (term_se != NULL)
-    tputs (term_se, 1, (int (*) (int)) putchar);
-
-  /* Now go to the appropriate spot on the end line */
-  buffer = tgoto (term_cursor_move, to_column, end);
-  tputs (buffer, 1, (int (*) (int)) putchar);
   fflush (stdout);
-
   tui_owns_terminal = 0;
-}				/* tuiTermUnsetup */
+}
Index: tuiIO.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiIO.h,v
retrieving revision 1.2
diff -u -p -r1.2 tuiIO.h
--- tuiIO.h	2000/05/28 01:12:42	1.2
+++ tuiIO.h	2001/03/25 16:55:45
@@ -8,7 +8,7 @@
 #include <stdio.h>
 
 extern void tuiPuts_unfiltered  (const char *, struct ui_file *);
-extern unsigned int tuiGetc (void);
+extern unsigned int tuiGetc (FILE *);
 extern unsigned int tuiBufferGetc (void);
 extern int tuiRead (int, char *, int);
 extern void tuiStartNewLines (int);
Index: tuiLayout.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiLayout.c,v
retrieving revision 1.5
diff -u -p -r1.5 tuiLayout.c
--- tuiLayout.c	2000/12/15 01:01:51	1.5
+++ tuiLayout.c	2001/03/25 16:55:50
@@ -577,7 +577,7 @@ _tuiSetLayoutTo (layoutName)
 		dpyType = TUI_GENERAL_REGS;
 	      else if (subsetCompare (bufPtr, TUI_SPECIAL_REGS_NAME))
 		dpyType = TUI_SPECIAL_REGS;
-	      else
+	      else if (dataWin)
 		{
 		  if (dataWin->detail.dataDisplayInfo.regsDisplayType !=
 		      TUI_UNDEFINED_REGS)
@@ -624,14 +624,16 @@ _extractDisplayStartAddr ()
 {
   TuiLayoutType curLayout = currentLayout ();
   Opaque addr;
+  CORE_ADDR pc;
 
   switch (curLayout)
     {
     case SRC_COMMAND:
     case SRC_DATA_COMMAND:
-      addr = (Opaque) find_line_pc (
-				     current_source_symtab,
-			  srcWin->detail.sourceInfo.startLineOrAddr.lineNo);
+      find_line_pc (current_source_symtab,
+		    srcWin->detail.sourceInfo.startLineOrAddr.lineNo,
+		    &pc);
+      addr =(Opaque) pc;
       break;
     case DISASSEM_COMMAND:
     case SRC_DISASSEM_COMMAND:
@@ -1243,7 +1245,7 @@ _initAndMakeWin (winInfoPtr, winType, he
       makeWindow (generic, boxIt);
       if (winType == LOCATOR_WIN)
 	tuiClearLocatorDisplay ();
-      echo ();
+      /* echo (); */
     }
   *winInfoPtr = opaqueWinInfo;
 
Index: tuiRegs.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiRegs.c,v
retrieving revision 1.4
diff -u -p -r1.4 tuiRegs.c
--- tuiRegs.c	2001/03/13 23:31:14	1.4
+++ tuiRegs.c	2001/03/25 16:55:55
@@ -17,8 +17,8 @@
 #include "target.h"
 #include "tuiLayout.h"
 #include "tuiWin.h"
+#include "tui-file.h"
 
-
 /*****************************************
 ** LOCAL DEFINITIONS                    **
 ******************************************/
@@ -624,19 +624,10 @@ registers.\n",
    **        Return the register name.
  */
 static char *
-#ifdef __STDC__
-_tuiRegisterName (
-		   int regNum)
-#else
-_tuiRegisterName (regNum)
-     int regNum;
-#endif
+_tuiRegisterName (int regNum)
 {
-  if (reg_names[regNum] != (char *) NULL && *(reg_names[regNum]) != (char) 0)
-    return reg_names[regNum];
-  else
-    return ((char *) NULL);
-}				/* tuiGetRegisterName */
+  return REGISTER_NAME (regNum);
+}
 
 
 /*
@@ -664,9 +655,26 @@ _tuiRegisterFormat (buf, bufLen, regNum,
   char tmpBuf[15];
   char *fmt;
   struct ui_file *stream;
+  int i;
+  ULONGEST val;
+  char *name;
 
+  name = REGISTER_NAME (regNum);
+  if (name == 0)
+    {
+      strcpy (buf, "");
+      return;
+    }
+  
   stream = tui_sfileopen (bufLen);
+#if 0
   pa_do_strcat_registers_info (regNum, 0, stream, precision);
+#endif
+
+  val = read_register (regNum);
+  fprintf_filtered (stream, "%8.8s %8.8lx",
+                    name, (long) (val));
+
   strcpy (buf, tui_file_get_strbuf (stream));
   ui_file_delete (stream);
 
@@ -697,7 +705,12 @@ _tuiSetGeneralRegsContent (refreshValues
 }				/* _tuiSetGeneralRegsContent */
 
 
+#ifndef PCOQ_HEAD_REGNUM
+#define START_SPECIAL_REGS  0
+#else
 #define START_SPECIAL_REGS    PCOQ_HEAD_REGNUM
+#endif
+
 /*
    ** _tuiSetSpecialRegsContent().
    **      Set the content of the data window to consist of the special registers.
@@ -859,10 +872,13 @@ _tuiGetRegisterRawValue (regNum, regValu
 
   if (target_has_registers)
     {
-      read_relative_register_raw_bytes_for_frame (regNum, regValue, frame);
-      ret = TUI_SUCCESS;
+      int opt;
+      
+      get_saved_register (regValue, &opt, (CORE_ADDR*) NULL, frame,
+			  regNum, (enum lval_type*) NULL);
+      if (register_cached (regNum) >= 0)
+	ret = TUI_SUCCESS;
     }
-
   return ret;
 }				/* _tuiGetRegisterRawValue */
 
Index: tuiSource.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiSource.c,v
retrieving revision 1.2
diff -u -p -r1.2 tuiSource.c
--- tuiSource.c	2000/05/28 01:12:42	1.2
+++ tuiSource.c	2001/03/25 16:55:55
@@ -451,8 +451,9 @@ _hasBreak (sourceFileName, lineNo)
        (bp != (struct breakpoint *) NULL &&
 	bpWithBreak == (struct breakpoint *) NULL);
        bp = bp->next)
-    if ((strcmp (sourceFileName, bp->source_file) == 0) &&
-	(lineNo == bp->line_number))
+    if (bp->source_file
+	&& (strcmp (sourceFileName, bp->source_file) == 0)
+	&& (lineNo == bp->line_number))
       bpWithBreak = bp;
 
   return bpWithBreak;
Index: tuiSourceWin.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiSourceWin.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 tuiSourceWin.c
--- tuiSourceWin.c	1999/07/07 20:19:30	1.1.1.2
+++ tuiSourceWin.c	2001/03/25 16:55:57
@@ -280,16 +280,22 @@ tuiUpdateSourceWindowsWithLine (s, line)
      int line;
 #endif
 {
+  CORE_ADDR pc;
+  
   switch (currentLayout ())
     {
     case DISASSEM_COMMAND:
     case DISASSEM_DATA_COMMAND:
-      tuiUpdateSourceWindowsWithAddr ((Opaque) find_line_pc (s, line));
+      find_line_pc (s, line, &pc);
+      tuiUpdateSourceWindowsWithAddr ((Opaque) pc);
       break;
     default:
       tuiShowSource (s, (Opaque) line, FALSE);
       if (currentLayout () == SRC_DISASSEM_COMMAND)
-	tuiShowDisassem ((Opaque) find_line_pc (s, line));
+	{
+	  find_line_pc (s, line, pc);
+	  tuiShowDisassem ((Opaque) pc);
+	}
       break;
     }
 
@@ -623,6 +629,7 @@ tuiSetHasBreakAt (bp, winInfo, hasBreak)
 	    fileNameDisplayed = current_source_symtab->filename;
 
 	  gotIt = (fileNameDisplayed != (char *) NULL &&
+                   bp->source_file != NULL &&
 		   (strcmp (bp->source_file, fileNameDisplayed) == 0) &&
 		   content[i]->whichElement.source.lineOrAddr.lineNo ==
 		   bp->line_number);
Index: tuiStack.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiStack.c,v
retrieving revision 1.3
diff -u -p -r1.3 tuiStack.c
--- tuiStack.c	2000/07/30 01:48:28	1.3
+++ tuiStack.c	2001/03/25 16:55:58
@@ -6,6 +6,7 @@
 #include "symtab.h"
 #include "breakpoint.h"
 #include "frame.h"
+#include "command.h"
 
 #include "tui.h"
 #include "tuiData.h"
@@ -385,6 +386,9 @@ tuiShowFrameInfo (fi)
 
 
       s = find_pc_symtab (fi->pc);
+      if (s == 0)
+        return;
+      
       sourceAlreadyDisplayed = tuiSourceIsDisplayed (s->filename);
       tuiUpdateLocatorDisplay (fi);
       for (i = 0; i < (sourceWindows ())->count; i++)
Index: tuiWin.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiWin.c,v
retrieving revision 1.3
diff -u -p -r1.3 tuiWin.c
--- tuiWin.c	2000/07/30 01:48:28	1.3
+++ tuiWin.c	2001/03/25 16:56:01
@@ -397,7 +397,7 @@ tuiRefreshAll ()
   refreshAll (winList);
   for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
     {
-      if (winList[type]->generic.isVisible)
+      if (winList[type] && winList[type]->generic.isVisible)
 	{
 	  switch (type)
 	    {
@@ -777,7 +777,7 @@ The window name specified must be valid 
 	  keypad (cmdWin->generic.handle, (winInfo != cmdWin));
 	}
 
-      if (dataWin->generic.isVisible)
+      if (dataWin && dataWin->generic.isVisible)
 	tuiRefreshDataWin ();
       tuiFree (bufPtr);
       printf_filtered ("Focus set to %s window.\n",
@@ -1422,7 +1422,12 @@ _makeVisibleWithNewHeight (winInfo)
 	  if (winInfo->generic.type == SRC_WIN)
 	    line = (Opaque) current_source_line;
 	  else
-	    line = (Opaque) find_line_pc (s, current_source_line);
+	    {
+	      CORE_ADDR pc;
+
+	      find_line_pc (s, current_source_line, &pc);
+	      line = (Opaque) pc;
+	    }
 	  tuiUpdateSourceWindow (winInfo, s, line, TRUE);
 	}
       if (m_hasLocator (winInfo))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]