The target_async_permitted flag allows a user to override whether a
target can act in async mode or not. In previous commits I have moved
the checking of this flag out of the various ::can_async_p methods and
into the common target.c code.
In this commit I will add some additional assertions into
target_is_async_p and target_async. The rules these assertions are
checking are:
1. A target that returns false for target_can_async_p should never
become "async enabled", and so ::is_async_p should always return
false. This is being checked in target_is_async_p.
2. GDB should never try to enable async mode for a target that
returns false for target_can_async_p, this is checked in
target_async.
There are a few places where we call the ::is_async_p method directly,
in these cases we will obviously not pass through the assert in
target_is_async_p, however, there are also plenty of places where we
do call target_is_async_p so if GDB starts to misbehave we should
catch it quickly enough.
There should be no user visible changes after this commit.
bool
target_is_async_p ()
{
- return current_inferior ()->top_target ()->is_async_p ();
+ bool result = current_inferior ()->top_target ()->is_async_p ();
+ gdb_assert (target_async_permitted || !result);
+ return result;
}
exec_direction_kind
void
target_async (int enable)
{
+ /* If we are trying to enable async mode then it must be the case that
+ async mode is possible for this target. */
+ gdb_assert (!enable || target_can_async_p ());
infrun_async (enable);
current_inferior ()->top_target ()->async (enable);
}