*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / frame.c
index 67ef967dd98dd8a418ccfe73e2dc08653e709936..36fcefe6f7b7b5eff0e3e982855a95e2cffb7652 100644 (file)
@@ -1,7 +1,8 @@
 /* Cache and manage frames for GDB, the GNU debugger.
 
    Copyright (C) 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000, 2001,
-   2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -43,6 +44,7 @@
 #include "gdbthread.h"
 #include "block.h"
 #include "inline-frame.h"
+#include  "tracepoint.h"
 
 static struct frame_info *get_prev_frame_1 (struct frame_info *this_frame);
 static struct frame_info *get_prev_frame_raw (struct frame_info *this_frame);
@@ -70,6 +72,12 @@ struct frame_info
      moment leave this as speculation.  */
   int level;
 
+  /* The frame's program space.  */
+  struct program_space *pspace;
+
+  /* The frame's address space.  */
+  struct address_space *aspace;
+
   /* The frame's low-level unwinder and corresponding cache.  The
      low-level unwinder is responsible for unwinding register values
      for the previous frame.  The low-level unwind methods are
@@ -122,6 +130,40 @@ struct frame_info
   enum unwind_stop_reason stop_reason;
 };
 
+/* A frame stash used to speed up frame lookups.  */
+
+/* We currently only stash one frame at a time, as this seems to be
+   sufficient for now.  */
+static struct frame_info *frame_stash = NULL;
+
+/* Add the following FRAME to the frame stash.  */
+
+static void
+frame_stash_add (struct frame_info *frame)
+{
+  frame_stash = frame;
+}
+
+/* Search the frame stash for an entry with the given frame ID.
+   If found, return that frame.  Otherwise return NULL.  */
+
+static struct frame_info *
+frame_stash_find (struct frame_id id)
+{
+  if (frame_stash && frame_id_eq (frame_stash->this_id.value, id))
+    return frame_stash;
+
+  return NULL;
+}
+
+/* Invalidate the frame stash by removing all entries in it.  */
+
+static void
+frame_stash_invalidate (void)
+{
+  frame_stash = NULL;
+}
+
 /* Flag to control debugging.  */
 
 int frame_debug;
@@ -139,8 +181,9 @@ static void
 show_backtrace_past_main (struct ui_file *file, int from_tty,
                          struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("\
-Whether backtraces should continue past \"main\" is %s.\n"),
+  fprintf_filtered (file,
+                   _("Whether backtraces should "
+                     "continue past \"main\" is %s.\n"),
                    value);
 }
 
@@ -149,8 +192,8 @@ static void
 show_backtrace_past_entry (struct ui_file *file, int from_tty,
                           struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("\
-Whether backtraces should continue past the entry point of a program is %s.\n"),
+  fprintf_filtered (file, _("Whether backtraces should continue past the "
+                           "entry point of a program is %s.\n"),
                    value);
 }
 
@@ -159,8 +202,9 @@ static void
 show_backtrace_limit (struct ui_file *file, int from_tty,
                      struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("\
-An upper bound on the number of backtrace levels is %s.\n"),
+  fprintf_filtered (file,
+                   _("An upper bound on the number "
+                     "of backtrace levels is %s.\n"),
                    value);
 }
 
@@ -279,9 +323,8 @@ struct frame_id
 get_frame_id (struct frame_info *fi)
 {
   if (fi == NULL)
-    {
-      return null_frame_id;
-    }
+    return null_frame_id;
+
   if (!fi->this_id.p)
     {
       if (frame_debug)
@@ -289,9 +332,12 @@ get_frame_id (struct frame_info *fi)
                            fi->level);
       /* Find the unwinder.  */
       if (fi->unwind == NULL)
-       fi->unwind = frame_unwind_find_by_frame (fi, &fi->prologue_cache);
+       frame_unwind_find_by_frame (fi, &fi->prologue_cache);
       /* Find THIS frame's ID.  */
+      /* Default to outermost if no ID is found.  */
+      fi->this_id.value = outer_frame_id;
       fi->unwind->this_id (fi, &fi->prologue_cache, &fi->this_id.value);
+      gdb_assert (frame_id_p (fi->this_id.value));
       fi->this_id.p = 1;
       if (frame_debug)
        {
@@ -300,6 +346,9 @@ get_frame_id (struct frame_info *fi)
          fprintf_unfiltered (gdb_stdlog, " }\n");
        }
     }
+
+  frame_stash_add (fi);
+
   return fi->this_id.value;
 }
 
@@ -328,12 +377,14 @@ frame_unwind_caller_id (struct frame_info *next_frame)
 }
 
 const struct frame_id null_frame_id; /* All zeros.  */
+const struct frame_id outer_frame_id = { 0, 0, 0, 0, 0, 1, 0 };
 
 struct frame_id
 frame_id_build_special (CORE_ADDR stack_addr, CORE_ADDR code_addr,
                         CORE_ADDR special_addr)
 {
   struct frame_id id = null_frame_id;
+
   id.stack_addr = stack_addr;
   id.stack_addr_p = 1;
   id.code_addr = code_addr;
@@ -347,6 +398,7 @@ struct frame_id
 frame_id_build (CORE_ADDR stack_addr, CORE_ADDR code_addr)
 {
   struct frame_id id = null_frame_id;
+
   id.stack_addr = stack_addr;
   id.stack_addr_p = 1;
   id.code_addr = code_addr;
@@ -358,6 +410,7 @@ struct frame_id
 frame_id_build_wild (CORE_ADDR stack_addr)
 {
   struct frame_id id = null_frame_id;
+
   id.stack_addr = stack_addr;
   id.stack_addr_p = 1;
   return id;
@@ -367,8 +420,12 @@ int
 frame_id_p (struct frame_id l)
 {
   int p;
+
   /* The frame is valid iff it has a valid stack address.  */
   p = l.stack_addr_p;
+  /* outer_frame_id is also valid.  */
+  if (!p && memcmp (&l, &outer_frame_id, sizeof (l)) == 0)
+    p = 1;
   if (frame_debug)
     {
       fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l=");
@@ -391,7 +448,16 @@ int
 frame_id_eq (struct frame_id l, struct frame_id r)
 {
   int eq;
-  if (!l.stack_addr_p || !r.stack_addr_p)
+
+  if (!l.stack_addr_p && l.special_addr_p
+      && !r.stack_addr_p && r.special_addr_p)
+    /* The outermost frame marker is equal to itself.  This is the
+       dodgy thing about outer_frame_id, since between execution steps
+       we might step into another function - from which we can't
+       unwind either.  More thought required to get rid of
+       outer_frame_id.  */
+    eq = 1;
+  else if (!l.stack_addr_p || !r.stack_addr_p)
     /* Like a NaN, if either ID is invalid, the result is false.
        Note that a frame ID is invalid iff it is the null frame ID.  */
     eq = 0;
@@ -433,7 +499,7 @@ frame_id_eq (struct frame_id l, struct frame_id r)
    to sigaltstack).
 
    However, it can be used as safety net to discover invalid frame
-   IDs in certain circumstances. Assuming that NEXT is the immediate
+   IDs in certain circumstances.  Assuming that NEXT is the immediate
    inner frame to THIS and that NEXT and THIS are both NORMAL frames:
 
    * The stack address of NEXT must be inner-than-or-equal to the stack
@@ -453,7 +519,7 @@ frame_id_eq (struct frame_id l, struct frame_id r)
    is involved, because signal handlers might be executed on a different
    stack than the stack used by the routine that caused the signal
    to be raised.  This can happen for instance when a thread exceeds
-   its maximum stack size. In this case, certain compilers implement
+   its maximum stack size.  In this case, certain compilers implement
    a stack overflow strategy that cause the handler to be run on a
    different stack.  */
 
@@ -461,6 +527,7 @@ static int
 frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
 {
   int inner;
+
   if (!l.stack_addr_p || !r.stack_addr_p)
     /* Like NaN, any operation involving an invalid ID always fails.  */
     inner = 0;
@@ -514,9 +581,22 @@ frame_find_by_id (struct frame_id id)
   if (!frame_id_p (id))
     return NULL;
 
+  /* Try using the frame stash first.  Finding it there removes the need
+     to perform the search by looping over all frames, which can be very
+     CPU-intensive if the number of frames is very high (the loop is O(n)
+     and get_prev_frame performs a series of checks that are relatively
+     expensive).  This optimization is particularly useful when this function
+     is called from another function (such as value_fetch_lazy, case
+     VALUE_LVAL (val) == lval_register) which already loops over all frames,
+     making the overall behavior O(n^2).  */
+  frame = frame_stash_find (id);
+  if (frame)
+    return frame;
+
   for (frame = get_current_frame (); ; frame = prev_frame)
     {
       struct frame_id this = get_frame_id (frame);
+
       if (frame_id_eq (id, this))
        /* An exact match.  */
        return frame;
@@ -545,6 +625,7 @@ frame_unwind_pc (struct frame_info *this_frame)
   if (!this_frame->prev_pc.p)
     {
       CORE_ADDR pc;
+
       if (gdbarch_unwind_pc_p (frame_unwind_arch (this_frame)))
        {
          /* The right way.  The `pure' way.  The one true way.  This
@@ -571,7 +652,8 @@ frame_unwind_pc (struct frame_info *this_frame)
       this_frame->prev_pc.p = 1;
       if (frame_debug)
        fprintf_unfiltered (gdb_stdlog,
-                           "{ frame_unwind_caller_pc (this_frame=%d) -> 0x%s }\n",
+                           "{ frame_unwind_caller_pc "
+                           "(this_frame=%d) -> %s }\n",
                            this_frame->level,
                            hex_string (this_frame->prev_pc.value));
     }
@@ -614,8 +696,11 @@ do_frame_register_read (void *src, int regnum, gdb_byte *buf)
 struct regcache *
 frame_save_as_regcache (struct frame_info *this_frame)
 {
-  struct regcache *regcache = regcache_xmalloc (get_frame_arch (this_frame));
+  struct address_space *aspace = get_frame_address_space (this_frame);
+  struct regcache *regcache = regcache_xmalloc (get_frame_arch (this_frame),
+                                               aspace);
   struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
+
   regcache_save (regcache, do_frame_register_read, this_frame);
   discard_cleanups (cleanups);
   return regcache;
@@ -691,7 +776,7 @@ frame_register_unwind (struct frame_info *frame, int regnum,
   *addrp = value_address (value);
   *realnump = VALUE_REGNUM (value);
 
-  if (bufferp)
+  if (bufferp && !*optimizedp)
     memcpy (bufferp, value_contents_all (value),
            TYPE_LENGTH (value_type (value)));
 
@@ -728,6 +813,7 @@ frame_unwind_register (struct frame_info *frame, int regnum, gdb_byte *buf)
   CORE_ADDR addr;
   int realnum;
   enum lval_type lval;
+
   frame_register_unwind (frame, regnum, &optimized, &lval, &addr,
                         &realnum, buf);
 }
@@ -750,15 +836,16 @@ frame_unwind_register_value (struct frame_info *frame, int regnum)
 
   if (frame_debug)
     {
-      fprintf_unfiltered (gdb_stdlog, "\
-{ frame_unwind_register_value (frame=%d,regnum=%d(%s),...) ",
+      fprintf_unfiltered (gdb_stdlog,
+                         "{ frame_unwind_register_value "
+                         "(frame=%d,regnum=%d(%s),...) ",
                          frame->level, regnum,
                          user_reg_map_regnum_to_name (gdbarch, regnum));
     }
 
   /* Find the unwinder.  */
   if (frame->unwind == NULL)
-    frame->unwind = frame_unwind_find_by_frame (frame, &frame->prologue_cache);
+    frame_unwind_find_by_frame (frame, &frame->prologue_cache);
 
   /* Ask this frame to unwind its register.  */
   value = frame->unwind->prev_register (frame, &frame->prologue_cache, regnum);
@@ -814,6 +901,7 @@ frame_unwind_register_signed (struct frame_info *frame, int regnum)
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int size = register_size (gdbarch, regnum);
   gdb_byte buf[MAX_REGISTER_SIZE];
+
   frame_unwind_register (frame, regnum, buf);
   return extract_signed_integer (buf, size, byte_order);
 }
@@ -831,6 +919,7 @@ frame_unwind_register_unsigned (struct frame_info *frame, int regnum)
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int size = register_size (gdbarch, regnum);
   gdb_byte buf[MAX_REGISTER_SIZE];
+
   frame_unwind_register (frame, regnum, buf);
   return extract_unsigned_integer (buf, size, byte_order);
 }
@@ -850,6 +939,7 @@ put_frame_register (struct frame_info *frame, int regnum,
   int optim;
   enum lval_type lval;
   CORE_ADDR addr;
+
   frame_register (frame, regnum, &optim, &lval, &addr, &realnum, NULL);
   if (optim)
     error (_("Attempt to assign to a value that was optimized out."));
@@ -860,6 +950,7 @@ put_frame_register (struct frame_info *frame, int regnum,
        /* FIXME: write_memory doesn't yet take constant buffers.
            Arrrg!  */
        gdb_byte tmp[MAX_REGISTER_SIZE];
+
        memcpy (tmp, buf, register_size (gdbarch, regnum));
        write_memory (addr, tmp, register_size (gdbarch, regnum));
        break;
@@ -887,6 +978,7 @@ frame_register_read (struct frame_info *frame, int regnum,
   enum lval_type lval;
   CORE_ADDR addr;
   int realnum;
+
   frame_register (frame, regnum, &optimized, &lval, &addr, &realnum, myaddr);
 
   return !optimized;
@@ -915,6 +1007,7 @@ get_frame_register_bytes (struct frame_info *frame, int regnum,
   for (i = regnum; i < numregs; i++)
     {
       int thissize = register_size (gdbarch, i);
+
       if (thissize == 0)
        break;  /* This register is not available on this architecture.  */
       maxsize += thissize;
@@ -930,6 +1023,7 @@ get_frame_register_bytes (struct frame_info *frame, int regnum,
   while (len > 0)
     {
       int curr_len = register_size (gdbarch, regnum) - offset;
+
       if (curr_len > len)
        curr_len = len;
 
@@ -941,6 +1035,7 @@ get_frame_register_bytes (struct frame_info *frame, int regnum,
       else
        {
          gdb_byte buf[MAX_REGISTER_SIZE];
+
          if (!frame_register_read (frame, regnum, buf))
            return 0;
          memcpy (myaddr, buf + offset, curr_len);
@@ -972,6 +1067,7 @@ put_frame_register_bytes (struct frame_info *frame, int regnum,
   while (len > 0)
     {
       int curr_len = register_size (gdbarch, regnum) - offset;
+
       if (curr_len > len)
        curr_len = len;
 
@@ -982,6 +1078,7 @@ put_frame_register_bytes (struct frame_info *frame, int regnum,
       else
        {
          gdb_byte buf[MAX_REGISTER_SIZE];
+
          frame_register_read (frame, regnum, buf);
          memcpy (buf + offset, myaddr, curr_len);
          put_frame_register (frame, regnum, buf);
@@ -997,16 +1094,19 @@ put_frame_register_bytes (struct frame_info *frame, int regnum,
 /* Create a sentinel frame.  */
 
 static struct frame_info *
-create_sentinel_frame (struct regcache *regcache)
+create_sentinel_frame (struct program_space *pspace, struct regcache *regcache)
 {
   struct frame_info *frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
+
   frame->level = -1;
+  frame->pspace = pspace;
+  frame->aspace = get_regcache_aspace (regcache);
   /* Explicitly initialize the sentinel frame's cache.  Provide it
      with the underlying regcache.  In the future additional
      information, such as the frame's thread will be added.  */
   frame->prologue_cache = sentinel_frame_cache (regcache);
   /* For the moment there is only one sentinel frame implementation.  */
-  frame->unwind = sentinel_frame_unwind;
+  frame->unwind = &sentinel_frame_unwind;
   /* Link this frame back to itself.  The frame is self referential
      (the unwound PC is the same as the pc), so make it so.  */
   frame->next = frame;
@@ -1023,7 +1123,7 @@ create_sentinel_frame (struct regcache *regcache)
   return frame;
 }
 
-/* Info about the innermost stack frame (contents of FP register) */
+/* Info about the innermost stack frame (contents of FP register) */
 
 static struct frame_info *current_frame;
 
@@ -1037,6 +1137,7 @@ void *
 frame_obstack_zalloc (unsigned long size)
 {
   void *data = obstack_alloc (&frame_cache_obstack, size);
+
   memset (data, 0, size);
   return data;
 }
@@ -1050,6 +1151,7 @@ static int
 unwind_to_current_frame (struct ui_out *ui_out, void *args)
 {
   struct frame_info *frame = get_prev_frame (args);
+
   /* A sentinel frame can fail to unwind, e.g., because its PC value
      lands in somewhere like start.  */
   if (frame == NULL)
@@ -1072,17 +1174,21 @@ get_current_frame (void)
     error (_("No stack."));
   if (!target_has_memory)
     error (_("No memory."));
-  if (ptid_equal (inferior_ptid, null_ptid))
-    error (_("No selected thread."));
-  if (is_exited (inferior_ptid))
-    error (_("Invalid selected thread."));
-  if (is_executing (inferior_ptid))
-    error (_("Target is executing."));
+  /* Traceframes are effectively a substitute for the live inferior.  */
+  if (get_traceframe_number () < 0)
+    {
+      if (ptid_equal (inferior_ptid, null_ptid))
+       error (_("No selected thread."));
+      if (is_exited (inferior_ptid))
+       error (_("Invalid selected thread."));
+      if (is_executing (inferior_ptid))
+       error (_("Target is executing."));
+    }
 
   if (current_frame == NULL)
     {
       struct frame_info *sentinel_frame =
-       create_sentinel_frame (get_current_regcache ());
+       create_sentinel_frame (current_program_space, get_current_regcache ());
       if (catch_exceptions (uiout, unwind_to_current_frame, sentinel_frame,
                            RETURN_MASK_ERROR) != 0)
        {
@@ -1173,7 +1279,7 @@ select_frame (struct frame_info *fi)
 
      Once we have frame-parameterized frame (and frame-related) commands,
      the event notification can be moved here, since this function will only
-     be called when the user's selected frame is being changed. */
+     be called when the user's selected frame is being changed.  */
 
   /* Ensure that symbols for this frame are read in.  Also, determine the
      source language of this frame, and switch to it if desired.  */
@@ -1213,7 +1319,8 @@ create_new_frame (CORE_ADDR addr, CORE_ADDR pc)
 
   fi = FRAME_OBSTACK_ZALLOC (struct frame_info);
 
-  fi->next = create_sentinel_frame (get_current_regcache ());
+  fi->next = create_sentinel_frame (current_program_space,
+                                   get_current_regcache ());
 
   /* Set/update this frame's cached PC value, found in the next frame.
      Do this before looking for this frame's unwinder.  A sniffer is
@@ -1222,9 +1329,13 @@ create_new_frame (CORE_ADDR addr, CORE_ADDR pc)
   fi->next->prev_pc.value = pc;
   fi->next->prev_pc.p = 1;
 
+  /* We currently assume that frame chain's can't cross spaces.  */
+  fi->pspace = fi->next->pspace;
+  fi->aspace = fi->next->aspace;
+
   /* Select/initialize both the unwind function and the frame's type
      based on the PC.  */
-  fi->unwind = frame_unwind_find_by_frame (fi, &fi->prologue_cache);
+  frame_unwind_find_by_frame (fi, &fi->prologue_cache);
 
   fi->this_id.p = 1;
   fi->this_id.value = frame_id_build (addr, pc);
@@ -1276,7 +1387,7 @@ reinit_frame_cache (void)
        fi->base->unwind->dealloc_cache (fi, fi->base_cache);
     }
 
-  /* Since we can't really be sure what the first object allocated was */
+  /* Since we can't really be sure what the first object allocated was */
   obstack_free (&frame_cache_obstack, 0);
   obstack_init (&frame_cache_obstack);
 
@@ -1285,6 +1396,7 @@ reinit_frame_cache (void)
 
   current_frame = NULL;                /* Invalidate cache */
   select_frame (NULL);
+  frame_stash_invalidate ();
   if (frame_debug)
     fprintf_unfiltered (gdb_stdlog, "{ reinit_frame_cache () }\n");
 }
@@ -1358,8 +1470,7 @@ get_prev_frame_1 (struct frame_info *this_frame)
      sniffers will think that this frame's sniffer tried to unwind
      further (see frame_cleanup_after_sniffer).  */
   if (this_frame->unwind == NULL)
-    this_frame->unwind
-      = frame_unwind_find_by_frame (this_frame, &this_frame->prologue_cache);
+    frame_unwind_find_by_frame (this_frame, &this_frame->prologue_cache);
 
   this_frame->prev_p = 1;
   this_frame->stop_reason = UNWIND_NO_REASON;
@@ -1376,7 +1487,7 @@ get_prev_frame_1 (struct frame_info *this_frame)
      unwind to the prev frame.  Be careful to not apply this test to
      the sentinel frame.  */
   this_id = get_frame_id (this_frame);
-  if (this_frame->level >= 0 && !frame_id_p (this_id))
+  if (this_frame->level >= 0 && frame_id_eq (this_id, outer_frame_id))
     {
       if (frame_debug)
        {
@@ -1397,14 +1508,27 @@ get_prev_frame_1 (struct frame_info *this_frame)
       && frame_id_inner (get_frame_arch (this_frame->next), this_id,
                         get_frame_id (this_frame->next)))
     {
-      if (frame_debug)
+      CORE_ADDR this_pc_in_block;
+      struct minimal_symbol *morestack_msym;
+      const char *morestack_name = NULL;
+      
+      /* gcc -fsplit-stack __morestack can continue the stack anywhere.  */
+      this_pc_in_block = get_frame_address_in_block (this_frame);
+      morestack_msym = lookup_minimal_symbol_by_pc (this_pc_in_block);
+      if (morestack_msym)
+       morestack_name = SYMBOL_LINKAGE_NAME (morestack_msym);
+      if (!morestack_name || strcmp (morestack_name, "__morestack") != 0)
        {
-         fprintf_unfiltered (gdb_stdlog, "-> ");
-         fprint_frame (gdb_stdlog, NULL);
-         fprintf_unfiltered (gdb_stdlog, " // this frame ID is inner }\n");
+         if (frame_debug)
+           {
+             fprintf_unfiltered (gdb_stdlog, "-> ");
+             fprint_frame (gdb_stdlog, NULL);
+             fprintf_unfiltered (gdb_stdlog,
+                                 " // this frame ID is inner }\n");
+           }
+         this_frame->stop_reason = UNWIND_INNER_ID;
+         return NULL;
        }
-      this_frame->stop_reason = UNWIND_INNER_ID;
-      return NULL;
     }
 
   /* Check that this and the next frame are not identical.  If they
@@ -1494,6 +1618,11 @@ get_prev_frame_raw (struct frame_info *this_frame)
   prev_frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
   prev_frame->level = this_frame->level + 1;
 
+  /* For now, assume we don't have frame chains crossing address
+     spaces.  */
+  prev_frame->pspace = this_frame->pspace;
+  prev_frame->aspace = this_frame->aspace;
+
   /* Don't yet compute ->unwind (and hence ->type).  It is computed
      on-demand in get_frame_type, frame_register_unwind, and
      get_frame_id.  */
@@ -1570,7 +1699,12 @@ inside_main_func (struct frame_info *this_frame)
 static int
 inside_entry_func (struct frame_info *this_frame)
 {
-  return (get_frame_func (this_frame) == entry_point_address ());
+  CORE_ADDR entry_point;
+
+  if (!entry_point_address_query (&entry_point))
+    return 0;
+
+  return get_frame_func (this_frame) == entry_point;
 }
 
 /* Return a structure containing various interesting information about
@@ -1585,8 +1719,6 @@ inside_entry_func (struct frame_info *this_frame)
 struct frame_info *
 get_prev_frame (struct frame_info *this_frame)
 {
-  struct frame_info *prev_frame;
-
   /* There is always a frame.  If this assertion fails, suspect that
      something should be calling get_selected_frame() or
      get_current_frame().  */
@@ -1814,7 +1946,6 @@ get_frame_base_address (struct frame_info *fi)
 CORE_ADDR
 get_frame_locals_address (struct frame_info *fi)
 {
-  void **cache;
   if (get_frame_type (fi) != NORMAL_FRAME)
     return 0;
   /* If there isn't a frame address method, find it.  */
@@ -1830,7 +1961,6 @@ get_frame_locals_address (struct frame_info *fi)
 CORE_ADDR
 get_frame_args_address (struct frame_info *fi)
 {
-  void **cache;
   if (get_frame_type (fi) != NORMAL_FRAME)
     return 0;
   /* If there isn't a frame address method, find it.  */
@@ -1850,7 +1980,7 @@ int
 frame_unwinder_is (struct frame_info *fi, const struct frame_unwind *unwinder)
 {
   if (fi->unwind == NULL)
-    fi->unwind = frame_unwind_find_by_frame (fi, &fi->prologue_cache);
+    frame_unwind_find_by_frame (fi, &fi->prologue_cache);
   return fi->unwind == unwinder;
 }
 
@@ -1872,10 +2002,33 @@ get_frame_type (struct frame_info *frame)
   if (frame->unwind == NULL)
     /* Initialize the frame's unwinder because that's what
        provides the frame's type.  */
-    frame->unwind = frame_unwind_find_by_frame (frame, &frame->prologue_cache);
+    frame_unwind_find_by_frame (frame, &frame->prologue_cache);
   return frame->unwind->type;
 }
 
+struct program_space *
+get_frame_program_space (struct frame_info *frame)
+{
+  return frame->pspace;
+}
+
+struct program_space *
+frame_unwind_program_space (struct frame_info *this_frame)
+{
+  gdb_assert (this_frame);
+
+  /* This is really a placeholder to keep the API consistent --- we
+     assume for now that we don't have frame chains crossing
+     spaces.  */
+  return this_frame->pspace;
+}
+
+struct address_space *
+get_frame_address_space (struct frame_info *frame)
+{
+  return frame->aspace;
+}
+
 /* Memory access methods.  */
 
 void
@@ -1891,6 +2044,7 @@ get_frame_memory_signed (struct frame_info *this_frame, CORE_ADDR addr,
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   return read_memory_integer (addr, len, byte_order);
 }
 
@@ -1900,6 +2054,7 @@ get_frame_memory_unsigned (struct frame_info *this_frame, CORE_ADDR addr,
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   return read_memory_unsigned_integer (addr, len, byte_order);
 }
 
@@ -1927,9 +2082,7 @@ frame_unwind_arch (struct frame_info *next_frame)
       struct gdbarch *arch;
 
       if (next_frame->unwind == NULL)
-       next_frame->unwind
-         = frame_unwind_find_by_frame (next_frame,
-                                       &next_frame->prologue_cache);
+       frame_unwind_find_by_frame (next_frame, &next_frame->prologue_cache);
 
       if (next_frame->unwind->prev_arch != NULL)
        arch = next_frame->unwind->prev_arch (next_frame,
@@ -1961,6 +2114,7 @@ CORE_ADDR
 get_frame_sp (struct frame_info *this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
+
   /* Normality - an architecture that provides a way of obtaining any
      frame inner-most address.  */
   if (gdbarch_unwind_sp_p (gdbarch))
@@ -2115,7 +2269,7 @@ Set whether backtraces should continue past the entry point of a program."),
 Show whether backtraces should continue past the entry point of a program."),
                           _("\
 Normally there are no callers beyond the entry point of a program, so GDB\n\
-will terminate the backtrace there.  Set this variable if you need to see \n\
+will terminate the backtrace there.  Set this variable if you need to see\n\
 the rest of the stack trace."),
                           NULL,
                           show_backtrace_past_entry,
@@ -2133,7 +2287,7 @@ Zero is unlimited."),
                           &set_backtrace_cmdlist,
                           &show_backtrace_cmdlist);
 
-  /* Debug this files internals. */
+  /* Debug this files internals.  */
   add_setshow_zinteger_cmd ("frame", class_maintenance, &frame_debug,  _("\
 Set frame debugging."), _("\
 Show frame debugging."), _("\
This page took 0.039789 seconds and 4 git commands to generate.