From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 5C07D382FC93 for ; Wed, 16 Nov 2022 01:01:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C07D382FC93 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=us.ibm.com Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AG0Ll9W016963; Wed, 16 Nov 2022 01:01:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=SJk9S3KbxxdcWJPhPVEAYSuyrW/XhDIQGgUAU+V1j94=; b=qtUtyl75ILHNuuwXiK08Z6FdcA4pOJXXrYU2nCdzJfnATc5KrDl81QRR9h/fJkGzgzWP qDmTFQHcX2/v3vniX81N/MG0d66/V/udC94CmVQzxI9h5ZAQICLfEUWgKX/Up5c6oF0D 5Bgv4BtHWTCVhKiZGg8MCqPhq8/tdrzcG++VpfJg6v0CrKFvkPNY6T6JKkc851OiBP/I E6FGoMjEeGuulHsVhu2qKIxsopzRZEr1opc2IJnPX+3EANTKjFPAe4d/3K2+ILsqklWB 4XPsTeI+ZAiJuq/0W/obwgeLiY8DdDVfsTLj8SR/+BXmg0I7mgCAz/ymGc6TYGTr+Jnl Sg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kvn8k0m97-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 01:01:51 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AG10QPK012678; Wed, 16 Nov 2022 01:01:51 GMT Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kvn8k0m8y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 01:01:51 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AG0pVwf021020; Wed, 16 Nov 2022 01:01:50 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma04dal.us.ibm.com with ESMTP id 3kt349wc6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 01:01:50 +0000 Received: from smtpav05.wdc07v.mail.ibm.com ([9.208.128.117]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AG11njk9503384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 01:01:49 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 193A458063; Wed, 16 Nov 2022 01:01:49 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C29E5805F; Wed, 16 Nov 2022 01:01:48 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.163.52.7]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 16 Nov 2022 01:01:48 +0000 (GMT) Message-ID: <6cb9fd038eefd825bd0e66c80da3771e4a512b68.camel@us.ibm.com> Subject: Re: [PATCH 2/2 ver 3] PowerPC, fix support for printing the function return value for non-trivial values. From: Carl Love To: Ulrich Weigand , "gdb-patches@sourceware.org" , "tdevries@suse.de" , Simon Marchi Cc: "kevinb@redhat.com" , "will_schmidt@vnet.ibm.com" , "blarsen@redhat.com" , cel@us.ibm.com Date: Tue, 15 Nov 2022 17:01:47 -0800 In-Reply-To: References: <2db5ad69b32f4cda9c53b252ad37cd783f827c14.camel@de.ibm.com> <7f476265-c6a9-9fcf-ce13-ff550ea5e6f6@suse.de> <6ed2cf1714e5b8dc386e66b634b540efdf828ed5.camel@de.ibm.com> <2466b7efc91dd4964add9a0d7ce4cd47678f5800.camel@us.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: v1qaPdwzYw0IqF7Bb-sCjKPnEGgz4J4- X-Proofpoint-ORIG-GUID: BwxT2q8zmBV_GkgoOVQNLMh1SqbMb3rP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-15_08,2022-11-15_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 spamscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160002 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Ulrich, Tom, Simon: On Tue, 2022-11-15 at 18:05 +0000, Ulrich Weigand wrote: > Carl Love wrote: > > > + else > > + sm->return_buf = 0; > > + } > > else > > - sm->return_buf = 0; > > + sm->return_buf = 0; /* Return buffer address is not > > available. */ > > Just as a minor nit, it might be cleaner to initialize > sm->return_buf to 0 just once up-front. > > Patch is OK otherwise. > > > Thanks, > Ulrich Yes, I agree, it would be best to just set sm->return_buf = 0 initially. Then if the return buffer is available update it as needed. That makes things a lot cleaner. The updated patch is below. Note, it has been tested on PowerPC and X86_64. It does not introduce any additional regression errors. It does fix the seven unresolved testcases that the initial patch introduced and were missed by my testing of the initial patch. Tom, if you can verify this fix works on your system it would be greatly appreciated. Thanks. Carl Love --------------------------------------------------- Bug fix in commit for printing the function return value for non-trivial values The recent commit: commit a0eda3df5b750ae32576a9be092b361281a41787 Author: Carl Love Date: Mon Nov 14 16:22:37 2022 -0500 PowerPC, fix support for printing the function return value for non-trivial values. Is generating a segmentation fault on x86_64-linux. segfault: ... PASS: gdb.asm/asm-source.exp: info source asmsrc1.s ERROR: GDB process no longer exists UNRESOLVED: gdb.asm/asm-source.exp: finish from foo3 ... Reproduced on command line: ... $ gdb -q -batch -x outputs/gdb.asm/asm-source/gdb.in.1 ... The problem seems to be that: ... Thread 1 "gdb" received signal SIGSEGV, Segmentation fault. 0x000000000043de7a in symbol::type (this=0x0) at .../gdb_versions/devel/src/gdb/symtab.h:1287 1287 return m_type; ... because: ... (gdb) up #1 0x0000000000852d94 in finish_command (arg=0x0, from_tty=0) at .../gdb_versions/devel/src/gdb/infcmd.c:1887 1887 = check_typedef (sm->function->type ()->target_type ()); (gdb) p sm->function $1 = (symbol *) 0x0 The code is not checking if sm->function is NULL. If sm->function is NULL the check for the return buffer should be skipped. --- gdb/infcmd.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index b71dc10370b..a72df2d6a01 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1877,26 +1877,28 @@ finish_command (const char *arg, int from_tty) /* Find the function we will return from. */ frame_info_ptr callee_frame = get_selected_frame (NULL); sm->function = find_pc_function (get_frame_pc (callee_frame)); + sm->return_buf = 0; /* Initialize buffer address is not available. */ /* Determine the return convention. If it is RETURN_VALUE_STRUCT_CONVENTION, attempt to determine the address of the return buffer. */ - enum return_value_convention return_value; - struct gdbarch *gdbarch = get_frame_arch (callee_frame); + if (sm->function != NULL) + { + enum return_value_convention return_value; + struct gdbarch *gdbarch = get_frame_arch (callee_frame); - struct type * val_type - = check_typedef (sm->function->type ()->target_type ()); + struct type * val_type + = check_typedef (sm->function->type ()->target_type ()); - return_value = gdbarch_return_value (gdbarch, - read_var_value (sm->function, NULL, - callee_frame), - val_type, NULL, NULL, NULL); + return_value = gdbarch_return_value (gdbarch, + read_var_value (sm->function, NULL, + callee_frame), + val_type, NULL, NULL, NULL); - if (return_value == RETURN_VALUE_STRUCT_CONVENTION - && val_type->code () != TYPE_CODE_VOID) - sm->return_buf = gdbarch_get_return_buf_addr (gdbarch, val_type, - callee_frame); - else - sm->return_buf = 0; + if (return_value == RETURN_VALUE_STRUCT_CONVENTION + && val_type->code () != TYPE_CODE_VOID) + sm->return_buf = gdbarch_get_return_buf_addr (gdbarch, val_type, + callee_frame); + } /* Print info on the selected frame, including level number but not source. */ -- 2.31.1