+/* Get the current frame for TP. */
+
+static struct frame_info *
+get_thread_current_frame (struct thread_info *tp)
+{
+ struct frame_info *frame;
+ ptid_t old_inferior_ptid;
+ int executing;
+
+ /* Set INFERIOR_PTID, which is implicitly used by get_current_frame. */
+ old_inferior_ptid = inferior_ptid;
+ inferior_ptid = tp->ptid;
+
+ /* Clear the executing flag to allow changes to the current frame.
+ We are not actually running, yet. We just started a reverse execution
+ command or a record goto command.
+ For the latter, EXECUTING is false and this has no effect.
+ For the former, EXECUTING is true and we're in to_wait, about to
+ move the thread. Since we need to recompute the stack, we temporarily
+ set EXECUTING to flase. */
+ executing = is_executing (inferior_ptid);
+ set_executing (inferior_ptid, 0);
+
+ frame = NULL;
+ TRY
+ {
+ frame = get_current_frame ();
+ }
+ CATCH (except, RETURN_MASK_ALL)
+ {
+ /* Restore the previous execution state. */
+ set_executing (inferior_ptid, executing);
+
+ /* Restore the previous inferior_ptid. */
+ inferior_ptid = old_inferior_ptid;
+
+ throw_exception (except);
+ }
+ END_CATCH
+
+ /* Restore the previous execution state. */
+ set_executing (inferior_ptid, executing);
+
+ /* Restore the previous inferior_ptid. */
+ inferior_ptid = old_inferior_ptid;
+
+ return frame;
+}
+