From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60787 invoked by alias); 7 Sep 2016 15:08:38 -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 60746 invoked by uid 89); 7 Sep 2016 15:08:37 -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=Carl, love X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Sep 2016 15:08:36 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u87F7rIf058021 for ; Wed, 7 Sep 2016 11:08:34 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 25a1kmrqyq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 07 Sep 2016 11:08:34 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 Sep 2016 09:08:23 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 7 Sep 2016 09:08:22 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: cel@us.ibm.com Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id AE48C19D8065 for ; Wed, 7 Sep 2016 09:07:52 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u87F8Mv45898506; Wed, 7 Sep 2016 08:08:22 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10EC47805F; Wed, 7 Sep 2016 09:08:22 -0600 (MDT) Received: from [9.70.82.29] (unknown [9.70.82.29]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 9FBD178056; Wed, 7 Sep 2016 09:08:21 -0600 (MDT) Subject: [PATCH] Fix for gdb.server/non-existing-program.exp test case From: "Carl E. Love" To: Andreas Arnez , gdb-patches@sourceware.org, cel@us.ibm.com, Edjunior Barbosa Machado , Ulrich Weigand Date: Wed, 07 Sep 2016 15:08:00 -0000 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: 16090715-0016-0000-0000-0000049A1D9E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005722; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000185; SDB=6.00754952; UDB=6.00357356; IPR=6.00527831; BA=6.00004701; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012613; XFM=3.00000011; UTC=2016-09-07 15:08:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16090715-0017-0000-0000-000032B43249 Message-Id: <1473260901.4102.84.camel@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-07_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=1 spamscore=1 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1609070230 X-SW-Source: 2016-09/txt/msg00074.txt.bz2 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..8a6708f 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. Depending on the architecture, + the function target_post_create_inferior () may make additional ptrace () + calls that will fail if the target has already exited. + */ 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