From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32450 invoked by alias); 10 Mar 2006 01:04:52 -0000 Received: (qmail 32437 invoked by uid 22791); 10 Mar 2006 01:04:51 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 10 Mar 2006 01:04:49 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id k2A14mFK012999 for ; Thu, 9 Mar 2006 20:04:48 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id k2A14l126900; Thu, 9 Mar 2006 20:04:47 -0500 Received: from [172.16.24.50] (bluegiant.sfbay.redhat.com [172.16.24.50]) by potter.sfbay.redhat.com (8.12.8/8.12.8) with ESMTP id k2A14jmG029786; Thu, 9 Mar 2006 20:04:45 -0500 Message-ID: <4410D0AC.1000505@redhat.com> Date: Fri, 10 Mar 2006 02:11:00 -0000 From: Michael Snyder User-Agent: Mozilla Thunderbird 1.0.7-1.4.1 (X11/20050929) MIME-Version: 1.0 To: GDB Patches CC: Daniel Jacobowitz , Randolph Chung Subject: [RFA] linux multi-fork kill (re: "run", and executable file/symtab association?) Content-Type: multipart/mixed; boundary="------------060806050805050901080700" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00153.txt.bz2 This is a multi-part message in MIME format. --------------060806050805050901080700 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 378 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. --------------060806050805050901080700 Content-Type: text/plain; name="killall.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="killall.txt" Content-length: 3408 2006-03-09 Michael Snyder * 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 --------------060806050805050901080700--