infun debug: Use correct target pid
Commit Message
The infrun debug reads the id for the exited thread from the ws value.
However, this is always 0, causing an assert in find_inferior_pid.
Instead, the id should be read from the wait return value.
This fixes a racy FAIL in gdb.threads/watchthreads-reorder.exp
gdb/ChangeLog:
2019-03-25 Alan Hayward <alan.hayward@arm.com>
* infrun.c (stop_all_threads): Fix debug print.
---
gdb/infrun.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
Comments
>>>>> "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:
Alan> The infrun debug reads the id for the exited thread from the ws value.
Alan> However, this is always 0, causing an assert in find_inferior_pid.
Alan> Instead, the id should be read from the wait return value.
FWIW this is already being discussed in another thread:
https://sourceware.org/ml/gdb-patches/2019-03/msg00516.html
Tom
> On 25 Mar 2019, at 16:21, Tom Tromey <tom@tromey.com> wrote:
>
>>>>>> "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:
>
> Alan> The infrun debug reads the id for the exited thread from the ws value.
> Alan> However, this is always 0, causing an assert in find_inferior_pid.
>
> Alan> Instead, the id should be read from the wait return value.
>
> FWIW this is already being discussed in another thread:
>
> https://sourceware.org/ml/gdb-patches/2019-03/msg00516.html
>
> Tom
!!! Yes, I totally missed that! Complete coincidence too.
I’ll drop my patch.
Alan.
On Mon, 2019-03-25 at 16:58 +0000, Alan Hayward wrote:
> > On 25 Mar 2019, at 16:21, Tom Tromey <tom@tromey.com> wrote:
> >
> > > > > > > "Alan" == Alan Hayward <Alan.Hayward@arm.com> writes:
> >
> > Alan> The infrun debug reads the id for the exited thread from the ws value.
> > Alan> However, this is always 0, causing an assert in find_inferior_pid.
> >
> > Alan> Instead, the id should be read from the wait return value.
> >
> > FWIW this is already being discussed in another thread:
> >
> > https://sourceware.org/ml/gdb-patches/2019-03/msg00516.html
> >
> > Tom
>
> !!! Yes, I totally missed that! Complete coincidence too.
> I’ll drop my patch.
I have just sent an RFAv2
https://sourceware.org/ml/gdb-patches/2019-03/msg00758.html
that fixes the above and improves some other related tracing.
Philippe
@@ -4364,14 +4364,10 @@ stop_all_threads (void)
|| ws.kind == TARGET_WAITKIND_SIGNALLED)
{
if (debug_infrun)
- {
- ptid_t ptid = ptid_t (ws.value.integer);
-
- fprintf_unfiltered (gdb_stdlog,
- "infrun: %s exited while "
- "stopping threads\n",
- target_pid_to_str (ptid).c_str ());
- }
+ fprintf_unfiltered (gdb_stdlog,
+ "infrun: %s exited while "
+ "stopping threads\n",
+ target_pid_to_str (event_ptid).c_str ());
}
else
{