[PATCH v2 20/47] gdbserver, ze: report TARGET_WAITKIND_UNAVAILABLE events

Tankut Baris Aktemur
2024-12-13T16:28:04Z

Do not ignore a TARGET_WAITKIND_UNAVAILABLE event. This could be the result of

1. GDB sending a stop request, but the thread being unavailable.
2. target generating a library load event for which there is no
actual stop event.

In case 1, if we do not inform GDB, it would wait indefinitely for the
thread it attempted to stop.

In case 2, if we do not inform GDB, the target may wait for an ack
which will never come from GDB.
---
gdbserver/server.cc | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index eb541a9917f0faf6b4805700216e589054dc19bd..abaa6509041eb6b1c60ca4e99b2fdc1402d202da 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -5209,12 +5209,14 @@ handle_target_event (int err, gdb_client_data client_data)
}
else if (cs.last_status.kind () == TARGET_WAITKIND_UNAVAILABLE)
{
- /* Update the thread state but otherwise silently ignore this.
-
- We do need to report thread unavailability on resume or stop
- requests, but not as async target events. */
+ /* Update the thread state and report the event. GDB must have
+ sent a stop request for the thread, which turned out to be
+ unavailable. To not make GDB wait indefinitely, we report
+ the event. */
if (current_thread != nullptr)
current_thread->last_status = cs.last_status;
+
+ push_stop_notification (cs.last_ptid, cs.last_status);
}
else if (cs.last_status.kind () != TARGET_WAITKIND_IGNORE)
{