public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: pass frames as `const frame_info_ptr &`
@ 2024-02-20 15:45 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2024-02-20 15:45 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8480a37e146c40e82a93c0ecf6144571516c95c5

commit 8480a37e146c40e82a93c0ecf6144571516c95c5
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Mon Feb 19 13:07:47 2024 -0500

    gdb: pass frames as `const frame_info_ptr &`
    
    We currently pass frames to function by value, as `frame_info_ptr`.
    This is somewhat expensive:
    
     - the size of `frame_info_ptr` is 64 bytes, which is a bit big to pass
       by value
     - the constructors and destructor link/unlink the object in the global
       `frame_info_ptr::frame_list` list.  This is an `intrusive_list`, so
       it's not so bad: it's just assigning a few points, there's no memory
       allocation as if it was `std::list`, but still it's useless to do
       that over and over.
    
    As suggested by Tom Tromey, change many function signatures to accept
    `const frame_info_ptr &` instead of `frame_info_ptr`.
    
    Some functions reassign their `frame_info_ptr` parameter, like:
    
      void
      the_func (frame_info_ptr frame)
      {
        for (; frame != nullptr; frame = get_prev_frame (frame))
          {
            ...
          }
      }
    
    I wondered what to do about them, do I leave them as-is or change them
    (and need to introduce a separate local variable that can be
    re-assigned).  I opted for the later for consistency.  It might not be
    clear why some functions take `const frame_info_ptr &` while others take
    `frame_info_ptr`.  Also, if a function took a `frame_info_ptr` because
    it did re-assign its parameter, I doubt that we would think to change it
    to `const frame_info_ptr &` should the implementation change such that
    it doesn't need to take `frame_info_ptr` anymore.  It seems better to
    have a simple rule and apply it everywhere.
    
    Change-Id: I59d10addef687d157f82ccf4d54f5dde9a963fd0
    Approved-By: Andrew Burgess <aburgess@redhat.com>

Diff:
---
 gdb/aarch64-fbsd-tdep.c                  |   6 +-
 gdb/aarch64-linux-tdep.c                 |   8 +-
 gdb/aarch64-tdep.c                       |  46 ++++-----
 gdb/ada-lang.c                           |  10 +-
 gdb/ada-lang.h                           |   2 +-
 gdb/alpha-linux-tdep.c                   |   2 +-
 gdb/alpha-mdebug-tdep.c                  |  16 +--
 gdb/alpha-netbsd-tdep.c                  |   2 +-
 gdb/alpha-obsd-tdep.c                    |   2 +-
 gdb/alpha-tdep.c                         |  22 ++--
 gdb/alpha-tdep.h                         |   2 +-
 gdb/amd64-darwin-tdep.c                  |   2 +-
 gdb/amd64-fbsd-tdep.c                    |   2 +-
 gdb/amd64-linux-tdep.c                   |   6 +-
 gdb/amd64-netbsd-tdep.c                  |   4 +-
 gdb/amd64-obsd-tdep.c                    |  12 +--
 gdb/amd64-sol2-tdep.c                    |   2 +-
 gdb/amd64-tdep.c                         |  42 ++++----
 gdb/amd64-windows-tdep.c                 |  12 +--
 gdb/amdgpu-tdep.c                        |   8 +-
 gdb/arc-linux-tdep.c                     |   4 +-
 gdb/arc-tdep.c                           |  20 ++--
 gdb/arc-tdep.h                           |   4 +-
 gdb/arch-utils.c                         |   9 +-
 gdb/arch-utils.h                         |   8 +-
 gdb/arm-fbsd-tdep.c                      |   2 +-
 gdb/arm-linux-tdep.c                     |  12 +--
 gdb/arm-obsd-tdep.c                      |   2 +-
 gdb/arm-tdep.c                           |  74 ++++++-------
 gdb/arm-tdep.h                           |   4 +-
 gdb/arm-wince-tdep.c                     |   2 +-
 gdb/avr-tdep.c                           |  14 +--
 gdb/bfin-linux-tdep.c                    |   2 +-
 gdb/bfin-tdep.c                          |  12 +--
 gdb/blockframe.c                         |   4 +-
 gdb/bpf-tdep.c                           |   8 +-
 gdb/cp-abi.c                             |   2 +-
 gdb/cp-abi.h                             |   4 +-
 gdb/cris-tdep.c                          |  36 +++----
 gdb/csky-linux-tdep.c                    |   4 +-
 gdb/csky-tdep.c                          |  22 ++--
 gdb/dtrace-probe.c                       |   4 +-
 gdb/dummy-frame.c                        |   8 +-
 gdb/dummy-frame.h                        |   2 +-
 gdb/dwarf2/ada-imported.c                |   2 +-
 gdb/dwarf2/call-site.h                   |   4 +-
 gdb/dwarf2/expr.c                        |   8 +-
 gdb/dwarf2/expr.h                        |   4 +-
 gdb/dwarf2/frame-tailcall.c              |  23 +++--
 gdb/dwarf2/frame-tailcall.h              |   4 +-
 gdb/dwarf2/frame.c                       |  40 ++++----
 gdb/dwarf2/frame.h                       |  25 +++--
 gdb/dwarf2/loc.c                         |  51 ++++-----
 gdb/dwarf2/loc.h                         |  26 +++--
 gdb/extension-priv.h                     |   2 +-
 gdb/extension.c                          |   2 +-
 gdb/extension.h                          |   2 +-
 gdb/findvar.c                            |  24 +++--
 gdb/frame-base.c                         |   8 +-
 gdb/frame-base.h                         |  10 +-
 gdb/frame-unwind.c                       |  24 ++---
 gdb/frame-unwind.h                       |  51 +++++----
 gdb/frame.c                              | 171 ++++++++++++++++---------------
 gdb/frame.h                              | 142 ++++++++++++-------------
 gdb/frv-linux-tdep.c                     |  10 +-
 gdb/frv-tdep.c                           |  10 +-
 gdb/ft32-tdep.c                          |   8 +-
 gdb/gdbarch-gen.h                        |  72 ++++++-------
 gdb/gdbarch.c                            |  36 +++----
 gdb/gdbarch_components.py                |  36 +++----
 gdb/gnu-v3-abi.c                         |   2 +-
 gdb/h8300-tdep.c                         |  12 +--
 gdb/hppa-bsd-tdep.c                      |   2 +-
 gdb/hppa-linux-tdep.c                    |   8 +-
 gdb/hppa-netbsd-tdep.c                   |   4 +-
 gdb/hppa-tdep.c                          |  32 +++---
 gdb/hppa-tdep.h                          |   8 +-
 gdb/i386-bsd-tdep.c                      |   2 +-
 gdb/i386-darwin-tdep.c                   |   4 +-
 gdb/i386-darwin-tdep.h                   |   2 +-
 gdb/i386-fbsd-tdep.c                     |   2 +-
 gdb/i386-gnu-tdep.c                      |   6 +-
 gdb/i386-linux-tdep.c                    |  10 +-
 gdb/i386-netbsd-tdep.c                   |   4 +-
 gdb/i386-nto-tdep.c                      |   4 +-
 gdb/i386-obsd-tdep.c                     |  10 +-
 gdb/i386-sol2-tdep.c                     |   2 +-
 gdb/i386-tdep.c                          |  64 ++++++------
 gdb/i386-tdep.h                          |  12 +--
 gdb/i386-windows-tdep.c                  |   2 +-
 gdb/i387-tdep.c                          |   6 +-
 gdb/i387-tdep.h                          |   6 +-
 gdb/ia64-libunwind-tdep.c                |  10 +-
 gdb/ia64-libunwind-tdep.h                |   8 +-
 gdb/ia64-tdep.c                          |  44 ++++----
 gdb/ia64-tdep.h                          |   2 +-
 gdb/infcmd.c                             |  11 +-
 gdb/inferior.h                           |   4 +-
 gdb/infrun.c                             |  22 ++--
 gdb/infrun.h                             |   2 +-
 gdb/inline-frame.c                       |   8 +-
 gdb/inline-frame.h                       |   2 +-
 gdb/iq2000-tdep.c                        |  10 +-
 gdb/jit.c                                |   6 +-
 gdb/language.h                           |   2 +-
 gdb/lm32-tdep.c                          |   8 +-
 gdb/loongarch-linux-tdep.c               |   4 +-
 gdb/loongarch-tdep.c                     |  10 +-
 gdb/loongarch-tdep.h                     |   2 +-
 gdb/m32c-tdep.c                          |  10 +-
 gdb/m32r-linux-tdep.c                    |  14 +--
 gdb/m32r-tdep.c                          |   8 +-
 gdb/m68hc11-tdep.c                       |  16 +--
 gdb/m68k-linux-tdep.c                    |  12 +--
 gdb/m68k-tdep.c                          |  18 ++--
 gdb/mep-tdep.c                           |   8 +-
 gdb/mi/mi-cmd-stack.c                    |   6 +-
 gdb/mi/mi-main.c                         |   4 +-
 gdb/microblaze-linux-tdep.c              |   4 +-
 gdb/microblaze-tdep.c                    |  10 +-
 gdb/minsyms.c                            |   2 +-
 gdb/mips-fbsd-tdep.c                     |   4 +-
 gdb/mips-linux-tdep.c                    |  22 ++--
 gdb/mips-netbsd-tdep.c                   |   2 +-
 gdb/mips-sde-tdep.c                      |  12 +--
 gdb/mips-tdep.c                          |  96 ++++++++---------
 gdb/mips-tdep.h                          |   2 +-
 gdb/mips64-obsd-tdep.c                   |   2 +-
 gdb/mn10300-linux-tdep.c                 |   4 +-
 gdb/mn10300-tdep.c                       |   8 +-
 gdb/moxie-tdep.c                         |   8 +-
 gdb/msp430-tdep.c                        |  10 +-
 gdb/nds32-tdep.c                         |  20 ++--
 gdb/nios2-linux-tdep.c                   |   4 +-
 gdb/nios2-tdep.c                         |  22 ++--
 gdb/nios2-tdep.h                         |   2 +-
 gdb/observable.h                         |   2 +-
 gdb/or1k-linux-tdep.c                    |   4 +-
 gdb/or1k-tdep.c                          |  12 +--
 gdb/ppc-fbsd-tdep.c                      |   8 +-
 gdb/ppc-linux-tdep.c                     |  12 +--
 gdb/ppc-netbsd-tdep.c                    |   2 +-
 gdb/ppc-obsd-tdep.c                      |   8 +-
 gdb/ppc-sysv-tdep.c                      |   3 +-
 gdb/ppc-tdep.h                           |   4 +-
 gdb/ppc64-tdep.c                         |  20 ++--
 gdb/ppc64-tdep.h                         |   2 +-
 gdb/printcmd.c                           |   2 +-
 gdb/probe.c                              |   2 +-
 gdb/probe.h                              |   4 +-
 gdb/python/py-event.h                    |   2 +-
 gdb/python/py-frame.c                    |   2 +-
 gdb/python/py-framefilter.c              |  14 +--
 gdb/python/py-inferior.c                 |   2 +-
 gdb/python/py-infevents.c                |   4 +-
 gdb/python/py-unwind.c                   |   6 +-
 gdb/python/python-internal.h             |   4 +-
 gdb/record-btrace.c                      |  14 +--
 gdb/riscv-fbsd-tdep.c                    |   2 +-
 gdb/riscv-linux-tdep.c                   |   6 +-
 gdb/riscv-tdep.c                         |  12 +--
 gdb/riscv-tdep.h                         |   2 +-
 gdb/rl78-tdep.c                          |  12 +--
 gdb/rs6000-aix-tdep.c                    |   8 +-
 gdb/rs6000-tdep.c                        |  34 +++---
 gdb/rx-tdep.c                            |  16 +--
 gdb/s12z-tdep.c                          |  10 +-
 gdb/s390-linux-tdep.c                    |   8 +-
 gdb/s390-tdep.c                          |  36 +++----
 gdb/s390-tdep.h                          |   2 +-
 gdb/sentinel-frame.c                     |   6 +-
 gdb/sh-linux-tdep.c                      |   6 +-
 gdb/sh-tdep.c                            |  16 +--
 gdb/sol2-tdep.c                          |   2 +-
 gdb/sol2-tdep.h                          |   2 +-
 gdb/sparc-linux-tdep.c                   |   6 +-
 gdb/sparc-netbsd-tdep.c                  |  12 +--
 gdb/sparc-obsd-tdep.c                    |   8 +-
 gdb/sparc-sol2-tdep.c                    |   8 +-
 gdb/sparc-tdep.c                         |  18 ++--
 gdb/sparc-tdep.h                         |  10 +-
 gdb/sparc64-fbsd-tdep.c                  |   8 +-
 gdb/sparc64-linux-tdep.c                 |   8 +-
 gdb/sparc64-netbsd-tdep.c                |  10 +-
 gdb/sparc64-obsd-tdep.c                  |  16 +--
 gdb/sparc64-sol2-tdep.c                  |   8 +-
 gdb/sparc64-tdep.c                       |  10 +-
 gdb/sparc64-tdep.h                       |   2 +-
 gdb/stack.c                              |  42 ++++----
 gdb/stack.h                              |   4 +-
 gdb/stap-probe.c                         |   4 +-
 gdb/std-regs.c                           |   8 +-
 gdb/symtab.h                             |   8 +-
 gdb/tic6x-linux-tdep.c                   |   4 +-
 gdb/tic6x-tdep.c                         |  22 ++--
 gdb/tic6x-tdep.h                         |   2 +-
 gdb/tilegx-linux-tdep.c                  |   2 +-
 gdb/tilegx-tdep.c                        |  12 +--
 gdb/tracepoint.c                         |   2 +-
 gdb/trad-frame.c                         |   8 +-
 gdb/trad-frame.h                         |   8 +-
 gdb/tramp-frame.c                        |  10 +-
 gdb/tramp-frame.h                        |   4 +-
 gdb/tui/tui-disasm.c                     |   2 +-
 gdb/tui/tui-disasm.h                     |   2 +-
 gdb/tui/tui-hooks.c                      |   2 +-
 gdb/tui/tui-regs.c                       |   4 +-
 gdb/tui/tui-regs.h                       |   2 +-
 gdb/tui/tui-source.c                     |   2 +-
 gdb/tui/tui-source.h                     |   2 +-
 gdb/tui/tui-status.c                     |   4 +-
 gdb/tui/tui-status.h                     |   2 +-
 gdb/tui/tui-winsource.h                  |   2 +-
 gdb/unittests/frame_info_ptr-selftests.c |   2 +-
 gdb/user-regs.c                          |   4 +-
 gdb/user-regs.h                          |   4 +-
 gdb/v850-tdep.c                          |  10 +-
 gdb/valops.c                             |   4 +-
 gdb/value.c                              |  23 +++--
 gdb/value.h                              |  35 ++++---
 gdb/vax-tdep.c                           |  14 +--
 gdb/xstormy16-tdep.c                     |  12 +--
 gdb/xtensa-tdep.c                        |  20 ++--
 gdb/z80-tdep.c                           |   6 +-
 224 files changed, 1351 insertions(+), 1339 deletions(-)

