aboutsummaryrefslogtreecommitdiff
path: root/gdb/regcache.h
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2018-02-21 11:20:02 +0000
committerYao Qi <yao.qi@linaro.org>2018-02-21 11:20:02 +0000
commit31716595b5bda8524fc841378468fd1c47510dd3 (patch)
tree703d7d5c58447df908453effdbf29abf45d4225e /gdb/regcache.h
parentbbad996200720297c10313ae45906be80cf5f260 (diff)
downloadgdb-31716595b5bda8524fc841378468fd1c47510dd3.zip
gdb-31716595b5bda8524fc841378468fd1c47510dd3.tar.gz
gdb-31716595b5bda8524fc841378468fd1c47510dd3.tar.bz2
Class reg_buffer
This patch adds a new class reg_buffer, and regcache inherits it. Class reg_buffer is a very simple class, which has the buffer for register contents and status only. It doesn't have any methods to set contents and status, and it is expected that its children classes can inherit it and add different access methods. Another reason I keep class reg_buffer so simple is that I think reg_buffer can be even reused in other classes which need to record the registers contents and status, like frame cache for example. gdb: 2018-02-21 Yao Qi <yao.qi@linaro.org> * regcache.c (regcache::regcache): Call reg_buffer ctor. (regcache::arch): Move it to reg_buffer::arch. (regcache::register_buffer): Likewise. (regcache::assert_regnum): Likewise. (regcache::num_raw_registers): Likewise. * regcache.h (reg_buffer): New class. (regcache): Inherit reg_buffer.
Diffstat (limited to 'gdb/regcache.h')
-rw-r--r--gdb/regcache.h62
1 files changed, 36 insertions, 26 deletions
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 9e3da8c..e2c76211 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -227,9 +227,44 @@ typedef struct cached_reg
gdb_byte *data;
} cached_reg_t;
+/* Buffer of registers. */
+
+class reg_buffer
+{
+public:
+ reg_buffer (gdbarch *gdbarch, bool has_pseudo);
+
+ DISABLE_COPY_AND_ASSIGN (reg_buffer);
+
+ /* Return regcache's architecture. */
+ gdbarch *arch () const;
+
+ virtual ~reg_buffer ()
+ {
+ xfree (m_registers);
+ xfree (m_register_status);
+ }
+
+protected:
+ /* Assert on the range of REGNUM. */
+ void assert_regnum (int regnum) const;
+
+ int num_raw_registers () const;
+
+ gdb_byte *register_buffer (int regnum) const;
+
+ struct regcache_descr *m_descr;
+
+ bool m_has_pseudo;
+ /* The register buffers. */
+ gdb_byte *m_registers;
+ /* Register cache status. */
+ signed char *m_register_status;
+};
+
/* The register cache for storing raw register values. */
-class regcache
+class regcache : public reg_buffer
{
public:
regcache (gdbarch *gdbarch)
@@ -244,15 +279,6 @@ public:
DISABLE_COPY_AND_ASSIGN (regcache);
- ~regcache ()
- {
- xfree (m_registers);
- xfree (m_register_status);
- }
-
- /* Return regcache's architecture. */
- gdbarch *arch () const;
-
/* Return REGCACHE's address space. */
const address_space *aspace () const
{
@@ -339,14 +365,9 @@ public:
static void regcache_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid);
protected:
regcache (gdbarch *gdbarch, const address_space *aspace_, bool readonly_p_);
-
- int num_raw_registers () const;
-
static std::forward_list<regcache *> current_regcache;
private:
- gdb_byte *register_buffer (int regnum) const;
-
void restore (struct regcache *src);
enum register_status xfer_part (int regnum, int offset, int len, void *in,
@@ -357,21 +378,10 @@ 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
makes sense, like PC or SP). */
const address_space * const m_aspace;
- /* The register buffers. A read-only register cache can hold the
- full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write
- register cache can only hold [0 .. gdbarch_num_regs). */
- gdb_byte *m_registers;
- /* Register cache status. */
- signed char *m_register_status;
/* Is this a read-only cache? A read-only cache is used for saving
the target's register state (e.g, across an inferior function
call or just before forcing a function return). A read-only