diff options
-rw-r--r-- | gdb/ChangeLog | 19 | ||||
-rw-r--r-- | gdb/abug-rom.c | 23 | ||||
-rw-r--r-- | gdb/cpu32bug-rom.c | 23 | ||||
-rw-r--r-- | gdb/dbug-rom.c | 27 | ||||
-rw-r--r-- | gdb/monitor.c | 13 | ||||
-rw-r--r-- | gdb/monitor.h | 3 | ||||
-rw-r--r-- | gdb/remote-est.c | 25 | ||||
-rw-r--r-- | gdb/rom68k-rom.c | 24 |
8 files changed, 124 insertions, 33 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6c637f771be..90c0e39122b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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> * breakpoint.c (delete_command): Don't repeat `delete' commands. diff --git a/gdb/abug-rom.c b/gdb/abug-rom.c index b4c44a94b54..8a9e8ff47c7 100644 --- a/gdb/abug-rom.c +++ b/gdb/abug-rom.c @@ -76,12 +76,22 @@ abug_supply_register (char *regname, int regnamelen, char *val, int vallen) * 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 @@ -141,7 +151,8 @@ init_abug_cmds (void) 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 */ }; diff --git a/gdb/cpu32bug-rom.c b/gdb/cpu32bug-rom.c index 2801be9ea0f..efaf89a4b70 100644 --- a/gdb/cpu32bug-rom.c +++ b/gdb/cpu32bug-rom.c @@ -74,12 +74,22 @@ cpu32bug_supply_register (char *regname, int regnamelen, char *val, int vallen) * 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 @@ -139,7 +149,8 @@ init_cpu32bug_cmds (void) 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 */ diff --git a/gdb/dbug-rom.c b/gdb/dbug-rom.c index f31555738eb..bd20184c006 100644 --- a/gdb/dbug-rom.c +++ b/gdb/dbug-rom.c @@ -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 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; @@ -135,7 +147,8 @@ init_dbug_cmds (void) 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 */ diff --git a/gdb/monitor.c b/gdb/monitor.c index 81340d4be02..44c8e8f1e86 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -1183,7 +1183,10 @@ monitor_fetch_register (int regno) 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')) @@ -1335,8 +1338,12 @@ monitor_store_register (int regno) { 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"); diff --git a/gdb/monitor.h b/gdb/monitor.h index 85a44ff7e71..5d6138c4398 100644 --- a/gdb/monitor.h +++ b/gdb/monitor.h @@ -116,6 +116,9 @@ struct monitor_ops 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 */ diff --git a/gdb/remote-est.c b/gdb/remote-est.c index e045a8951cd..86310e9033d 100644 --- a/gdb/remote-est.c +++ b/gdb/remote-est.c @@ -76,12 +76,24 @@ est_supply_register (char *regname, int regnamelen, char *val, int vallen) * 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 @@ -143,7 +155,8 @@ init_est_cmds (void) 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 */ diff --git a/gdb/rom68k-rom.c b/gdb/rom68k-rom.c index ec49f5d7177..cc0586f8ed5 100644 --- a/gdb/rom68k-rom.c +++ b/gdb/rom68k-rom.c @@ -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 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 @@ -220,7 +233,8 @@ init_rom68k_cmds (void) 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 */ |