aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-11-02 15:15:41 +0000
committerYao Qi <yao.qi@linaro.org>2017-11-02 15:15:41 +0000
commit4e888c281cd19f019248bd165d7055af88641c80 (patch)
treefe7a19cd3bfdc9b56724c6364b457f9c7a7de966 /gdb
parent2e1b49b32ab9aec1aca94f424cbe275e5f6f9ab4 (diff)
downloadgdb-4e888c281cd19f019248bd165d7055af88641c80.zip
gdb-4e888c281cd19f019248bd165d7055af88641c80.tar.gz
gdb-4e888c281cd19f019248bd165d7055af88641c80.tar.bz2
New method regcache::assert_regnum
class regcache has some methods checking the range of register number, this patch is to move it in a new method assert_regnum. gdb: 2017-11-02 Yao Qi <yao.qi@linaro.org> * regcache.c (regcache::assert_regnum): New method. (regcache::invalidate): Call assert_regnum. (regcache::raw_update): Likewise. (regcache::raw_write): Likewise. (regcache::raw_read_part): Likewise. (regcache::raw_write_part): Likewise. (regcache::raw_supply): Likewise. (regcache::raw_supply_integer): Likewise. (regcache::raw_supply_zeroed): Likewise. (regcache::raw_collect): Likewise. (regcache::raw_collect_integer): Likewise. * regcache.h (regcache::assert_regnum): Declare.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog15
-rw-r--r--gdb/regcache.c31
-rw-r--r--gdb/regcache.h3
3 files changed, 36 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bb22304..68e4aa9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,20 @@
2017-11-02 Yao Qi <yao.qi@linaro.org>
+ * regcache.c (regcache::assert_regnum): New method.
+ (regcache::invalidate): Call assert_regnum.
+ (regcache::raw_update): Likewise.
+ (regcache::raw_write): Likewise.
+ (regcache::raw_read_part): Likewise.
+ (regcache::raw_write_part): Likewise.
+ (regcache::raw_supply): Likewise.
+ (regcache::raw_supply_integer): Likewise.
+ (regcache::raw_supply_zeroed): Likewise.
+ (regcache::raw_collect): Likewise.
+ (regcache::raw_collect_integer): Likewise.
+ * regcache.h (regcache::assert_regnum): Declare.
+
+2017-11-02 Yao Qi <yao.qi@linaro.org>
+
* regcache.c (regcache::dump): Remove code.
2017-11-02 Yao Qi <yao.qi@linaro.org>
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 0d3fe3d..0aee934 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -393,12 +393,17 @@ regcache_invalidate (struct regcache *regcache, int regnum)
void
regcache::invalidate (int regnum)
{
- gdb_assert (regnum >= 0);
gdb_assert (!m_readonly_p);
- gdb_assert (regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
m_register_status[regnum] = REG_UNKNOWN;
}
+void
+regcache::assert_regnum (int regnum) const
+{
+ gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+}
+
/* Global structure containing the current regcache. */
/* NOTE: this is a write-through cache. There is no "dirty" bit for
@@ -546,7 +551,7 @@ regcache_raw_update (struct regcache *regcache, int regnum)
void
regcache::raw_update (int regnum)
{
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
/* Make certain that the register cache is up-to-date with respect
to the current thread. This switching shouldn't be necessary
@@ -600,7 +605,7 @@ regcache::raw_read (int regnum, T *val)
gdb_byte *buf;
enum register_status status;
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
status = raw_read (regnum, buf);
if (status == REG_VALID)
@@ -633,7 +638,7 @@ regcache::raw_write (int regnum, T val)
{
gdb_byte *buf;
- gdb_assert (regnum >=0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
store_integer (buf, m_descr->sizeof_register[regnum],
gdbarch_byte_order (m_descr->gdbarch), val);
@@ -844,7 +849,7 @@ regcache::raw_write (int regnum, const gdb_byte *buf)
{
gdb_assert (buf != NULL);
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
gdb_assert (!m_readonly_p);
/* On the sparc, writing %g0 is a no-op, so we don't even want to
@@ -953,7 +958,7 @@ regcache_raw_read_part (struct regcache *regcache, int regnum,
enum register_status
regcache::raw_read_part (int regnum, int offset, int len, gdb_byte *buf)
{
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
return xfer_part (regnum, offset, len, buf, NULL, true);
}
@@ -968,7 +973,7 @@ void
regcache::raw_write_part (int regnum, int offset, int len,
const gdb_byte *buf)
{
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
xfer_part (regnum, offset, len, NULL, buf, true);
}
@@ -1017,7 +1022,7 @@ regcache::raw_supply (int regnum, const void *buf)
void *regbuf;
size_t size;
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
gdb_assert (!m_readonly_p);
regbuf = register_buffer (regnum);
@@ -1052,7 +1057,7 @@ regcache::raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len,
gdb_byte *regbuf;
size_t regsize;
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
gdb_assert (!m_readonly_p);
regbuf = register_buffer (regnum);
@@ -1073,7 +1078,7 @@ regcache::raw_supply_zeroed (int regnum)
void *regbuf;
size_t size;
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
gdb_assert (!m_readonly_p);
regbuf = register_buffer (regnum);
@@ -1099,7 +1104,7 @@ regcache::raw_collect (int regnum, void *buf) const
size_t size;
gdb_assert (buf != NULL);
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
regbuf = register_buffer (regnum);
size = m_descr->sizeof_register[regnum];
@@ -1124,7 +1129,7 @@ regcache::raw_collect_integer (int regnum, gdb_byte *addr, int addr_len,
const gdb_byte *regbuf;
size_t regsize;
- gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers);
+ assert_regnum (regnum);
regbuf = register_buffer (regnum);
regsize = m_descr->sizeof_register[regnum];
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 0eea042..6fb790d 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -358,6 +358,9 @@ private:
int regnum, const void *in_buf,
void *out_buf, size_t size) const;
+ /* Assert on the range of REGNUM. */
+ void assert_regnum (int regnum) const;
+
struct regcache_descr *m_descr;
/* The address space of this register cache (for registers where it