[PATCH 07/11] Re-add zombie leader on exit, gdb/linux

Simon Marchi simark@simark.ca
Mon Mar 7 20:08:05 GMT 2022


On 2022-03-03 09:40, Pedro Alves wrote:
> @@ -2814,7 +2822,23 @@ linux_nat_filter_event (int lwpid, int status)
>  	  /* Don't report an event for the exit of an LWP not in our
>  	     list, i.e. not part of any inferior we're debugging.
>  	     This can happen if we detach from a program we originally
> -	     forked and then it exits.  */
> +	     forked and then it exits.  However, note that we may have
> +	     earlier deleted a leader of an inferior we're debugging,
> +	     in check_zombie_leaders.  Re-add it back here if so.  */
> +	  for (inferior *inf : all_inferiors (linux_target))
> +	    {
> +	      if (inf->pid == lwpid)
> +		{
> +		  linux_nat_debug_printf
> +		    ("Re-adding thread group leader LWP %d after exit.",
> +		     lwpid);
> +
> +		  lp = add_lwp (ptid_t (lwpid, lwpid));
> +		  lp->resumed = 1;
> +		  add_thread (linux_target, lp->ptid);
> +		  break;
> +		}
> +	    }

Should we do this only if WIFEXITED?  We don't expect to get any other
event from a deleted leader, so it's more to be safe in case there is a
kernel bug or something that would make us see something else.

Otherwise, LGTM.

Simon


More information about the Gdb-patches mailing list