aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2021-11-17 09:35:46 +0000
committerAndrew Burgess <aburgess@redhat.com>2021-11-25 10:00:40 +0000
commitbf94662bfe3ac43e792a4a6c44e35d7aafa9d0c1 (patch)
tree9f5a85c1bee6848ec5cd1ba810763e9013f9bbdb /gdb/target.c
parentfce6cd341b48a2589cb4520c7718c80cb0b27c80 (diff)
downloadgdb-bf94662bfe3ac43e792a4a6c44e35d7aafa9d0c1.zip
gdb-bf94662bfe3ac43e792a4a6c44e35d7aafa9d0c1.tar.gz
gdb-bf94662bfe3ac43e792a4a6c44e35d7aafa9d0c1.tar.bz2
gdb: add asserts in target.c for target_async_permitted
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.
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gdb/target.c b/gdb/target.c
index db1abcc..06a21c4 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -409,7 +409,9 @@ target_can_async_p (struct target_ops *target)
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
@@ -4338,6 +4340,9 @@ maintenance_print_target_stack (const char *cmd, int from_tty)
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);
}