merge from gcc
[deliverable/binutils-gdb.git] / gdb / tui / tuiRegs.c
index 6dc6eed8947240cf429f479b65807d9a06d0b225..3a0c4590c8ccb9a331289daedbcf3292ccff6021 100644 (file)
@@ -1,5 +1,8 @@
 /* TUI display registers in window.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
+   Inc.
+
    Contributed by Hewlett-Packard Company.
 
    This file is part of GDB.
@@ -26,6 +29,7 @@
 #include "gdbtypes.h"
 #include "gdbcmd.h"
 #include "frame.h"
+#include "regcache.h"
 #include "inferior.h"
 #include "target.h"
 #include "tuiLayout.h"
 #include "tuiGeneralWin.h"
 #include "tui-file.h"
 
+#ifdef HAVE_NCURSES_H       
+#include <ncurses.h>
+#else
+#ifdef HAVE_CURSES_H
+#include <curses.h>
+#endif
+#endif
+
 /*****************************************
 ** LOCAL DEFINITIONS                    **
 ******************************************/
@@ -66,7 +78,7 @@
 ******************************************/
 static TuiStatus _tuiSetRegsContent
   (int, int, struct frame_info *, TuiRegisterDisplayType, int);
-static char *_tuiRegisterName (int);
+static const char *_tuiRegisterName (int);
 static TuiStatus _tuiGetRegisterRawValue (int, char *, struct frame_info *);
 static void _tuiSetRegisterElement
   (int, struct frame_info *, TuiDataElementPtr, int);
@@ -291,7 +303,7 @@ tuiDisplayRegistersFrom (int startElementNo)
       dataWin->detail.dataDisplayInfo.regsContentCount > 0)
     {
       register int i = startElementNo;
-      int j, valueCharsWide, charsWide, itemWinWidth, curY, labelWidth;
+      int j, valueCharsWide, itemWinWidth, curY, labelWidth;
       enum precision_type precision;
 
       precision = (dataWin->detail.dataDisplayInfo.regsDisplayType
@@ -347,6 +359,8 @@ tuiDisplayRegistersFrom (int startElementNo)
                  makeWindow (dataItemWin, DONT_BOX_WINDOW);
                   scrollok (dataItemWin->handle, FALSE);
                }
+              touchwin (dataItemWin->handle);
+
              /*
                 ** Get the printable representation of the register
                 ** and display it
@@ -413,8 +427,6 @@ tuiDisplayRegElementAtLine (int startElementNo, int startLineNo)
 int
 tuiDisplayRegistersFromLine (int lineNo, int forceDisplay)
 {
-  int elementNo;
-
   if (dataWin->detail.dataDisplayInfo.regsContentCount > 0)
     {
       int line, elementNo;
@@ -468,7 +480,7 @@ tuiCheckRegisterValues (struct frame_info *frame)
       else
        {
          int i, j;
-         char rawBuf[MAX_REGISTER_RAW_SIZE];
+         char rawBuf[MAX_REGISTER_SIZE];
 
          for (i = 0;
               (i < dataWin->detail.dataDisplayInfo.regsContentCount); i++)
@@ -488,7 +500,7 @@ tuiCheckRegisterValues (struct frame_info *frame)
                {
                   int size;
 
-                  size = REGISTER_RAW_SIZE (dataElementPtr->itemNo);
+                  size = DEPRECATED_REGISTER_RAW_SIZE (dataElementPtr->itemNo);
                  for (j = 0; j < size; j++)
                    ((char *) dataElementPtr->value)[j] = rawBuf[j];
                  _tuiDisplayRegister (
@@ -540,7 +552,7 @@ tuiToggleFloatRegs (void)
 void
 _initialize_tuiRegs (void)
 {
-  if (tui_version && xdb_commands)
+  if (xdb_commands)
     {
       add_com ("fr", class_tui, _tuiShowFloat_command,
               "Display only floating point registers\n");
@@ -561,9 +573,7 @@ _initialize_tuiRegs (void)
 registers.\n",
               &togglelist);
     }
-
-  return;
-}                              /* _initialize_tuiRegs */
+}
 
 
 /*****************************************
@@ -575,7 +585,7 @@ registers.\n",
    ** _tuiRegisterName().
    **        Return the register name.
  */
