aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-11-07 01:55:16 +0000
committerAndrew Cagney <cagney@redhat.com>2002-11-07 01:55:16 +0000
commitf9418c0f1999be27c83657a70e5136f735c66038 (patch)
treea1a3027e62cd117164389309bfeac4117c9b4fed /gdb/infcmd.c
parent1bd34ded16b7de96e58fde42802d0420963d8e57 (diff)
downloadgdb-f9418c0f1999be27c83657a70e5136f735c66038.zip
gdb-f9418c0f1999be27c83657a70e5136f735c66038.tar.gz
gdb-f9418c0f1999be27c83657a70e5136f735c66038.tar.bz2
2002-11-06 Andrew Cagney <ac131313@redhat.com>
* infcmd.c: Include "reggroups.h" and <ctype.h>. (print_float_info): Print registers in float_reggroup. (print_vector_info): Print registers in vector_reggroup. (default_print_registers_info): When all, print registers in all_reggroup. Otherwize, print registers in general_reggroup. (registers_info): Rewrite. Add support for register groups. Eliminate a goto.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c115
1 files changed, 87 insertions, 28 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 2cdc394..15efbe1 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -41,6 +41,8 @@
#include "event-top.h"
#include "parser-defs.h"
#include "regcache.h"
+#include "reggroups.h"
+#include <ctype.h>
/* Functions exported for general use, in inferior.h: */
@@ -1583,11 +1585,14 @@ default_print_registers_info (struct gdbarch *gdbarch,
specific reg. */
if (regnum == -1)
{
- if (!print_all)
+ if (print_all)
{
- if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
+ if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
continue;
- if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)))
+ }
+ else
+ {
+ if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
continue;
}
}
@@ -1685,35 +1690,89 @@ registers_info (char *addr_exp, int fpregs)
return;
}
- do
+ while (*addr_exp != '\0')
{
- if (addr_exp[0] == '$')
- addr_exp++;
- end = addr_exp;
- while (*end != '\0' && *end != ' ' && *end != '\t')
- ++end;
- numregs = NUM_REGS + NUM_PSEUDO_REGS;
-
- regnum = frame_map_name_to_regnum (addr_exp, end - addr_exp);
- if (regnum >= 0)
- goto found;
+ char *start;
+ const char *end;
- regnum = numregs;
+ /* Keep skipping leading white space. */
+ if (isspace ((*addr_exp)))
+ {
+ addr_exp++;
+ continue;
+ }
- if (*addr_exp >= '0' && *addr_exp <= '9')
- regnum = atoi (addr_exp); /* Take a number */
- if (regnum >= numregs) /* Bad name, or bad number */
- error ("%.*s: invalid register", (int) (end - addr_exp), addr_exp);
+ /* Discard any leading ``$''. Check that there is something
+ resembling a register following it. */
+ if (addr_exp[0] == '$')
+ addr_exp++;
+ if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
+ error ("Missing register name");
- found:
- gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
- selected_frame, regnum, fpregs);
+ /* Find the start/end of this register name/num/group. */
+ start = addr_exp;
+ while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
+ addr_exp++;
+ end = addr_exp;
+
+ /* Figure out what we've found and display it. */
+
+ /* A register name? */
+ {
+ int regnum = frame_map_name_to_regnum (start, end - start);
+ if (regnum >= 0)
+ {
+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+ selected_frame, regnum, fpregs);
+ continue;
+ }
+ }
+
+ /* A register number? (how portable is this one?). */
+ {
+ char *endptr;
+ int regnum = strtol (start, &endptr, 0);
+ if (endptr == end
+ && regnum >= 0
+ && regnum < NUM_REGS + NUM_PSEUDO_REGS)
+ {
+ gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
+ selected_frame, regnum, fpregs);
+ continue;
+ }
+ }
+
+ /* A register group? */
+ {
+ struct reggroup *const *group;
+ for (group = reggroups (current_gdbarch);
+ (*group) != NULL;
+ group++)
+ {
+ /* Don't bother with a length check. Should the user
+ enter a short register group name, go with the first
+ group that matches. */
+ if (strncmp (start, reggroup_name ((*group)), end - start) == 0)
+ break;
+ }
+ if ((*group) != NULL)
+ {
+ int regnum;
+ for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
+ {
+ if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
+ (*group)))
+ gdbarch_print_registers_info (current_gdbarch,
+ gdb_stdout, selected_frame,
+ regnum, fpregs);
+ }
+ continue;
+ }
+ }
- addr_exp = end;
- while (*addr_exp == ' ' || *addr_exp == '\t')
- ++addr_exp;
+ /* Nothing matched. */
+ error ("Invalid register `%.*s'", (int) (end - start), start);
}
- while (*addr_exp != '\0');
}
void
@@ -1746,7 +1805,7 @@ print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
{
- if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (regnum)))
+ if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
{
printed_something = 1;
gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
@@ -1919,7 +1978,7 @@ print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
{
- if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
+ if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
{
printed_something = 1;
gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);