* 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.
This commit is contained in:
Grace Sainsbury 2002-06-26 15:14:32 +00:00
parent eb3f2f5cfd
commit 1c617db829
8 changed files with 124 additions and 33 deletions

View file

@ -1,3 +1,22 @@
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> 2002-06-25 Tom Tromey <tromey@redhat.com>
* breakpoint.c (delete_command): Don't repeat `delete' commands. * breakpoint.c (delete_command): Don't repeat `delete' commands.

View file

@ -76,13 +76,23 @@ abug_supply_register (char *regname, int regnamelen, char *val, int vallen)
* registers either. So, typing "info reg sp" becomes an "A7". * registers either. So, typing "info reg sp" becomes an "A7".
*/ */
static char *abug_regnames[NUM_REGS] = static const char *
abug_regname (int index)
{
static char *regnames[] =
{ {
"D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
"A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
"PC", "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 * Define the monitor command strings. Since these are passed directly
* through to a printf style function, we need can include formatting * through to a printf style function, we need can include formatting
@ -141,7 +151,8 @@ init_abug_cmds (void)
abug_cmds.cmd_end = NULL; /* optional command terminator */ abug_cmds.cmd_end = NULL; /* optional command terminator */
abug_cmds.target = &abug_ops; /* target operations */ abug_cmds.target = &abug_ops; /* target operations */
abug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ 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 */ abug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
}; };

View file

@ -74,13 +74,23 @@ cpu32bug_supply_register (char *regname, int regnamelen, char *val, int vallen)
* registers either. So, typing "info reg sp" becomes an "A7". * registers either. So, typing "info reg sp" becomes an "A7".
*/ */
static char *cpu32bug_regnames[NUM_REGS] = static const char *
cpu32bug_regname (int index)
{
static char *regnames[] =
{ {
"D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
"A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
"SR", "PC", "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 * Define the monitor command strings. Since these are passed directly
* through to a printf style function, we need can include formatting * through to a printf style function, we need can include formatting
@ -139,7 +149,8 @@ init_cpu32bug_cmds (void)
cpu32bug_cmds.cmd_end = NULL; /* optional command terminator */ cpu32bug_cmds.cmd_end = NULL; /* optional command terminator */
cpu32bug_cmds.target = &cpu32bug_ops; /* target operations */ cpu32bug_cmds.target = &cpu32bug_ops; /* target operations */
cpu32bug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ 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 */ cpu32bug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
}; /* init_cpu32bug_cmds */ }; /* init_cpu32bug_cmds */

View file

@ -76,13 +76,25 @@ dbug_supply_register (char *regname, int regnamelen, char *val, int vallen)
different names than GDB does, and don't support all the registers different names than GDB does, and don't support all the registers
either. So, typing "info reg sp" becomes an "A7". */ either. So, typing "info reg sp" becomes an "A7". */
static char *dbug_regnames[NUM_REGS] = static const char *
dbug_regname (int index)
{
static char *regnames[] =
{ {
"D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
"A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
"SR", "PC" "SR", "PC"
/* no float registers */ /* 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 target_ops dbug_ops;
static struct monitor_ops dbug_cmds; static struct monitor_ops dbug_cmds;
@ -135,7 +147,8 @@ init_dbug_cmds (void)
dbug_cmds.cmd_end = NULL; /* optional command terminator */ dbug_cmds.cmd_end = NULL; /* optional command terminator */
dbug_cmds.target = &dbug_ops; /* target operations */ dbug_cmds.target = &dbug_ops; /* target operations */
dbug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ 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 */ dbug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
} /* init_debug_ops */ } /* init_debug_ops */

View file

@ -1183,6 +1183,9 @@ monitor_fetch_register (int regno)
zerobuf = alloca (MAX_REGISTER_RAW_SIZE); zerobuf = alloca (MAX_REGISTER_RAW_SIZE);
memset (zerobuf, 0, MAX_REGISTER_RAW_SIZE); memset (zerobuf, 0, MAX_REGISTER_RAW_SIZE);
if (current_monitor->regname != NULL)
name = current_monitor->regname (regno);
else
name = current_monitor->regnames[regno]; name = current_monitor->regnames[regno];
monitor_debug ("MON fetchreg %d '%s'\n", regno, name ? name : "(null name)"); monitor_debug ("MON fetchreg %d '%s'\n", regno, name ? name : "(null name)");
@ -1336,7 +1339,11 @@ monitor_store_register (int regno)
char *name; char *name;
ULONGEST val; ULONGEST val;
if (current_monitor->regname != NULL)
name = current_monitor->regname (regno);
else
name = current_monitor->regnames[regno]; name = current_monitor->regnames[regno];
if (!name || (*name == '\0')) if (!name || (*name == '\0'))
{ {
monitor_debug ("MON Cannot store unknown register\n"); monitor_debug ("MON Cannot store unknown register\n");

View file

@ -116,6 +116,9 @@ struct monitor_ops
struct target_ops *target; /* target operations */ struct target_ops *target; /* target operations */
int stopbits; /* number of stop bits */ int stopbits; /* number of stop bits */
char **regnames; /* array of register names in ascii */ 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 int num_breakpoints; /* If set_break != NULL, number of supported
breakpoints */ breakpoints */
int magic; /* Check value */ int magic; /* Check value */

View file

@ -76,13 +76,25 @@ est_supply_register (char *regname, int regnamelen, char *val, int vallen)
* registers either. So, typing "info reg sp" becomes a "r30". * registers either. So, typing "info reg sp" becomes a "r30".
*/ */
static char *est_regnames[NUM_REGS] = static char *
est_regname (int index)
{
static char *regnames[] =
{ {
"D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
"A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
"SR", "PC", "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 * Define the monitor command strings. Since these are passed directly
* through to a printf style function, we need can include formatting * through to a printf style function, we need can include formatting
@ -143,7 +155,8 @@ init_est_cmds (void)
est_cmds.cmd_end = NULL; /* optional command terminator */ est_cmds.cmd_end = NULL; /* optional command terminator */
est_cmds.target = &est_ops; /* target operations */ est_cmds.target = &est_ops; /* target operations */
est_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ 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 */ est_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
} /* init_est_cmds */ } /* init_est_cmds */

View file

@ -157,11 +157,24 @@ rom68k_supply_register (char *regname, int regnamelen, char *val, int vallen)
than does GDB, and don't necessarily support all the registers than does GDB, and don't necessarily support all the registers
either. So, typing "info reg sp" becomes a "r30". */ either. So, typing "info reg sp" becomes a "r30". */
static char *rom68k_regnames[NUM_REGS] = static const char *
rom68k_regname (int index)
{
static char *regnames[] =
{ {
"D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
"A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "ISP",
"SR", "PC"}; "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 /* Define the monitor command strings. Since these are passed directly
through to a printf style function, we may include formatting through to a printf style function, we may include formatting
@ -220,7 +233,8 @@ init_rom68k_cmds (void)
rom68k_cmds.cmd_end = ".\r"; rom68k_cmds.cmd_end = ".\r";
rom68k_cmds.target = &rom68k_ops; rom68k_cmds.target = &rom68k_ops;
rom68k_cmds.stopbits = SERIAL_1_STOPBITS; 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; rom68k_cmds.magic = MONITOR_OPS_MAGIC;
} /* init_rom68k_cmds */ } /* init_rom68k_cmds */