Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] linux multi-fork kill (re: "run", and executable file/symtab  association?)
@ 2006-03-10  2:11 Michael Snyder
  2006-03-11 11:39 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Snyder @ 2006-03-10  2:11 UTC (permalink / raw)
  To: GDB Patches; +Cc: Daniel Jacobowitz, Randolph Chung

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

Randolph, this is in response to your bug report.
Daniel, see if this looks OK to you.  Instead of calling
pop_target (which, I agree, was iffy), we just go thru
target_mourn_inferior like we always did.

Rearranged linux_fork_killall because of an unexpected
interaction with delete_fork -- at least one fork wasn't
getting killed, because delete_fork tries to be too clever.


[-- Attachment #2: killall.txt --]
[-- Type: text/plain, Size: 3408 bytes --]

2006-03-09  Michael Snyder  <msnyder@redhat.com>

	* linux-nat.c (kill_inferior): Just call target_mourn_inferior
	instead of getting tricky for the multi-fork case.
	* linux-fork.c (linux_fork_killall): Call PT_KILL and waitpid
	for each fork, and then use init_fork_list to delete them.

Index: linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.c,v
retrieving revision 1.38
diff -p -r1.38 linux-nat.c
*** linux-nat.c	20 Feb 2006 17:01:28 -0000	1.38
--- linux-nat.c	10 Mar 2006 00:57:30 -0000
*************** kill_inferior (void)
*** 616,623 ****
    if (forks_exist_p ())
      {
        linux_fork_killall ();
-       pop_target ();
-       generic_mourn_inferior ();
      }
    else
      {
--- 616,621 ----
*************** kill_inferior (void)
*** 646,653 ****
  	  ptrace (PT_KILL, pid, 0, 0);
  	  ret = wait (&status);
  	}
-       target_mourn_inferior ();
      }
  }
  
  /* On GNU/Linux there are no real LWP's.  The closest thing to LWP's
--- 644,651 ----
  	  ptrace (PT_KILL, pid, 0, 0);
  	  ret = wait (&status);
  	}
      }
+   target_mourn_inferior ();
  }
  
  /* On GNU/Linux there are no real LWP's.  The closest thing to LWP's
Index: linux-fork.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-fork.c,v
retrieving revision 1.3
diff -p -r1.3 linux-fork.c
*** linux-fork.c	15 Jan 2006 19:07:17 -0000	1.3
--- linux-fork.c	10 Mar 2006 00:57:30 -0000
*************** add_fork (pid_t pid)
*** 72,79 ****
  {
    struct fork_info *fp;
  
!   if (fork_list == NULL &&
!       pid != PIDGET (inferior_ptid))
      {
        /* Special case -- if this is the first fork in the list
  	 (the list is hitherto empty), and if this new fork is
--- 72,78 ----
  {
    struct fork_info *fp;
  
!   if (fork_list == NULL && pid != PIDGET (inferior_ptid))
      {
        /* Special case -- if this is the first fork in the list
  	 (the list is hitherto empty), and if this new fork is
*************** linux_fork_killall (void)
*** 322,338 ****
       status for it) -- however any process may be a child
       or a parent, so may get a SIGCHLD from a previously
       killed child.  Wait them all out.  */
    pid_t pid, ret;
    int status;
  
!   do {
!     pid = PIDGET (fork_list->ptid);
!     do {
!       ptrace (PT_KILL, pid, 0, 0);
!       ret = waitpid (pid, &status, 0);
!     } while (ret == pid && WIFSTOPPED (status));
!     delete_fork (fork_list->ptid);
!   } while (fork_list != NULL);
  }
  
  /* The current inferior_ptid has exited, but there are other viable
--- 321,342 ----
       status for it) -- however any process may be a child
       or a parent, so may get a SIGCHLD from a previously
       killed child.  Wait them all out.  */
+   struct fork_info *fp;
    pid_t pid, ret;
    int status;
  
!   for (fp = fork_list; fp; fp = fp->next)
!     {
!       pid = PIDGET (fp->ptid);
!       do {
! 	ptrace (PT_KILL, pid, 0, 0);
! 	ret = waitpid (pid, &status, 0);
! 	/* We might get a SIGCHLD instead of an exit status.  This is
! 	 aggravated by the first kill above - a child has just
! 	 died.  MVS comment cut-and-pasted from linux-nat.  */
!       } while (ret == pid && WIFSTOPPED (status));
!     }
!   init_fork_list ();	/* Clear list, prepare to start fresh.  */
  }
  
  /* The current inferior_ptid has exited, but there are other viable

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

* Re: [RFA] linux multi-fork kill (re: "run", and executable file/symtab association?)
  2006-03-10  2:11 [RFA] linux multi-fork kill (re: "run", and executable file/symtab association?) Michael Snyder
@ 2006-03-11 11:39 ` Daniel Jacobowitz
  2006-03-11 19:08   ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2006-03-11 11:39 UTC (permalink / raw)
  To: Michael Snyder; +Cc: GDB Patches, Randolph Chung

On Thu, Mar 09, 2006 at 05:04:44PM -0800, Michael Snyder wrote:
> Randolph, this is in response to your bug report.
> Daniel, see if this looks OK to you.  Instead of calling
> pop_target (which, I agree, was iffy), we just go thru
> target_mourn_inferior like we always did.
> 
> Rearranged linux_fork_killall because of an unexpected
> interaction with delete_fork -- at least one fork wasn't
> getting killed, because delete_fork tries to be too clever.

Looks good to me.  You're right, I'll need to re-merge - how about
you go first since I don't know when I'll have a chance to update
that patch?

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFA] linux multi-fork kill (re: "run", and executable file/symtab  association?)
  2006-03-11 11:39 ` Daniel Jacobowitz
@ 2006-03-11 19:08   ` Michael Snyder
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Snyder @ 2006-03-11 19:08 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: GDB Patches, Randolph Chung

Daniel Jacobowitz wrote:
> On Thu, Mar 09, 2006 at 05:04:44PM -0800, Michael Snyder wrote:
> 
>>Randolph, this is in response to your bug report.
>>Daniel, see if this looks OK to you.  Instead of calling
>>pop_target (which, I agree, was iffy), we just go thru
>>target_mourn_inferior like we always did.
>>
>>Rearranged linux_fork_killall because of an unexpected
>>interaction with delete_fork -- at least one fork wasn't
>>getting killed, because delete_fork tries to be too clever.
> 
> 
> Looks good to me.  You're right, I'll need to re-merge - how about
> you go first since I don't know when I'll have a chance to update
> that patch?
> 

Committed.


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

end of thread, other threads:[~2006-03-10 20:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-10  2:11 [RFA] linux multi-fork kill (re: "run", and executable file/symtab association?) Michael Snyder
2006-03-11 11:39 ` Daniel Jacobowitz
2006-03-11 19:08   ` Michael Snyder

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