[06/11] gdb, remote: fix ptid matching for process-wide stop events
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
Commit Message
From: "Rohr, Stephan" <stephan.rohr@intel.com>
If an inferior call results in a process event for a non-stop remote
target, GDB does not properly handle the event but is hanging. This
reproduces with 'gdb.base/exit-in-condition.exp'.
Because GDB is evaluating a breakpoint condition, the corresponding
inferior call is evaluated w.r.t. the ptid of the current thread.
gdbserver sends a process exit event; the event is not matched by the
thread PTID and GDB hangs.
Fix this by matching a process event in 'stop_reply_queue' if there is
no matching thread event. This ensures a thread event is prioritized
if both a thread event and a process event are queued and preserves the
current behavior.
---
gdb/remote.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
@@ -8363,6 +8363,20 @@ remote_target::remote_notif_remove_queued_reply (ptid_t ptid)
{
return event->ptid.matches (ptid);
});
+
+ /* Match process events if PTID is a thread and there is no matching event
+ queued. Prioritize thread events to preserve the existing behavior. */
+ if (iter == rs->stop_reply_queue.end ()
+ && ptid != minus_one_ptid
+ && !ptid.is_pid ())
+ iter = std::find_if (rs->stop_reply_queue.begin (),
+ rs->stop_reply_queue.end (),
+ [=] (const stop_reply_up &event)
+ {
+ return (event->ptid.is_pid ()
+ && event->ptid.pid () == ptid.pid ());
+ });
+
stop_reply_up result;
if (iter != rs->stop_reply_queue.end ())
{