diff options
author | Kevin Buettner <kevinb@redhat.com> | 2002-12-17 23:13:31 +0000 |
---|---|---|
committer | Kevin Buettner <kevinb@redhat.com> | 2002-12-17 23:13:31 +0000 |
commit | 6819ae388f58b841d2b4b6a55aa5db2137e8e49d (patch) | |
tree | 156720e6259a5f03a0434106812995c0383acd84 /gdb/dve3900-rom.c | |
parent | 2e51bbe3d2011df8151c3ab7c13208d9675e50d0 (diff) | |
download | gdb-6819ae388f58b841d2b4b6a55aa5db2137e8e49d.zip gdb-6819ae388f58b841d2b4b6a55aa5db2137e8e49d.tar.gz gdb-6819ae388f58b841d2b4b6a55aa5db2137e8e49d.tar.bz2 |
Don't use NUM_REGS to determine array size.
Diffstat (limited to 'gdb/dve3900-rom.c')
-rw-r--r-- | gdb/dve3900-rom.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gdb/dve3900-rom.c b/gdb/dve3900-rom.c index feb8e12..c8834e9 100644 --- a/gdb/dve3900-rom.c +++ b/gdb/dve3900-rom.c @@ -113,7 +113,7 @@ static int ethernet = 0; different names than GDB does, and don't support all the registers either. */ -static char *r3900_regnames[NUM_REGS] = +static char *r3900_regnames[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", @@ -456,8 +456,15 @@ fetch_bitmapped_register (int regno, struct bit_field *bf) { unsigned long val; unsigned char regbuf[MAX_REGISTER_RAW_SIZE]; + char *regname = NULL; - monitor_printf ("x%s\r", r3900_regnames[regno]); + if (regno >= sizeof (r3900_regnames) / sizeof (r3900_regnames[0])) + internal_error (__FILE__, __LINE__, + "fetch_bitmapped_register: regno out of bounds"); + else + regname = r3900_regnames[regno]; + + monitor_printf ("x%s\r", regname); val = fetch_fields (bf); monitor_printf (".\r"); monitor_expect_prompt (NULL, 0); @@ -501,9 +508,16 @@ static void store_bitmapped_register (int regno, struct bit_field *bf) { unsigned long oldval, newval; + char *regname = NULL; + + if (regno >= sizeof (r3900_regnames) / sizeof (r3900_regnames[0])) + internal_error (__FILE__, __LINE__, + "fetch_bitmapped_register: regno out of bounds"); + else + regname = r3900_regnames[regno]; /* Fetch the current value of the register. */ - monitor_printf ("x%s\r", r3900_regnames[regno]); + monitor_printf ("x%s\r", regname); oldval = fetch_fields (bf); newval = read_register (regno); |