From patchwork Fri Oct 27 09:31:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 23904 Received: (qmail 52317 invoked by alias); 27 Oct 2017 09:31:59 -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 52217 invoked by uid 89); 27 Oct 2017 09:31:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Oct 2017 09:31:55 +0000 Received: by mail-wm0-f49.google.com with SMTP id t139so2480893wmt.1 for ; Fri, 27 Oct 2017 02:31:55 -0700 (PDT) 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=aimti5AFz9qlp4NfBKV8/cUNw9lVI6nzcGsgAEBwOyE=; b=nujT8LC0z4e53KUgMOQ16503w2Hi7iSAEkK1644c+peb04V+D3siVvpLooG17j7sLV zLcRzPEIv0+2tUXhNBuMzrRPx8DEI7BHM2OIhhfkTUU+hadyfqrWxqo8DzuNVwMLyDn9 njnthfYcpDWQ8g/4r/1yJ0rZ+8AXrTlwywI1gOC6Rh9p2ygo8QnAkkTrrAEF4yZkbb3D 8v8cKx1zlFd3CGC+4Audr6jAkqtjuF5z/m3dXSdqQ7M0D4n6Q/0EsoyS3NF+oipQ9U2L I4uJ/gsbzgAO/rsx6OipLGzXlKEAJS376S5AGHABcTlh2JPInfxseeDnM02/oOPhElIv W4QQ== X-Gm-Message-State: AMCzsaVQD6acwvziVb31mUPnuavlAouXb6pCGtwv5X7AF79eitKsUmCS NSBG2bQw6qCdXfFDnIlwOQRu6g== X-Google-Smtp-Source: ABhQp+RyNL/Vkck7jE+cFQtH+bK/cH0VcA7SdOYnWBsFCN8BXgBJgCTbJfPV49nQ1Cvdg96y9nSAnQ== X-Received: by 10.28.104.214 with SMTP id d205mr51636wmc.151.1509096713262; Fri, 27 Oct 2017 02:31:53 -0700 (PDT) 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 r29sm10349378wra.71.2017.10.27.02.31.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Oct 2017 02:31:52 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 6/8] const-fy regcache::m_aspace Date: Fri, 27 Oct 2017 10:31:40 +0100 Message-Id: <1509096702-12202-7-git-send-email-yao.qi@linaro.org> In-Reply-To: <1509096702-12202-1-git-send-email-yao.qi@linaro.org> References: <1509096702-12202-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes regcache::m_aspace is a const, never changed during the lifetime of regcache object. gdb: 2017-10-23 Yao Qi * frame.c (create_sentinel_frame): Cast. * infrun.c (displaced_step_prepare_throw): Change variable const. (resume): Likewise. (proceed): Likewise. (adjust_pc_after_break): Likewise. (save_waitstatus): Likewise. (handle_signal_stop): Likewise. (keep_going_pass_signal): Likewise. * record-full.c (record_full_wait_1): Likewise. (record_full_wait_1): Likewise. * regcache.c (regcache::regcache): Change parameter to const. * regcache.h (regcache::regcache): Likewise. (regcache::aspace): Return const address_space *. (regcache) : Add const. --- gdb/frame.c | 2 +- gdb/infrun.c | 24 +++++++++++------------- gdb/record-full.c | 5 ++--- gdb/regcache.c | 2 +- gdb/regcache.h | 8 ++++---- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index 5380c7d..bf308ba 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1521,7 +1521,7 @@ create_sentinel_frame (struct program_space *pspace, struct regcache *regcache) frame->level = -1; frame->pspace = pspace; - frame->aspace = regcache->aspace (); + frame->aspace = const_cast (regcache->aspace ()); /* Explicitly initialize the sentinel frame's cache. Provide it with the underlying regcache. In the future additional information, such as the frame's thread will be added. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index 0e31dbc..3e0cc86 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1760,7 +1760,7 @@ displaced_step_prepare_throw (ptid_t ptid) struct thread_info *tp = find_thread_ptid (ptid); struct regcache *regcache = get_thread_regcache (ptid); struct gdbarch *gdbarch = regcache->arch (); - struct address_space *aspace = regcache->aspace (); + const address_space *aspace = regcache->aspace (); CORE_ADDR original, copy; ULONGEST len; struct displaced_step_closure *closure; @@ -2388,7 +2388,7 @@ resume (enum gdb_signal sig) struct gdbarch *gdbarch = regcache->arch (); struct thread_info *tp = inferior_thread (); CORE_ADDR pc = regcache_read_pc (regcache); - struct address_space *aspace = regcache->aspace (); + const address_space *aspace = regcache->aspace (); ptid_t resume_ptid; /* This represents the user's step vs continue request. When deciding whether "set scheduler-locking step" applies, it's the @@ -2591,7 +2591,7 @@ resume (enum gdb_signal sig) if (target_is_non_stop_p ()) stop_all_threads (); - set_step_over_info (regcache->aspace (), + set_step_over_info (const_cast (regcache->aspace ()), regcache_read_pc (regcache), 0, tp->global_num); step = maybe_software_singlestep (gdbarch, pc); @@ -2983,7 +2983,6 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) struct gdbarch *gdbarch; struct thread_info *tp; CORE_ADDR pc; - struct address_space *aspace; ptid_t resume_ptid; struct execution_control_state ecss; struct execution_control_state *ecs = &ecss; @@ -3007,7 +3006,8 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) regcache = get_current_regcache (); gdbarch = regcache->arch (); - aspace = regcache->aspace (); + const address_space *aspace = regcache->aspace (); + pc = regcache_read_pc (regcache); tp = inferior_thread (); @@ -4070,7 +4070,6 @@ adjust_pc_after_break (struct thread_info *thread, { struct regcache *regcache; struct gdbarch *gdbarch; - struct address_space *aspace; CORE_ADDR breakpoint_pc, decr_pc; /* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP. If @@ -4150,7 +4149,7 @@ adjust_pc_after_break (struct thread_info *thread, if (decr_pc == 0) return; - aspace = regcache->aspace (); + const address_space *aspace = regcache->aspace (); /* Find the location where (if we've hit a breakpoint) the breakpoint would be. */ @@ -4385,7 +4384,6 @@ static void save_waitstatus (struct thread_info *tp, struct target_waitstatus *ws) { struct regcache *regcache; - struct address_space *aspace; if (debug_infrun) { @@ -4404,7 +4402,7 @@ save_waitstatus (struct thread_info *tp, struct target_waitstatus *ws) tp->suspend.waitstatus_pending_p = 1; regcache = get_thread_regcache (tp->ptid); - aspace = regcache->aspace (); + const address_space *aspace = regcache->aspace (); if (ws->kind == TARGET_WAITKIND_STOPPED && ws->value.sig == GDB_SIGNAL_TRAP) @@ -5776,11 +5774,11 @@ handle_signal_stop (struct execution_control_state *ecs) if (ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_TRAP) { struct regcache *regcache; - struct address_space *aspace; CORE_ADDR pc; regcache = get_thread_regcache (ecs->ptid); - aspace = regcache->aspace (); + const address_space *aspace = regcache->aspace (); + pc = regcache_read_pc (regcache); /* However, before doing so, if this single-step breakpoint was @@ -5871,7 +5869,7 @@ handle_signal_stop (struct execution_control_state *ecs) inline function call sites). */ if (ecs->event_thread->control.step_range_end != 1) { - struct address_space *aspace = + const address_space *aspace = get_thread_regcache (ecs->ptid)->aspace (); /* skip_inline_frames is expensive, so we avoid it if we can @@ -7758,7 +7756,7 @@ keep_going_pass_signal (struct execution_control_state *ecs) if (remove_bp && (remove_wps || !use_displaced_stepping (ecs->event_thread))) { - set_step_over_info (regcache->aspace (), + set_step_over_info (const_cast (regcache->aspace ()), regcache_read_pc (regcache), remove_wps, ecs->event_thread->global_num); } diff --git a/gdb/record-full.c b/gdb/record-full.c index 0488b71..6fc29d6 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -1098,7 +1098,6 @@ record_full_wait_1 (struct target_ops *ops, && status->value.sig == GDB_SIGNAL_TRAP) { struct regcache *regcache; - struct address_space *aspace; enum target_stop_reason *stop_reason_p = &record_full_stop_reason; @@ -1109,7 +1108,7 @@ record_full_wait_1 (struct target_ops *ops, registers_changed (); regcache = get_current_regcache (); tmp_pc = regcache_read_pc (regcache); - aspace = regcache->aspace (); + const struct address_space *aspace = regcache->aspace (); if (target_stopped_by_watchpoint ()) { @@ -1172,7 +1171,7 @@ record_full_wait_1 (struct target_ops *ops, { struct regcache *regcache = get_current_regcache (); struct gdbarch *gdbarch = regcache->arch (); - struct address_space *aspace = regcache->aspace (); + const struct address_space *aspace = regcache->aspace (); int continue_flag = 1; int first_record_full_end = 1; struct cleanup *old_cleanups diff --git a/gdb/regcache.c b/gdb/regcache.c index 6985dc9..2cffb70 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -181,7 +181,7 @@ regcache_register_size (const struct regcache *regcache, int n) return register_size (regcache->arch (), n); } -regcache::regcache (gdbarch *gdbarch, address_space *aspace_, +regcache::regcache (gdbarch *gdbarch, const address_space *aspace_, bool readonly_p_) : m_aspace (aspace_), m_readonly_p (readonly_p_) { diff --git a/gdb/regcache.h b/gdb/regcache.h index 2360e27..be87af5 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -232,7 +232,7 @@ typedef struct cached_reg class regcache { public: - regcache (gdbarch *gdbarch, address_space *aspace_) + regcache (gdbarch *gdbarch, const address_space *aspace_) : regcache (gdbarch, aspace_, true) {} @@ -254,7 +254,7 @@ public: gdbarch *arch () const; /* Return REGCACHE's address space. */ - address_space *aspace () const + const address_space *aspace () const { return m_aspace; } @@ -338,7 +338,7 @@ public: static void regcache_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid); protected: - regcache (gdbarch *gdbarch, address_space *aspace_, bool readonly_p_); + regcache (gdbarch *gdbarch, const address_space *aspace_, bool readonly_p_); static std::forward_list current_regcache; @@ -362,7 +362,7 @@ private: /* The address space of this register cache (for registers where it makes sense, like PC or SP). */ - struct address_space *m_aspace; + const address_space *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