const-fy regcache::m_aspace
authorYao Qi <yao.qi@linaro.org>
Thu, 2 Nov 2017 15:15:42 +0000 (15:15 +0000)
committerYao Qi <yao.qi@linaro.org>
Thu, 2 Nov 2017 15:15:42 +0000 (15:15 +0000)
regcache::m_aspace is a const, never changed during the lifetime of
regcache object.  The address_space object is a const object too.

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* breakpoint.c (insert_single_step_breakpoints): Update.
* frame.c (struct frame_info) <aspace>: Add const.
(frame_save_as_regcache): Add const.
(get_frame_address_space): Return const address_space *.
* frame.h (get_frame_address_space): Update declaration.
* infrun.c (struct step_over_info) <aspace>: Add const.
(set_step_over_info): Make aspace const.
(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.
* jit.c (jit_frame_sniffer): Add const.
* mips-tdep.c (mips_single_step_through_delay): Likewise.
* ppc-linux-tdep.c (ppu2spu_sniffer): Likewise.
* record-full.c (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) <m_aspace>: Add const.

gdb/ChangeLog
gdb/breakpoint.c
gdb/frame.c
gdb/frame.h
gdb/infrun.c
gdb/jit.c
gdb/mips-tdep.c
gdb/ppc-linux-tdep.c
gdb/record-full.c
gdb/regcache.c
gdb/regcache.h

index 9d846abdadb55e37c11cb2bedeae8f5fa9c11b78..c1a0cbe42aac3923735683fe1f645c3437f6cedf 100644 (file)
@@ -1,3 +1,28 @@
+2017-11-02  Yao Qi  <yao.qi@linaro.org>
+
+       * breakpoint.c (insert_single_step_breakpoints): Update.
+       * frame.c (struct frame_info) <aspace>: Add const.
+       (frame_save_as_regcache): Add const.
+       (get_frame_address_space): Return const address_space *.
+       * frame.h (get_frame_address_space): Update declaration.
+       * infrun.c (struct step_over_info) <aspace>: Add const.
+       (set_step_over_info): Make aspace const.
+       (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.
+       * jit.c (jit_frame_sniffer): Add const.
+       * mips-tdep.c (mips_single_step_through_delay): Likewise.
+       * ppc-linux-tdep.c (ppu2spu_sniffer): Likewise.
+       * record-full.c (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) <m_aspace>: Add const.
+
 2017-11-02  Yao Qi  <yao.qi@linaro.org>
 
        * darwin-nat.c (cancel_breakpoint): Use regcache->aspace ().
index aadd6cada25abc08c07920f9e67053df22c20231..0bf47d5f566e46d268b8f35b5bc531ee73a45cd9 100644 (file)
@@ -14557,7 +14557,7 @@ insert_single_step_breakpoints (struct gdbarch *gdbarch)
   if (!next_pcs.empty ())
     {
       struct frame_info *frame = get_current_frame ();
-      struct address_space *aspace = get_frame_address_space (frame);
+      const address_space *aspace = get_frame_address_space (frame);
 
       for (CORE_ADDR pc : next_pcs)
        insert_single_step_breakpoint (gdbarch, aspace, pc);
index 5380c7d77064c85a885a2fa0348bf1404cda1fe0..e40685f715dbd0ec46957e8d0269aa76b13f2b49 100644 (file)
@@ -99,7 +99,7 @@ struct frame_info
   struct program_space *pspace;
 
   /* The frame's address space.  */
-  struct address_space *aspace;
+  const address_space *aspace;
 
   /* The frame's low-level unwinder and corresponding cache.  The
      low-level unwinder is responsible for unwinding register values
@@ -1020,7 +1020,7 @@ do_frame_register_read (void *src, int regnum, gdb_byte *buf)
 std::unique_ptr<struct regcache>
 frame_save_as_regcache (struct frame_info *this_frame)
 {
-  struct address_space *aspace = get_frame_address_space (this_frame);
+  const address_space *aspace = get_frame_address_space (this_frame);
   std::unique_ptr<struct regcache> regcache
     (new struct regcache (get_frame_arch (this_frame), aspace));
 
@@ -2643,7 +2643,7 @@ frame_unwind_program_space (struct frame_info *this_frame)
   return this_frame->pspace;
 }
 
-struct address_space *
+const address_space *
 get_frame_address_space (struct frame_info *frame)
 {
   return frame->aspace;
index 190ce7623f80d77c869658f0abbd66917480279b..c75100274b7673b783dae0b8cccfce482554c376 100644 (file)
@@ -494,8 +494,10 @@ extern struct program_space *get_frame_program_space (struct frame_info *);
 /* Unwind THIS frame's program space from the NEXT frame.  */
 extern struct program_space *frame_unwind_program_space (struct frame_info *);
 
+class address_space;
+
 /* Return the frame's address space.  */
-extern struct address_space *get_frame_address_space (struct frame_info *);
+extern const address_space *get_frame_address_space (struct frame_info *);
 
 /* For frames where we can not unwind further, describe why.  */
 
index 0e31dbcdb54cfbefd291b2e9d8be8aa0500e281f..ef5a505d89e535a5f3d6b20fbf87bdada658358d 100644 (file)
@@ -1289,7 +1289,7 @@ struct step_over_info
      and address of the instruction the breakpoint is set at.  We'll
      skip inserting all breakpoints here.  Valid iff ASPACE is
      non-NULL.  */
-  struct address_space *aspace;
+  const address_space *aspace;
   CORE_ADDR address;
 
   /* The instruction being stepped over triggers a nonsteppable
@@ -1332,7 +1332,7 @@ static struct step_over_info step_over_info;
    because when we need the info later the thread may be running.  */
 
 static void
-set_step_over_info (struct address_space *aspace, CORE_ADDR address,
+set_step_over_info (const address_space *aspace, CORE_ADDR address,
                    int nonsteppable_watchpoint_p,
                    int thread)
 {
@@ -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
@@ -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
index a2d1f6d6a113d1d3a18ee8c7ddb4f5900c12ff42..b70f87cb087f97f39aed4b57230bc99640934315 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -1186,7 +1186,6 @@ jit_frame_sniffer (const struct frame_unwind *self,
   struct jit_unwind_private *priv_data;
   struct gdb_unwind_callbacks callbacks;
   struct gdb_reader_funcs *funcs;
-  struct address_space *aspace;
   struct gdbarch *gdbarch;
 
   callbacks.reg_get = jit_unwind_reg_get_impl;
@@ -1200,7 +1199,8 @@ jit_frame_sniffer (const struct frame_unwind *self,
 
   gdb_assert (!*cache);
 
-  aspace = get_frame_address_space (this_frame);
+  const address_space *aspace = get_frame_address_space (this_frame);
+
   gdbarch = get_frame_arch (this_frame);
 
   *cache = XCNEW (struct jit_unwind_private);
index 4b1989623a9c4325f81086b6d6a57a800697b65b..20bd5d37bbbc80e0fe1a7498f1eff4d32f9c93ce 100644 (file)
@@ -6598,7 +6598,6 @@ mips_single_step_through_delay (struct gdbarch *gdbarch,
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR pc = get_frame_pc (frame);
-  struct address_space *aspace;
   enum mips_isa isa;
   ULONGEST insn;
   int status;
@@ -6616,7 +6615,9 @@ mips_single_step_through_delay (struct gdbarch *gdbarch,
   /* _has_delay_slot above will have validated the read.  */
   insn = mips_fetch_instruction (gdbarch, isa, pc, NULL);
   size = mips_insn_size (isa, insn);
-  aspace = get_frame_address_space (frame);
+
+  const address_space *aspace = get_frame_address_space (frame);
+
   return breakpoint_here_p (aspace, pc + size) != no_breakpoint_here;
 }
 
index 67d830594981fa95c69552018e4f34299446f916..d01cff8d68f90de77b775704e65c6f00f04f0356 100644 (file)
@@ -1362,7 +1362,7 @@ ppu2spu_sniffer (const struct frame_unwind *self,
          struct ppu2spu_cache *cache
            = FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache);
 
-         struct address_space *aspace = get_frame_address_space (this_frame);
+         const address_space *aspace = get_frame_address_space (this_frame);
          std::unique_ptr<struct regcache> regcache
            (new struct regcache (data.gdbarch, aspace));
          regcache_save (regcache.get (), ppu2spu_unwind_register, &data);
index 0488b7148a70ba56b555061e26c23d4e76d8c658..6fc29d6170ddfddf3123f7a9df1f1d717057bc8c 100644 (file)
@@ -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
index 0bae395536415711216d72e5a0f15f5d8ab832c0..ef0516813c29ae4b24b37cad5fab16d852b0a314 100644 (file)
@@ -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_)
 {
index 861a6d25af99580d036ede49d9f3dfe837df5e4a..7eb56a70f1458e9907bdbcf3d908c38d7eba795a 100644 (file)
@@ -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_);
 
   int num_raw_registers () const;
 
@@ -364,7 +364,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 * 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
This page took 0.067494 seconds and 4 git commands to generate.