diff options
author | Thiago Jung Bauermann <thiago.bauermann@linaro.org> | 2022-08-16 17:18:47 +0000 |
---|---|---|
committer | Thiago Jung Bauermann <thiago.bauermann@linaro.org> | 2023-02-01 19:48:07 +0000 |
commit | cbd02f9fa521a6cb21c04b15ee7671c8bb4be55b (patch) | |
tree | 2020002b59cf64272d5407c6cfcde95a9cf56b64 | |
parent | cded17bfca35566fa4d36e9ec06fa071bd7dab17 (diff) | |
download | gdb-cbd02f9fa521a6cb21c04b15ee7671c8bb4be55b.zip gdb-cbd02f9fa521a6cb21c04b15ee7671c8bb4be55b.tar.gz gdb-cbd02f9fa521a6cb21c04b15ee7671c8bb4be55b.tar.bz2 |
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>
-rw-r--r-- | gdbserver/regcache.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 3aeefcc..0b11416 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -199,6 +199,9 @@ regcache_cpy (struct regcache *dst, struct regcache *src) static const struct gdb::reg & 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]; } @@ -440,8 +443,6 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum, int size; gdb_assert (regcache != NULL); - gdb_assert (regnum >= 0 - && regnum < regcache->tdesc->reg_defs.size ()); size = register_size (regcache->tdesc, regnum); |