This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/rfc] Eliminate PRINT_REGISTER_HOOK from SPARC
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 23 Oct 2002 15:43:05 -0400
- Subject: [patch/rfc] Eliminate PRINT_REGISTER_HOOK from SPARC
Hello,
The last one. Slightly more tricky than the others as the not 100%
multi-arch SPARC has two variants.
The change itself is mechanical, just need to double check it works on a
Solaris box.
Again, baring comments, I'll commit it in a few days.
Andrew
2002-10-23 Andrew Cagney <cagney@redhat.com>
* sparc-tdep.c (sparc_print_register_hook): Make static.
(sparc_print_registers_info): New function.
(sparc_do_registers_info): New function.
(sparclet_print_registers_info): New function.
(sparclet_do_registers_info): New function.
(do_sparc_print_registers_info): New function.
(sparc_print_registers): New static function, clone of infcmd.c's
default_print_registers_info.
* config/sparc/tm-sparclet.h (PRINT_REGISTER_HOOK): Delete macro.
(sparclet_do_registers_info): Declare.
(DO_REGISTERS_INFO): Re-define.
* config/sparc/tm-sparc.h (DO_REGISTERS_INFO): Re-define.
(sparc_do_registers_info): Declare.
(PRINT_REGISTER_HOOK): Delete macro.
(sparc_print_register_hook): Delete declaration.
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.39
diff -u -r1.39 sparc-tdep.c
--- sparc-tdep.c 24 Aug 2002 00:21:35 -0000 1.39
+++ sparc-tdep.c 23 Oct 2002 19:37:11 -0000
@@ -1858,7 +1858,7 @@
Pretty print various registers. */
/* FIXME: Would be nice if this did some fancy things for 32 bit sparc. */
-void
+static void
sparc_print_register_hook (int regno)
{
ULONGEST val;
@@ -2028,6 +2028,146 @@
#undef BITS
}
+
+static void
+sparc_print_registers (struct gdbarch *gdbarch,
+ struct ui_file *file,
+ struct frame_info *frame,
+ int regnum, int print_all,
+ void (*print_register_hook) (int))
+{
+ 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);
+
+ for (i = 0; i < numregs; i++)
+ {
+ /* Decide between printing all regs, non-float / vector regs, or
+ specific reg. */
+ if (regnum == -1)
+ {
+ if (!print_all)
+ {
+ if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
+ continue;
+ if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)))
+ continue;
+ }
+ }
+ else
+ {
+ if (i != regnum)
+ continue;
+ }
+
+ /* If the register name is empty, it is undefined for this
+ processor, so don't display anything. */
+ if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
+ continue;
+
+ 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 (frame, i, raw_buffer))
+ {
+ 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))
+ {
+ REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i),
+ raw_buffer, virtual_buffer);
+ }
+ else
+ {
+ memcpy (virtual_buffer, raw_buffer,
+ REGISTER_VIRTUAL_SIZE (i));
+ }
+
+ /* If virtual format is floating, print it that way, and in raw
+ hex. */
+ if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
+ {
+ int j;
+
+ val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
+ file, 0, 1, 0, Val_pretty_default);
+
+ fprintf_filtered (file, "\t(raw 0x");
+ for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
+ {
+ 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]);
+ }
+ fprintf_filtered (file, ")");
+ }
+ else
+ {
+ /* Print the register in hex. */
+ val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
+ file, 'x', 1, 0, Val_pretty_default);
+ /* If not a vector register, print it also according to its
+ natural format. */
+ if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)) == 0)
+ {
+ fprintf_filtered (file, "\t");
+ val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
+ file, 0, 1, 0, Val_pretty_default);
+ }
+ }
+
+ /* Some sparc specific info. */
+ if (print_register_hook != NULL)
+ print_register_hook (i);
+
+ fprintf_filtered (file, "\n");
+ }
+}
+
+static void
+sparc_print_registers_info (struct gdbarch *gdbarch,
+ struct ui_file *file,
+ struct frame_info *frame,
+ int regnum, int print_all)
+{
+ sparc_print_registers (gdbarch, file, frame, regnum, print_all,
+ sparc_print_register_hook);
+}
+
+void
+sparc_do_registers_info (int regnum, int all)
+{
+ sparc_print_registers_info (current_gdbarch, gdb_stdout, selected_frame,
+ regnum, all);
+}
+
+static void
+sparclet_print_registers_info (struct gdbarch *gdbarch,
+ struct ui_file *file,
+ struct frame_info *frame,
+ int regnum, int print_all)
+{
+ sparc_print_registers (gdbarch, file, frame, regnum, print_all, NULL);
+}
+
+void
+sparclet_do_registers_info (int regnum, int all)
+{
+ sparclet_print_registers_info (current_gdbarch, gdb_stdout, selected_frame,
+ regnum, all);
+}
+
int
gdb_print_insn_sparc (bfd_vma memaddr, disassemble_info *info)
Index: config/sparc/tm-sparc.h
===================================================================
RCS file: /cvs/src/src/gdb/config/sparc/tm-sparc.h,v
retrieving revision 1.18
diff -u -r1.18 tm-sparc.h
--- config/sparc/tm-sparc.h 24 Aug 2002 00:21:36 -0000 1.18
+++ config/sparc/tm-sparc.h 23 Oct 2002 19:37:11 -0000
@@ -736,14 +736,9 @@
#define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
extern struct frame_info *setup_arbitrary_frame (int, CORE_ADDR *);
-/* To print every pair of float registers as a double, we use this hook.
- We also print the condition code registers in a readable format
- (FIXME: can expand this to all control regs). */
-
-#undef PRINT_REGISTER_HOOK
-#define PRINT_REGISTER_HOOK(regno) \
- sparc_print_register_hook (regno)
-extern void sparc_print_register_hook (int regno);
+extern void sparc_do_registers_info (int regnum, int all);
+#undef DO_REGISTERS_INFO
+#define DO_REGISTERS_INFO(REGNUM,ALL) sparc_do_registers_info (REGNUM, ALL)
/* Optimization for storing registers to the inferior. The hook
DO_DEFERRED_STORES
Index: config/sparc/tm-sparclet.h
===================================================================
RCS file: /cvs/src/src/gdb/config/sparc/tm-sparclet.h,v
retrieving revision 1.8
diff -u -r1.8 tm-sparclet.h
--- config/sparc/tm-sparclet.h 24 Aug 2002 00:21:36 -0000 1.8
+++ config/sparc/tm-sparclet.h 23 Oct 2002 19:37:11 -0000
@@ -127,8 +127,10 @@
#endif /* GDB_MULTI_ARCH */
-#undef PRINT_REGISTER_HOOK
-#define PRINT_REGISTER_HOOK(regno)
+extern void sparclet_do_registers_info (int regnum, int all);
+#undef DO_REGISTERS_INFO
+#define DO_REGISTERS_INFO(REGNUM,ALL) sparclet_do_registers_info (REGNUM, ALL)
+
/* Offsets into jmp_buf. Not defined by Sun, but at least documented in a
comment in <machine/setjmp.h>! */