aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>2022-08-16 17:18:47 +0000
committerThiago Jung Bauermann <thiago.bauermann@linaro.org>2023-02-01 19:48:07 +0000
commitcbd02f9fa521a6cb21c04b15ee7671c8bb4be55b (patch)
tree2020002b59cf64272d5407c6cfcde95a9cf56b64 /gdbserver
parentcded17bfca35566fa4d36e9ec06fa071bd7dab17 (diff)
downloadgdb-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>
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/regcache.cc5
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);