diff --git a/gdb/aarch64-fbsd-tdep.c b/gdb/aarch64-fbsd-tdep.c
index 2b043c0e735..44ca6c90c81 100644
--- a/gdb/aarch64-fbsd-tdep.c
+++ b/gdb/aarch64-fbsd-tdep.c
@@ -88,9 +88,9 @@ static const struct regcache_map_entry aarch64_fbsd_tls_regmap[] =
 
 static void
 aarch64_fbsd_sigframe_init (const struct tramp_frame *self,
-			     frame_info_ptr this_frame,
-			     struct trad_frame_cache *this_cache,
-			     CORE_ADDR func)
+			    const frame_info_ptr &this_frame,
+			    struct trad_frame_cache *this_cache,
+			    CORE_ADDR func)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 7812ec5b7a1..4ebc173a0a0 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -381,8 +381,8 @@ aarch64_linux_restore_vregs (struct gdbarch *gdbarch,
    SIGNAL_FRAME.  */
 
 static void
-aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame,
-				  struct aarch64_linux_sigframe &signal_frame)
+aarch64_linux_read_signal_frame_info (const frame_info_ptr &this_frame,
+				      aarch64_linux_sigframe &signal_frame)
 {
   signal_frame.sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
   signal_frame.sigcontext_address
@@ -570,7 +570,7 @@ aarch64_linux_read_signal_frame_info (frame_info_ptr this_frame,
 
 static void
 aarch64_linux_sigframe_init (const struct tramp_frame *self,
-			     frame_info_ptr this_frame,
+			     const frame_info_ptr &this_frame,
 			     struct trad_frame_cache *this_cache,
 			     CORE_ADDR func)
 {
@@ -704,7 +704,7 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self,
 /* Implements the "prev_arch" method of struct tramp_frame.  */
 
 static struct gdbarch *
-aarch64_linux_sigframe_prev_arch (frame_info_ptr this_frame,
+aarch64_linux_sigframe_prev_arch (const frame_info_ptr &this_frame,
 				  void **frame_cache)
 {
   struct trad_frame_cache *cache
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index b97e2153e14..d1d5486f90d 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -268,7 +268,7 @@ class instruction_reader : public abstract_instruction_reader
 
 static CORE_ADDR
 aarch64_frame_unmask_lr (aarch64_gdbarch_tdep *tdep,
-			 frame_info_ptr this_frame, CORE_ADDR addr)
+			 const frame_info_ptr &this_frame, CORE_ADDR addr)
 {
   if (tdep->has_pauth ()
       && frame_unwind_register_unsigned (this_frame,
@@ -298,7 +298,7 @@ aarch64_frame_unmask_lr (aarch64_gdbarch_tdep *tdep,
 /* Implement the "get_pc_address_flags" gdbarch method.  */
 
 static std::string
-aarch64_get_pc_address_flags (frame_info_ptr frame, CORE_ADDR pc)
+aarch64_get_pc_address_flags (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   if (pc != 0 && get_frame_pc_masked (frame))
     return "PAC";
@@ -995,7 +995,7 @@ aarch64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
    cache CACHE.  */
 
 static void
-aarch64_scan_prologue (frame_info_ptr this_frame,
+aarch64_scan_prologue (const frame_info_ptr &this_frame,
 		       struct aarch64_prologue_cache *cache)
 {
   CORE_ADDR block_addr = get_frame_address_in_block (this_frame);
@@ -1049,7 +1049,7 @@ aarch64_scan_prologue (frame_info_ptr this_frame,
    not available.  */
 
 static void
-aarch64_make_prologue_cache_1 (frame_info_ptr this_frame,
+aarch64_make_prologue_cache_1 (const frame_info_ptr &this_frame,
 			       struct aarch64_prologue_cache *cache)
 {
   CORE_ADDR unwound_fp;
@@ -1087,7 +1087,7 @@ aarch64_make_prologue_cache_1 (frame_info_ptr this_frame,
    *THIS_CACHE.  */
 
 static struct aarch64_prologue_cache *
-aarch64_make_prologue_cache (frame_info_ptr this_frame, void **this_cache)
+aarch64_make_prologue_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct aarch64_prologue_cache *cache;
 
@@ -1114,7 +1114,7 @@ aarch64_make_prologue_cache (frame_info_ptr this_frame, void **this_cache)
 /* Implement the "stop_reason" frame_unwind method.  */
 
 static enum unwind_stop_reason
-aarch64_prologue_frame_unwind_stop_reason (frame_info_ptr this_frame,
+aarch64_prologue_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
 					   void **this_cache)
 {
   struct aarch64_prologue_cache *cache
@@ -1140,7 +1140,7 @@ aarch64_prologue_frame_unwind_stop_reason (frame_info_ptr this_frame,
    PC and the caller's SP when we were called.  */
 
 static void
-aarch64_prologue_this_id (frame_info_ptr this_frame,
+aarch64_prologue_this_id (const frame_info_ptr &this_frame,
 			  void **this_cache, struct frame_id *this_id)
 {
   struct aarch64_prologue_cache *cache
@@ -1155,7 +1155,7 @@ aarch64_prologue_this_id (frame_info_ptr this_frame,
 /* Implement the "prev_register" frame_unwind method.  */
 
 static struct value *
-aarch64_prologue_prev_register (frame_info_ptr this_frame,
+aarch64_prologue_prev_register (const frame_info_ptr &this_frame,
 				void **this_cache, int prev_regnum)
 {
   struct aarch64_prologue_cache *cache
@@ -1221,7 +1221,7 @@ static frame_unwind aarch64_prologue_unwind =
    *THIS_CACHE.  */
 
 static struct aarch64_prologue_cache *
-aarch64_make_stub_cache (frame_info_ptr this_frame, void **this_cache)
+aarch64_make_stub_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct aarch64_prologue_cache *cache;
 
@@ -1251,7 +1251,7 @@ aarch64_make_stub_cache (frame_info_ptr this_frame, void **this_cache)
 /* Implement the "stop_reason" frame_unwind method.  */
 
 static enum unwind_stop_reason
-aarch64_stub_frame_unwind_stop_reason (frame_info_ptr this_frame,
+aarch64_stub_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
 				       void **this_cache)
 {
   struct aarch64_prologue_cache *cache
@@ -1266,7 +1266,7 @@ aarch64_stub_frame_unwind_stop_reason (frame_info_ptr this_frame,
 /* Our frame ID for a stub frame is the current SP and LR.  */
 
 static void
-aarch64_stub_this_id (frame_info_ptr this_frame,
+aarch64_stub_this_id (const frame_info_ptr &this_frame,
 		      void **this_cache, struct frame_id *this_id)
 {
   struct aarch64_prologue_cache *cache
@@ -1282,7 +1282,7 @@ aarch64_stub_this_id (frame_info_ptr this_frame,
 
 static int
 aarch64_stub_unwind_sniffer (const struct frame_unwind *self,
-			     frame_info_ptr this_frame,
+			     const frame_info_ptr &this_frame,
 			     void **this_prologue_cache)
 {
   CORE_ADDR addr_in_block;
@@ -1313,7 +1313,7 @@ static frame_unwind aarch64_stub_unwind =
 /* Return the frame base address of *THIS_FRAME.  */
 
 static CORE_ADDR
-aarch64_normal_frame_base (frame_info_ptr this_frame, void **this_cache)
+aarch64_normal_frame_base (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct aarch64_prologue_cache *cache
     = aarch64_make_prologue_cache (this_frame, this_cache);
@@ -1334,7 +1334,7 @@ static frame_base aarch64_normal_base =
    *THIS_FRAME.  */
 
 static struct value *
-aarch64_dwarf2_prev_register (frame_info_ptr this_frame,
+aarch64_dwarf2_prev_register (const frame_info_ptr &this_frame,
 			      void **this_cache, int regnum)
 {
   gdbarch *arch = get_frame_arch (this_frame);
@@ -1361,7 +1361,7 @@ static const unsigned char op_lit1 = DW_OP_lit1;
 static void
 aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 			       struct dwarf2_frame_state_reg *reg,
-			       frame_info_ptr this_frame)
+			       const frame_info_ptr &this_frame)
 {
   aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
 
@@ -2780,7 +2780,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value,
 /* Implement the "get_longjmp_target" gdbarch method.  */
 
 static int
-aarch64_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
+aarch64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
 {
   CORE_ADDR jb_addr;
   gdb_byte buf[X_REGISTER_SIZE];
@@ -3105,7 +3105,7 @@ aarch64_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 /* Helper for aarch64_pseudo_read_value.  */
 
 static value *
-aarch64_pseudo_read_value_1 (frame_info_ptr next_frame,
+aarch64_pseudo_read_value_1 (const frame_info_ptr &next_frame,
 			     const int pseudo_reg_num, int raw_regnum_offset)
 {
   unsigned v_regnum = AARCH64_V0_REGNUM + raw_regnum_offset;
@@ -3197,7 +3197,7 @@ aarch64_za_offsets_from_regnum (struct gdbarch *gdbarch, int regnum)
 /* Given REGNUM, a SME pseudo-register number, return its value in RESULT.  */
 
 static value *
-aarch64_sme_pseudo_register_read (gdbarch *gdbarch, frame_info_ptr next_frame,
+aarch64_sme_pseudo_register_read (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 				  const int pseudo_reg_num)
 {
   aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
@@ -3231,7 +3231,7 @@ aarch64_sme_pseudo_register_read (gdbarch *gdbarch, frame_info_ptr next_frame,
 /* Implement the "pseudo_register_read_value" gdbarch method.  */
 
 static value *
-aarch64_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
+aarch64_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 			   const int pseudo_reg_num)
 {
   aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
@@ -3296,7 +3296,7 @@ aarch64_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
 /* Helper for aarch64_pseudo_write.  */
 
 static void
-aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame,
+aarch64_pseudo_write_1 (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 			int regnum_offset,
 			gdb::array_view<const gdb_byte> buf)
 {
@@ -3322,7 +3322,7 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame,
    pseudo-register.  */
 
 static void
-aarch64_sme_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
+aarch64_sme_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 				   const int regnum,
 				   gdb::array_view<const gdb_byte> data)
 {
@@ -3364,7 +3364,7 @@ aarch64_sme_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
 /* Implement the "pseudo_register_write" gdbarch method.  */
 
 static void
-aarch64_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
+aarch64_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 		      const int pseudo_reg_num,
 		      gdb::array_view<const gdb_byte> buf)
 {
@@ -3437,7 +3437,7 @@ aarch64_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
 /* Callback function for user_reg_add.  */
 
 static struct value *
-value_of_aarch64_user_reg (frame_info_ptr frame, const void *baton)
+value_of_aarch64_user_reg (const frame_info_ptr &frame, const void *baton)
 {
   const int *reg_p = (const int *) baton;
 
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a3fd695e003..3f398540010 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11720,7 +11720,7 @@ ada_exception_support_info_sniffer (void)
    to most users.  */
 
 static int
-is_known_support_routine (frame_info_ptr frame)
+is_known_support_routine (const frame_info_ptr &frame)
 {
   enum language func_lang;
   int i;
@@ -11779,9 +11779,9 @@ is_known_support_routine (frame_info_ptr frame)
    part of the Ada run-time, starting from FI and moving upward.  */
 
 void
-ada_find_printable_frame (frame_info_ptr fi)
+ada_find_printable_frame (const frame_info_ptr &initial_fi)
 {
-  for (; fi != NULL; fi = get_prev_frame (fi))
+  for (frame_info_ptr fi = initial_fi; fi != nullptr; fi = get_prev_frame (fi))
     {
       if (!is_known_support_routine (fi))
 	{
@@ -12913,7 +12913,7 @@ ada_add_standard_exceptions (compiled_regex *preg,
 
 static void
 ada_add_exceptions_from_frame (compiled_regex *preg,
-			       frame_info_ptr frame,
+			       const frame_info_ptr &frame,
 			       std::vector<ada_exc_info> *exceptions)
 {
   const struct block *block = get_frame_block (frame, 0);
@@ -13339,7 +13339,7 @@ public:
 
   struct value *read_var_value (struct symbol *var,
 				const struct block *var_block,
-				frame_info_ptr frame) const override
+				const frame_info_ptr &frame) const override
   {
     /* The only case where default_read_var_value is not sufficient
        is when VAR is a renaming...  */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index aefd335ff39..5083d004ac9 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -341,7 +341,7 @@ extern enum ada_renaming_category ada_parse_renaming (struct symbol *,
 						      const char **,
 						      int *, const char **);
 
-extern void ada_find_printable_frame (frame_info_ptr fi);
+extern void ada_find_printable_frame (const frame_info_ptr &fi);
 
 extern const char *ada_main_name ();
 
diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c
index 1a19626d9f0..5f5e46d514e 100644
--- a/gdb/alpha-linux-tdep.c
+++ b/gdb/alpha-linux-tdep.c
@@ -126,7 +126,7 @@ alpha_linux_pc_in_sigtramp (struct gdbarch *gdbarch,
 }
 
 static CORE_ADDR
-alpha_linux_sigcontext_addr (frame_info_ptr this_frame)
+alpha_linux_sigcontext_addr (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR pc;
diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c
index 7691a53148a..7e9312d2aa7 100644
--- a/gdb/alpha-mdebug-tdep.c
+++ b/gdb/alpha-mdebug-tdep.c
@@ -185,7 +185,7 @@ struct alpha_mdebug_unwind_cache
    and store the resulting register save locations in the structure.  */
 
 static struct alpha_mdebug_unwind_cache *
-alpha_mdebug_frame_unwind_cache (frame_info_ptr this_frame, 
+alpha_mdebug_frame_unwind_cache (const frame_info_ptr &this_frame,
 				 void **this_prologue_cache)
 {
   struct alpha_mdebug_unwind_cache *info;
@@ -262,7 +262,7 @@ alpha_mdebug_frame_unwind_cache (frame_info_ptr this_frame,
    frame.  This will be used to create a new GDB frame struct.  */
 
 static void
-alpha_mdebug_frame_this_id (frame_info_ptr this_frame,
+alpha_mdebug_frame_this_id (const frame_info_ptr &this_frame,
 			    void **this_prologue_cache,
 			    struct frame_id *this_id)
 {
@@ -275,7 +275,7 @@ alpha_mdebug_frame_this_id (frame_info_ptr this_frame,
 /* Retrieve the value of REGNUM in FRAME.  Don't give up!  */
 
 static struct value *
-alpha_mdebug_frame_prev_register (frame_info_ptr this_frame,
+alpha_mdebug_frame_prev_register (const frame_info_ptr &this_frame,
 				  void **this_prologue_cache, int regnum)
 {
   struct alpha_mdebug_unwind_cache *info
@@ -306,7 +306,7 @@ alpha_mdebug_max_frame_size_exceeded (struct mdebug_extra_func_info *proc_desc)
 
 static int
 alpha_mdebug_frame_sniffer (const struct frame_unwind *self,
-			    frame_info_ptr this_frame,
+			    const frame_info_ptr &this_frame,
 			    void **this_cache)
 {
   CORE_ADDR pc = get_frame_address_in_block (this_frame);
@@ -343,7 +343,7 @@ static const struct frame_unwind alpha_mdebug_frame_unwind =
 };
 
 static CORE_ADDR
-alpha_mdebug_frame_base_address (frame_info_ptr this_frame,
+alpha_mdebug_frame_base_address (const frame_info_ptr &this_frame,
 				 void **this_prologue_cache)
 {
   struct alpha_mdebug_unwind_cache *info
@@ -353,7 +353,7 @@ alpha_mdebug_frame_base_address (frame_info_ptr this_frame,
 }
 
 static CORE_ADDR
-alpha_mdebug_frame_locals_address (frame_info_ptr this_frame,
+alpha_mdebug_frame_locals_address (const frame_info_ptr &this_frame,
 				   void **this_prologue_cache)
 {
   struct alpha_mdebug_unwind_cache *info
@@ -363,7 +363,7 @@ alpha_mdebug_frame_locals_address (frame_info_ptr this_frame,
 }
 
 static CORE_ADDR
-alpha_mdebug_frame_args_address (frame_info_ptr this_frame,
+alpha_mdebug_frame_args_address (const frame_info_ptr &this_frame,
 				 void **this_prologue_cache)
 {
   struct alpha_mdebug_unwind_cache *info
@@ -380,7 +380,7 @@ static const struct frame_base alpha_mdebug_frame_base = {
 };
 
 static const struct frame_base *
-alpha_mdebug_frame_base_sniffer (frame_info_ptr this_frame)
+alpha_mdebug_frame_base_sniffer (const frame_info_ptr &this_frame)
 {
   CORE_ADDR pc = get_frame_address_in_block (this_frame);
   struct mdebug_extra_func_info *proc_desc;
diff --git a/gdb/alpha-netbsd-tdep.c b/gdb/alpha-netbsd-tdep.c
index 0213fe5b94f..569fe42a2a9 100644
--- a/gdb/alpha-netbsd-tdep.c
+++ b/gdb/alpha-netbsd-tdep.c
@@ -235,7 +235,7 @@ alphanbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
 }
 
 static CORE_ADDR
-alphanbsd_sigcontext_addr (frame_info_ptr frame)
+alphanbsd_sigcontext_addr (const frame_info_ptr &frame)
 {
   /* FIXME: This is not correct for all versions of NetBSD/alpha.
      We will probably need to disassemble the trampoline to figure
diff --git a/gdb/alpha-obsd-tdep.c b/gdb/alpha-obsd-tdep.c
index b22e584a4e4..610866835c8 100644
--- a/gdb/alpha-obsd-tdep.c
+++ b/gdb/alpha-obsd-tdep.c
@@ -69,7 +69,7 @@ alphaobsd_pc_in_sigtramp (struct gdbarch *gdbarch,
 }
 
 static CORE_ADDR
-alphaobsd_sigcontext_addr (frame_info_ptr this_frame)
+alphaobsd_sigcontext_addr (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR pc = get_frame_pc (this_frame);
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index cafadae45c7..e5e0860fe24 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -233,7 +233,7 @@ alpha_convert_register_p (struct gdbarch *gdbarch, int regno,
 }
 
 static int
-alpha_register_to_value (frame_info_ptr frame, int regnum,
+alpha_register_to_value (const frame_info_ptr &frame, int regnum,
 			 struct type *valtype, gdb_byte *out,
 			int *optimizedp, int *unavailablep)
 {
@@ -260,7 +260,7 @@ alpha_register_to_value (frame_info_ptr frame, int regnum,
 }
 
 static void
-alpha_value_to_register (frame_info_ptr frame, int regnum,
+alpha_value_to_register (const frame_info_ptr &frame, int regnum,
 			 struct type *valtype, const gdb_byte *in)
 {
   int reg_size = register_size (get_frame_arch (frame), regnum);
@@ -840,7 +840,7 @@ alpha_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
    into the "pc".  This routine returns true on success.  */
 
 static int
-alpha_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
+alpha_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
@@ -871,7 +871,7 @@ struct alpha_sigtramp_unwind_cache
 };
 
 static struct alpha_sigtramp_unwind_cache *
-alpha_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
+alpha_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
 				   void **this_prologue_cache)
 {
   struct alpha_sigtramp_unwind_cache *info;
@@ -912,7 +912,7 @@ alpha_sigtramp_register_address (struct gdbarch *gdbarch,
    frame.  This will be used to create a new GDB frame struct.  */
 
 static void
-alpha_sigtramp_frame_this_id (frame_info_ptr this_frame,
+alpha_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
 			      void **this_prologue_cache,
 			      struct frame_id *this_id)
 {
@@ -954,7 +954,7 @@ alpha_sigtramp_frame_this_id (frame_info_ptr this_frame,
 /* Retrieve the value of REGNUM in FRAME.  Don't give up!  */
 
 static struct value *
-alpha_sigtramp_frame_prev_register (frame_info_ptr this_frame,
+alpha_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
 				    void **this_prologue_cache, int regnum)
 {
   struct alpha_sigtramp_unwind_cache *info
@@ -979,7 +979,7 @@ alpha_sigtramp_frame_prev_register (frame_info_ptr this_frame,
 
 static int
 alpha_sigtramp_frame_sniffer (const struct frame_unwind *self,
-			      frame_info_ptr this_frame,
+			      const frame_info_ptr &this_frame,
 			      void **this_prologue_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -1221,7 +1221,7 @@ alpha_heuristic_analyze_probing_loop (struct gdbarch *gdbarch, CORE_ADDR *pc,
 }
 
 static struct alpha_heuristic_unwind_cache *
-alpha_heuristic_frame_unwind_cache (frame_info_ptr this_frame,
+alpha_heuristic_frame_unwind_cache (const frame_info_ptr &this_frame,
 				    void **this_prologue_cache,
 				    CORE_ADDR start_pc)
 {
@@ -1398,7 +1398,7 @@ alpha_heuristic_frame_unwind_cache (frame_info_ptr this_frame,
    frame.  This will be used to create a new GDB frame struct.  */
 
 static void
-alpha_heuristic_frame_this_id (frame_info_ptr this_frame,
+alpha_heuristic_frame_this_id (const frame_info_ptr &this_frame,
 			       void **this_prologue_cache,
 			       struct frame_id *this_id)
 {
@@ -1411,7 +1411,7 @@ alpha_heuristic_frame_this_id (frame_info_ptr this_frame,
 /* Retrieve the value of REGNUM in FRAME.  Don't give up!  */
 
 static struct value *
-alpha_heuristic_frame_prev_register (frame_info_ptr this_frame,
+alpha_heuristic_frame_prev_register (const frame_info_ptr &this_frame,
 				     void **this_prologue_cache, int regnum)
 {
   struct alpha_heuristic_unwind_cache *info
@@ -1438,7 +1438,7 @@ static const struct frame_unwind alpha_heuristic_frame_unwind =
 };
 
 static CORE_ADDR
-alpha_heuristic_frame_base_address (frame_info_ptr this_frame,
+alpha_heuristic_frame_base_address (const frame_info_ptr &this_frame,
 				    void **this_prologue_cache)
 {
   struct alpha_heuristic_unwind_cache *info
diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
index f9c7e295609..0423abb2558 100644
--- a/gdb/alpha-tdep.h
+++ b/gdb/alpha-tdep.h
@@ -81,7 +81,7 @@ struct alpha_gdbarch_tdep : gdbarch_tdep_base
 
   /* Translate a signal handler stack base address into the address of
      the sigcontext structure for that signal handler.  */
-  CORE_ADDR (*sigcontext_addr) (frame_info_ptr) = nullptr;
+  CORE_ADDR (*sigcontext_addr) (const frame_info_ptr &) = nullptr;
 
   /* Does the PC fall in a signal trampoline.  */
   /* NOTE: cagney/2004-04-30: Do not copy/clone this code.  Instead
diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c
index bfba7a5284a..001f5379def 100644
--- a/gdb/amd64-darwin-tdep.c
+++ b/gdb/amd64-darwin-tdep.c
@@ -75,7 +75,7 @@ const int amd64_darwin_thread_state_num_regs =
    address of the associated sigcontext structure.  */
 
 static CORE_ADDR
-amd64_darwin_sigcontext_addr (frame_info_ptr this_frame)
+amd64_darwin_sigcontext_addr (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c
index 9144801a5d2..a837bd197ff 100644
--- a/gdb/amd64-fbsd-tdep.c
+++ b/gdb/amd64-fbsd-tdep.c
@@ -169,7 +169,7 @@ const struct regset amd64_fbsd_segbases_regset =
 
 static void
 amd64_fbsd_sigframe_init (const struct tramp_frame *self,
-			  frame_info_ptr this_frame,
+			  const frame_info_ptr &this_frame,
 			  struct trad_frame_cache *this_cache,
 			  CORE_ADDR func)
 {
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index fe7f5d4a259..1deb13b4e9a 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -133,7 +133,7 @@ static const gdb_byte amd64_x32_linux_sigtramp_code[] =
    the routine.  Otherwise, return 0.  */
 
 static CORE_ADDR
-amd64_linux_sigtramp_start (frame_info_ptr this_frame)
+amd64_linux_sigtramp_start (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch;
   const gdb_byte *sigtramp_code;
@@ -175,7 +175,7 @@ amd64_linux_sigtramp_start (frame_info_ptr this_frame)
    routine.  */
 
 static int
-amd64_linux_sigtramp_p (frame_info_ptr this_frame)
+amd64_linux_sigtramp_p (const frame_info_ptr &this_frame)
 {
   CORE_ADDR pc = get_frame_pc (this_frame);
   const char *name;
@@ -201,7 +201,7 @@ amd64_linux_sigtramp_p (frame_info_ptr this_frame)
    address of the associated sigcontext structure.  */
 
 static CORE_ADDR
-amd64_linux_sigcontext_addr (frame_info_ptr this_frame)
+amd64_linux_sigcontext_addr (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
diff --git a/gdb/amd64-netbsd-tdep.c b/gdb/amd64-netbsd-tdep.c
index d1a7cf3a049..40500ee5f76 100644
--- a/gdb/amd64-netbsd-tdep.c
+++ b/gdb/amd64-netbsd-tdep.c
@@ -35,7 +35,7 @@
    routine.  */
 
 static int
-amd64nbsd_sigtramp_p (frame_info_ptr this_frame)
+amd64nbsd_sigtramp_p (const frame_info_ptr &this_frame)
 {
   CORE_ADDR pc = get_frame_pc (this_frame);
   const char *name;
@@ -48,7 +48,7 @@ amd64nbsd_sigtramp_p (frame_info_ptr this_frame)
    return the address of the associated mcontext structure.  */
 
 static CORE_ADDR
-amd64nbsd_mcontext_addr (frame_info_ptr this_frame)
+amd64nbsd_mcontext_addr (const frame_info_ptr &this_frame)
 {
   CORE_ADDR addr;
 
diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c
index 9cca6b12c84..6b37e8954ee 100644
--- a/gdb/amd64-obsd-tdep.c
+++ b/gdb/amd64-obsd-tdep.c
@@ -45,7 +45,7 @@ static const int amd64obsd_page_size = 4096;
    routine.  */
 
 static int
-amd64obsd_sigtramp_p (frame_info_ptr this_frame)
+amd64obsd_sigtramp_p (const frame_info_ptr &this_frame)
 {
   CORE_ADDR pc = get_frame_pc (this_frame);
   CORE_ADDR start_pc = (pc & ~(amd64obsd_page_size - 1));
@@ -98,7 +98,7 @@ amd64obsd_sigtramp_p (frame_info_ptr this_frame)
    address of the associated sigcontext structure.  */
 
 static CORE_ADDR
-amd64obsd_sigcontext_addr (frame_info_ptr this_frame)
+amd64obsd_sigcontext_addr (const frame_info_ptr &this_frame)
 {
   CORE_ADDR pc = get_frame_pc (this_frame);
   ULONGEST offset = (pc & (amd64obsd_page_size - 1));
@@ -315,7 +315,7 @@ amd64obsd_collect_uthread (const struct regcache *regcache,
 #define amd64obsd_tf_reg_offset amd64obsd_sc_reg_offset
 
 static struct trad_frame_cache *
-amd64obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
+amd64obsd_trapframe_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -362,7 +362,7 @@ amd64obsd_trapframe_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static void
-amd64obsd_trapframe_this_id (frame_info_ptr this_frame,
+amd64obsd_trapframe_this_id (const frame_info_ptr &this_frame,
 			     void **this_cache, struct frame_id *this_id)
 {
   struct trad_frame_cache *cache =
@@ -372,7 +372,7 @@ amd64obsd_trapframe_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-amd64obsd_trapframe_prev_register (frame_info_ptr this_frame,
+amd64obsd_trapframe_prev_register (const frame_info_ptr &this_frame,
 				   void **this_cache, int regnum)
 {
   struct trad_frame_cache *cache =
@@ -383,7 +383,7 @@ amd64obsd_trapframe_prev_register (frame_info_ptr this_frame,
 
 static int
 amd64obsd_trapframe_sniffer (const struct frame_unwind *self,
-			     frame_info_ptr this_frame,
+			     const frame_info_ptr &this_frame,
 			     void **this_prologue_cache)
 {
   ULONGEST cs;
diff --git a/gdb/amd64-sol2-tdep.c b/gdb/amd64-sol2-tdep.c
index 30a5dfa4c5e..6cc84017f74 100644
--- a/gdb/amd64-sol2-tdep.c
+++ b/gdb/amd64-sol2-tdep.c
@@ -67,7 +67,7 @@ static int amd64_sol2_gregset_reg_offset[] = {
    'mcontext_t' that contains the saved set of machine registers.  */
 
 static CORE_ADDR
-amd64_sol2_mcontext_addr (frame_info_ptr this_frame)
+amd64_sol2_mcontext_addr (const frame_info_ptr &this_frame)
 {
   CORE_ADDR sp, ucontext_addr;
 
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index a8ff9246b8a..f5968ab4d0f 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -348,7 +348,7 @@ amd64_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
 }
 
 static value *
-amd64_pseudo_register_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
+amd64_pseudo_register_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 				  int regnum)
 {
   i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
@@ -379,7 +379,7 @@ amd64_pseudo_register_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
 }
 
 static void
-amd64_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
+amd64_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 			     int regnum, gdb::array_view<const gdb_byte> buf)
 {
   i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
@@ -2510,7 +2510,7 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 /* Normal frames.  */
 
 static void
-amd64_frame_cache_1 (frame_info_ptr this_frame,
+amd64_frame_cache_1 (const frame_info_ptr &this_frame,
 		     struct amd64_frame_cache *cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -2579,7 +2579,7 @@ amd64_frame_cache_1 (frame_info_ptr this_frame,
 }
 
 static struct amd64_frame_cache *
-amd64_frame_cache (frame_info_ptr this_frame, void **this_cache)
+amd64_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct amd64_frame_cache *cache;
 
@@ -2603,7 +2603,7 @@ amd64_frame_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static enum unwind_stop_reason
-amd64_frame_unwind_stop_reason (frame_info_ptr this_frame,
+amd64_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
 				void **this_cache)
 {
   struct amd64_frame_cache *cache =
@@ -2620,7 +2620,7 @@ amd64_frame_unwind_stop_reason (frame_info_ptr this_frame,
 }
 
 static void
-amd64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
+amd64_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
 		     struct frame_id *this_id)
 {
   struct amd64_frame_cache *cache =
@@ -2638,7 +2638,7 @@ amd64_frame_this_id (frame_info_ptr this_frame, void **this_cache,
 }
 
 static struct value *
-amd64_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
+amd64_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
 			   int regnum)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -2692,7 +2692,7 @@ amd64_gen_return_address (struct gdbarch *gdbarch,
    on both platforms.  */
 
 static struct amd64_frame_cache *
-amd64_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
+amd64_sigtramp_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
@@ -2732,7 +2732,7 @@ amd64_sigtramp_frame_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static enum unwind_stop_reason
-amd64_sigtramp_frame_unwind_stop_reason (frame_info_ptr this_frame,
+amd64_sigtramp_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
 					 void **this_cache)
 {
   struct amd64_frame_cache *cache =
@@ -2745,7 +2745,7 @@ amd64_sigtramp_frame_unwind_stop_reason (frame_info_ptr this_frame,
 }
 
 static void
-amd64_sigtramp_frame_this_id (frame_info_ptr this_frame,
+amd64_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
 			      void **this_cache, struct frame_id *this_id)
 {
   struct amd64_frame_cache *cache =
@@ -2763,7 +2763,7 @@ amd64_sigtramp_frame_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-amd64_sigtramp_frame_prev_register (frame_info_ptr this_frame,
+amd64_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
 				    void **this_cache, int regnum)
 {
   /* Make sure we've initialized the cache.  */
@@ -2774,7 +2774,7 @@ amd64_sigtramp_frame_prev_register (frame_info_ptr this_frame,
 
 static int
 amd64_sigtramp_frame_sniffer (const struct frame_unwind *self,
-			      frame_info_ptr this_frame,
+			      const frame_info_ptr &this_frame,
 			      void **this_cache)
 {
   gdbarch *arch = get_frame_arch (this_frame);
@@ -2816,7 +2816,7 @@ static const struct frame_unwind amd64_sigtramp_frame_unwind =
 \f
 
 static CORE_ADDR
-amd64_frame_base_address (frame_info_ptr this_frame, void **this_cache)
+amd64_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct amd64_frame_cache *cache =
     amd64_frame_cache (this_frame, this_cache);
@@ -2878,7 +2878,7 @@ amd64_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 
 static int
 amd64_epilogue_frame_sniffer_1 (const struct frame_unwind *self,
-				frame_info_ptr this_frame,
+				const frame_info_ptr &this_frame,
 				void **this_prologue_cache, bool override_p)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -2911,7 +2911,7 @@ amd64_epilogue_frame_sniffer_1 (const struct frame_unwind *self,
 
 static int
 amd64_epilogue_override_frame_sniffer (const struct frame_unwind *self,
-				       frame_info_ptr this_frame,
+				       const frame_info_ptr &this_frame,
 				       void **this_prologue_cache)
 {
   return amd64_epilogue_frame_sniffer_1 (self, this_frame, this_prologue_cache,
@@ -2920,7 +2920,7 @@ amd64_epilogue_override_frame_sniffer (const struct frame_unwind *self,
 
 static int
 amd64_epilogue_frame_sniffer (const struct frame_unwind *self,
-			      frame_info_ptr this_frame,
+			      const frame_info_ptr &this_frame,
 			      void **this_prologue_cache)
 {
   return amd64_epilogue_frame_sniffer_1 (self, this_frame, this_prologue_cache,
@@ -2928,7 +2928,7 @@ amd64_epilogue_frame_sniffer (const struct frame_unwind *self,
 }
 
 static struct amd64_frame_cache *
-amd64_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
+amd64_epilogue_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -2969,7 +2969,7 @@ amd64_epilogue_frame_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static enum unwind_stop_reason
-amd64_epilogue_frame_unwind_stop_reason (frame_info_ptr this_frame,
+amd64_epilogue_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
 					 void **this_cache)
 {
   struct amd64_frame_cache *cache
@@ -2982,7 +2982,7 @@ amd64_epilogue_frame_unwind_stop_reason (frame_info_ptr this_frame,
 }
 
 static void
-amd64_epilogue_frame_this_id (frame_info_ptr this_frame,
+amd64_epilogue_frame_this_id (const frame_info_ptr &this_frame,
 			      void **this_cache,
 			      struct frame_id *this_id)
 {
@@ -3018,7 +3018,7 @@ static const struct frame_unwind amd64_epilogue_frame_unwind =
 };
 
 static struct frame_id
-amd64_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
+amd64_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
 {
   CORE_ADDR fp;
 
@@ -3081,7 +3081,7 @@ const struct regset amd64_fpregset =
    success.  */
 
 static int
-amd64_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
+amd64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
 {
   gdb_byte buf[8];
   CORE_ADDR jb_addr;
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 50304e15cb8..7c5169fd98c 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -517,7 +517,7 @@ pc_in_range (CORE_ADDR pc, const struct amd64_windows_frame_cache *cache)
    Return 1 if an epilogue sequence was recognized, 0 otherwise.  */
 
 static int
-amd64_windows_frame_decode_epilogue (frame_info_ptr this_frame,
+amd64_windows_frame_decode_epilogue (const frame_info_ptr &this_frame,
 				     struct amd64_windows_frame_cache *cache)
 {
   /* According to MSDN an epilogue "must consist of either an add RSP,constant
@@ -697,7 +697,7 @@ amd64_windows_frame_decode_epilogue (frame_info_ptr this_frame,
 /* Decode and execute unwind insns at UNWIND_INFO.  */
 
 static void
-amd64_windows_frame_decode_insns (frame_info_ptr this_frame,
+amd64_windows_frame_decode_insns (const frame_info_ptr &this_frame,
 				  struct amd64_windows_frame_cache *cache,
 				  CORE_ADDR unwind_info)
 {
@@ -1077,7 +1077,7 @@ amd64_windows_find_unwind_info (struct gdbarch *gdbarch, CORE_ADDR pc,
    for THIS_FRAME.  */
 
 static struct amd64_windows_frame_cache *
-amd64_windows_frame_cache (frame_info_ptr this_frame, void **this_cache)
+amd64_windows_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1123,7 +1123,7 @@ amd64_windows_frame_cache (frame_info_ptr this_frame, void **this_cache)
    using the standard Windows x64 SEH info.  */
 
 static struct value *
-amd64_windows_frame_prev_register (frame_info_ptr this_frame,
+amd64_windows_frame_prev_register (const frame_info_ptr &this_frame,
 				   void **this_cache, int regnum)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -1169,7 +1169,7 @@ amd64_windows_frame_prev_register (frame_info_ptr this_frame,
    the standard Windows x64 SEH info.  */
 
 static void
-amd64_windows_frame_this_id (frame_info_ptr this_frame, void **this_cache,
+amd64_windows_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
 		   struct frame_id *this_id)
 {
   struct amd64_windows_frame_cache *cache =
@@ -1235,7 +1235,7 @@ amd64_windows_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 /* Check Win64 DLL jmp trampolines and find jump destination.  */
 
 static CORE_ADDR
-amd64_windows_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
+amd64_windows_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   CORE_ADDR destination = 0;
   struct gdbarch *gdbarch = get_frame_arch (frame);
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index 44252e559cd..ac137d9acc4 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -846,7 +846,7 @@ struct amdgpu_frame_cache
 };
 
 static amdgpu_frame_cache *
-amdgpu_frame_cache (frame_info_ptr this_frame, void **this_cache)
+amdgpu_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   if (*this_cache != nullptr)
     return (struct amdgpu_frame_cache *) *this_cache;
@@ -862,7 +862,7 @@ amdgpu_frame_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static void
-amdgpu_frame_this_id (frame_info_ptr this_frame, void **this_cache,
+amdgpu_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
 		      frame_id *this_id)
 {
   struct amdgpu_frame_cache *cache
@@ -880,13 +880,13 @@ amdgpu_frame_this_id (frame_info_ptr this_frame, void **this_cache,
 }
 
 static frame_id
-amdgpu_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
+amdgpu_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
 {
   return frame_id_build (0, get_frame_pc (this_frame));
 }
 
 static struct value *
-amdgpu_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
+amdgpu_frame_prev_register (const frame_info_ptr &this_frame, void **this_cache,
 			    int regnum)
 {
   return frame_unwind_got_register (this_frame, regnum, regnum);
diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
index 03ff49a2b19..ca630ab6df0 100644
--- a/gdb/arc-linux-tdep.c
+++ b/gdb/arc-linux-tdep.c
@@ -159,7 +159,7 @@ static const int arc_linux_core_reg_offsets[] = {
    Returns TRUE if this is a sigtramp frame.  */
 
 static bool
-arc_linux_is_sigtramp (frame_info_ptr this_frame)
+arc_linux_is_sigtramp (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR pc = get_frame_pc (this_frame);
@@ -257,7 +257,7 @@ arc_linux_is_sigtramp (frame_info_ptr this_frame)
    etc) in GDB hardcode values.  */
 
 static CORE_ADDR
-arc_linux_sigcontext_addr (frame_info_ptr this_frame)
+arc_linux_sigcontext_addr (const frame_info_ptr &this_frame)
 {
   const int ucontext_offset = 0x80;
   const int sigcontext_offset = 0x14;
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 84e211ce9ad..12d8aee949f 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -998,7 +998,7 @@ arc_store_return_value (struct gdbarch *gdbarch, struct type *type,
 /* Implement the "get_longjmp_target" gdbarch method.  */
 
 static int
-arc_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
+arc_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
 {
   arc_debug_printf ("called");
 
@@ -1062,7 +1062,7 @@ arc_return_value (struct gdbarch *gdbarch, struct value *function,
    frame pointer.  */
 
 static CORE_ADDR
-arc_frame_base_address (frame_info_ptr this_frame, void **prologue_cache)
+arc_frame_base_address (const frame_info_ptr &this_frame, void **prologue_cache)
 {
   return (CORE_ADDR) get_frame_register_unsigned (this_frame, ARC_FP_REGNUM);
 }
@@ -1643,7 +1643,7 @@ arc_print_frame_cache (struct gdbarch *gdbarch, const char *message,
 /* Frame unwinder for normal frames.  */
 
 static struct arc_frame_cache *
-arc_make_frame_cache (frame_info_ptr this_frame)
+arc_make_frame_cache (const frame_info_ptr &this_frame)
 {
   arc_debug_printf ("called");
 
@@ -1710,7 +1710,7 @@ arc_make_frame_cache (frame_info_ptr this_frame)
 /* Implement the "this_id" frame_unwind method.  */
 
 static void
-arc_frame_this_id (frame_info_ptr this_frame, void **this_cache,
+arc_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
 		   struct frame_id *this_id)
 {
   arc_debug_printf ("called");
@@ -1755,7 +1755,7 @@ arc_frame_this_id (frame_info_ptr this_frame, void **this_cache,
 /* Implement the "prev_register" frame_unwind method.  */
 
 static struct value *
-arc_frame_prev_register (frame_info_ptr this_frame,
+arc_frame_prev_register (const frame_info_ptr &this_frame,
 			 void **this_cache, int regnum)
 {
   if (*this_cache == NULL)
@@ -1792,7 +1792,7 @@ arc_frame_prev_register (frame_info_ptr this_frame,
 static void
 arc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 			   struct dwarf2_frame_state_reg *reg,
-			   frame_info_ptr info)
+			   const frame_info_ptr &info)
 {
   if (regnum == gdbarch_pc_regnum (gdbarch))
     /* The return address column.  */
@@ -1806,7 +1806,7 @@ arc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
     from within signal handlers.  */
 
 static struct arc_frame_cache *
-arc_make_sigtramp_frame_cache (frame_info_ptr this_frame)
+arc_make_sigtramp_frame_cache (const frame_info_ptr &this_frame)
 {
   arc_debug_printf ("called");
 
@@ -1845,7 +1845,7 @@ arc_make_sigtramp_frame_cache (frame_info_ptr this_frame)
    frames.  */
 
 static void
-arc_sigtramp_frame_this_id (frame_info_ptr this_frame,
+arc_sigtramp_frame_this_id (const frame_info_ptr &this_frame,
 			    void **this_cache, struct frame_id *this_id)
 {
   arc_debug_printf ("called");
@@ -1864,7 +1864,7 @@ arc_sigtramp_frame_this_id (frame_info_ptr this_frame,
 /* Get a register from a signal handler frame.  */
 
 static struct value *
-arc_sigtramp_frame_prev_register (frame_info_ptr this_frame,
+arc_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
 				  void **this_cache, int regnum)
 {
   arc_debug_printf ("regnum = %d", regnum);
@@ -1882,7 +1882,7 @@ arc_sigtramp_frame_prev_register (frame_info_ptr this_frame,
 
 static int
 arc_sigtramp_frame_sniffer (const struct frame_unwind *self,
-			    frame_info_ptr this_frame,
+			    const frame_info_ptr &this_frame,
 			    void **this_cache)
 {
   arc_debug_printf ("called");
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index 6fc1131a435..c59490dec00 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -131,10 +131,10 @@ struct arc_gdbarch_tdep : gdbarch_tdep_base
   bool has_hw_loops = false;
 
   /* Detect sigtramp.  */
-  bool (*is_sigtramp) (frame_info_ptr) = nullptr;
+  bool (*is_sigtramp) (const frame_info_ptr &) = nullptr;
 
   /* Get address of sigcontext for sigtramp.  */
-  CORE_ADDR (*sigcontext_addr) (frame_info_ptr) = nullptr;
+  CORE_ADDR (*sigcontext_addr) (const frame_info_ptr &) = nullptr;
 
   /* Offset of registers in `struct sigcontext'.  */
   const int *sc_reg_offset = nullptr;
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 1faa013c16f..ae3354f6579 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -140,7 +140,7 @@ default_get_memtag (struct gdbarch *gdbarch, struct value *address,
 }
 
 CORE_ADDR
-generic_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
+generic_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   return 0;
 }
@@ -166,7 +166,7 @@ generic_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 
 int
 default_code_of_frame_writable (struct gdbarch *gdbarch,
-				frame_info_ptr frame)
+				const frame_info_ptr &frame)
 {
   return 1;
 }
@@ -1079,7 +1079,7 @@ default_type_align (struct gdbarch *gdbarch, struct type *type)
 /* See arch-utils.h.  */
 
 std::string
-default_get_pc_address_flags (frame_info_ptr frame, CORE_ADDR pc)
+default_get_pc_address_flags (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   return "";
 }
@@ -1105,7 +1105,8 @@ default_use_target_description_from_corefile_notes (struct gdbarch *gdbarch,
 }
 
 CORE_ADDR
-default_get_return_buf_addr (struct type *val_type, frame_info_ptr cur_frame)
+default_get_return_buf_addr (struct type *val_type,
+			     const frame_info_ptr &cur_frame)
 {
   return 0;
 }
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 0f37aaf20f8..2dcd8f6dc53 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -158,7 +158,7 @@ struct value *default_get_memtag (struct gdbarch *gdbarch,
 				  struct value *address,
 				  memtag_type tag_type);
 
-extern CORE_ADDR generic_skip_trampoline_code (frame_info_ptr frame,
+extern CORE_ADDR generic_skip_trampoline_code (const frame_info_ptr &frame,
 					       CORE_ADDR pc);
 
 extern CORE_ADDR generic_skip_solib_resolver (struct gdbarch *gdbarch,
@@ -171,7 +171,7 @@ extern int generic_stack_frame_destroyed_p (struct gdbarch *gdbarch,
 					    CORE_ADDR pc);
 
 extern int default_code_of_frame_writable (struct gdbarch *gdbarch,
-					   frame_info_ptr frame);
+					   const frame_info_ptr &frame);
 
 /* By default, registers are not convertible.  */
 extern int generic_convert_register_p (struct gdbarch *gdbarch, int regnum,
@@ -295,7 +295,7 @@ extern ULONGEST default_type_align (struct gdbarch *gdbarch,
 				    struct type *type);
 
 /* Default implementation of gdbarch get_pc_address_flags method.  */
-extern std::string default_get_pc_address_flags (frame_info_ptr frame,
+extern std::string default_get_pc_address_flags (const frame_info_ptr &frame,
 						 CORE_ADDR pc);
 
 /* Default implementation of gdbarch read_core_file_mappings method.  */
@@ -313,7 +313,7 @@ extern bool default_use_target_description_from_corefile_notes
 
 /* Default implementation of gdbarch default_get_return_buf_addr method.  */
 extern CORE_ADDR default_get_return_buf_addr (struct type *val_typegdbarch,
-					      frame_info_ptr cur_frame);
+					      const frame_info_ptr &cur_frame);
 
 /* Default implementation of gdbarch default_dwarf2_omit_typedef_p method.  */
 extern bool default_dwarf2_omit_typedef_p (struct type *target_type,
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index 143aaf121b7..b485951c376 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -105,7 +105,7 @@ static const struct regcache_map_entry arm_fbsd_tls_regmap[] =
 
 static void
 arm_fbsd_sigframe_init (const struct tramp_frame *self,
-			frame_info_ptr this_frame,
+			const frame_info_ptr &this_frame,
 			struct trad_frame_cache *this_cache,
 			CORE_ADDR func)
 {
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index b559de0fb2d..cc79247aaf1 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -277,7 +277,7 @@ static struct arm_get_next_pcs_ops arm_linux_get_next_pcs_ops = {
 };
 
 static void
-arm_linux_sigtramp_cache (frame_info_ptr this_frame,
+arm_linux_sigtramp_cache (const frame_info_ptr &this_frame,
 			  struct trad_frame_cache *this_cache,
 			  CORE_ADDR func, int regs_offset)
 {
@@ -300,7 +300,7 @@ arm_linux_sigtramp_cache (frame_info_ptr this_frame,
 /* See arm-linux.h for stack layout details.  */
 static void
 arm_linux_sigreturn_init (const struct tramp_frame *self,
-			  frame_info_ptr this_frame,
+			  const frame_info_ptr &this_frame,
 			  struct trad_frame_cache *this_cache,
 			  CORE_ADDR func)
 {
@@ -320,7 +320,7 @@ arm_linux_sigreturn_init (const struct tramp_frame *self,
 
 static void
 arm_linux_rt_sigreturn_init (const struct tramp_frame *self,
-			  frame_info_ptr this_frame,
+			  const frame_info_ptr &this_frame,
 			  struct trad_frame_cache *this_cache,
 			  CORE_ADDR func)
 {
@@ -343,7 +343,7 @@ arm_linux_rt_sigreturn_init (const struct tramp_frame *self,
 
 static void
 arm_linux_restart_syscall_init (const struct tramp_frame *self,
-				frame_info_ptr this_frame,
+				const frame_info_ptr &this_frame,
 				struct trad_frame_cache *this_cache,
 				CORE_ADDR func)
 {
@@ -756,7 +756,7 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
    will return to ARM or Thumb code.  Return 0 if it is not a
    rt_sigreturn/sigreturn syscall.  */
 static int
-arm_linux_sigreturn_return_addr (frame_info_ptr frame,
+arm_linux_sigreturn_return_addr (const frame_info_ptr &frame,
 				 unsigned long svc_number,
 				 CORE_ADDR *pc, int *is_thumb)
 {
@@ -1720,7 +1720,7 @@ arm_linux_syscall_record (struct regcache *regcache, unsigned long svc_number)
 /* Implement the skip_trampoline_code gdbarch method.  */
 
 static CORE_ADDR
-arm_linux_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
+arm_linux_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   CORE_ADDR target_pc = arm_skip_stub (frame, pc);
 
diff --git a/gdb/arm-obsd-tdep.c b/gdb/arm-obsd-tdep.c
index 9aa2408f36e..0bdecec3b6f 100644
--- a/gdb/arm-obsd-tdep.c
+++ b/gdb/arm-obsd-tdep.c
@@ -30,7 +30,7 @@
 
 static void
 armobsd_sigframe_init (const struct tramp_frame *self,
-		       frame_info_ptr this_frame,
+		       const frame_info_ptr &this_frame,
 		       struct trad_frame_cache *cache,
 		       CORE_ADDR func)
 {
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 081e934cf86..3b4ae15df07 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -339,7 +339,7 @@ arm_cache_init (struct arm_prologue_cache *cache, struct gdbarch *gdbarch)
 /* Similar to the previous function, but extracts GDBARCH from FRAME.  */
 
 static void
-arm_cache_init (struct arm_prologue_cache *cache, frame_info_ptr frame)
+arm_cache_init (struct arm_prologue_cache *cache, const frame_info_ptr &frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
@@ -628,7 +628,7 @@ arm_is_thumb (struct regcache *regcache)
    frame.  */
 
 int
-arm_frame_is_thumb (frame_info_ptr frame)
+arm_frame_is_thumb (const frame_info_ptr &frame)
 {
   /* Check the architecture of FRAME.  */
   struct gdbarch *gdbarch = get_frame_arch (frame);
@@ -2213,7 +2213,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
 }
 
 static void
-arm_scan_prologue (frame_info_ptr this_frame,
+arm_scan_prologue (const frame_info_ptr &this_frame,
 		   struct arm_prologue_cache *cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -2310,7 +2310,7 @@ arm_scan_prologue (frame_info_ptr this_frame,
 }
 
 static struct arm_prologue_cache *
-arm_make_prologue_cache (frame_info_ptr this_frame)
+arm_make_prologue_cache (const frame_info_ptr &this_frame)
 {
   int reg;
   struct arm_prologue_cache *cache;
@@ -2344,7 +2344,7 @@ arm_make_prologue_cache (frame_info_ptr this_frame)
 /* Implementation of the stop_reason hook for arm_prologue frames.  */
 
 static enum unwind_stop_reason
-arm_prologue_unwind_stop_reason (frame_info_ptr this_frame,
+arm_prologue_unwind_stop_reason (const frame_info_ptr &this_frame,
 				 void **this_cache)
 {
   struct arm_prologue_cache *cache;
@@ -2372,7 +2372,7 @@ arm_prologue_unwind_stop_reason (frame_info_ptr this_frame,
    and the caller's SP when we were called.  */
 
 static void
-arm_prologue_this_id (frame_info_ptr this_frame,
+arm_prologue_this_id (const frame_info_ptr &this_frame,
 		      void **this_cache,
 		      struct frame_id *this_id)
 {
@@ -2400,7 +2400,7 @@ arm_prologue_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-arm_prologue_prev_register (frame_info_ptr this_frame,
+arm_prologue_prev_register (const frame_info_ptr &this_frame,
 			    void **this_cache,
 			    int prev_regnum)
 {
@@ -2794,7 +2794,7 @@ arm_find_exidx_entry (CORE_ADDR memaddr, CORE_ADDR *start)
    for the ARM Architecture" document.  */
 
 static struct arm_prologue_cache *
-arm_exidx_fill_cache (frame_info_ptr this_frame, gdb_byte *entry)
+arm_exidx_fill_cache (const frame_info_ptr &this_frame, gdb_byte *entry)
 {
   CORE_ADDR vsp = 0;
   int vsp_valid = 0;
@@ -3092,7 +3092,7 @@ arm_exidx_fill_cache (frame_info_ptr this_frame, gdb_byte *entry)
 
 static int
 arm_exidx_unwind_sniffer (const struct frame_unwind *self,
-			  frame_info_ptr this_frame,
+			  const frame_info_ptr &this_frame,
 			  void **this_prologue_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -3199,7 +3199,7 @@ struct frame_unwind arm_exidx_unwind = {
 };
 
 static struct arm_prologue_cache *
-arm_make_epilogue_frame_cache (frame_info_ptr this_frame)
+arm_make_epilogue_frame_cache (const frame_info_ptr &this_frame)
 {
   struct arm_prologue_cache *cache;
   int reg;
@@ -3231,7 +3231,7 @@ arm_make_epilogue_frame_cache (frame_info_ptr this_frame)
    'struct frame_uwnind' for epilogue unwinder.  */
 
 static void
-arm_epilogue_frame_this_id (frame_info_ptr this_frame,
+arm_epilogue_frame_this_id (const frame_info_ptr &this_frame,
 			    void **this_cache,
 			    struct frame_id *this_id)
 {
@@ -3259,7 +3259,7 @@ arm_epilogue_frame_this_id (frame_info_ptr this_frame,
    'struct frame_uwnind' for epilogue unwinder.  */
 
 static struct value *
-arm_epilogue_frame_prev_register (frame_info_ptr this_frame,
+arm_epilogue_frame_prev_register (const frame_info_ptr &this_frame,
 				  void **this_cache, int regnum)
 {
   if (*this_cache == NULL)
@@ -3278,7 +3278,7 @@ static int thumb_stack_frame_destroyed_p (struct gdbarch *gdbarch,
 
 static int
 arm_epilogue_frame_sniffer (const struct frame_unwind *self,
-			    frame_info_ptr this_frame,
+			    const frame_info_ptr &this_frame,
 			    void **this_prologue_cache)
 {
   if (frame_relative_level (this_frame) == 0)
@@ -3335,7 +3335,7 @@ static const struct frame_unwind arm_epilogue_frame_unwind =
    The trampoline 'bx r2' doesn't belong to main.  */
 
 static CORE_ADDR
-arm_skip_bx_reg (frame_info_ptr frame, CORE_ADDR pc)
+arm_skip_bx_reg (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   /* The heuristics of recognizing such trampoline is that FRAME is
      executing in Thumb mode and the instruction on PC is 'bx Rm'.  */
@@ -3367,7 +3367,7 @@ arm_skip_bx_reg (frame_info_ptr frame, CORE_ADDR pc)
 }
 
 static struct arm_prologue_cache *
-arm_make_stub_cache (frame_info_ptr this_frame)
+arm_make_stub_cache (const frame_info_ptr &this_frame)
 {
   struct arm_prologue_cache *cache;
 
@@ -3386,7 +3386,7 @@ arm_make_stub_cache (frame_info_ptr this_frame)
 /* Our frame ID for a stub frame is the current SP and LR.  */
 
 static void
-arm_stub_this_id (frame_info_ptr this_frame,
+arm_stub_this_id (const frame_info_ptr &this_frame,
 		  void **this_cache,
 		  struct frame_id *this_id)
 {
@@ -3404,7 +3404,7 @@ arm_stub_this_id (frame_info_ptr this_frame,
 
 static int
 arm_stub_unwind_sniffer (const struct frame_unwind *self,
-			 frame_info_ptr this_frame,
+			 const frame_info_ptr &this_frame,
 			 void **this_prologue_cache)
 {
   CORE_ADDR addr_in_block;
@@ -3442,7 +3442,7 @@ struct frame_unwind arm_stub_unwind = {
    returned.  */
 
 static struct arm_prologue_cache *
-arm_m_exception_cache (frame_info_ptr this_frame)
+arm_m_exception_cache (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
@@ -3828,7 +3828,7 @@ arm_m_exception_cache (frame_info_ptr this_frame)
 /* Implementation of the stop_reason hook for arm_m_exception frames.  */
 
 static enum unwind_stop_reason
-arm_m_exception_frame_unwind_stop_reason (frame_info_ptr this_frame,
+arm_m_exception_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
 					  void **this_cache)
 {
   struct arm_prologue_cache *cache;
@@ -3850,7 +3850,7 @@ arm_m_exception_frame_unwind_stop_reason (frame_info_ptr this_frame,
    'struct frame_uwnind'.  */
 
 static void
-arm_m_exception_this_id (frame_info_ptr this_frame,
+arm_m_exception_this_id (const frame_info_ptr &this_frame,
 			 void **this_cache,
 			 struct frame_id *this_id)
 {
@@ -3871,7 +3871,7 @@ arm_m_exception_this_id (frame_info_ptr this_frame,
    'struct frame_uwnind'.  */
 
 static struct value *
-arm_m_exception_prev_register (frame_info_ptr this_frame,
+arm_m_exception_prev_register (const frame_info_ptr &this_frame,
 			       void **this_cache,
 			       int prev_regnum)
 {
@@ -3936,7 +3936,7 @@ arm_m_exception_prev_register (frame_info_ptr this_frame,
 
 static int
 arm_m_exception_unwind_sniffer (const struct frame_unwind *self,
-				frame_info_ptr this_frame,
+				const frame_info_ptr &this_frame,
 				void **this_prologue_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -3964,7 +3964,7 @@ struct frame_unwind arm_m_exception_unwind =
 };
 
 static CORE_ADDR
-arm_normal_frame_base (frame_info_ptr this_frame, void **this_cache)
+arm_normal_frame_base (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct arm_prologue_cache *cache;
 
@@ -3997,7 +3997,7 @@ struct arm_dwarf2_prev_register_cache
 };
 
 static struct value *
-arm_dwarf2_prev_register (frame_info_ptr this_frame, void **this_cache,
+arm_dwarf2_prev_register (const frame_info_ptr &this_frame, void **this_cache,
 			  int regnum)
 {
   struct gdbarch * gdbarch = get_frame_arch (this_frame);
@@ -4897,7 +4897,7 @@ print_fpu_flags (struct ui_file *file, int flags)
    (if present) or emulator.  */
 static void
 arm_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
-		      frame_info_ptr frame, const char *args)
+		      const frame_info_ptr &frame, const char *args)
 {
   unsigned long status = get_frame_register_unsigned (frame, ARM_FPS_REGNUM);
   int type;
@@ -5244,7 +5244,7 @@ static const unsigned char op_lit0 = DW_OP_lit0;
 static void
 arm_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 			   struct dwarf2_frame_state_reg *reg,
-			   frame_info_ptr this_frame)
+			   const frame_info_ptr &this_frame)
 {
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
 
@@ -9343,7 +9343,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function,
 
 
 static int
-arm_get_longjmp_target (frame_info_ptr frame, CORE_ADDR *pc)
+arm_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
@@ -9415,7 +9415,7 @@ arm_is_sgstubs_section (struct obj_section *sec)
    return the target PC.  Otherwise return 0.  */
 
 CORE_ADDR
-arm_skip_stub (frame_info_ptr frame, CORE_ADDR pc)
+arm_skip_stub (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   const char *name;
   int namelen;
@@ -9821,7 +9821,7 @@ arm_neon_quad_read (struct gdbarch *gdbarch, readable_regcache *regcache,
    register, in [0, 15].  */
 
 static value *
-arm_neon_quad_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
+arm_neon_quad_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 			  int pseudo_reg_num, int quad_reg_index)
 {
   std::string raw_reg_name = string_printf ("d%d", quad_reg_index << 1);
@@ -9836,7 +9836,7 @@ arm_neon_quad_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
 /* Read the contents of the MVE pseudo register REGNUM and return it as a
    value.  */
 static value *
-arm_mve_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
+arm_mve_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 			   int pseudo_reg_num)
 {
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
@@ -9847,7 +9847,7 @@ arm_mve_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
 }
 
 static value *
-arm_pseudo_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
+arm_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 		       const int pseudo_reg_num)
 {
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
@@ -9909,7 +9909,7 @@ arm_neon_quad_write (struct gdbarch *gdbarch, struct regcache *regcache,
 }
 
 static void
-arm_neon_quad_write (gdbarch *gdbarch, frame_info_ptr next_frame,
+arm_neon_quad_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 		     int quad_reg_index, gdb::array_view<const gdb_byte> buf)
 {
   std::string raw_reg_name = string_printf ("d%d", quad_reg_index << 1);
@@ -9923,7 +9923,7 @@ arm_neon_quad_write (gdbarch *gdbarch, frame_info_ptr next_frame,
 /* Store the contents of BUF to the MVE pseudo register REGNUM.  */
 
 static void
-arm_mve_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
+arm_mve_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 		      int pseudo_reg_num, gdb::array_view<const gdb_byte> buf)
 {
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
@@ -9933,7 +9933,7 @@ arm_mve_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
 }
 
 static void
-arm_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
+arm_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 		  const int pseudo_reg_num,
 		  gdb::array_view<const gdb_byte> buf)
 {
@@ -9973,7 +9973,7 @@ arm_pseudo_write (gdbarch *gdbarch, frame_info_ptr next_frame,
 }
 
 static struct value *
-value_of_arm_user_reg (frame_info_ptr frame, const void *baton)
+value_of_arm_user_reg (const frame_info_ptr &frame, const void *baton)
 {
   const int *reg_p = (const int *) baton;
   return value_of_register (*reg_p, get_next_frame_sentinel_okay (frame));
@@ -10067,7 +10067,7 @@ arm_register_g_packet_guesses (struct gdbarch *gdbarch)
 /* Implement the code_of_frame_writable gdbarch method.  */
 
 static int
-arm_code_of_frame_writable (struct gdbarch *gdbarch, frame_info_ptr frame)
+arm_code_of_frame_writable (struct gdbarch *gdbarch, const frame_info_ptr &frame)
 {
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
 
@@ -10095,7 +10095,7 @@ arm_gnu_triplet_regexp (struct gdbarch *gdbarch)
 /* Implement the "get_pc_address_flags" gdbarch method.  */
 
 static std::string
-arm_get_pc_address_flags (frame_info_ptr frame, CORE_ADDR pc)
+arm_get_pc_address_flags (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   if (get_frame_pc_masked (frame))
     return "PAC";
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 506387b529d..11839b0ff4d 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -279,7 +279,7 @@ extern void
 		       arm_displaced_step_copy_insn_closure *dsc, int regno,
 		       ULONGEST val, enum pc_write_style write_pc);
 
-CORE_ADDR arm_skip_stub (frame_info_ptr, CORE_ADDR);
+CORE_ADDR arm_skip_stub (const frame_info_ptr &, CORE_ADDR);
 
 ULONGEST arm_get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr,
 							int len,
@@ -292,7 +292,7 @@ int arm_get_next_pcs_is_thumb (struct arm_get_next_pcs *self);
 
 std::vector<CORE_ADDR> arm_software_single_step (struct regcache *);
 int arm_is_thumb (struct regcache *regcache);
-int arm_frame_is_thumb (frame_info_ptr frame);
+int arm_frame_is_thumb (const frame_info_ptr &frame);
 
 extern void arm_displaced_step_fixup (struct gdbarch *,
 				      displaced_step_copy_insn_closure *,
diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c
index a31da71de08..b722851e7e1 100644
--- a/gdb/arm-wince-tdep.c
+++ b/gdb/arm-wince-tdep.c
@@ -36,7 +36,7 @@ static const gdb_byte arm_wince_thumb_le_breakpoint[] = { 0xfe, 0xdf };
 #define ARM_WINCE_JB_PC			10
 
 static CORE_ADDR
-arm_pe_skip_trampoline_code (frame_info_ptr frame, CORE_ADDR pc)
+arm_pe_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 63b45be7563..2d38f41cd7f 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -979,7 +979,7 @@ avr_return_value (struct gdbarch *gdbarch, struct value *function,
    for it IS the sp for the next frame.  */
 
 static struct avr_unwind_cache *
-avr_frame_unwind_cache (frame_info_ptr this_frame,
+avr_frame_unwind_cache (const frame_info_ptr &this_frame,
 			void **this_prologue_cache)
 {
   CORE_ADDR start_pc, current_pc;
@@ -1059,7 +1059,7 @@ avr_frame_unwind_cache (frame_info_ptr this_frame,
 }
 
 static CORE_ADDR
-avr_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
+avr_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
 {
   ULONGEST pc;
 
@@ -1069,7 +1069,7 @@ avr_unwind_pc (struct gdbarch *gdbarch, frame_info_ptr next_frame)
 }
 
 static CORE_ADDR
-avr_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
+avr_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
 {
   ULONGEST sp;
 
@@ -1082,7 +1082,7 @@ avr_unwind_sp (struct gdbarch *gdbarch, frame_info_ptr next_frame)
    frame.  This will be used to create a new GDB frame struct.  */
 
 static void
-avr_frame_this_id (frame_info_ptr this_frame,
+avr_frame_this_id (const frame_info_ptr &this_frame,
 		   void **this_prologue_cache,
 		   struct frame_id *this_id)
 {
@@ -1107,7 +1107,7 @@ avr_frame_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-avr_frame_prev_register (frame_info_ptr this_frame,
+avr_frame_prev_register (const frame_info_ptr &this_frame,
 			 void **this_prologue_cache, int regnum)
 {
   struct avr_unwind_cache *info
@@ -1166,7 +1166,7 @@ static const struct frame_unwind avr_frame_unwind = {
 };
 
 static CORE_ADDR
-avr_frame_base_address (frame_info_ptr this_frame, void **this_cache)
+avr_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct avr_unwind_cache *info
     = avr_frame_unwind_cache (this_frame, this_cache);
@@ -1186,7 +1186,7 @@ static const struct frame_base avr_frame_base = {
    save_dummy_frame_tos(), and the PC match the dummy frame's breakpoint.  */
 
 static struct frame_id
-avr_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
+avr_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
 {
   ULONGEST base;
 
diff --git a/gdb/bfin-linux-tdep.c b/gdb/bfin-linux-tdep.c
index 35fdf3f2acb..31aa14765ae 100644
--- a/gdb/bfin-linux-tdep.c
+++ b/gdb/bfin-linux-tdep.c
@@ -95,7 +95,7 @@ static const int bfin_linux_sigcontext_reg_offset[BFIN_NUM_REGS] =
 
 static void
 bfin_linux_sigframe_init (const struct tramp_frame *self,
-			  frame_info_ptr this_frame,
+			  const frame_info_ptr &this_frame,
 			  struct trad_frame_cache *this_cache,
 			  CORE_ADDR func)
 {
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index 877fd94d7df..357866ef953 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -288,7 +288,7 @@ bfin_alloc_frame_cache (void)
 }
 
 static struct bfin_frame_cache *
-bfin_frame_cache (frame_info_ptr this_frame, void **this_cache)
+bfin_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct bfin_frame_cache *cache;
   int i;
@@ -340,7 +340,7 @@ bfin_frame_cache (frame_info_ptr this_frame, void **this_cache)
 }
 
 static void
-bfin_frame_this_id (frame_info_ptr this_frame,
+bfin_frame_this_id (const frame_info_ptr &this_frame,
 		    void **this_cache,
 		    struct frame_id *this_id)
 {
@@ -355,7 +355,7 @@ bfin_frame_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-bfin_frame_prev_register (frame_info_ptr this_frame,
+bfin_frame_prev_register (const frame_info_ptr &this_frame,
 			  void **this_cache,
 			  int regnum)
 {
@@ -724,7 +724,7 @@ bfin_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 }
 
 static CORE_ADDR
-bfin_frame_base_address (frame_info_ptr this_frame, void **this_cache)
+bfin_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct bfin_frame_cache *cache = bfin_frame_cache (this_frame, this_cache);
 
@@ -732,7 +732,7 @@ bfin_frame_base_address (frame_info_ptr this_frame, void **this_cache)
 }
 
 static CORE_ADDR
-bfin_frame_local_address (frame_info_ptr this_frame, void **this_cache)
+bfin_frame_local_address (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct bfin_frame_cache *cache = bfin_frame_cache (this_frame, this_cache);
 
@@ -740,7 +740,7 @@ bfin_frame_local_address (frame_info_ptr this_frame, void **this_cache)
 }
 
 static CORE_ADDR
-bfin_frame_args_address (frame_info_ptr this_frame, void **this_cache)
+bfin_frame_args_address (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct bfin_frame_cache *cache = bfin_frame_cache (this_frame, this_cache);
 
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 6076ad64a4a..451818332de 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -52,7 +52,7 @@
    slot instruction.  */
 
 const struct block *
-get_frame_block (frame_info_ptr frame, CORE_ADDR *addr_in_block)
+get_frame_block (const frame_info_ptr &frame, CORE_ADDR *addr_in_block)
 {
   CORE_ADDR pc;
   const struct block *bl;
@@ -115,7 +115,7 @@ get_pc_function_start (CORE_ADDR pc)
 /* Return the symbol for the function executing in frame FRAME.  */
 
 struct symbol *
-get_frame_function (frame_info_ptr frame)
+get_frame_function (const frame_info_ptr &frame)
 {
   const struct block *bl = get_frame_block (frame, 0);
 
diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c
index 4409a1e696c..1b3f3e72c5b 100644
--- a/gdb/bpf-tdep.c
+++ b/gdb/bpf-tdep.c
@@ -154,7 +154,7 @@ bpf_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 /* Given THIS_FRAME, return its ID.  */
 
 static void
-bpf_frame_this_id (frame_info_ptr this_frame,
+bpf_frame_this_id (const frame_info_ptr &this_frame,
 		   void **this_prologue_cache,
 		   struct frame_id *this_id)
 {
@@ -165,7 +165,7 @@ bpf_frame_this_id (frame_info_ptr this_frame,
 /* Return the reason why we can't unwind past THIS_FRAME.  */
 
 static enum unwind_stop_reason
-bpf_frame_unwind_stop_reason (frame_info_ptr this_frame,
+bpf_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
 			      void **this_cache)
 {
   return UNWIND_OUTERMOST;
@@ -174,7 +174,7 @@ bpf_frame_unwind_stop_reason (frame_info_ptr this_frame,
 /* Ask THIS_FRAME to unwind its register.  */
 
 static struct value *
-bpf_frame_prev_register (frame_info_ptr this_frame,
+bpf_frame_prev_register (const frame_info_ptr &this_frame,
 			 void **this_prologue_cache, int regnum)
 {
   return frame_unwind_got_register (this_frame, regnum, regnum);
@@ -235,7 +235,7 @@ bpf_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 /* Assuming THIS_FRAME is a dummy frame, return its frame ID.  */
 
 static struct frame_id
-bpf_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
+bpf_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
 {
   CORE_ADDR sp = get_frame_register_unsigned (this_frame,
 					      gdbarch_sp_regnum (gdbarch));
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index a6de59bf292..882c1a03fe2 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -153,7 +153,7 @@ cplus_make_method_ptr (struct type *type, gdb_byte *contents,
 }
 
 CORE_ADDR
-cplus_skip_trampoline (frame_info_ptr frame,
+cplus_skip_trampoline (const frame_info_ptr &frame,
 		       CORE_ADDR stop_pc)
 {
   if (current_cp_abi.skip_trampoline == NULL)
diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h
index a993e1dd18a..fdbe4843129 100644
--- a/gdb/cp-abi.h
+++ b/gdb/cp-abi.h
@@ -204,7 +204,7 @@ extern std::string cplus_typename_from_type_info (struct value *value);
    address of the routine we are thunking to and continue to there
    instead.  */
 
-CORE_ADDR cplus_skip_trampoline (frame_info_ptr frame,
+CORE_ADDR cplus_skip_trampoline (const frame_info_ptr &frame,
 				 CORE_ADDR stop_pc);
 
 /* Return a struct that provides pass-by-reference information
@@ -247,7 +247,7 @@ struct cp_abi_ops
   struct type *(*get_typeid_type) (struct gdbarch *gdbarch);
   struct type *(*get_type_from_type_info) (struct value *value);
   std::string (*get_typename_from_type_info) (struct value *value);
-  CORE_ADDR (*skip_trampoline) (frame_info_ptr, CORE_ADDR);
+  CORE_ADDR (*skip_trampoline) (const frame_info_ptr &, CORE_ADDR);
   struct language_pass_by_ref_info (*pass_by_reference) (struct type *type);
 };
 
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 1f108740ad2..02c35da723d 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -193,7 +193,7 @@ static const unsigned short rt_sigtramp_code[] =
    the routine.  Otherwise, return 0.  */
 
 static CORE_ADDR
-cris_sigtramp_start (frame_info_ptr this_frame)
+cris_sigtramp_start (const frame_info_ptr &this_frame)
 {
   CORE_ADDR pc = get_frame_pc (this_frame);
   gdb_byte buf[SIGTRAMP_LEN];
@@ -221,7 +221,7 @@ cris_sigtramp_start (frame_info_ptr this_frame)
    the routine.  Otherwise, return 0.  */
 
 static CORE_ADDR
-cris_rt_sigtramp_start (frame_info_ptr this_frame)
+cris_rt_sigtramp_start (const frame_info_ptr &this_frame)
 {
   CORE_ADDR pc = get_frame_pc (this_frame);
   gdb_byte buf[SIGTRAMP_LEN];
@@ -249,7 +249,7 @@ cris_rt_sigtramp_start (frame_info_ptr this_frame)
    return the address of the associated sigcontext structure.  */
 
 static CORE_ADDR
-cris_sigcontext_addr (frame_info_ptr this_frame)
+cris_sigcontext_addr (const frame_info_ptr &this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -309,7 +309,7 @@ struct cris_unwind_cache
 };
 
 static struct cris_unwind_cache *
-cris_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
+cris_sigtramp_frame_unwind_cache (const frame_info_ptr &this_frame,
 				  void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -402,7 +402,7 @@ cris_sigtramp_frame_unwind_cache (frame_info_ptr this_frame,
 }
 
 static void
-cris_sigtramp_frame_this_id (frame_info_ptr this_frame, void **this_cache,
+cris_sigtramp_frame_this_id (const frame_info_ptr &this_frame, void **this_cache,
 			     struct frame_id *this_id)
 {
   struct cris_unwind_cache *cache =
@@ -412,10 +412,10 @@ cris_sigtramp_frame_this_id (frame_info_ptr this_frame, void **this_cache,
 
 /* Forward declaration.  */
 
-static struct value *cris_frame_prev_register (frame_info_ptr this_frame,
+static struct value *cris_frame_prev_register (const frame_info_ptr &this_frame,
 					       void **this_cache, int regnum);
 static struct value *
-cris_sigtramp_frame_prev_register (frame_info_ptr this_frame,
+cris_sigtramp_frame_prev_register (const frame_info_ptr &this_frame,
 				   void **this_cache, int regnum)
 {
   /* Make sure we've initialized the cache.  */
@@ -425,7 +425,7 @@ cris_sigtramp_frame_prev_register (frame_info_ptr this_frame,
 
 static int
 cris_sigtramp_frame_sniffer (const struct frame_unwind *self,
-			     frame_info_ptr this_frame,
+			     const frame_info_ptr &this_frame,
 			     void **this_cache)
 {
   if (cris_sigtramp_start (this_frame) 
@@ -448,7 +448,7 @@ static const struct frame_unwind cris_sigtramp_frame_unwind =
 
 static int
 crisv32_single_step_through_delay (struct gdbarch *gdbarch,
-				   frame_info_ptr this_frame)
+				   const frame_info_ptr &this_frame)
 {
   cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
   ULONGEST erp;
@@ -645,11 +645,11 @@ static void set_cris_dwarf2_cfi (const char *ignore_args, int from_tty,
 				 struct cmd_list_element *c);
 
 static CORE_ADDR cris_scan_prologue (CORE_ADDR pc, 
-				     frame_info_ptr this_frame,
+				     const frame_info_ptr &this_frame,
 				     struct cris_unwind_cache *info);
 
 static CORE_ADDR crisv32_scan_prologue (CORE_ADDR pc, 
-					frame_info_ptr this_frame,
+					const frame_info_ptr &this_frame,
 					struct cris_unwind_cache *info);
 
 /* When arguments must be pushed onto the stack, they go on in reverse
@@ -692,7 +692,7 @@ pop_stack_item (struct cris_stack_item *si)
    for it IS the sp for the next frame.  */
 
 static struct cris_unwind_cache *
-cris_frame_unwind_cache (frame_info_ptr this_frame,
+cris_frame_unwind_cache (const frame_info_ptr &this_frame,
 			 void **this_prologue_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -729,7 +729,7 @@ cris_frame_unwind_cache (frame_info_ptr this_frame,
    frame.  This will be used to create a new GDB frame struct.  */
 
 static void
-cris_frame_this_id (frame_info_ptr this_frame,
+cris_frame_this_id (const frame_info_ptr &this_frame,
 		    void **this_prologue_cache,
 		    struct frame_id *this_id)
 {
@@ -755,7 +755,7 @@ cris_frame_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-cris_frame_prev_register (frame_info_ptr this_frame,
+cris_frame_prev_register (const frame_info_ptr &this_frame,
 			  void **this_prologue_cache, int regnum)
 {
   struct cris_unwind_cache *info
@@ -912,7 +912,7 @@ static const struct frame_unwind cris_frame_unwind =
 };
 
 static CORE_ADDR
-cris_frame_base_address (frame_info_ptr this_frame, void **this_cache)
+cris_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct cris_unwind_cache *info
     = cris_frame_unwind_cache (this_frame, this_cache);
@@ -1004,7 +1004,7 @@ static const struct frame_base cris_frame_base =
    determine that it is a prologue (1).  */
 
 static CORE_ADDR 
-cris_scan_prologue (CORE_ADDR pc, frame_info_ptr this_frame,
+cris_scan_prologue (CORE_ADDR pc, const frame_info_ptr &this_frame,
 		    struct cris_unwind_cache *info)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -1287,7 +1287,7 @@ cris_scan_prologue (CORE_ADDR pc, frame_info_ptr this_frame,
 }
 
 static CORE_ADDR 
-crisv32_scan_prologue (CORE_ADDR pc, frame_info_ptr this_frame,
+crisv32_scan_prologue (CORE_ADDR pc, const frame_info_ptr &this_frame,
 		    struct cris_unwind_cache *info)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
@@ -1756,7 +1756,7 @@ cris_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 static void
 cris_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 			    struct dwarf2_frame_state_reg *reg,
-			    frame_info_ptr this_frame)
+			    const frame_info_ptr &this_frame)
 {
   /* The return address column.  */
   if (regnum == gdbarch_pc_regnum (gdbarch))
diff --git a/gdb/csky-linux-tdep.c b/gdb/csky-linux-tdep.c
index d3105dc5475..d485f176317 100644
--- a/gdb/csky-linux-tdep.c
+++ b/gdb/csky-linux-tdep.c
@@ -310,7 +310,7 @@ csky_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 
 static void
 csky_linux_rt_sigreturn_init (const struct tramp_frame *self,
-			      frame_info_ptr this_frame,
+			      const frame_info_ptr &this_frame,
 			      struct trad_frame_cache *this_cache,
 			      CORE_ADDR func)
 {
@@ -355,7 +355,7 @@ csky_linux_rt_sigreturn_tramp_frame = {
 
 static void
 csky_linux_rt_sigreturn_init_pt_regs (const struct tramp_frame *self,
-				      frame_info_ptr this_frame,
+				      const frame_info_ptr &this_frame,
 				      struct trad_frame_cache *this_cache,
 				      CORE_ADDR func)
 {
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index 2aa6c0abcb8..c1ce8a5b02c 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -958,7 +958,7 @@ csky_analyze_prologue (struct gdbarch *gdbarch,
 		       CORE_ADDR start_pc,
 		       CORE_ADDR limit_pc,
 		       CORE_ADDR end_pc,
-		       frame_info_ptr this_frame,
+		       const frame_info_ptr &this_frame,
 		       struct csky_unwind_cache *this_cache,
 		       lr_type_t lr_type)
 {
@@ -2063,7 +2063,7 @@ csky_analyze_lr_type (struct gdbarch *gdbarch,
 /* Heuristic unwinder.  */
 
 static struct csky_unwind_cache *
-csky_frame_unwind_cache (frame_info_ptr this_frame)
+csky_frame_unwind_cache (const frame_info_ptr &this_frame)
 {
   CORE_ADDR prologue_start, prologue_end, func_end, prev_pc, block_addr;
   struct csky_unwind_cache *cache;
@@ -2122,7 +2122,7 @@ csky_frame_unwind_cache (frame_info_ptr this_frame)
 /* Implement the this_id function for the normal unwinder.  */
 
 static void
-csky_frame_this_id (frame_info_ptr this_frame,
+csky_frame_this_id (const frame_info_ptr &this_frame,
 		    void **this_prologue_cache, struct frame_id *this_id)
 {
   struct csky_unwind_cache *cache;
@@ -2143,7 +2143,7 @@ csky_frame_this_id (frame_info_ptr this_frame,
 /* Implement the prev_register function for the normal unwinder.  */
 
 static struct value *
-csky_frame_prev_register (frame_info_ptr this_frame,
+csky_frame_prev_register (const frame_info_ptr &this_frame,
 			  void **this_prologue_cache, int regnum)
 {
   struct csky_unwind_cache *cache;
@@ -2172,7 +2172,7 @@ static const struct frame_unwind csky_unwind_cache = {
 };
 
 static CORE_ADDR
-csky_check_long_branch (frame_info_ptr frame, CORE_ADDR pc)
+csky_check_long_branch (const frame_info_ptr &frame, CORE_ADDR pc)
 {
   gdb_byte buf[8];
   struct gdbarch *gdbarch = get_frame_arch (frame);
@@ -2209,7 +2209,7 @@ csky_check_long_branch (frame_info_ptr frame, CORE_ADDR pc)
 
 static int
 csky_stub_unwind_sniffer (const struct frame_unwind *self,
-			  frame_info_ptr this_frame,
+			  const frame_info_ptr &this_frame,
 			  void **this_prologue_cache)
 {
   CORE_ADDR addr_in_block, pc;
@@ -2240,7 +2240,7 @@ csky_stub_unwind_sniffer (const struct frame_unwind *self,
 }
 
 static struct csky_unwind_cache *
-csky_make_stub_cache (frame_info_ptr this_frame)
+csky_make_stub_cache (const frame_info_ptr &this_frame)
 {
   struct csky_unwind_cache *cache;
 
@@ -2252,7 +2252,7 @@ csky_make_stub_cache (frame_info_ptr this_frame)
 }
 
 static void
-csky_stub_this_id (frame_info_ptr this_frame,
+csky_stub_this_id (const frame_info_ptr &this_frame,
 		  void **this_cache,
 		  struct frame_id *this_id)
 {
@@ -2267,7 +2267,7 @@ csky_stub_this_id (frame_info_ptr this_frame,
 }
 
 static struct value *
-csky_stub_prev_register (frame_info_ptr this_frame,
+csky_stub_prev_register (const frame_info_ptr &this_frame,
 			    void **this_cache,
 			    int prev_regnum)
 {
@@ -2307,7 +2307,7 @@ static frame_unwind csky_stub_unwind = {
    for the normal unwinder.  */
 
 static CORE_ADDR
-csky_frame_base_address (frame_info_ptr this_frame, void **this_cache)
+csky_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
 {
   struct csky_unwind_cache *cache;
 
@@ -2330,7 +2330,7 @@ static const struct frame_base csky_frame_base = {
 static void
 csky_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 			    struct dwarf2_frame_state_reg *reg,
-			    frame_info_ptr this_frame)
+			    const frame_info_ptr &this_frame)
 {
   if (regnum == gdbarch_pc_regnum (gdbarch))
     reg->how = DWARF2_FRAME_REG_RA;
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index 8bde53ea8fd..5757de1cf77 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -129,7 +129,7 @@ public:
 
   /* See probe.h.  */
   struct value *evaluate_argument (unsigned n,
-				   frame_info_ptr frame) override;
+				   const frame_info_ptr &frame) override;
 
   /* See probe.h.  */
   void compile_to_ax (struct agent_expr *aexpr,
@@ -708,7 +708,7 @@ dtrace_probe::can_evaluate_arguments () const
 
 struct value *
 dtrace_probe::evaluate_argument (unsigned n,
-				 frame_info_ptr frame)
+				 const frame_info_ptr &frame)
 {
   struct gdbarch *gdbarch = this->get_gdbarch ();
   struct dtrace_probe_arg *arg;
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
index 309483d95d4..5969ef2cdad 100644
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -288,7 +288,7 @@ struct dummy_frame_cache
 
 static int
 dummy_frame_sniffer (const struct frame_unwind *self,
-		     frame_info_ptr this_frame,
+		     const frame_info_ptr &this_frame,
 		     void **this_prologue_cache)
 {
   /* When unwinding a normal frame, the stack structure is determined
@@ -334,7 +334,7 @@ dummy_frame_sniffer (const struct frame_unwind *self,
    register value is taken from the local copy of the register buffer.  */
 
 static struct value *
-dummy_frame_prev_register (frame_info_ptr this_frame,
+dummy_frame_prev_register (const frame_info_ptr &this_frame,
 			   void **this_prologue_cache,
 			   int regnum)
 {
@@ -364,7 +364,7 @@ dummy_frame_prev_register (frame_info_ptr this_frame,
    dummy cache is located and saved in THIS_PROLOGUE_CACHE.  */
 
 static void
-dummy_frame_this_id (frame_info_ptr this_frame,
+dummy_frame_this_id (const frame_info_ptr &this_frame,
 		     void **this_prologue_cache,
 		     struct frame_id *this_id)
 {
@@ -390,7 +390,7 @@ const struct frame_unwind dummy_frame_unwind =
 /* See dummy-frame.h.  */
 
 struct frame_id
-default_dummy_id (struct gdbarch *gdbarch, frame_info_ptr this_frame)
+default_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame)
 {
   CORE_ADDR sp, pc;
 
diff --git a/gdb/dummy-frame.h b/gdb/dummy-frame.h
index 753be1aa54c..7d963ad9beb 100644
--- a/gdb/dummy-frame.h
+++ b/gdb/dummy-frame.h
@@ -78,6 +78,6 @@ extern int find_dummy_frame_dtor (dummy_frame_dtor_ftype *dtor,
    for THIS_FRAME assuming that the frame is a dummy frame.  */
 
 extern struct frame_id default_dummy_id (struct gdbarch *gdbarch,
-					 frame_info_ptr this_frame);
+					 const frame_info_ptr &this_frame);
 
 #endif /* !defined (DUMMY_FRAME_H)  */
diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c
index 1a0bc1d528e..065e2b90a0f 100644
--- a/gdb/dwarf2/ada-imported.c
+++ b/gdb/dwarf2/ada-imported.c
@@ -32,7 +32,7 @@ get_imported_name (const struct symbol *sym)
 /* Implement the read_variable method from symbol_computed_ops.  */
 
 static struct value *
-ada_imported_read_variable (struct symbol *symbol, frame_info_ptr frame)
+ada_imported_read_variable (struct symbol *symbol, const frame_info_ptr &frame)
 {
   const char *name = get_imported_name (symbol);
   bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (name, false);
diff --git a/gdb/dwarf2/call-site.h b/gdb/dwarf2/call-site.h
index 5434c845260..0a0c7e83b81 100644
--- a/gdb/dwarf2/call-site.h
+++ b/gdb/dwarf2/call-site.h
@@ -94,7 +94,7 @@ struct call_site_target
 
   void iterate_over_addresses (struct gdbarch *call_site_gdbarch,
 			       const struct call_site *call_site,
-			       frame_info_ptr caller_frame,
+			       const frame_info_ptr &caller_frame,
 			       iterate_ftype callback) const;
 
 private:
@@ -201,7 +201,7 @@ struct call_site
      throw NO_ENTRY_VALUE_ERROR.  */
 
   void iterate_over_addresses (struct gdbarch *call_site_gdbarch,
-			       frame_info_ptr caller_frame,
+			       const frame_info_ptr &caller_frame,
 			       call_site_target::iterate_ftype callback)
     const
   {
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 9cfae104f31..d0256e7009d 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -49,7 +49,7 @@ static const registry<gdbarch>::key<dwarf_gdbarch_types> dwarf_arch_cookie;
 /* Ensure that a FRAME is defined, throw an exception otherwise.  */
 
 static void
-ensure_have_frame (frame_info_ptr frame, const char *op_name)
+ensure_have_frame (const frame_info_ptr &frame, const char *op_name)
 {
   if (frame == nullptr)
     throw_error (GENERIC_ERROR,
@@ -78,7 +78,7 @@ bits_to_bytes (ULONGEST start, ULONGEST n_bits)
 /* See expr.h.  */
 
 CORE_ADDR
-read_addr_from_reg (frame_info_ptr frame, int reg)
+read_addr_from_reg (const frame_info_ptr &frame, int reg)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   int regnum = dwarf_reg_to_regnum_or_error (gdbarch, reg);
@@ -112,7 +112,7 @@ static piece_closure *
 allocate_piece_closure (dwarf2_per_cu_data *per_cu,
 			dwarf2_per_objfile *per_objfile,
 			std::vector<dwarf_expr_piece> &&pieces,
-			frame_info_ptr frame)
+			const frame_info_ptr &frame)
 {
   piece_closure *c = new piece_closure;
 
@@ -1076,7 +1076,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
 
 value *
 dwarf_expr_context::evaluate (const gdb_byte *addr, size_t len, bool as_lval,
-			      dwarf2_per_cu_data *per_cu, frame_info_ptr frame,
+			      dwarf2_per_cu_data *per_cu, const frame_info_ptr &frame,
 			      const struct property_addr_info *addr_info,
 			      struct type *type, struct type *subobj_type,
 			      LONGEST subobj_offset)
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index 6acd07811f8..b02cc531640 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -137,7 +137,7 @@ struct dwarf_expr_context
      The ADDR_INFO property can be specified to override the range of
      memory addresses with the passed in buffer.  */
   value *evaluate (const gdb_byte *addr, size_t len, bool as_lval,
-		   dwarf2_per_cu_data *per_cu, frame_info_ptr frame,
[...]

[diff truncated at 100000 bytes]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-20 15:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 15:45 [binutils-gdb] gdb: pass frames as `const frame_info_ptr &` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).