-static char *
+static const char *
 _tuiRegisterName (int regNum)
 {
   return REGISTER_NAME (regNum);
@@ -602,9 +612,10 @@ _tuiRegisterFormat (char *buf, int bufLen, int regNum,
 {
   struct ui_file *stream;
   struct ui_file *old_stdout;
-  char *name;
+  const char *name;
   struct cleanup *cleanups;
   char *p;
+  int pos;
 
   name = REGISTER_NAME (regNum);
   if (name == 0)
@@ -618,10 +629,27 @@ _tuiRegisterFormat (char *buf, int bufLen, int regNum,
   stream = tui_sfileopen (bufLen);
   gdb_stdout = stream;
   cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout);
-  do_registers_info (regNum, 0);
+  gdbarch_print_registers_info (current_gdbarch, stream, deprecated_selected_frame,
+                                regNum, 1);
 
   /* Save formatted output in the buffer.  */
-  strncpy (buf, tui_file_get_strbuf (stream), bufLen);
+  p = tui_file_get_strbuf (stream);
+  pos = 0;
+  while (*p && *p == *name++ && bufLen)
+    {
+      *buf++ = *p++;
+      bufLen--;
+      pos++;
+    }
+  while (*p == ' ')
+    p++;
+  while (pos < 8 && bufLen)
+    {
+      *buf++ = ' ';
+      bufLen--;
+      pos++;
+    }
+  strncpy (buf, p, bufLen);
 
   /* Remove the possible \n.  */
   p = strchr (buf, '\n');
@@ -642,7 +670,7 @@ _tuiSetGeneralRegsContent (int refreshValuesOnly)
 {
   return (_tuiSetRegsContent (0,
                              NUM_GENERAL_REGS - 1,
-                             selected_frame,
+                             deprecated_selected_frame,
                              TUI_GENERAL_REGS,
                              refreshValuesOnly));
 
@@ -663,18 +691,12 @@ static TuiStatus
 _tuiSetSpecialRegsContent (int refreshValuesOnly)
 {
   TuiStatus ret = TUI_FAILURE;
-  int i, endRegNum;
+  int endRegNum;
 
   endRegNum = FP0_REGNUM - 1;
-#if 0
-  endRegNum = (-1);
-  for (i = START_SPECIAL_REGS; (i < NUM_REGS && endRegNum < 0); i++)
-    if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
-      endRegNum = i - 1;
-#endif
   ret = _tuiSetRegsContent (START_SPECIAL_REGS,
                            endRegNum,
-                           selected_frame,
+                           deprecated_selected_frame,
                            TUI_SPECIAL_REGS,
                            refreshValuesOnly);
 
@@ -690,17 +712,11 @@ static TuiStatus
 _tuiSetGeneralAndSpecialRegsContent (int refreshValuesOnly)
 {
   TuiStatus ret = TUI_FAILURE;
-  int i, endRegNum = (-1);
+  int endRegNum = (-1);
 
   endRegNum = FP0_REGNUM - 1;
-#if 0
-  endRegNum = (-1);
-  for (i = 0; (i < NUM_REGS && endRegNum < 0); i++)
-    if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
-      endRegNum = i - 1;
-#endif
   ret = _tuiSetRegsContent (
-        0, endRegNum, selected_frame, TUI_SPECIAL_REGS, refreshValuesOnly);
+        0, endRegNum, deprecated_selected_frame, TUI_SPECIAL_REGS, refreshValuesOnly);
 
   return ret;
 }                              /* _tuiSetGeneralAndSpecialRegsContent */
@@ -713,18 +729,12 @@ static TuiStatus
 _tuiSetFloatRegsContent (TuiRegisterDisplayType dpyType, int refreshValuesOnly)
 {
   TuiStatus ret = TUI_FAILURE;
-  int i, startRegNum;
+  int startRegNum;
 
   startRegNum = FP0_REGNUM;
-#if 0
-  startRegNum = (-1);
-  for (i = NUM_REGS - 1; (i >= 0 && startRegNum < 0); i--)
-    if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) != TYPE_CODE_FLT)
-      startRegNum = i + 1;
-#endif
   ret = _tuiSetRegsContent (startRegNum,
                            NUM_REGS - 1,
-                           selected_frame,
+                           deprecated_selected_frame,
                            dpyType,
                            refreshValuesOnly);
 
@@ -747,13 +757,13 @@ _tuiRegValueHasChanged (TuiDataElementPtr dataElement,
   if (dataElement->itemNo != UNDEFINED_ITEM &&
       _tuiRegisterName (dataElement->itemNo) != (char *) NULL)
     {
-      char rawBuf[MAX_REGISTER_RAW_SIZE];
+      char rawBuf[MAX_REGISTER_SIZE];
       int i;
 
       if (_tuiGetRegisterRawValue (
                         dataElement->itemNo, rawBuf, frame) == TUI_SUCCESS)
        {
-          int size = REGISTER_RAW_SIZE (dataElement->itemNo);
+          int size = DEPRECATED_REGISTER_RAW_SIZE (dataElement->itemNo);
           
          for (i = 0; (i < size && !hasChanged); i++)
            hasChanged = (((char *) dataElement->value)[i] != rawBuf[i]);
@@ -780,10 +790,10 @@ _tuiGetRegisterRawValue (int regNum, char *regValue, struct frame_info *frame)
 
   if (target_has_registers)
     {
-      int opt;
-      
-      get_saved_register (regValue, &opt, (CORE_ADDR*) NULL, frame,
-                         regNum, (enum lval_type*) NULL);
+      get_frame_register (frame, regNum, regValue);
+      /* NOTE: cagney/2003-03-13: This is bogus.  It is refering to
+         the register cache and not the frame which could have pulled
+         the register value off the stack.  */
       if (register_cached (regNum) >= 0)
        ret = TUI_SUCCESS;
     }
@@ -811,7 +821,7 @@ _tuiSetRegisterElement (int regNum, struct frame_info *frame,
          dataElement->highlight = FALSE;
        }
       if (dataElement->value == (Opaque) NULL)
-       dataElement->value = (Opaque) xmalloc (MAX_REGISTER_RAW_SIZE);
+       dataElement->value = (Opaque) xmalloc (MAX_REGISTER_SIZE);
       if (dataElement->value != (Opaque) NULL)
        _tuiGetRegisterRawValue (regNum, dataElement->value, frame);
     }
This page took 0.02768 seconds and 4 git commands to generate.