structure. This way NUM_REGS does not have to be a constant.
* monitor.c (monitor_fetch_register): Added support for regname
function. The function is called if the array regnames is NULL.
(monitor_store_register): Same.
* cpu32bug-rom.c (cpu32bug_regname): Add function. Replaces regnames array.
(init_cpu32bug_cmds): set cpu32bug_cmds.regnames to NULL,
cpu32bug_cmds.regname to point to new function.
* abug-rom.c (abug_regname): Same as above.
(init_abug_cmds): Same.
* dbug-rom.c (dbug_regname): Same as above.
(init_dbug_cmds): Same.
* remote-est.c (est_regname): Same.
(init_est_cmds): Same.
* rom68k-rom.c (rom68k_regname): Same.
(init_rom68k_cmds): Same.
+2002-06-26 Grace Sainsbury <graces@redhat.com>
+
+ * monitor.h: Add the function regname to monitor_ops
+ structure. This way NUM_REGS does not have to be a constant.
+ * monitor.c (monitor_fetch_register): Added support for regname
+ function. The function is called if the array regnames is NULL.
+ (monitor_store_register): Same.
+ * cpu32bug-rom.c (cpu32bug_regname): Add function. Replaces regnames array.
+ (init_cpu32bug_cmds): set cpu32bug_cmds.regnames to NULL,
+ cpu32bug_cmds.regname to point to new function.
+ * abug-rom.c (abug_regname): Same as above.
+ (init_abug_cmds): Same.
+ * dbug-rom.c (dbug_regname): Same as above.
+ (init_dbug_cmds): Same.
+ * remote-est.c (est_regname): Same.
+ (init_est_cmds): Same.
+ * rom68k-rom.c (rom68k_regname): Same.
+ (init_rom68k_cmds): Same.
+
2002-06-25 Tom Tromey <tromey@redhat.com>
* breakpoint.c (delete_command): Don't repeat `delete' commands.
* registers either. So, typing "info reg sp" becomes an "A7".
*/
-static char *abug_regnames[NUM_REGS] =
+static const char *
+abug_regname (int index)
{
- "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
- "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
- "PC",
-};
+ static char *regnames[] =
+ {
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
+ "PC",
+ };
+
+ if ((index >= (sizeof (regnames) / sizeof (regnames[0])))
+ || (index < 0) || (index >= NUM_REGS))
+ return NULL;
+ else
+ return regnames[index];
+}
/*
* Define the monitor command strings. Since these are passed directly
abug_cmds.cmd_end = NULL; /* optional command terminator */
abug_cmds.target = &abug_ops; /* target operations */
abug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- abug_cmds.regnames = abug_regnames; /* registers names */
+ abug_cmds.regnames = NULL; /* registers names */
+ abug_cmds.regname = abug_regname;
abug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
};
* registers either. So, typing "info reg sp" becomes an "A7".
*/
-static char *cpu32bug_regnames[NUM_REGS] =
+static const char *
+cpu32bug_regname (int index)
{
- "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
- "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
- "SR", "PC",
-};
+ static char *regnames[] =
+ {
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
+ "SR", "PC"
+ };
+
+ if ((index >= (sizeof (regnames) / sizeof (regnames[0])))
+ || (index < 0) || (index >= NUM_REGS))
+ return NULL;
+ else
+ return regnames[index];
+}
/*
* Define the monitor command strings. Since these are passed directly
cpu32bug_cmds.cmd_end = NULL; /* optional command terminator */
cpu32bug_cmds.target = &cpu32bug_ops; /* target operations */
cpu32bug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- cpu32bug_cmds.regnames = cpu32bug_regnames; /* registers names */
+ cpu32bug_cmds.regnames = NULL; /* registers names */
+ cpu32bug_cmds.regname = cpu32bug_regname;
cpu32bug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
}; /* init_cpu32bug_cmds */
different names than GDB does, and don't support all the registers
either. So, typing "info reg sp" becomes an "A7". */
-static char *dbug_regnames[NUM_REGS] =
+static const char *
+dbug_regname (int index)
{
- "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
- "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
- "SR", "PC"
- /* no float registers */
-};
+ static char *regnames[] =
+ {
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
+ "SR", "PC"
+ /* no float registers */
+ };
+
+ if ((index >= (sizeof (regnames) / sizeof (regnames[0])))
+ || (index < 0) || (index >= NUM_REGS))
+ return NULL;
+ else
+ return regnames[index];
+
+}
+
static struct target_ops dbug_ops;
static struct monitor_ops dbug_cmds;
dbug_cmds.cmd_end = NULL; /* optional command terminator */
dbug_cmds.target = &dbug_ops; /* target operations */
dbug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- dbug_cmds.regnames = dbug_regnames; /* registers names */
+ dbug_cmds.regnames = NULL; /* registers names */
+ dbug_cmds.regname = dbug_regname;
dbug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
} /* init_debug_ops */
zerobuf = alloca (MAX_REGISTER_RAW_SIZE);
memset (zerobuf, 0, MAX_REGISTER_RAW_SIZE);
- name = current_monitor->regnames[regno];
+ if (current_monitor->regname != NULL)
+ name = current_monitor->regname (regno);
+ else
+ name = current_monitor->regnames[regno];
monitor_debug ("MON fetchreg %d '%s'\n", regno, name ? name : "(null name)");
if (!name || (*name == '\0'))
{
char *name;
ULONGEST val;
-
- name = current_monitor->regnames[regno];
+
+ if (current_monitor->regname != NULL)
+ name = current_monitor->regname (regno);
+ else
+ name = current_monitor->regnames[regno];
+
if (!name || (*name == '\0'))
{
monitor_debug ("MON Cannot store unknown register\n");
struct target_ops *target; /* target operations */
int stopbits; /* number of stop bits */
char **regnames; /* array of register names in ascii */
+ /* deprecated: use regname instead */
+ const char *(*regname) (int index);
+ /* function for dynamic regname array */
int num_breakpoints; /* If set_break != NULL, number of supported
breakpoints */
int magic; /* Check value */
* registers either. So, typing "info reg sp" becomes a "r30".
*/
-static char *est_regnames[NUM_REGS] =
+static char *
+est_regname (int index)
{
- "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
- "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
- "SR", "PC",
-};
+
+ static char *regnames[] =
+ {
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
+ "SR", "PC",
+ };
+
+
+ if ((index >= (sizeof (regnames) / sizeof (regnames[0])))
+ || (index < 0) || (index >= NUM_REGS))
+ return NULL;
+ else
+ return regnames[index];
+}
/*
* Define the monitor command strings. Since these are passed directly
est_cmds.cmd_end = NULL; /* optional command terminator */
est_cmds.target = &est_ops; /* target operations */
est_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- est_cmds.regnames = est_regnames; /* registers names */
+ est_cmds.regnames = NULL;
+ est_cmds.regname = est_regname; /*register names*/
est_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
} /* init_est_cmds */
than does GDB, and don't necessarily support all the registers
either. So, typing "info reg sp" becomes a "r30". */
-static char *rom68k_regnames[NUM_REGS] =
+static const char *
+rom68k_regname (int index)
{
- "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
- "A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP",
- "SR", "PC"};
+
+ static char *regnames[] =
+ {
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+ "A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP",
+ "SR", "PC"
+ };
+
+ if ((index >= (sizeof (regnames) / sizeof(regnames[0])))
+ || (index < 0) || (index >= NUM_REGS))
+ return NULL;
+ else
+ return regnames[index];
+
+}
/* Define the monitor command strings. Since these are passed directly
through to a printf style function, we may include formatting
rom68k_cmds.cmd_end = ".\r";
rom68k_cmds.target = &rom68k_ops;
rom68k_cmds.stopbits = SERIAL_1_STOPBITS;
- rom68k_cmds.regnames = rom68k_regnames;
+ rom68k_cmds.regnames = NULL;
+ rom68k_cmds.regname = rom68k_regname;
rom68k_cmds.magic = MONITOR_OPS_MAGIC;
} /* init_rom68k_cmds */