Remove regcache::m_readonly_p
authorYao Qi <yao.qi@linaro.org>
Wed, 21 Feb 2018 11:20:03 +0000 (11:20 +0000)
committerYao Qi <yao.qi@linaro.org>
Wed, 21 Feb 2018 11:20:03 +0000 (11:20 +0000)
Now, m_readonly_p is always false, so we can remove it, and regcache no
longer includes pseudo registers.  Some regcache methods are lift up to
its parent class, like reg_buffer or detached_regcache.

gdb:

2018-02-21  Yao Qi  <yao.qi@linaro.org>

* regcache.c (regcache::regcache): Update.
(regcache::invalidate): Move it to detached_regcache::invalidate.
(get_thread_arch_aspace_regcache): Update.
(regcache::raw_update): Update.
(regcache::cooked_read): Remove some code.
(regcache::cooked_read_value): Likewise.
(regcache::raw_write): Remove assert on m_readonly_p.
(regcache::raw_supply_integer): Move it to
detached_regcache::raw_supply_integer.
(regcache::raw_supply_zeroed): Likewise.
* regcache.h (detached_regcache) <raw_supply_integer>: New
declaration.
<raw_supply_zeroed, invalidate>: Likewise.
(regcache) <raw_supply_integer, raw_supply_zeroed>: Removed.
<invalidate>: Likewise.
<m_readonly_p>: Removed.

gdb/ChangeLog
gdb/regcache.c
gdb/regcache.h

index 30db821bfca933c786224e1569f258411d4a0228..6936cf5936274e0b855f5546d66333d6a7b0feae 100644 (file)
@@ -1,3 +1,22 @@
+2018-02-21  Yao Qi  <yao.qi@linaro.org>
+
+       * regcache.c (regcache::regcache): Update.
+       (regcache::invalidate): Move it to detached_regcache::invalidate.
+       (get_thread_arch_aspace_regcache): Update.
+       (regcache::raw_update): Update.
+       (regcache::cooked_read): Remove some code.
+       (regcache::cooked_read_value): Likewise.
+       (regcache::raw_write): Remove assert on m_readonly_p.
+       (regcache::raw_supply_integer): Move it to
+       detached_regcache::raw_supply_integer.
+       (regcache::raw_supply_zeroed): Likewise.
+       * regcache.h (detached_regcache) <raw_supply_integer>: New
+       declaration.
+       <raw_supply_zeroed, invalidate>: Likewise.
+       (regcache) <raw_supply_integer, raw_supply_zeroed>: Removed.
+       <invalidate>: Likewise.
+       <m_readonly_p>: Removed.
+
 2018-02-21  Yao Qi  <yao.qi@linaro.org>
 
        * infcmd.c (get_return_value): Let stop_regs point to
index 8f81163c4922778dcb9042801534ab26f08f9869..082b62e43e598c089fbd88a3d4fe1abf97793711 100644 (file)
@@ -200,13 +200,10 @@ reg_buffer::reg_buffer (gdbarch *gdbarch, bool has_pseudo)
     }
 }
 
-regcache::regcache (gdbarch *gdbarch, const address_space *aspace_,
-                   bool readonly_p_)
-/* 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).  */
-  : detached_regcache (gdbarch, readonly_p_),
-    m_aspace (aspace_), m_readonly_p (readonly_p_)
+regcache::regcache (gdbarch *gdbarch, const address_space *aspace_)
+/* The register buffers.  A read/write register cache can only hold
+   [0 .. gdbarch_num_regs).  */
+  : detached_regcache (gdbarch, false), m_aspace (aspace_)
 {
   m_ptid = minus_one_ptid;
 }
@@ -319,7 +316,6 @@ regcache::restore (readonly_detached_regcache *src)
   int regnum;
 
   gdb_assert (src != NULL);
-  gdb_assert (!m_readonly_p);
   gdb_assert (src->m_has_pseudo);
 
   gdb_assert (gdbarch == src->arch ());
@@ -361,9 +357,8 @@ regcache_invalidate (struct regcache *regcache, int regnum)
 }
 
 void
-regcache::invalidate (int regnum)
+detached_regcache::invalidate (int regnum)
 {
-  gdb_assert (!m_readonly_p);
   assert_regnum (regnum);
   m_register_status[regnum] = REG_UNKNOWN;
 }
