From: Andrew Cagney Date: Tue, 13 Aug 2002 23:06:40 +0000 (+0000) Subject: 2002-08-13 Andrew Cagney X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=53826de97c0834aee03c2e9dc91ea000e3faa1ac;p=binutils-gdb.git 2002-08-13 Andrew Cagney * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 71eae60d0d1..a34f45aa5c1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2002-08-13 Andrew Cagney + + * 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 + nr_raw_registers. + (set_register_cached): Add range checking assertions. Use + current_regcache. + 2002-08-13 Mark Kettenis * i386-tdep.c (i386_stab_reg_to_regnum): Return correct register 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)