[PATCHv2 3/6] gdb: add asserts in target.c for target_async_permitted
Simon Marchi
simark@simark.ca
Wed Nov 24 21:21:27 GMT 2021
On 2021-11-24 7:22 a.m., Andrew Burgess via Gdb-patches wrote:
> 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.
Despite what I said in my v1 review, it would actually be nice to have a
target_is_async_p wrapper like the new target_can_async_p wrapper, just
to have the gdb_assert checked consistently. But I think it can be done
later, to avoid having a v3 of this series just for a minor detail like
that.
The patch LGTM as-is.
Simon
More information about the Gdb-patches
mailing list