@@ -394,7 +389,7 @@ get_thread_arch_aspace_regcache (ptid_t ptid, struct gdbarch *gdbarch,
     if (ptid_equal (regcache->ptid (), ptid) && regcache->arch () == gdbarch)
       return regcache;
 
-  regcache *new_regcache = new regcache (gdbarch, aspace, false);
+  regcache *new_regcache = new regcache (gdbarch, aspace);
 
   regcache::current_regcache.push_front (new_regcache);
   new_regcache->set_ptid (ptid);
@@ -532,7 +527,7 @@ regcache::raw_update (int regnum)
      only there is still only one target side register cache.  Sigh!
      On the bright side, at least there is a regcache object.  */
 
-  if (!m_readonly_p && get_register_status (regnum) == REG_UNKNOWN)
+  if (get_register_status (regnum) == REG_UNKNOWN)
     {
       target_fetch_registers (this, regnum);
 
@@ -805,7 +800,6 @@ regcache::raw_write (int regnum, const gdb_byte *buf)
 
   gdb_assert (buf != NULL);
   assert_regnum (regnum);
-  gdb_assert (!m_readonly_p);
 
   /* On the sparc, writing %g0 is a no-op, so we don't even want to
      change the registers array if something writes to this register.  */
@@ -1028,15 +1022,14 @@ detached_regcache::raw_supply (int regnum, const void *buf)
    most significant bytes of the integer will be truncated.  */
 
 void
-regcache::raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len,
-                             bool is_signed)
+detached_regcache::raw_supply_integer (int regnum, const gdb_byte *addr,
+                                  int addr_len, bool is_signed)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch);
   gdb_byte *regbuf;
   size_t regsize;
 
   assert_regnum (regnum);
-  gdb_assert (!m_readonly_p);
 
   regbuf = register_buffer (regnum);
   regsize = m_descr->sizeof_register[regnum];
@@ -1051,13 +1044,12 @@ regcache::raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len,
    unavailable).  */
 
 void
-regcache::raw_supply_zeroed (int regnum)
+detached_regcache::raw_supply_zeroed (int regnum)
 {
   void *regbuf;
   size_t size;
 
   assert_regnum (regnum);
-  gdb_assert (!m_readonly_p);
 
   regbuf = register_buffer (regnum);
   size = m_descr->sizeof_register[regnum];
@@ -1871,7 +1863,7 @@ class readwrite_regcache : public regcache
 {
 public:
   readwrite_regcache (struct gdbarch *gdbarch)
-    : regcache (gdbarch, nullptr, false)
+    : regcache (gdbarch, nullptr)
   {}
 };
 
index 6531afff254edf212af190144b3c85bd799c0dae..289b72197f746224a477e96fc7011a033fe5e9ec 100644 (file)
@@ -297,6 +297,13 @@ public:
   void raw_update (int regnum) override
   {}
 
+  void raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len,
+                          bool is_signed);
+
+  void raw_supply_zeroed (int regnum);
+
+  void invalidate (int regnum);
+
   DISABLE_COPY_AND_ASSIGN (detached_regcache);
 };
 
@@ -338,13 +345,6 @@ public:
   void raw_collect_integer (int regnum, gdb_byte *addr, int addr_len,
                            bool is_signed) const;
 
-  void raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len,
-                          bool is_signed);
-
-  void raw_supply_zeroed (int regnum);
-
-  void invalidate (int regnum);
-
   void raw_write_part (int regnum, int offset, int len, const gdb_byte *buf);
 
   void cooked_write_part (int regnum, int offset, int len,
@@ -373,7 +373,7 @@ 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_);
+  regcache (gdbarch *gdbarch, const address_space *aspace_);
   static std::forward_list<regcache *> current_regcache;
 
 private:
@@ -391,12 +391,6 @@ private:
      makes sense, like PC or SP).  */
   const address_space * const m_aspace;
 
-  /* 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
-     cache can only be created via a constructor.  The actual contents
-     are determined by the save and restore methods.  */
-  const bool m_readonly_p;
   /* If this is a read-write cache, which thread's registers is
      it connected to?  */
   ptid_t m_ptid;
This page took 0.035608 seconds and 4 git commands to generate.