Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* lin-lwp and exiting threads
@ 2003-08-26 17:52 Daniel Jacobowitz
  2003-08-26 18:32 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-08-26 17:52 UTC (permalink / raw)
  To: gdb-patches, jjohnstn

Hi Jeff,

I'm doing some work in lin-lwp.c and I saw this bit you recently committed:

+      /* Check if the current LWP has previously exited.  For nptl threads,
+         there is no exit signal issued for LWPs that are not the
+         main thread so we should check whenever the thread is stopped.  */
+      if (!lin_lwp_thread_alive (lp->ptid))
+       {
+         if (in_thread_list (lp->ptid))
+           {
+             /* Core GDB cannot deal with us deleting the current
+                thread.  */
+             if (!ptid_equal (lp->ptid, inferior_ptid))
+               delete_thread (lp->ptid);
+             printf_unfiltered ("[%s exited]\n",
+                                target_pid_to_str (lp->ptid));
+           }
+         if (debug_lin_lwp)
+           fprintf_unfiltered (gdb_stdlog,
+                               "SWC: %s already exited.\n",
                                target_pid_to_str (lp->ptid));


This is right after waitpid has returned a non-exiting stopped status for
lp->ptid.  Were you just being thorough, or do you have some reason to
believe that waitpid would ever return WIFSTOPPED (status) and yet the
thread would be dead?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: lin-lwp and exiting threads
  2003-08-26 17:52 lin-lwp and exiting threads Daniel Jacobowitz
@ 2003-08-26 18:32 ` Daniel Jacobowitz
  2003-08-26 19:17   ` J. Johnston
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-08-26 18:32 UTC (permalink / raw)
  To: gdb-patches, jjohnstn

On Tue, Aug 26, 2003 at 01:51:35PM -0400, Daniel Jacobowitz wrote:
> Hi Jeff,
> 
> I'm doing some work in lin-lwp.c and I saw this bit you recently committed:
> 
> +      /* Check if the current LWP has previously exited.  For nptl threads,
> +         there is no exit signal issued for LWPs that are not the
> +         main thread so we should check whenever the thread is stopped.  */
> +      if (!lin_lwp_thread_alive (lp->ptid))
> +       {
> +         if (in_thread_list (lp->ptid))
> +           {
> +             /* Core GDB cannot deal with us deleting the current
> +                thread.  */
> +             if (!ptid_equal (lp->ptid, inferior_ptid))
> +               delete_thread (lp->ptid);
> +             printf_unfiltered ("[%s exited]\n",
> +                                target_pid_to_str (lp->ptid));
> +           }
> +         if (debug_lin_lwp)
> +           fprintf_unfiltered (gdb_stdlog,
> +                               "SWC: %s already exited.\n",
>                                 target_pid_to_str (lp->ptid));
> 
> 
> This is right after waitpid has returned a non-exiting stopped status for
> lp->ptid.  Were you just being thorough, or do you have some reason to
> believe that waitpid would ever return WIFSTOPPED (status) and yet the
> thread would be dead?

Also, there's:
  pid = waitpid (GET_LWP (lp->ptid), &status, 0);
  if (pid == -1 && errno == ECHILD)
    {
      pid = waitpid (GET_LWP (lp->ptid), &status, __WCLONE);
      if (pid == -1 && errno == ECHILD)
        {
          /* The thread has previously exited.  We need to delete it now
             because in the case of NPTL threads, there won't be an
             exit event unless it is the main thread.  */
          if (debug_lin_lwp)
            fprintf_unfiltered (gdb_stdlog,
                                "SWC: %s exited.\n",
                                target_pid_to_str (lp->ptid));
          delete_lwp (lp->ptid);
          return 0;
        }
    }
  
Is there some reason you don't also call delete_thread?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: lin-lwp and exiting threads
  2003-08-26 19:17   ` J. Johnston
@ 2003-08-26 18:48     ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-08-26 18:48 UTC (permalink / raw)
  To: J. Johnston; +Cc: gdb-patches

On Tue, Aug 26, 2003 at 02:43:23PM -0400, J. Johnston wrote:
> Daniel Jacobowitz wrote:
> >On Tue, Aug 26, 2003 at 01:51:35PM -0400, Daniel Jacobowitz wrote:
> >
> >>Hi Jeff,
> >>
> >>I'm doing some work in lin-lwp.c and I saw this bit you recently 
> >>committed:
> >>
> >>+      /* Check if the current LWP has previously exited.  For nptl 
> >>threads,
> >>+         there is no exit signal issued for LWPs that are not the
> >>+         main thread so we should check whenever the thread is stopped.  
> >>*/
> >>+      if (!lin_lwp_thread_alive (lp->ptid))
> >>+       {
> >>+         if (in_thread_list (lp->ptid))
> >>+           {
> >>+             /* Core GDB cannot deal with us deleting the current
> >>+                thread.  */
> >>+             if (!ptid_equal (lp->ptid, inferior_ptid))
> >>+               delete_thread (lp->ptid);
> >>+             printf_unfiltered ("[%s exited]\n",
> >>+                                target_pid_to_str (lp->ptid));
> >>+           }
> >>+         if (debug_lin_lwp)
> >>+           fprintf_unfiltered (gdb_stdlog,
> >>+                               "SWC: %s already exited.\n",
> >>                               target_pid_to_str (lp->ptid));
> >>
> >>
> >>This is right after waitpid has returned a non-exiting stopped status for
> >>lp->ptid.  Were you just being thorough, or do you have some reason to
> >>believe that waitpid would ever return WIFSTOPPED (status) and yet the
> >>thread would be dead?
> >
> 
> In the early days of nptl, the kernel wasn't always doing what it was
> expected to.  This appears to be leftover code as I attempted to ensure we
> caught the thread exiting one way or another.
> 
> >
> >Also, there's:
> >  pid = waitpid (GET_LWP (lp->ptid), &status, 0);
> >  if (pid == -1 && errno == ECHILD)
> >    {
> >      pid = waitpid (GET_LWP (lp->ptid), &status, __WCLONE);
> >      if (pid == -1 && errno == ECHILD)
> >        {
> >          /* The thread has previously exited.  We need to delete it now
> >             because in the case of NPTL threads, there won't be an
> >             exit event unless it is the main thread.  */
> >          if (debug_lin_lwp)
> >            fprintf_unfiltered (gdb_stdlog,
> >                                "SWC: %s exited.\n",
> >                                target_pid_to_str (lp->ptid));
> >          delete_lwp (lp->ptid);
> >          return 0;
> >        }
> >    }
> >  
> >Is there some reason you don't also call delete_thread?
> >
> 
> Hmm, appears to be an oversight on my part.
> 
> Do you want to make these changes?

I'll take care of it, since I'm moving this code anyway.  I just wanted
to check that I wasn't missing some Grand Design (TM).

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: lin-lwp and exiting threads
  2003-08-26 18:32 ` Daniel Jacobowitz
@ 2003-08-26 19:17   ` J. Johnston
  2003-08-26 18:48     ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: J. Johnston @ 2003-08-26 19:17 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz wrote:
> On Tue, Aug 26, 2003 at 01:51:35PM -0400, Daniel Jacobowitz wrote:
> 
>>Hi Jeff,
>>
>>I'm doing some work in lin-lwp.c and I saw this bit you recently committed:
>>
>>+      /* Check if the current LWP has previously exited.  For nptl threads,
>>+         there is no exit signal issued for LWPs that are not the
>>+         main thread so we should check whenever the thread is stopped.  */
>>+      if (!lin_lwp_thread_alive (lp->ptid))
>>+       {
>>+         if (in_thread_list (lp->ptid))
>>+           {
>>+             /* Core GDB cannot deal with us deleting the current
>>+                thread.  */
>>+             if (!ptid_equal (lp->ptid, inferior_ptid))
>>+               delete_thread (lp->ptid);
>>+             printf_unfiltered ("[%s exited]\n",
>>+                                target_pid_to_str (lp->ptid));
>>+           }
>>+         if (debug_lin_lwp)
>>+           fprintf_unfiltered (gdb_stdlog,
>>+                               "SWC: %s already exited.\n",
>>                                target_pid_to_str (lp->ptid));
>>
>>
>>This is right after waitpid has returned a non-exiting stopped status for
>>lp->ptid.  Were you just being thorough, or do you have some reason to
>>believe that waitpid would ever return WIFSTOPPED (status) and yet the
>>thread would be dead?
> 

In the early days of nptl, the kernel wasn't always doing what it was
expected to.  This appears to be leftover code as I attempted to ensure we
caught the thread exiting one way or another.

> 
> Also, there's:
>   pid = waitpid (GET_LWP (lp->ptid), &status, 0);
>   if (pid == -1 && errno == ECHILD)
>     {
>       pid = waitpid (GET_LWP (lp->ptid), &status, __WCLONE);
>       if (pid == -1 && errno == ECHILD)
>         {
>           /* The thread has previously exited.  We need to delete it now
>              because in the case of NPTL threads, there won't be an
>              exit event unless it is the main thread.  */
>           if (debug_lin_lwp)
>             fprintf_unfiltered (gdb_stdlog,
>                                 "SWC: %s exited.\n",
>                                 target_pid_to_str (lp->ptid));
>           delete_lwp (lp->ptid);
>           return 0;
>         }
>     }
>   
> Is there some reason you don't also call delete_thread?
> 

Hmm, appears to be an oversight on my part.

Do you want to make these changes?

-- Jeff J.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-08-26 19:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-26 17:52 lin-lwp and exiting threads Daniel Jacobowitz
2003-08-26 18:32 ` Daniel Jacobowitz
2003-08-26 19:17   ` J. Johnston
2003-08-26 18:48     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox