2002-08-21 Andrew Cagney <ac131313@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Wed, 21 Aug 2002 16:34:10 +0000 (16:34 +0000)
committerAndrew Cagney <cagney@redhat.com>
Wed, 21 Aug 2002 16:34:10 +0000 (16:34 +0000)
* infcmd.c (default_print_registers_info): Replace
do_registers_info.
(registers_info): Use gdbarch_print_registers_info instead of
DO_REGISTERS_INFO.
* inferior.h (default_print_registers_info): Replace
do_registers_info.
* gdbarch.sh (PRINT_REGISTERS_INFO): New method.
(DO_REGISTERS_INFO): Change to a predicate function.
* gdbarch.h, gdbarch.c: Regenerate.

2002-08-21  Andrew Cagney  <ac131313@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Document
print_registers_info.  Note that DO_REGISTERS_INFO is deprecated.

gdb/ChangeLog
gdb/doc/ChangeLog
gdb/doc/gdbint.texinfo
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/infcmd.c
gdb/inferior.h

index e462110b3824b3bc2c2676e52362d511b0acc6f3..c072c1f36196ff57250fb6c90991036171278dab 100644 (file)
@@ -1,3 +1,15 @@
+2002-08-21  Andrew Cagney  <ac131313@redhat.com>
+
+       * infcmd.c (default_print_registers_info): Replace
+       do_registers_info.
+       (registers_info): Use gdbarch_print_registers_info instead of
+       DO_REGISTERS_INFO.
+       * inferior.h (default_print_registers_info): Replace
+       do_registers_info.
+       * gdbarch.sh (PRINT_REGISTERS_INFO): New method.
+       (DO_REGISTERS_INFO): Change to a predicate function.
+       * gdbarch.h, gdbarch.c: Regenerate.
+       
 2002-08-21  Keith Seitz  <keiths@redhat.com>
 
        * gdb-events.sh: Add target-changed event.
index 8d18f3298a9d241b93009ce10fc98000610862d6..27cd9aa013b316a3ae96313a0e7d85e3c8914e23 100644 (file)
@@ -1,3 +1,8 @@
+2002-08-21  Andrew Cagney  <ac131313@redhat.com>
+
+       * gdbint.texinfo (Target Architecture Definition): Document
+       print_registers_info.  Note that DO_REGISTERS_INFO is deprecated.
+
 2002-08-19  Andrew Cagney  <ac131313@redhat.com>
 
        * gdb.texinfo (Remote Protocol): Reformat.  Use cross references.
index d560c3658a0c501119fa460550c3d6e63a08e564..e8bbd79828f74acaaaabf60a80d7553e16cdbc24 100644 (file)
@@ -3094,11 +3094,23 @@ library in which breakpoints cannot be set and so should be disabled.
 @findex DO_REGISTERS_INFO
 If defined, use this to print the value of a register or all registers.
 
+This method is deprecated.
+
 @item PRINT_FLOAT_INFO()
-#findex PRINT_FLOAT_INFO
+@findex PRINT_FLOAT_INFO
 If defined, then the @samp{info float} command will print information about
 the processor's floating point unit.
 
+@item print_registers_info (@var{gdbarch}, @var{frame}, @var{regnum}, @var{all})
+@findex print_registers_info
+If defined, pretty print the value of the register @var{regnum} for the
+specified @var{frame}.  If the value of @var{regnum} is -1, pretty print
+either all registers (@var{all} is non zero) or a select subset of
+registers (@var{all} is zero).
+
+The default method prints one register per line, and if @var{all} is
+zero omits floating-point registers.
+
 @item PRINT_VECTOR_INFO()
 @findex PRINT_VECTOR_INFO
 If defined, then the @samp{info vector} command will call this function
index 3c2df6d5c2bf3f8ecf02d4a17ca5c4c2258c67da..447e3c743fd5c01921e468a8dd9fa749af39c396 100644 (file)
@@ -172,6 +172,7 @@ struct gdbarch
   int max_register_virtual_size;
   gdbarch_register_virtual_type_ftype *register_virtual_type;
   gdbarch_do_registers_info_ftype *do_registers_info;
+  gdbarch_print_registers_info_ftype *print_registers_info;
   gdbarch_print_float_info_ftype *print_float_info;
   gdbarch_print_vector_info_ftype *print_vector_info;
   gdbarch_register_sim_regno_ftype *register_sim_regno;
@@ -324,6 +325,7 @@ struct gdbarch startup_gdbarch =
   0,
   0,
   0,
+  default_print_registers_info,
   0,
   0,
   0,
@@ -493,7 +495,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
   current_gdbarch->max_register_raw_size = -1;
   current_gdbarch->register_virtual_size = generic_register_size;
   current_gdbarch->max_register_virtual_size = -1;
-  current_gdbarch->do_registers_info = do_registers_info;
+  current_gdbarch->print_registers_info = default_print_registers_info;
   current_gdbarch->register_sim_regno = legacy_register_sim_regno;
   current_gdbarch->cannot_fetch_register = cannot_register_not;
   current_gdbarch->cannot_store_register = cannot_register_not;
@@ -640,7 +642,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
   if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
       && (gdbarch->register_virtual_type == 0))
     fprintf_unfiltered (log, "\n\tregister_virtual_type");
-  /* Skip verify of do_registers_info, invalid_p == 0 */
+  /* Skip verify of do_registers_info, has predicate */
+  /* Skip verify of print_registers_info, invalid_p == 0 */
   /* Skip verify of print_float_info, has predicate */
   /* Skip verify of print_vector_info, has predicate */
   /* Skip verify of register_sim_regno, invalid_p == 0 */
@@ -1566,6 +1569,10 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
     fprintf_unfiltered (file,
                         "gdbarch_dump: print_float_info = 0x%08lx\n",
                         (long) current_gdbarch->print_float_info);
+  if (GDB_MULTI_ARCH)
+    fprintf_unfiltered (file,
+                        "gdbarch_dump: print_registers_info = 0x%08lx\n",
+                        (long) current_gdbarch->print_registers_info);
   if (GDB_MULTI_ARCH)
     fprintf_unfiltered (file,
                         "gdbarch_dump: print_vector_info = 0x%08lx\n",
@@ -2996,6 +3003,13 @@ set_gdbarch_register_virtual_type (struct gdbarch *gdbarch,
   gdbarch->register_virtual_type = register_virtual_type;
 }
 
+int
+gdbarch_do_registers_info_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->do_registers_info != 0;
+}
+
 void
 gdbarch_do_registers_info (struct gdbarch *gdbarch, int reg_nr, int fpregs)
 {
@@ -3015,6 +3029,25 @@ set_gdbarch_do_registers_info (struct gdbarch *gdbarch,
   gdbarch->do_registers_info = do_registers_info;
 }
 
+void
+gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch->print_registers_info == 0)
+    internal_error (__FILE__, __LINE__,
+                    "gdbarch: gdbarch_print_registers_info invalid");
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_print_registers_info called\n");
+  gdbarch->print_registers_info (gdbarch, file, frame, regnum, all);
+}
+
+void
+set_gdbarch_print_registers_info (struct gdbarch *gdbarch,
+                                  gdbarch_print_registers_info_ftype print_registers_info)
+{
+  gdbarch->print_registers_info = print_registers_info;
+}
+
 int
 gdbarch_print_float_info_p (struct gdbarch *gdbarch)
 {
index f9f631314c22ea69ad7e317b5da66b741be90fb2..d27b7c72e2dff55f10e4f2385525ca3c33323793 100644 (file)
@@ -778,9 +778,29 @@ extern void set_gdbarch_register_virtual_type (struct gdbarch *gdbarch, gdbarch_
 #endif
 #endif
 
+#if defined (DO_REGISTERS_INFO)
+/* Legacy for systems yet to multi-arch DO_REGISTERS_INFO */
+#if !defined (DO_REGISTERS_INFO_P)
+#define DO_REGISTERS_INFO_P() (1)
+#endif
+#endif
+
+/* Default predicate for non- multi-arch targets. */
+#if (!GDB_MULTI_ARCH) && !defined (DO_REGISTERS_INFO_P)
+#define DO_REGISTERS_INFO_P() (0)
+#endif
+
+extern int gdbarch_do_registers_info_p (struct gdbarch *gdbarch);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DO_REGISTERS_INFO_P)
+#error "Non multi-arch definition of DO_REGISTERS_INFO"
+#endif
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (DO_REGISTERS_INFO_P)
+#define DO_REGISTERS_INFO_P() (gdbarch_do_registers_info_p (current_gdbarch))
+#endif
+
 /* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (DO_REGISTERS_INFO)
-#define DO_REGISTERS_INFO(reg_nr, fpregs) (do_registers_info (reg_nr, fpregs))
+#define DO_REGISTERS_INFO(reg_nr, fpregs) (internal_error (__FILE__, __LINE__, "DO_REGISTERS_INFO"), 0)
 #endif
 
 typedef void (gdbarch_do_registers_info_ftype) (int reg_nr, int fpregs);
@@ -795,6 +815,10 @@ extern void set_gdbarch_do_registers_info (struct gdbarch *gdbarch, gdbarch_do_r
 #endif
 #endif
 
+typedef void (gdbarch_print_registers_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all);
+extern void gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all);
+extern void set_gdbarch_print_registers_info (struct gdbarch *gdbarch, gdbarch_print_registers_info_ftype *print_registers_info);
+
 extern int gdbarch_print_float_info_p (struct gdbarch *gdbarch);
 
 typedef void (gdbarch_print_float_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
index 94d4c25fdc4a3d4947b23e6ea30e31bea6bf9b2f..45cce8b6b85d9123138a4132e7a1c0b3050f0a41 100755 (executable)
@@ -467,7 +467,9 @@ v:2:MAX_REGISTER_RAW_SIZE:int:max_register_raw_size::::0:-1
 f:2:REGISTER_VIRTUAL_SIZE:int:register_virtual_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0
 v:2:MAX_REGISTER_VIRTUAL_SIZE:int:max_register_virtual_size::::0:-1
 f:2:REGISTER_VIRTUAL_TYPE:struct type *:register_virtual_type:int reg_nr:reg_nr::0:0
-f:2:DO_REGISTERS_INFO:void:do_registers_info:int reg_nr, int fpregs:reg_nr, fpregs:::do_registers_info::0
+#
+F:2:DO_REGISTERS_INFO:void:do_registers_info:int reg_nr, int fpregs:reg_nr, fpregs
+m:2:PRINT_REGISTERS_INFO:void:print_registers_info:struct ui_file *file, struct frame_info *frame, int regnum, int all:file, frame, regnum, all:::default_print_registers_info::0
 M:2:PRINT_FLOAT_INFO:void:print_float_info:struct ui_file *file, struct frame_info *frame, const char *args:file, frame, args
 M:2:PRINT_VECTOR_INFO:void:print_vector_info:struct ui_file *file, struct frame_info *frame, const char *args:file, frame, args
 # MAP a GDB RAW register number onto a simulator register number.  See
index 9aa8542a8c436b4986543e9a3db8233c4c30c985..433332555e852f78b0135630bff6aaa9b825ca02 100644 (file)
@@ -1550,23 +1550,33 @@ path_command (char *dirname, int from_tty)
 char *gdb_register_names[] = REGISTER_NAMES;
 #endif
 /* Print out the machine register regnum. If regnum is -1, print all
-   registers (all == 1) or all non-float and non-vector registers (all
-   == 0).
+   registers (print_all == 1) or all non-float and non-vector
+   registers (print_all == 0).
 
    For most machines, having all_registers_info() print the
-   register(s) one per line is good enough. If a different format
-   is required, (eg, for MIPS or Pyramid 90x, which both have
-   lots of regs), or there is an existing convention for showing
-   all the registers, define the macro DO_REGISTERS_INFO(regnum, fp)
-   to provide that format.  */
+   register(s) one per line is good enough.  If a different format is
+   required, (eg, for MIPS or Pyramid 90x, which both have lots of
+   regs), or there is an existing convention for showing all the
+   registers, define the architecture method PRINT_REGISTERS_INFO to
+   provide that format.  */
 
 void
-do_registers_info (int regnum, int print_all)
+default_print_registers_info (struct gdbarch *gdbarch,
+                             struct ui_file *file,
+                             struct frame_info *frame,
+                             int regnum, int print_all)
 {
-  register int i;
-  int numregs = NUM_REGS + NUM_PSEUDO_REGS;
-  char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
-  char *virtual_buffer = (char*) alloca (MAX_REGISTER_VIRTUAL_SIZE);
+  int i;
+  const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
+  char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
+  char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
+
+  /* FIXME: cagney/2002-03-08: This should be deprecated.  */
+  if (DO_REGISTERS_INFO_P ())
+    {
+      DO_REGISTERS_INFO (regnum, print_all);
+      return;
+    }
 
   for (i = 0; i < numregs; i++)
     {
@@ -1593,16 +1603,19 @@ do_registers_info (int regnum, int print_all)
       if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
        continue;
 
-      fputs_filtered (REGISTER_NAME (i), gdb_stdout);
-      print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), gdb_stdout);
+      fputs_filtered (REGISTER_NAME (i), file);
+      print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
 
       /* Get the data in raw format.  */
-      if (! frame_register_read (selected_frame, i, raw_buffer))
+      if (! frame_register_read (frame, i, raw_buffer))
        {
-         printf_filtered ("*value not available*\n");
+         fprintf_filtered (file, "*value not available*\n");
          continue;
        }
 
+      /* FIXME: cagney/2002-08-03: This code shouldn't be necessary.
+         The function frame_register_read() should have returned the
+         pre-cooked register so no conversion is necessary.  */
       /* Convert raw data to virtual format if necessary.  */
       if (REGISTER_CONVERTIBLE (i))
        {
@@ -1615,22 +1628,26 @@ do_registers_info (int regnum, int print_all)
                  REGISTER_VIRTUAL_SIZE (i));
        }
 
-      /* If virtual format is floating, print it that way, and in raw hex.  */
+      /* If virtual format is floating, print it that way, and in raw
+         hex.  */
       if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
        {
-         register int j;
+         int j;
 
          val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
-                    gdb_stdout, 0, 1, 0, Val_pretty_default);
+                    file, 0, 1, 0, Val_pretty_default);
 
-         printf_filtered ("\t(raw 0x");
+         fprintf_filtered (file, "\t(raw 0x");
          for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
            {
-             register int idx = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? j
-             : REGISTER_RAW_SIZE (i) - 1 - j;
-             printf_filtered ("%02x", (unsigned char) raw_buffer[idx]);
+             int idx;
+             if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+               idx = j;
+             else
+               idx = REGISTER_RAW_SIZE (i) - 1 - j;
+             fprintf_filtered (file, "%02x", (unsigned char) raw_buffer[idx]);
            }
-         printf_filtered (")");
+         fprintf_filtered (file, ")");
        }
       else
        {
@@ -1653,7 +1670,7 @@ do_registers_info (int regnum, int print_all)
       PRINT_REGISTER_HOOK (i);
 #endif
 
-      printf_filtered ("\n");
+      fprintf_filtered (file, "\n");
     }
 }
 
@@ -1670,7 +1687,8 @@ registers_info (char *addr_exp, int fpregs)
 
   if (!addr_exp)
     {
-      DO_REGISTERS_INFO (-1, fpregs);
+      gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+                                   selected_frame, -1, fpregs);
       return;
     }
 
@@ -1695,7 +1713,8 @@ registers_info (char *addr_exp, int fpregs)
        error ("%.*s: invalid register", (int) (end - addr_exp), addr_exp);
 
     found:
-      DO_REGISTERS_INFO (regnum, fpregs);
+      gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+                                   selected_frame, regnum, fpregs);
 
       addr_exp = end;
       while (*addr_exp == ' ' || *addr_exp == '\t')
@@ -1737,11 +1756,7 @@ print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
          if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (regnum)))
            {
              printed_something = 1;
-#if 0
              gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
-#else
-             do_registers_info (regnum, 1);
-#endif
            }
        }
       if (!printed_something)
@@ -1921,11 +1936,7 @@ print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
          if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
            {
              printed_something = 1;
-#if 0
              gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
-#else
-             do_registers_info (regnum, 1);
-#endif
            }
        }
       if (!printed_something)
index 716daf93ac1e95abfbd9674aa955f36fef8c9692..e875e9cc1865853be2518b52b56c5dc8f086e3a5 100644 (file)
@@ -205,7 +205,10 @@ extern void resume (int, enum target_signal);
 
 /* From misc files */
 
-extern void do_registers_info (int, int);
+extern void default_print_registers_info (struct gdbarch *gdbarch,
+                                         struct ui_file *file,
+                                         struct frame_info *frame,
+                                         int regnum, int all);
 
 extern void store_inferior_registers (int);