2002-11-06 Andrew Cagney <ac131313@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Thu, 7 Nov 2002 01:55:16 +0000 (01:55 +0000)
committerAndrew Cagney <cagney@redhat.com>
Thu, 7 Nov 2002 01:55:16 +0000 (01:55 +0000)
* infcmd.c: Include "reggroups.h" and <ctype.h>.
(print_float_info): Print registers in float_reggroup.
(print_vector_info): Print registers in vector_reggroup.
(default_print_registers_info): When all, print registers in
all_reggroup.  Otherwize, print registers in general_reggroup.
(registers_info): Rewrite.  Add support for register groups.
Eliminate a goto.

gdb/ChangeLog
gdb/infcmd.c

index fca22967497dfb65084f84c0aa991cf3a48931db..28699717eb2bc5974bfe9993482b87e9deadba78 100644 (file)
@@ -1,3 +1,13 @@
+2002-11-06  Andrew Cagney  <ac131313@redhat.com>
+
+       * infcmd.c: Include "reggroups.h" and <ctype.h>.
+       (print_float_info): Print registers in float_reggroup.
+       (print_vector_info): Print registers in vector_reggroup.
+       (default_print_registers_info): When all, print registers in
+       all_reggroup.  Otherwize, print registers in general_reggroup.
+       (registers_info): Rewrite.  Add support for register groups.
+       Eliminate a goto.
+
 2002-11-06  Elena Zannoni  <ezannoni@redhat.com>
 
        * symtab.c (methods_info): Delete. It has been ifdeffed out for
index 2cdc39435191ebf3eaff1bf6641c3673550918e6..15efbe1937a560ab417e9de3971b189ca0fb5e26 100644 (file)
@@ -41,6 +41,8 @@
 #include "event-top.h"
 #include "parser-defs.h"
 #include "regcache.h"
+#include "reggroups.h"
+#include <ctype.h>
 
 /* Functions exported for general use, in inferior.h: */
 
@@ -1583,11 +1585,14 @@ default_print_registers_info (struct gdbarch *gdbarch,
          specific reg.  */
       if (regnum == -1)
        {
-         if (!print_all)
+         if (print_all)
            {
-             if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
+             if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
                continue;
-             if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)))
+           }
+         else
+           {
+             if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
                continue;
            }
        }
@@ -1685,35 +1690,89 @@ registers_info (char *addr_exp, int fpregs)
       return;
     }
 
-  do
+  while (*addr_exp != '\0')
     {
-      if (addr_exp[0] == '$')
-       addr_exp++;
-      end = addr_exp;
-      while (*end != '\0' && *end != ' ' && *end != '\t')
-       ++end;
-      numregs = NUM_REGS + NUM_PSEUDO_REGS;
-
-      regnum = frame_map_name_to_regnum (addr_exp, end - addr_exp);
-      if (regnum >= 0)
-       goto found;
+      char *start;
+      const char *end;
 
-      regnum = numregs;
+      /* Keep skipping leading white space.  */
+      if (isspace ((*addr_exp)))
+       {
+         addr_exp++;
+         continue;
+       }
 
-      if (*addr_exp >= '0' && *addr_exp <= '9')
-       regnum = atoi (addr_exp);       /* Take a number */
-      if (regnum >= numregs)   /* Bad name, or bad number */
-       error ("%.*s: invalid register", (int) (end - addr_exp), addr_exp);
+      /* Discard any leading ``$''.  Check that there is something
+         resembling a register following it.  */
+      if (addr_exp[0] == '$')
+       addr_exp++;
+      if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
+       error ("Missing register name");
 
-    found:
-      gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
-                                   selected_frame, regnum, fpregs);
+      /* Find the start/end of this register name/num/group.  */
+      start = addr_exp;
+      while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
+       addr_exp++;
+      end = addr_exp;
+      
+      /* Figure out what we've found and display it.  */
+
+      /* A register name?  */
+      {
+       int regnum = frame_map_name_to_regnum (start, end - start);
+       if (regnum >= 0)
+         {
+           gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+                                         selected_frame, regnum, fpregs);
+           continue;
+         }
+      }
+       
+      /* A register number?  (how portable is this one?).  */
+      {
+       char *endptr;
+       int regnum = strtol (start, &endptr, 0);
+       if (endptr == end
+           && regnum >= 0
+           && regnum < NUM_REGS + NUM_PSEUDO_REGS)
+         {
+           gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+                                         selected_frame, regnum, fpregs);
+           continue;
+         }
+      }
+
+      /* A register group?  */
+      {
+       struct reggroup *const *group;
+       for (group = reggroups (current_gdbarch);
+            (*group) != NULL;
+            group++)
+         {
+           /* Don't bother with a length check.  Should the user
+              enter a short register group name, go with the first
+              group that matches.  */
+           if (strncmp (start, reggroup_name ((*group)), end - start) == 0)
+             break;
+         }
+       if ((*group) != NULL)
+         {
+           int regnum;
+           for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
+             {
+               if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
+                                                (*group)))
+                 gdbarch_print_registers_info (current_gdbarch,
+                                               gdb_stdout, selected_frame,
+                                               regnum, fpregs);
+             }
+           continue;
+         }
+      }
 
-      addr_exp = end;
-      while (*addr_exp == ' ' || *addr_exp == '\t')
-       ++addr_exp;
+      /* Nothing matched.  */
+      error ("Invalid register `%.*s'", (int) (end - start), start);
     }
-  while (*addr_exp != '\0');
 }
 
 void
@@ -1746,7 +1805,7 @@ print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
 
       for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
        {
-         if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (regnum)))
+         if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
            {
              printed_something = 1;
              gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
@@ -1919,7 +1978,7 @@ print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
 
       for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
        {
-         if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
+         if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
            {
              printed_something = 1;
              gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);