[PATCH v2 21/47] gdb, ze: handle TARGET_WAITKIND_UNAVAILABLE in stop_all_threads

Tankut Baris Aktemur
2024-12-13T16:22:45Z

If a TARGET_WAITKIND_UNAVAILABLE is received as the result of a stop
request, consider it the same as a stopped event with the 0 signal, and
do not save it as a pending event. We would expect the target to send us
a TARGET_WAITKIND_STOPPED status if there were a stopped event. We must
have received TARGET_WAITKIND_UNAVAILABLE because all the threads were
unavailable for our interrupt. Hence, it must be OK to treat the
TARGET_WAITKIND_UNAVAILABLE status as an internal stop and not report
to the user.
---
gdb/infrun.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 5d9dd1cbaf3f0cb5a56c52227ae818237958cd90..8cee2c6e4c59c70f49c350da9346930f525b7da9 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5578,8 +5578,18 @@ handle_one (const wait_one_event &event)
setup_inferior (0);
}

- if (event.ws.kind () == TARGET_WAITKIND_STOPPED
- && event.ws.sig () == GDB_SIGNAL_0)
+ /* If a TARGET_WAITKIND_UNAVAILABLE is received as the result of
+ a stop request, consider it the same as a stopped event with
+ the 0 signal, and do not save it as a pending event. We
+ would expect the target to send us a TARGET_WAITKIND_STOPPED
+ status if there were a stopped event. We must have received
+ TARGET_WAITKIND_UNAVAILABLE because all the threads were
+ unavailable for our interrupt. Hence, it must be OK to treat
+ the TARGET_WAITKIND_UNAVAILABLE status as an internal stop
+ and report to the user. */
+ if ((event.ws.kind () == TARGET_WAITKIND_STOPPED
+ && event.ws.sig () == GDB_SIGNAL_0)
+ || (event.ws.kind () == TARGET_WAITKIND_UNAVAILABLE))
{
/* We caught the event that we intended to catch, so
there's no event to save as pending. */