diff options
author | Pedro Alves <palves@redhat.com> | 2015-09-09 18:23:24 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-09-09 18:24:56 +0100 |
commit | cfc3163382898a537c742bee1bf8240b3c09df35 (patch) | |
tree | 22297b33b80887894426ddb7433d60aab214ef89 /gdb/infcmd.c | |
parent | 388a708404618466bbe51b7198de7a64f0a5da9f (diff) | |
download | gdb-cfc3163382898a537c742bee1bf8240b3c09df35.zip gdb-cfc3163382898a537c742bee1bf8240b3c09df35.tar.gz gdb-cfc3163382898a537c742bee1bf8240b3c09df35.tar.bz2 |
Convert the until/advance commands to thread_fsm mechanism
gdb/ChangeLog:
2015-09-09 Pedro Alves <palves@redhat.com>
* breakpoint.c: Include "thread-fsm.h".
(struct until_break_command_continuation_args): Delete.
(struct until_break_fsm): New.
(until_break_fsm_ops): New global.
(new_until_break_fsm, until_break_fsm_should_stop): New functions.
(until_break_command_continuation): Delete.
(until_break_fsm_clean_up): New function.
(until_break_fsm_async_reply_reason): New function.
(until_break_command): Adjust to create an until_break_fsm instead
of a continuation.
(momentary_bkpt_print_it): No longer print MI's async-stop-reason
here.
* infcmd.c (struct until_next_fsm): New.
(until_next_fsm_ops): New global.
(new_until_next_fsm, until_next_fsm_should_stop): New function.
(until_next_continuation): Delete.
(until_next_fsm_clean_up, until_next_fsm_async_reply_reason): New
functions.
(until_next_command): Adjust to create a new until_next_fsm
instead of a continuation.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r-- | gdb/infcmd.c | 92 |
1 files changed, 72 insertions, 20 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 437d919..98c386a 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1385,22 +1385,81 @@ queue_signal_command (char *signum_exp, int from_tty) tp->suspend.stop_signal = oursig; } -/* Continuation args to be passed to the "until" command - continuation. */ -struct until_next_continuation_args +/* Data for the FSM that manages the until (with no argument) + command. */ + +struct until_next_fsm { - /* The thread that was current when the command was executed. */ + /* The base class. */ + struct thread_fsm thread_fsm; + + /* The thread that as current when the command was executed. */ int thread; }; -/* A continuation callback for until_next_command. */ +static int until_next_fsm_should_stop (struct thread_fsm *self); +static void until_next_fsm_clean_up (struct thread_fsm *self); +static enum async_reply_reason + until_next_fsm_async_reply_reason (struct thread_fsm *self); + +/* until_next_fsm's vtable. */ + +static struct thread_fsm_ops until_next_fsm_ops = +{ + NULL, /* dtor */ + until_next_fsm_clean_up, + until_next_fsm_should_stop, + NULL, /* return_value */ + until_next_fsm_async_reply_reason, +}; + +/* Allocate a new until_next_fsm. */ + +static struct until_next_fsm * +new_until_next_fsm (int thread) +{ + struct until_next_fsm *sm; + + sm = XCNEW (struct until_next_fsm); + thread_fsm_ctor (&sm->thread_fsm, &until_next_fsm_ops); + + sm->thread = thread; + + return sm; +} + +/* Implementation of the 'should_stop' FSM method for the until (with + no arg) command. */ + +static int +until_next_fsm_should_stop (struct thread_fsm *self) +{ + struct thread_info *tp = inferior_thread (); + + if (tp->control.stop_step) + thread_fsm_set_finished (self); + + return 1; +} + +/* Implementation of the 'clean_up' FSM method for the until (with no + arg) command. */ static void -until_next_continuation (void *arg, int err) +until_next_fsm_clean_up (struct thread_fsm *self) { - struct until_next_continuation_args *a = arg; + struct until_next_fsm *sm = (struct until_next_fsm *) self; - delete_longjmp_breakpoint (a->thread); + delete_longjmp_breakpoint (sm->thread); +} + +/* Implementation of the 'async_reply_reason' FSM method for the until + (with no arg) command. */ + +static enum async_reply_reason +until_next_fsm_async_reply_reason (struct thread_fsm *self) +{ + return EXEC_ASYNC_END_STEPPING_RANGE; } /* Proceed until we reach a different source line with pc greater than @@ -1421,6 +1480,7 @@ until_next_command (int from_tty) struct thread_info *tp = inferior_thread (); int thread = tp->num; struct cleanup *old_chain; + struct until_next_fsm *sm; clear_proceed_status (0); set_step_frame (); @@ -1460,20 +1520,12 @@ until_next_command (int from_tty) set_longjmp_breakpoint (tp, get_frame_id (frame)); old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); - proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT); - - if (is_running (inferior_ptid)) - { - struct until_next_continuation_args *cont_args; + sm = new_until_next_fsm (tp->num); + tp->thread_fsm = &sm->thread_fsm; + discard_cleanups (old_chain); - discard_cleanups (old_chain); - cont_args = XNEW (struct until_next_continuation_args); - cont_args->thread = inferior_thread ()->num; + proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT); - add_continuation (tp, until_next_continuation, cont_args, xfree); - } - else - do_cleanups (old_chain); } static void |