From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B2FC03857352 for ; Wed, 8 Jun 2022 16:37:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B2FC03857352 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 258EqKEu021315 for ; Wed, 8 Jun 2022 16:37:34 GMT Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gjwwrjahf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 08 Jun 2022 16:37:34 +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 258GLE92011792 for ; Wed, 8 Jun 2022 16:37:33 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma04dal.us.ibm.com with ESMTP id 3gfy1abjhu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 08 Jun 2022 16:37:33 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 258GbW6U27132334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 Jun 2022 16:37:32 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BA54BE053; Wed, 8 Jun 2022 16:37:32 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DFDFDBE054; Wed, 8 Jun 2022 16:37:31 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.211.57.135]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 8 Jun 2022 16:37:31 +0000 (GMT) Message-ID: <56ccf64ceaaf37ab6c29b3dbcdce621a7378b556.camel@us.ibm.com> Subject: [PATCH] PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF. From: Carl Love To: gdb-patches@sourceware.org, Ulrich Weigand , Will Schmidt , cel@us.ibm.com Date: Wed, 08 Jun 2022 09:37:31 -0700 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: Ih_Bgp2jIf4caHf62SnnIGYuQjf5oVA0 X-Proofpoint-ORIG-GUID: Ih_Bgp2jIf4caHf62SnnIGYuQjf5oVA0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-08_05,2022-06-07_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=786 adultscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206080067 X-Spam-Status: No, score=-11.8 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 16:37:36 -0000 GDB maintainers: The current value for the ioctl numbers for TCGETS, TCSETS, TCSETSW and TCSETSF on PowerPC are not correct. The ioctl number is based on the size of the termios data structure for PowerPC. The size of the termios data structure on PowerPC is 0x2c, however the size in the ioctl number is set at 0x3c. This patch fixes the size of the ioctl numbers. This patch has been tested by running various ioctl tests in the ncurses testsuite using gdb record full. Without the patch gdb record full complains that the various ioctl calls are unkown. For example the following message is printed for the ncurses test firework when run under gdb and record full enabled. Process record and replay target doesn't support ioctl request 0x402c7413. With the patch, the ioctl number for TCGETS is corrected and gdb record full now records the ioctl call. The patch has been tested manually with various ncurses test case on a Power 10 system to verify the patch. Please let me know if this patch is acceptable for mainline. Carl Love ------------------------------------------------- PowerPC, correct the gdb ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF. Some of the ioctl numbers are based on the size of kernel termios structure. Currently the PowerPC GDB definitions are "hard coded" into the ioctl number. The current PowerPC values for TCGETS, TCSETS, TCSETSW and TCSETSF are defined in gdb/ppc-linux-tdep.c as: record_tdep->ioctl_TCGETS = 0x403c7413; record_tdep->ioctl_TCSETS = 0x803c7414; record_tdep->ioctl_TCSETSW = 0x803c7415; record_tdep->ioctl_TCSETSF = 0x803c7416; Where the termios structure size is in hex digits [5:4] as 0x3c. The definition for the PowerPC termios structure is given in: arch/powerpc/include/uapi/asm/termbits.h The size of the termios data structure in this file is 0x2c not 0x3c. This patch changes the hex digits for the size of the PowerPC termios size in the ioctl values for TCGETS, TCSETS, TCSETSW and TCSETSF to 0x2c. This patch also changes the hard coding to generate the number based on a #define to make it clearer how the ioctl numbers are generated and to make it easier to update the ioctl numbers. --- gdb/ppc-linux-tdep.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 4c5f8b7a281..469f06d2f22 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -1738,6 +1738,11 @@ static void ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep, int wordsize) { + /* The values for TCGETS, TCSETS, TCSETSW, TCSETSF are based on the + size of struct termios in the kernel source. + include/uapi/asm-generic/termbits.h */ +#define SIZE_OF_STRUCT_TERMIOS 0x2c + /* Simply return if it had been initialized. */ if (record_tdep->size_pointer != 0) return; @@ -1898,15 +1903,16 @@ ppc_init_linux_record_tdep (struct linux_record_tdep *record_tdep, /* These values are the second argument of system call "sys_ioctl". They are obtained from Linux Kernel source. - See arch/powerpc/include/uapi/asm/ioctls.h. */ - record_tdep->ioctl_TCGETS = 0x403c7413; - record_tdep->ioctl_TCSETS = 0x803c7414; - record_tdep->ioctl_TCSETSW = 0x803c7415; - record_tdep->ioctl_TCSETSF = 0x803c7416; record_tdep->ioctl_TCGETA = 0x40147417; record_tdep->ioctl_TCSETA = 0x80147418; record_tdep->ioctl_TCSETAW = 0x80147419; record_tdep->ioctl_TCSETAF = 0x8014741c; + See arch/powerpc/include/uapi/asm/ioctls.h. */ + record_tdep->ioctl_TCGETS = 0x40007413 | (SIZE_OF_STRUCT_TERMIOS << 16); + record_tdep->ioctl_TCSETS = 0x80007414 | (SIZE_OF_STRUCT_TERMIOS << 16); + record_tdep->ioctl_TCSETSW = 0x80007415 | (SIZE_OF_STRUCT_TERMIOS << 16); + record_tdep->ioctl_TCSETSF = 0x80007416 | (SIZE_OF_STRUCT_TERMIOS << 16); + record_tdep->ioctl_TCSBRK = 0x2000741d; record_tdep->ioctl_TCXONC = 0x2000741e; record_tdep->ioctl_TCFLSH = 0x2000741f; -- 2.31.1