From patchwork Fri Dec 1 10:48:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 24658 Received: (qmail 75082 invoked by alias); 1 Dec 2017 10:48:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 74860 invoked by uid 89); 1 Dec 2017 10:48:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=lift, 20013, 8006 X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 01 Dec 2017 10:48:27 +0000 Received: by mail-wm0-f52.google.com with SMTP id f140so2616906wmd.2 for ; Fri, 01 Dec 2017 02:48:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=uanVNYBtGqajenjOvfnm/KxtHB0QPHFkDPNKxjxYWtM=; b=H/FPgGyYfdBqz2T55S0RO6TOEMusDXvxqvzkKNuPBh0FGf4hbPt/azGOAfwRNWAmYy T/HJghPSvhkfiqSQc7IQnCNb+JtlWs3XIsSffvt+hNQc4A7l1rI+yBHsw+s4XXobRdXt Zt3NRCJIvmNKHqm6+H5u20TP2e5YijArbUmyO59pkq6lbRBkmQtTVF3QnoqG7RafnAfj vd8aPn9TbO0A2J6kJRdeIwtLLS10hUmjyTbc5vQp1p4x+In6xoH+4q5ZZp5k/BFuStT0 M8wBblBuD3JyMCYMyktZr4El7ff+LbHf6hCAzC9ZQCDytrNP7qerfuCoJ1WgPjDSNRL7 pxAQ== X-Gm-Message-State: AKGB3mLSyNQUqixcmfBZjX4iIblXtCdMzF+kq4F/OZ0PiJbGooVfXWFv il55p7aPbsu3cZ7kyvajBAj2LA== X-Google-Smtp-Source: AGs4zMYJn/z6RdmIfLi0IS0rMuWXyxdMjVhoT0Fa8tEGNE4MXPlByTsJ8+QkryCozC+ndSFo1hPLrg== X-Received: by 10.28.139.144 with SMTP id n138mr888494wmd.78.1512125305170; Fri, 01 Dec 2017 02:48:25 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id o10sm5316833wrg.5.2017.12.01.02.48.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Dec 2017 02:48:24 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 14/15] Remove regcache::m_readonly_p Date: Fri, 1 Dec 2017 10:48:05 +0000 Message-Id: <1512125286-29788-15-git-send-email-yao.qi@linaro.org> In-Reply-To: <1512125286-29788-1-git-send-email-yao.qi@linaro.org> References: <1512125286-29788-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes 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 reg_buffer_rw. gdb: 2017-11-07 Yao Qi * regcache.c (regcache::regcache): Update. (regcache::invalidate): Move it to reg_buffer_rw::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 reg_buffer_rw::raw_supply_integer. (regcache::raw_supply_zeroed): Likewise. * regcache.h (reg_buffer_rw) : New declaration. : Likewise. (regcache) : Removed. : Likewise. : Removed. --- gdb/regcache.c | 30 +++++++++++------------------- gdb/regcache.h | 22 ++++++++-------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/gdb/regcache.c b/gdb/regcache.c index 4286f36..4ea4a5d 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -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). */ - : reg_buffer_rw (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). */ + : reg_buffer_rw (gdbarch, false), m_aspace (aspace_) { m_ptid = minus_one_ptid; } @@ -319,7 +316,6 @@ regcache::restore (regcache_readonly *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) +reg_buffer_rw::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 @@ reg_buffer_rw::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) +reg_buffer_rw::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) +reg_buffer_rw::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) {} }; diff --git a/gdb/regcache.h b/gdb/regcache.h index fc645c4..d1e8506 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -295,6 +295,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 (reg_buffer_rw); }; @@ -336,13 +343,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, @@ -371,7 +371,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 current_regcache; private: @@ -389,12 +389,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;