* defs.h (add_inferior_continuation)

(do_all_inferior_continuations)
	(discard_all_inferior_continuations): Declare.
	* utils.c (add_inferior_continuation)
	(do_all_inferior_continuations)
	(discard_all_inferior_continuations): New.
	* inferior.h (struct inferior) <continuations>: New field.
	* inferior.c (free_inferior): Discard all the inferior
	continuations.
	* inf-loop.c (inferior_event_handler): Do all current inferior
	continuations.
	* infcmd.c (attach_command): Register an inferior continuation
	instead of a thread continuation.
	* infrun.c (handle_inferior_event): If stop_soon is
	STOP_QUIETLY_NO_SIGSTOP, also expect a TARGET_SIGNAL_0.
This commit is contained in:
Pedro Alves 2008-11-05 20:23:07 +00:00
parent 6dc6b6558b
commit e0ba674611
8 changed files with 107 additions and 5 deletions

View file

@ -505,6 +505,59 @@ add_continuation (struct thread_info *thread,
thread->continuations = (struct continuation *) as_cleanup;
}
/* Add a continuation to the continuation list of INFERIOR. The new
continuation will be added at the front. */
void
add_inferior_continuation (void (*continuation_hook) (void *), void *args,
void (*continuation_free_args) (void *))
{
struct inferior *inf = current_inferior ();
struct cleanup *as_cleanup = &inf->continuations->base;
make_cleanup_ftype *continuation_hook_fn = continuation_hook;
make_my_cleanup2 (&as_cleanup,
continuation_hook_fn,
args,
continuation_free_args);
inf->continuations = (struct continuation *) as_cleanup;
}
/* Do all continuations of the current inferior. */
void
do_all_inferior_continuations (void)
{
struct cleanup *old_chain;
struct cleanup *as_cleanup;
struct inferior *inf = current_inferior ();
if (inf->continuations == NULL)
return;
/* Copy the list header into another pointer, and set the global
list header to null, so that the global list can change as a side
effect of invoking the continuations and the processing of the
preexisting continuations will not be affected. */
as_cleanup = &inf->continuations->base;
inf->continuations = NULL;
/* Work now on the list we have set aside. */
do_my_cleanups (&as_cleanup, NULL);
}
/* Get rid of all the inferior-wide continuations of INF. */
void
discard_all_inferior_continuations (struct inferior *inf)
{
struct cleanup *continuation_ptr = &inf->continuations->base;
discard_my_cleanups (&continuation_ptr, NULL);
inf->continuations = NULL;
}
static void
restore_thread_cleanup (void *arg)
{