GNU Binutils with patches for OS216
Revisión | bab2e736d54c5e26aea3015c84a3b283b5f78c82 (tree) |
---|---|
Tiempo | 2019-09-07 07:31:05 |
Autor | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Tweak handling of remote errors in response to resumption packet
With current master, on a Fedora 27 machine with a kernel with buggy
watchpoint support, I see:
The FAILs themselves aren't what's interesting here. What is
interesting is that with the main multi-target patch applied, I was getting this:
The problem is that in remote_target::wait_as, we're hitting this:
not? Not is more likely, so report a stop. */
which leaves event_ptid as null_ptid. At the end of the function, we then reach:
&& status->kind != TARGET_WAITKIND_SIGNALLED)
record_currthread (rs, event_ptid);
event_ptid = inferior_ptid; <<<<< here
and the trouble is that with the multi-target patch, we'll get here
with inferior_ptid as null_ptid too. That is done exactly to find
these implicit assumptions that inferior_ptid is a good choice for
default thread, which isn't generaly true.
I first thought of fixing this in the "case 'E'" path, but, given that
this "event_ptid = inferior_ptid" path is also taken when the remote
target does not support threads at all, no thread-related packets or
extensions, it's better to fix it in latter path, to handle all
scenarios that miss reporting a thread.
That's what this patch does.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* remote.c (first_remote_resumed_thread): New.
(remote_target::wait_as): Use it as default event_ptid instead of
inferior_ptid.
@@ -7703,6 +7703,17 @@ remote_target::wait_ns (ptid_t ptid, struct target_waitstatus *status, int optio | ||
7703 | 7703 | } |
7704 | 7704 | } |
7705 | 7705 | |
7706 | +/* Return the first resumed thread. */ | |
7707 | + | |
7708 | +static ptid_t | |
7709 | +first_remote_resumed_thread () | |
7710 | +{ | |
7711 | + for (thread_info *tp : all_non_exited_threads (minus_one_ptid)) | |
7712 | + if (tp->resumed) | |
7713 | + return tp->ptid; | |
7714 | + return null_ptid; | |
7715 | +} | |
7716 | + | |
7706 | 7717 | /* Wait until the remote machine stops, then return, storing status in |
7707 | 7718 | STATUS just as `wait' would. */ |
7708 | 7719 |
@@ -7839,7 +7850,7 @@ remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options) | ||
7839 | 7850 | if (event_ptid != null_ptid) |
7840 | 7851 | record_currthread (rs, event_ptid); |
7841 | 7852 | else |
7842 | - event_ptid = inferior_ptid; | |
7853 | + event_ptid = first_remote_resumed_thread (); | |
7843 | 7854 | } |
7844 | 7855 | else |
7845 | 7856 | /* A process exit. Invalidate our notion of current thread. */ |