This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/rfc/rfa:doco] DO_REGISTERS_INFO -> print_registers_info; part#1
- From: Andrew Cagney <ac131313 at ges dot redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 03 Aug 2002 19:18:43 -0400
- Subject: [patch/rfc/rfa:doco] DO_REGISTERS_INFO -> print_registers_info; part#1
Hello,
This patch introduces the new method:
void print_registers_info (struct gdbarch *gdbarch, struct frame_info
*info, struct ui_file *file, int regnum, int all);
It prints the registers for FRAME on FILE.
The intent is for this method to eventually replace the existing
DO_REGISTERS_INFO. To that end, a follow-on patch will rename
DO_REGISTERS_INFO -> DEPRECATED_DO_REGISTERS_INO.
(If the doco is approved) I'll look to commit this in a few days.
enjoy,
Andrew
2002-08-03 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.
Index: doc/ChangeLog
2002-08-03 Andrew Cagney <ac131313@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Document
print_registers_info. Note that DO_REGISTERS_INFO is deprecated.
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.151
diff -u -r1.151 gdbarch.sh
--- gdbarch.sh 2 Aug 2002 20:51:21 -0000 1.151
+++ gdbarch.sh 3 Aug 2002 23:13:04 -0000
@@ -467,8 +467,11 @@
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:file, frame:::default_print_float_info::0
+#
# MAP a GDB RAW register number onto a simulator register number. See
# also include/...-sim.h.
f:2:REGISTER_SIM_REGNO:int:register_sim_regno:int reg_nr:reg_nr:::legacy_register_sim_regno::0
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.49
diff -u -r1.49 infcmd.c
--- infcmd.c 3 Jul 2002 20:36:54 -0000 1.49
+++ infcmd.c 3 Aug 2002 23:13:04 -0000
@@ -1549,31 +1549,41 @@
#ifdef REGISTER_NAMES
char *gdb_register_names[] = REGISTER_NAMES;
#endif
-/* Print out the machine register regnum. If regnum is -1,
- print all registers (fpregs == 1) or all non-float registers
- (fpregs == 0).
+/* Print out the machine register regnum. If regnum is -1, print all
+ registers (all == 1) or all non-float registers (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 fpregs)
+default_print_registers_info (struct gdbarch *gdbarch,
+ struct ui_file *file,
+ struct frame_info *frame,
+ int regnum, int 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, all);
+ return;
+ }
for (i = 0; i < numregs; i++)
{
- /* Decide between printing all regs, nonfloat regs, or specific reg. */
+ /* Decide between printing all regs, nonfloat regs, or specific
+ reg. */
if (regnum == -1)
{
- if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT && !fpregs)
+ if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT && !all)
continue;
}
else
@@ -1587,16 +1597,19 @@
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))
{
@@ -1609,31 +1622,35 @@
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 print as integer in hex and in decimal. */
else
{
val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
- gdb_stdout, 'x', 1, 0, Val_pretty_default);
- printf_filtered ("\t");
+ file, 'x', 1, 0, Val_pretty_default);
+ fprintf_filtered (file, "\t");
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);
}
/* The SPARC wants to print even-numbered float regs as doubles
@@ -1642,7 +1659,7 @@
PRINT_REGISTER_HOOK (i);
#endif
- printf_filtered ("\n");
+ fprintf_filtered (file, "\n");
}
}
@@ -1659,7 +1676,8 @@
if (!addr_exp)
{
- DO_REGISTERS_INFO (-1, fpregs);
+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+ selected_frame, -1, fpregs);
return;
}
@@ -1684,7 +1702,8 @@
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')
Index: inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.29
diff -u -r1.29 inferior.h
--- inferior.h 3 Jul 2002 20:36:54 -0000 1.29
+++ inferior.h 3 Aug 2002 23:13:04 -0000
@@ -205,7 +205,10 @@
/* 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);
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.97
diff -u -r1.97 gdbint.texinfo
--- doc/gdbint.texinfo 1 Aug 2002 17:18:34 -0000 1.97
+++ doc/gdbint.texinfo 3 Aug 2002 23:13:06 -0000
@@ -3094,10 +3094,22 @@
@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 DWARF_REG_TO_REGNUM
@findex DWARF_REG_TO_REGNUM