mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-18 00:32:30 +08:00
gdbserver: Add assert in find_register_by_number
It helped me during development, catching bugs closer to when they actually happened. Also remove the equivalent gdb_assert in regcache_raw_read_unsigned, since it's checking the same condition a few frames above. Suggested-By: Simon Marchi <simon.marchi@efficios.com> Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
@ -199,6 +199,9 @@ regcache_cpy (struct regcache *dst, struct regcache *src)
|
|||||||
static const struct gdb::reg &
|
static const struct gdb::reg &
|
||||||
find_register_by_number (const struct target_desc *tdesc, int n)
|
find_register_by_number (const struct target_desc *tdesc, int n)
|
||||||
{
|
{
|
||||||
|
gdb_assert (n >= 0);
|
||||||
|
gdb_assert (n < tdesc->reg_defs.size ());
|
||||||
|
|
||||||
return tdesc->reg_defs[n];
|
return tdesc->reg_defs[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,8 +443,6 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
|
|||||||
int size;
|
int size;
|
||||||
|
|
||||||
gdb_assert (regcache != NULL);
|
gdb_assert (regcache != NULL);
|
||||||
gdb_assert (regnum >= 0
|
|
||||||
&& regnum < regcache->tdesc->reg_defs.size ());
|
|
||||||
|
|
||||||
size = register_size (regcache->tdesc, regnum);
|
size = register_size (regcache->tdesc, regnum);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user