#include "infcall.h"
#include "thread-fsm.h"
#include "top.h"
+#include "interps.h"
/* Local functions: */
/* If true, this is a stepi/nexti, otherwise a step/step. */
int single_inst;
-
- /* The thread that the command was run on. */
- int thread;
};
-static void step_command_fsm_clean_up (struct thread_fsm *self);
-static int step_command_fsm_should_stop (struct thread_fsm *self);
+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);
/* Allocate a new step_command_fsm. */
static struct step_command_fsm *
-new_step_command_fsm (void)
+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);
+ thread_fsm_ctor (&sm->thread_fsm, &step_command_fsm_ops, cmd_interp);
return sm;
}
sm->skip_subroutines = skip_subroutines;
sm->single_inst = single_inst;
sm->count = count;
- sm->thread = thread->global_num;
/* Leave the si command alone. */
if (!sm->single_inst || sm->skip_subroutines)
/* Setup the execution command state machine to handle all the COUNT
steps. */
thr = inferior_thread ();
- step_sm = new_step_command_fsm ();
+ step_sm = new_step_command_fsm (command_interp ());
thr->thread_fsm = &step_sm->thread_fsm;
step_command_fsm_prepare (step_sm, skip_subroutines,
/* Stepped into an inline frame. Pretend that we've
stopped. */
- thread_fsm_clean_up (thr->thread_fsm);
+ thread_fsm_clean_up (thr->thread_fsm, thr);
proceeded = normal_stop ();
if (!proceeded)
inferior_event_handler (INF_EXEC_COMPLETE, NULL);
will need to keep going. */
static int
-step_command_fsm_should_stop (struct thread_fsm *self)
+step_command_fsm_should_stop (struct thread_fsm *self, struct thread_info *tp)
{
struct step_command_fsm *sm = (struct step_command_fsm *) self;
- struct thread_info *tp = find_thread_global_id (sm->thread);
if (tp->control.stop_step)
{
/* Implementation of the 'clean_up' FSM method for stepping commands. */
static void
-step_command_fsm_clean_up (struct thread_fsm *self)
+step_command_fsm_clean_up (struct thread_fsm *self, struct thread_info *thread)
{
struct step_command_fsm *sm = (struct step_command_fsm *) self;
if (!sm->single_inst || sm->skip_subroutines)
- delete_longjmp_breakpoint (sm->thread);
+ delete_longjmp_breakpoint (thread->global_num);
}
/* Implementation of the 'async_reply_reason' FSM method for stepping
int thread;
};
-static int until_next_fsm_should_stop (struct thread_fsm *self);
-static void until_next_fsm_clean_up (struct thread_fsm *self);
+static int until_next_fsm_should_stop (struct thread_fsm *self,
+ struct thread_info *thread);
+static void until_next_fsm_clean_up (struct thread_fsm *self,
+ struct thread_info *thread);
static enum async_reply_reason
until_next_fsm_async_reply_reason (struct thread_fsm *self);
/* Allocate a new until_next_fsm. */
static struct until_next_fsm *
-new_until_next_fsm (int thread)
+new_until_next_fsm (struct interp *cmd_interp, int thread)
{
struct until_next_fsm *sm;
sm = XCNEW (struct until_next_fsm);
- thread_fsm_ctor (&sm->thread_fsm, &until_next_fsm_ops);
+ thread_fsm_ctor (&sm->thread_fsm, &until_next_fsm_ops, cmd_interp);
sm->thread = thread;
no arg) command. */
static int
-until_next_fsm_should_stop (struct thread_fsm *self)
+until_next_fsm_should_stop (struct thread_fsm *self,
+ struct thread_info *tp)
{
- struct thread_info *tp = inferior_thread ();
-
if (tp->control.stop_step)
thread_fsm_set_finished (self);
arg) command. */
static void
-until_next_fsm_clean_up (struct thread_fsm *self)
+until_next_fsm_clean_up (struct thread_fsm *self, struct thread_info *thread)
{
struct until_next_fsm *sm = (struct until_next_fsm *) self;
- delete_longjmp_breakpoint (sm->thread);
+ delete_longjmp_breakpoint (thread->global_num);
}
/* Implementation of the 'async_reply_reason' FSM method for the until
set_longjmp_breakpoint (tp, get_frame_id (frame));
old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
- sm = new_until_next_fsm (tp->global_num);
+ sm = new_until_next_fsm (command_interp (), tp->global_num);
tp->thread_fsm = &sm->thread_fsm;
discard_cleanups (old_chain);
/* The base class. */
struct thread_fsm thread_fsm;
- /* The thread that was current when the command was executed. */
- int thread;
-
/* The momentary breakpoint set at the function's return address in
the caller. */
struct breakpoint *breakpoint;
struct return_value_info return_value;
};
-static int finish_command_fsm_should_stop (struct thread_fsm *self);
-static void finish_command_fsm_clean_up (struct thread_fsm *self);
+static int finish_command_fsm_should_stop (struct thread_fsm *self,
+ struct thread_info *thread);
+static void finish_command_fsm_clean_up (struct thread_fsm *self,
+ struct thread_info *thread);
static struct return_value_info *
finish_command_fsm_return_value (struct thread_fsm *self);
static enum async_reply_reason
finish_command_fsm_should_stop,
finish_command_fsm_return_value,
finish_command_fsm_async_reply_reason,
+ NULL, /* should_notify_stop */
};
/* Allocate a new finish_command_fsm. */
static struct finish_command_fsm *
-new_finish_command_fsm (int thread)
+new_finish_command_fsm (struct interp *cmd_interp)
{
struct finish_command_fsm *sm;
sm = XCNEW (struct finish_command_fsm);
- thread_fsm_ctor (&sm->thread_fsm, &finish_command_fsm_ops);
-
- sm->thread = thread;
+ thread_fsm_ctor (&sm->thread_fsm, &finish_command_fsm_ops, cmd_interp);
return sm;
}
marks the FSM finished. */
static int
-finish_command_fsm_should_stop (struct thread_fsm *self)
+finish_command_fsm_should_stop (struct thread_fsm *self,
+ struct thread_info *tp)
{
struct finish_command_fsm *f = (struct finish_command_fsm *) self;
struct return_value_info *rv = &f->return_value;
- struct thread_info *tp = find_thread_global_id (f->thread);
if (f->function != NULL
&& bpstat_find_breakpoint (tp->control.stop_bpstat,
commands. */
static void
-finish_command_fsm_clean_up (struct thread_fsm *self)
+finish_command_fsm_clean_up (struct thread_fsm *self,
+ struct thread_info *thread)
{
struct finish_command_fsm *f = (struct finish_command_fsm *) self;
delete_breakpoint (f->breakpoint);
f->breakpoint = NULL;
}
- delete_longjmp_breakpoint (f->thread);
+ delete_longjmp_breakpoint (thread->global_num);
}
/* Implementation of the 'return_value' FSM method for the finish
tp = inferior_thread ();
- sm = new_finish_command_fsm (tp->global_num);
+ sm = new_finish_command_fsm (command_interp ());
tp->thread_fsm = &sm->thread_fsm;