infun debug: Use correct target pid

Message ID 20190325161820.15406-1-alan.hayward@arm.com
State New, archived
Headers

Commit Message

Alan Hayward March 25, 2019, 4:18 p.m. UTC
  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

Tom Tromey March 25, 2019, 4:21 p.m. UTC | #1
>>>>> "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
  
Alan Hayward March 25, 2019, 4:58 p.m. UTC | #2
> 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.
  
Philippe Waroquiers March 30, 2019, 10:05 a.m. UTC | #3
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
  

Patch

diff --git a/gdb/infrun.c b/gdb/infrun.c
index ad7892105a..5350ab73a1 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -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
 	    {