From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129979 invoked by alias); 13 Sep 2016 15:25:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 129965 invoked by uid 89); 13 Sep 2016 15:25:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:U*uweigand, 29016, H*m:115, H*MI:115 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Sep 2016 15:25:24 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8DFOU0q036168 for ; Tue, 13 Sep 2016 11:25:23 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 25dxu4rsdw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Sep 2016 11:25:23 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Sep 2016 09:25:22 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Sep 2016 09:25:19 -0600 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: cel@us.ibm.com Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id D32333E40041 for ; Tue, 13 Sep 2016 09:25:09 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8DFOcLj16187738; Tue, 13 Sep 2016 08:25:08 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7AF3A78061; Tue, 13 Sep 2016 09:25:08 -0600 (MDT) Received: from [9.70.82.29] (unknown [9.70.82.29]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 1505378059; Tue, 13 Sep 2016 09:25:08 -0600 (MDT) Subject: Re: [PATCH] Fix for gdb.server/non-existing-program.exp test case From: "Carl E. Love" To: Ulrich Weigand Cc: Andreas Arnez , gdb-patches@sourceware.org, Edjunior Barbosa Machado , Ulrich Weigand Date: Tue, 13 Sep 2016 15:25:00 -0000 In-Reply-To: <20160913132630.92A081161D1@oc8523832656.ibm.com> References: <20160913132630.92A081161D1@oc8523832656.ibm.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16091315-0020-0000-0000-000009C51E88 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005754; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000185; SDB=6.00757280; UDB=6.00359072; IPR=6.00530651; BA=6.00004715; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012661; XFM=3.00000011; UTC=2016-09-13 15:25:20 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16091315-0021-0000-0000-0000557080A7 Message-Id: <1473780307.4102.115.camel@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-13_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609130226 X-SW-Source: 2016-09/txt/msg00096.txt.bz2 On Tue, 2016-09-13 at 15:26 +0200, Ulrich Weigand wrote: > Carl Love wrote: > > > 2016-09-06 Carl Love > > > > * server.c (start_inferior): Do not call > > function target_post_create_inferior () if the > > inferior process has already exited. > > The patch makes sense to me, however there seem to be > some formatting issues (mail client problems?): > > > + /* The last_status.kind was set by the call to > > ptrace(PTRACE_TRACEME, ...). > > + The function linux_wait() has also been called. At this point, > > the > > + target process, if it exits, is stopped. Depending on the > > architecture, > > + the function target_post_create_inferior () may make additional > > ptrace () > > + calls that will fail if the target has already exited. > > + */ > > Please make sure this is properly formatted (and does not exceed > the 80 characters per line limit). > > Also, the comment seems a bit too specific; this file is also used > for targets other than Linux that may not use ptrace specifically. > I'd word the comment a bit more generically, along the lines of > "Do not call target_post_create_inferior if the process has already > exited, since the target implementation of that routine may rely on > the process being live." I fixed up the comment per your suggestion. Not sure what happened with the formatting. See if this looks better. Carl Love --------------------------------------------------------------------------- Fix for gdb.server/non-existing-program.exp test case The test checks to make sure GDB exits cleanly if there is no valid target binary. Currently, ppc and S390 fail on this test. The function target_post_create_inferior () calls linux_post_create_inferior () which calls the architecture specific functions s390_arch_setup () and ppc_arch_setup () which make ptrace calls to access the architecture specific registers. These ptrace calls fail because the process does not exist causing GDB to exit on error. This patch checks to see if the initial ptrace (PTRACE_TRACEME, ...) call returned a status of TARGET_WAITKIND_EXITED indicating the target has already exited. If the target has exited, then the target_post_create_inferior () is not called since there is no inferior to be setup. The test to see if the initial ptrace call succeeded is done after the ptrace (PTRACE_TRACEME, ...) call and the wait for the inferior process to stop, assuming it exists, has occurred. The patch has been tested on X86 64-bit, ppc64 and s390. If fixes the test failures on ppc64 and s390. The test does not fail on X86 64-bit. The patch does not introduce any additional regression failures on any of these three platforms. gdbserver/ChangeLog 2016-09-06 Carl Love * server.c (start_inferior): Do not call function target_post_create_inferior () if the inferior process has already exited. --- gdb/gdbserver/server.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 6fbd61d..908be47 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -290,11 +290,16 @@ start_inferior (char **argv) (assuming success). */ last_ptid = mywait (pid_to_ptid (signal_pid), &last_status, 0, 0); - target_post_create_inferior (); - + /* The last_status.kind was set by the call to ptrace(PTRACE_TRACEME, ...). + The function linux_wait() has also been called. At this point, the + target process, if it exits, is stopped. Do not call the function + target_post_create_inferior if the process has already exited, as the + target implementation of the routine may rely on the process being live. + */ if (last_status.kind != TARGET_WAITKIND_EXITED && last_status.kind != TARGET_WAITKIND_SIGNALLED) { + target_post_create_inferior (); current_thread->last_resume_kind = resume_stop; current_thread->last_status = last_status; } -- 2.4.11