]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move lookup_selected_frame to frame.c
authorPedro Alves <palves@redhat.com>
Thu, 9 Jul 2020 19:12:15 +0000 (20:12 +0100)
committerPedro Alves <pedro@palves.net>
Fri, 30 Oct 2020 01:26:49 +0000 (01:26 +0000)
This function is now external, and isn't really threads related.  Move
it to frame.c.

gdb/ChangeLog:

* thread.c (lookup_selected_frame): Move ...
* frame.c (lookup_selected_frame): ... here.

Change-Id: Ia96b79c15767337c68efd3358bcc715ce8e26c15

gdb/ChangeLog
gdb/frame.c
gdb/thread.c

index 978576ac7c764aa7d374ec76ddcaf2ef538fb6bb..d2df843b24f18dbdd30ca9635d06889acad04730 100644 (file)
@@ -1,3 +1,8 @@
+2020-10-30  Pedro Alves  <pedro@palves.net>
+
+       * thread.c (lookup_selected_frame): Move ...
+       * frame.c (lookup_selected_frame): ... here.
+
 2020-10-30  Pedro Alves  <pedro@palves.net>
 
        * blockframe.c (block_innermost_frame): Use get_selected_frame.
index bb835e2dbac7f8473a972a689bb294a925dff7e8..d0a4ce4d63f57060c9769beb0064a90e2ac5f3b6 100644 (file)
@@ -1740,6 +1740,72 @@ restore_selected_frame (frame_id frame_id, int frame_level)
   selected_frame = nullptr;
 }
 
+/* See frame.h.  */
+
+void
+lookup_selected_frame (struct frame_id a_frame_id, int frame_level)
+{
+  struct frame_info *frame = NULL;
+  int count;
+
+  /* This either means there was no selected frame, or the selected
+     frame was the current frame.  In either case, select the current
+     frame.  */
+  if (frame_level == -1)
+    {
+      select_frame (get_current_frame ());
+      return;
+    }
+
+  /* select_frame never saves 0 in SELECTED_FRAME_LEVEL, so we
+     shouldn't see it here.  */
+  gdb_assert (frame_level > 0);
+
+  /* Restore by level first, check if the frame id is the same as
+     expected.  If that fails, try restoring by frame id.  If that
+     fails, nothing to do, just warn the user.  */
+
+  count = frame_level;
+  frame = find_relative_frame (get_current_frame (), &count);
+  if (count == 0
+      && frame != NULL
+      /* The frame ids must match - either both valid or both
+        outer_frame_id.  The latter case is not failsafe, but since
+        it's highly unlikely the search by level finds the wrong
+        frame, it's 99.9(9)% of the time (for all practical purposes)
+        safe.  */
+      && frame_id_eq (get_frame_id (frame), a_frame_id))
+    {
+      /* Cool, all is fine.  */
+      select_frame (frame);
+      return;
+    }
+
+  frame = frame_find_by_id (a_frame_id);
+  if (frame != NULL)
+    {
+      /* Cool, refound it.  */
+      select_frame (frame);
+      return;
+    }
+
+  /* Nothing else to do, the frame layout really changed.  Select the
+     innermost stack frame.  */
+  select_frame (get_current_frame ());
+
+  /* Warn the user.  */
+  if (frame_level > 0 && !current_uiout->is_mi_like_p ())
+    {
+      warning (_("Couldn't restore frame #%d in "
+                "current thread.  Bottom (innermost) frame selected:"),
+              frame_level);
+      /* For MI, we should probably have a notification about current
+        frame change.  But this error is not very likely, so don't
+        bother for now.  */
+      print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+    }
+}
+
 bool
 has_stack_frames ()
 {
index 193f9d4c44f6c2e14c7a72c4dab192034c7cd30c..32d14e8662c57d39a2943961b9301b5b402ab75e 100644 (file)
@@ -1327,69 +1327,6 @@ switch_to_thread (process_stratum_target *proc_target, ptid_t ptid)
 
 /* See frame.h.  */
 
-void
-lookup_selected_frame (struct frame_id a_frame_id, int frame_level)
-{
-  struct frame_info *frame = NULL;
-  int count;
-
-  /* This either means there was no selected frame, or the selected
-     frame was the current frame.  In either case, select the current
-     frame.  */
-  if (frame_level == -1)
-    {
-      select_frame (get_current_frame ());
-      return;
-    }
-
-  /* select_frame never saves 0 in SELECTED_FRAME_LEVEL, so we
-     shouldn't see it here.  */
-  gdb_assert (frame_level > 0);
-
-  /* Restore by level first, check if the frame id is the same as
-     expected.  If that fails, try restoring by frame id.  If that
-     fails, nothing to do, just warn the user.  */
-
-  count = frame_level;
-  frame = find_relative_frame (get_current_frame (), &count);
-  if (count == 0
-      && frame != NULL
-      /* The frame ids must match - either both valid or both outer_frame_id.
-        The latter case is not failsafe, but since it's highly unlikely
-        the search by level finds the wrong frame, it's 99.9(9)% of
-        the time (for all practical purposes) safe.  */
-      && frame_id_eq (get_frame_id (frame), a_frame_id))
-    {
-      /* Cool, all is fine.  */
-      select_frame (frame);
-      return;
-    }
-
-  frame = frame_find_by_id (a_frame_id);
-  if (frame != NULL)
-    {
-      /* Cool, refound it.  */
-      select_frame (frame);
-      return;
-    }
-
-  /* Nothing else to do, the frame layout really changed.  Select the
-     innermost stack frame.  */
-  select_frame (get_current_frame ());
-
-  /* Warn the user.  */
-  if (frame_level > 0 && !current_uiout->is_mi_like_p ())
-    {
-      warning (_("Couldn't restore frame #%d in "
-                "current thread.  Bottom (innermost) frame selected:"),
-              frame_level);
-      /* For MI, we should probably have a notification about
-        current frame change.  But this error is not very
-        likely, so don't bother for now.  */
-      print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
-    }
-}
-
 void
 scoped_restore_current_thread::restore ()
 {