From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13151 invoked by alias); 26 Apr 2011 10:37:56 -0000 Received: (qmail 12990 invoked by uid 22791); 26 Apr 2011 10:37:55 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Apr 2011 10:37:41 +0000 Received: (qmail 16215 invoked from network); 26 Apr 2011 10:37:40 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 26 Apr 2011 10:37:40 -0000 From: Pedro Alves To: gdb@sourceware.org Subject: Re: bogus extra code in gdbserver detach command support? Date: Tue, 26 Apr 2011 10:37:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.6.2; x86_64; ; ) Cc: Doug Evans References: <20110425215758.AEED22461A8@ruffy.mtv.corp.google.com> In-Reply-To: <20110425215758.AEED22461A8@ruffy.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201104261137.45851.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-04/txt/msg00147.txt.bz2 On Monday 25 April 2011 22:57:58, Doug Evans wrote: > Hi. > > Under what circumstances does this code in server.c actually do something? > > /* If we are attached, then we can exit. Otherwise, we > need to hang around doing nothing, until the child is > gone. */ > for_each_inferior (&all_processes, > join_inferiors_callback); > > This is for the 'D' packet. > AIUI, this code will already have emptied all_processes: > > if (detach_inferior (pid) != 0) > write_enn (own_buf); Hmm, looks like I broke this with the multi-process changes. If you look back at, e.g., gdb 6.8, the join backend implementations would work because they only relied on the signal_pid global, not any process structure: static void linux_join (void) { extern unsigned long signal_pid; int status, ret; do { ret = waitpid (signal_pid, &status, 0); if (WIFEXITED (status) || WIFSIGNALED (status)) break; } while (ret != -1 || errno != ECHILD); } /* Wait for inferiors to end. */ static void win32_join (void) { extern unsigned long signal_pid; HANDLE h = OpenProcess (PROCESS_ALL_ACCESS, FALSE, signal_pid); if (h != NULL) { WaitForSingleObject (h, INFINITE); CloseHandle (h); } } Looks like removing the: struct process_info *process; process = find_process_pid (pid); if (process == NULL) return; bit from linux_join, and call join_inferior directly on the detachee's pid from server.c would restore the old behavior. > > Or can multiprocess debugging be used without the extended remote protocol? Nope. -- Pedro Alves