#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: */
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;
}
}
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
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);
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);