public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: filter inferiors using linux_target in check_zombie_leaders
@ 2022-02-18 22:58 Simon Marchi
  2022-02-19 10:17 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Marchi @ 2022-02-18 22:58 UTC (permalink / raw)
  To: gdb-patches

check_zombie_leaders, a help function of the linux-nat target, iterates
on all inferiors when looking for zombie leaders.  This potentially
includes inferiors from other targets.  This is not harmful, for
inferiors from other targets it will simply not find a matching lwp.
But it would make sense to only iterate on the target's inferiors.

We can also remove the "inf->pid == 0" check: inferiors that have the
linux-nat target pushed will have execution and a non-zero pid.

Change-Id: Ie31465dbae983fcc639478939877e1616848738b
---
 gdb/linux-nat.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 5b747f7822b3..352716eda9ba 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -3052,14 +3052,9 @@ linux_nat_filter_event (int lwpid, int status)
 static void
 check_zombie_leaders (void)
 {
-  for (inferior *inf : all_inferiors ())
+  for (inferior *inf : all_inferiors (linux_target))
     {
-      struct lwp_info *leader_lp;
-
-      if (inf->pid == 0)
-	continue;
-
-      leader_lp = find_lwp_pid (ptid_t (inf->pid));
+      lwp_info *leader_lp = find_lwp_pid (ptid_t (inf->pid));
       if (leader_lp != NULL
 	  /* Check if there are other threads in the group, as we may
 	     have raced with the inferior simply exiting.  */

base-commit: f6b3ad544063314a1e7fcaa703b5e29f5ff10780
-- 
2.35.1


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

* Re: [PATCH] gdb: filter inferiors using linux_target in check_zombie_leaders
  2022-02-18 22:58 [PATCH] gdb: filter inferiors using linux_target in check_zombie_leaders Simon Marchi
@ 2022-02-19 10:17 ` Andrew Burgess
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2022-02-19 10:17 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

* Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> [2022-02-18 17:58:39 -0500]:

> check_zombie_leaders, a help function of the linux-nat target, iterates
> on all inferiors when looking for zombie leaders.  This potentially
> includes inferiors from other targets.  This is not harmful, for
> inferiors from other targets it will simply not find a matching lwp.
> But it would make sense to only iterate on the target's inferiors.
> 
> We can also remove the "inf->pid == 0" check: inferiors that have the
> linux-nat target pushed will have execution and a non-zero pid.

LGTM.

Thanks,
Andrew

> 
> Change-Id: Ie31465dbae983fcc639478939877e1616848738b
> ---
>  gdb/linux-nat.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
> index 5b747f7822b3..352716eda9ba 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -3052,14 +3052,9 @@ linux_nat_filter_event (int lwpid, int status)
>  static void
>  check_zombie_leaders (void)
>  {
> -  for (inferior *inf : all_inferiors ())
> +  for (inferior *inf : all_inferiors (linux_target))
>      {
> -      struct lwp_info *leader_lp;
> -
> -      if (inf->pid == 0)
> -	continue;
> -
> -      leader_lp = find_lwp_pid (ptid_t (inf->pid));
> +      lwp_info *leader_lp = find_lwp_pid (ptid_t (inf->pid));
>        if (leader_lp != NULL
>  	  /* Check if there are other threads in the group, as we may
>  	     have raced with the inferior simply exiting.  */
> 
> base-commit: f6b3ad544063314a1e7fcaa703b5e29f5ff10780
> -- 
> 2.35.1
> 


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

end of thread, other threads:[~2022-02-19 10:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 22:58 [PATCH] gdb: filter inferiors using linux_target in check_zombie_leaders Simon Marchi
2022-02-19 10:17 ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).