- switch_to_thread (current_ptid);
-
- /* Code below copied from "up_silently_base" in "stack.c".
- * It restores the frame set by the user before the "info threads"
- * command. We have finished the info-threads display by switching
- * back to the current thread. That switch has put us at the top
- * of the stack (leaf frame).
- */
- counter = saved_frame_level;
- cur_frame = find_relative_frame (get_selected_frame (), &counter);
- if (counter != 0)
- {
- /* Ooops, can't restore, tell user where we are. */
- warning ("Couldn't restore frame in current thread, at frame 0");
- print_stack_frame (get_selected_frame (), 0, LOCATION);
- }
- else
+ /* Restores the current thread and the frame selected before
+ the "info threads" command. */
+ do_cleanups (old_chain);
+
+ /* If case we were not able to find the original frame, print the
+ new selected frame. */
+ if (frame_find_by_id (saved_frame_id) == NULL)