aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-12-01 11:27:17 -0500
committerSimon Marchi <simon.marchi@efficios.com>2023-12-14 16:04:49 +0000
commit08d8e7ff9474a88b491d22139ace851daae1a1c6 (patch)
tree7a32a5dabdddcb7a16fb24c134b241b8539fbe5c /gdb
parentf06b75776428f524d91d860aecbbe2734cf5580c (diff)
downloadgdb-08d8e7ff9474a88b491d22139ace851daae1a1c6.zip
gdb-08d8e7ff9474a88b491d22139ace851daae1a1c6.tar.gz
gdb-08d8e7ff9474a88b491d22139ace851daae1a1c6.tar.bz2
gdb: simplify conditions in regcache::{read,write,raw_collect,raw_supply}_part
Make a few simplifications in these functions. 1. When checking if we need to do nothing, if the length is 0, we don't need to do anything, regardless of the value of offset. Remove the offset check. 2. When check if transferring the whole register, if the length is equal to the register size, then we transfer the whole register, no need to check the offset. Remove the offset check. 3. In the gdb_asserts, it is unnecessary to check for: offset <= reg_size given that right after we check for: len >= 0 && offset + len <= reg_size If `offset + len` is <= reg_size and len is >= 0, then necessarily offset is <= reg_size. Remove the `offset <= reg_size` check. Change-Id: I30a73acdc7bf432c45a07f5f177224d1cdc298e8 Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/regcache.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 6c986b7..7eb54d2 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -873,16 +873,16 @@ readable_regcache::read_part (int regnum, int offset, int len,
int reg_size = register_size (arch (), regnum);
gdb_assert (out != NULL);
- gdb_assert (offset >= 0 && offset <= reg_size);
+ gdb_assert (offset >= 0);
gdb_assert (len >= 0 && offset + len <= reg_size);
- if (offset == 0 && len == 0)
+ if (len == 0)
{
/* Nothing to do. */
return REG_VALID;
}
- if (offset == 0 && len == reg_size)
+ if (len == reg_size)
{
/* Read the full register. */
return (is_raw) ? raw_read (regnum, out) : cooked_read (regnum, out);
@@ -910,16 +910,16 @@ reg_buffer::raw_collect_part (int regnum, int offset, int len,
int reg_size = register_size (arch (), regnum);
gdb_assert (out != nullptr);
- gdb_assert (offset >= 0 && offset <= reg_size);
+ gdb_assert (offset >= 0);
gdb_assert (len >= 0 && offset + len <= reg_size);
- if (offset == 0 && len == 0)
+ if (len == 0)
{
/* Nothing to do. */
return;
}
- if (offset == 0 && len == reg_size)
+ if (len == reg_size)
{
/* Collect the full register. */
return raw_collect (regnum, out);
@@ -940,16 +940,16 @@ regcache::write_part (int regnum, int offset, int len,
int reg_size = register_size (arch (), regnum);
gdb_assert (in != NULL);
- gdb_assert (offset >= 0 && offset <= reg_size);
+ gdb_assert (offset >= 0);
gdb_assert (len >= 0 && offset + len <= reg_size);
- if (offset == 0 && len == 0)
+ if (len == 0)
{
/* Nothing to do. */
return REG_VALID;
}
- if (offset == 0 && len == reg_size)
+ if (len == reg_size)
{
/* Write the full register. */
(is_raw) ? raw_write (regnum, in) : cooked_write (regnum, in);
@@ -979,16 +979,16 @@ reg_buffer::raw_supply_part (int regnum, int offset, int len,
int reg_size = register_size (arch (), regnum);
gdb_assert (in != nullptr);
- gdb_assert (offset >= 0 && offset <= reg_size);
+ gdb_assert (offset >= 0);
gdb_assert (len >= 0 && offset + len <= reg_size);
- if (offset == 0 && len == 0)
+ if (len == 0)
{
/* Nothing to do. */
return;
}
- if (offset == 0 && len == reg_size)
+ if (len == reg_size)
{
/* Supply the full register. */
return raw_supply (regnum, in);