aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-08-21 16:34:10 +0000
committerAndrew Cagney <cagney@redhat.com>2002-08-21 16:34:10 +0000
commit0ab7a791257080198a22f27a12563758f1e78c96 (patch)
treefe3c4ffb5bdd9935a68ac144d20d15bd8bb4f471
parente23792ccb6d6b4e8e30e5702eaacfd5556e4ac6e (diff)
downloadgdb-0ab7a791257080198a22f27a12563758f1e78c96.zip
gdb-0ab7a791257080198a22f27a12563758f1e78c96.tar.gz
gdb-0ab7a791257080198a22f27a12563758f1e78c96.tar.bz2
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 Andrew Cagney <ac131313@redhat.com> * gdbint.texinfo (Target Architecture Definition): Document print_registers_info. Note that DO_REGISTERS_INFO is deprecated.
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/gdbint.texinfo14
-rw-r--r--gdb/gdbarch.c37
-rw-r--r--gdb/gdbarch.h26
-rwxr-xr-xgdb/gdbarch.sh4
-rw-r--r--gdb/infcmd.c81
-rw-r--r--gdb/inferior.h5
8 files changed, 143 insertions, 41 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e462110..c072c1f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 8d18f32..27cd9aa 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -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.
diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
index d560c36..e8bbd79 100644
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -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
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 3c2df6d..447e3c7 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -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 */
@@ -1568,6 +1571,10 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
(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",
(long) current_gdbarch->print_vector_info);
#ifdef PROLOGUE_FRAMELESS_P
@@ -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)
{
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index f9f6313..d27b7c7 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -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);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 94d4c25..45cce8b 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -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
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 9aa8542..4333325 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -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)
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 716daf9..e875e9c 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -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);