+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.
+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.
@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
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;
0,
0,
0,
+ default_print_registers_info,
0,
0,
0,
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;
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 */
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",
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)
{
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)
{
#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);
#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);
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
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++)
{
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))
{
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_REGISTER_HOOK (i);
#endif
- printf_filtered ("\n");
+ fprintf_filtered (file, "\n");
}
}
if (!addr_exp)
{
- DO_REGISTERS_INFO (-1, fpregs);
+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+ selected_frame, -1, fpregs);
return;
}
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')
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)
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)
/* 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);