diff options
author | Andrew Cagney <cagney@redhat.com> | 2002-08-13 23:06:40 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2002-08-13 23:06:40 +0000 |
commit | 39033ce6fc7980b94cadaa744f5d67c4000448aa (patch) | |
tree | 2da40ab4055f968a47bdf4ba17f4bb3eebd2c6fd /gdb/regcache.c | |
parent | 3154a39df1bcdd843581054e193b8dc1b1147385 (diff) | |
download | gdb-39033ce6fc7980b94cadaa744f5d67c4000448aa.tar.gz |
2002-08-13 Andrew Cagney <cagney@redhat.com>
* regcache.c (init_regcache_descr): Overallocate the
raw_register_valid_p array including space for NUM_PSEUDO_REGS.
(registers_changed): Replace NUM_REGS+NUM_PSEUDO_REGS with
num_raw_registers.
(set_register_cached): Add range checking assertions. Use
current_regcache.
Diffstat (limited to 'gdb/regcache.c')
-rw-r--r-- | gdb/regcache.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c index 85d96c9e4ac..e46f082c843 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -161,7 +161,12 @@ init_regcache_descr (struct gdbarch *gdbarch) /* Construct a strictly RAW register cache. Don't allow pseudo's into the register cache. */ descr->nr_raw_registers = NUM_REGS; - descr->sizeof_raw_register_valid_p = NUM_REGS; + + /* FIXME: cagney/2002-08-13: Overallocate the register_valid_p + array. This pretects GDB from erant code that accesses elements + of the global register_valid_p[] array in the range [NUM_REGS + .. NUM_REGS + NUM_PSEUDO_REGS). */ + descr->sizeof_raw_register_valid_p = NUM_REGS + NUM_PSEUDO_REGS; /* Lay out the register cache. The pseud-registers are included in the layout even though their value isn't stored in the register @@ -431,7 +436,9 @@ register_cached (int regnum) void set_register_cached (int regnum, int state) { - register_valid[regnum] = state; + gdb_assert (regnum >= 0); + gdb_assert (regnum < current_regcache->descr->nr_raw_registers); + current_regcache->raw_register_valid_p[regnum] = state; } /* REGISTER_CHANGED @@ -485,7 +492,7 @@ registers_changed (void) gdb gives control to the user (ie watchpoints). */ alloca (0); - for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++) + for (i = 0; i < current_regcache->descr->nr_raw_registers; i++) set_register_cached (i, 0); if (registers_changed_hook) |