+/* Data for the FSM that manages the step/next/stepi/nexti
+ commands. */
+
+struct step_command_fsm
+{
+ /* The base class. */
+ struct thread_fsm thread_fsm;
+
+ /* How many steps left in a "step N"-like command. */
+ int count;
+
+ /* If true, this is a next/nexti, otherwise a step/stepi. */
+ int skip_subroutines;
+
+ /* If true, this is a stepi/nexti, otherwise a step/step. */
+ int single_inst;
+};
+
+static void step_command_fsm_clean_up (struct thread_fsm *self,
+ struct thread_info *thread);
+static int step_command_fsm_should_stop (struct thread_fsm *self,
+ struct thread_info *thread);
+static enum async_reply_reason
+ step_command_fsm_async_reply_reason (struct thread_fsm *self);
+
+/* step_command_fsm's vtable. */
+
+static struct thread_fsm_ops step_command_fsm_ops =
+{
+ NULL,
+ step_command_fsm_clean_up,
+ step_command_fsm_should_stop,
+ NULL, /* return_value */
+ step_command_fsm_async_reply_reason,
+};
+
+/* Allocate a new step_command_fsm. */
+
+static struct step_command_fsm *
+new_step_command_fsm (struct interp *cmd_interp)
+{
+ struct step_command_fsm *sm;
+
+ sm = XCNEW (struct step_command_fsm);
+ thread_fsm_ctor (&sm->thread_fsm, &step_command_fsm_ops, cmd_interp);
+
+ return sm;
+}
+
+/* Prepare for a step/next/etc. command. Any target resource
+ allocated here is undone in the FSM's clean_up method. */
+
+static void
+step_command_fsm_prepare (struct step_command_fsm *sm,
+ int skip_subroutines, int single_inst,
+ int count, struct thread_info *thread)
+{
+ sm->skip_subroutines = skip_subroutines;
+ sm->single_inst = single_inst;
+ sm->count = count;
+
+ /* Leave the si command alone. */
+ if (!sm->single_inst || sm->skip_subroutines)
+ set_longjmp_breakpoint (thread, get_frame_id (get_current_frame ()));
+
+ thread->control.stepping_command = 1;
+}
+
+static int prepare_one_step (struct step_command_fsm *sm);
+