From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8bxXAAEkwWmGjTUAWB0awg (envelope-from ) for ; Mon, 23 Mar 2026 07:29:05 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=windriver.com header.i=@windriver.com header.a=rsa-sha256 header.s=PPS06212021 header.b=YUez5b8w; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EFFBD1E0BC; Mon, 23 Mar 2026 07:29:04 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 25EE61E04F for ; Mon, 23 Mar 2026 07:29:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id B107C4BB3BA7 for ; Mon, 23 Mar 2026 11:29:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B107C4BB3BA7 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=windriver.com header.i=@windriver.com header.a=rsa-sha256 header.s=PPS06212021 header.b=YUez5b8w Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by sourceware.org (Postfix) with ESMTPS id 6ECAE4B9DB5B; Mon, 23 Mar 2026 11:28:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6ECAE4B9DB5B Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=windriver.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=windriver.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6ECAE4B9DB5B Authentication-Results: server2.sourceware.org; arc=fail smtp.remote-ip=205.220.178.238 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1774265312; cv=fail; b=Qobu4l2HOvV/er791jD5zQq8Zni4u52y+gJKSHtrZEg0mwXK2Uw3nEzn3WPQ9S7ZhQsDAv9QDz2O1De9Dmhul3xC1s6ZgAcDUUYgMK/Q7GQpUxHpSXiTZ42WM+v7hE9P8wejyINU1vbKzVbV2a4zw7v/x/5nOO8s4fo9grPs8sE= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1774265312; c=relaxed/simple; bh=5VF8TPnNAoMzavLfMeDBT+TVuo7AAYKOeAid120vLwo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tsmr99Ug4A/VWdpaYk2HqITwHYA3RS97mfZT21c9n8UaWdgbpDpNlugbgnt9aJhHp5dnepjZEld9M9OcBvDMWp+hLIMWzTIafKMlctnwaybeN0CkYr5Lo4baFepSgHTyhm0Zy0tVCX62jWjfdzbEk9UN0RXtYB6fZ3KZERiB1D0= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6ECAE4B9DB5B Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62N5kAi51354100; Mon, 23 Mar 2026 11:28:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=cc:content-transfer-encoding:content-type:date:from :message-id:mime-version:subject:to; s=PPS06212021; bh=YPYe7QgrI ne0bD8l9LrI8FyNclag6ATGHnZOiXG3lXM=; b=YUez5b8w5QzJ7Wy7uTyTSzZ/U 84UpsLLgvIIMkHWEYH0G6B07td1QvcHrBCuJFkixlk72myFwWlK/4B2h6bnZg3aF 9TVsdlPUTLFE1K5xzNOHpUG16ruoN5UKv0YUJu/IvsY2/fWUCBKfcLOifV5yCX5O atkePNaP/EKDE6KexWkE2BDnw/o8oeklZjufHNeG0kl8uP1BR1M8N4/YrV4hu4bw hVMRvd/J/K1m0VhTuzYp6PvwqtNzoq3HRKbbtmd6G136U2y3Q6D6IMZrTaaHplb9 iK9+GKwKulQ+aNQnOLHJGVcLw3kLO+Vw1w18Un/oYs6/GTOEmNYf8ZjxCWLzw== Received: from cy7pr03cu001.outbound.protection.outlook.com (mail-westcentralusazon11010062.outbound.protection.outlook.com [40.93.198.62]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 4d1ja6sr9u-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 Mar 2026 11:28:12 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X7KhAyuu9gDV8jGdcJK/cwbLL2D7WvpePZMGGX1OACiK9QQJBleqCcfcbvCaZCjSCZoRhaXlOnH6JPmMUt3l33sXo2lEYutD7SNRfgSWngehe5WBHc52Io1S6cXldNbsn7Dxo86V7iRezRjB3gLtIGN3+peyKUbkA7/uuAOuUIvauZVDkpsk8+4uxI1bvhGvw0OLW5XBJA63rEj1yQ60vrNQpLIYMEZc9mt1f+LUBiWj8bP5uZWhhtfuMMZFk8RDUIuhGIc2lDepF2rX6fJm/fR8p8AZ1bbZkhXPfXNp5vMa9UYsoBuRUjnRF8hiiEh+zD46vpJ7iitYN8CHZLuquQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YPYe7QgrIne0bD8l9LrI8FyNclag6ATGHnZOiXG3lXM=; b=aNh/Te8dyu+QHrhGhByzz1ClAbusEMWU9SBcjPT66y6QxyYoSEeyFfnco5zHaxeJf7SIBlyRH/+yxvUM0O6wQyEMl5BTpbl3mnNaM1AoE9oVh5BBSvX3MUX7r99NU2Z8BrxML8y6GJRgWys2jLBoR4xIvYhLe5xI9BuAKDMz3vXeZiSv4vY/p/6llH+UQXwZf/sd0c5SQo9964QaoAN0WtLFzo1FwechW3B01XQWmelxl508iVJe8K436DU1FIyA5g07kNTRwFTGQzDOG9W/8EEkJ/Kc7i8sxJeG+kWeXBAe1JtbwFhOsI4dkt4ixLv1Vr3ZNHptmTgGrfIXNg6dOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from DS0PR11MB7901.namprd11.prod.outlook.com (2603:10b6:8:f4::20) by DM3PPF027BB0053.namprd11.prod.outlook.com (2603:10b6:f:fc00::f05) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9745.15; Mon, 23 Mar 2026 11:28:09 +0000 Received: from DS0PR11MB7901.namprd11.prod.outlook.com ([fe80::4293:7c4b:a0b5:eb5f]) by DS0PR11MB7901.namprd11.prod.outlook.com ([fe80::4293:7c4b:a0b5:eb5f%3]) with mapi id 15.20.9745.019; Mon, 23 Mar 2026 11:28:09 +0000 From: sunilkumar.dora@windriver.com To: gdb-patches@sourceware.org Cc: kevinb@redhat.com, macro@orcam.me.uk, Randy.MacLeod@windriver.com, Sundeep.Kokkonda@windriver.com, schwab@linux-m68k.org, tromey@sourceware.org, simark@simark.ca, SunilKumar.Dora@windriver.com Subject: [PATCH V4] PR gdb/33747: gdb/ser-unix: modernize and fix custom baud rate support on musl Date: Mon, 23 Mar 2026 04:27:46 -0700 Message-ID: <20260323112746.2332070-1-sunilkumar.dora@windriver.com> X-Mailer: git-send-email 2.49.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: LO4P123CA0354.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18d::17) To DS0PR11MB7901.namprd11.prod.outlook.com (2603:10b6:8:f4::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7901:EE_|DM3PPF027BB0053:EE_ X-MS-Office365-Filtering-Correlation-Id: f31ac786-2578-4cfe-2d0c-08de88cf42d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|1800799024|366016|38350700014|56012099003|18002099003; X-Microsoft-Antispam-Message-Info: 136eg9bNOxSquxQ8Srp8HxV0Gp0/i1rIiUS6sHnaJMtQTG/7m0tbp0EZjkhTxTxPbcoTfVjuLMFHDd0PSFQpf3bHWuBrewD+b5IhlrcsvxSBZH9rBKSnM2vU167QUD/NRaGycCtmcO5/J9CpKVvi+TzUlVMqftdToxg6f+Mwbf5jE4K0E18rW1shhC/+sypqOtsV3DfnEU4XBfsSqK6fSvIYq1w9WGIItoz/UyY2ZXd+mmwOG4Z5p8CKvUf5YXznkIrS9iAkhFxd41QBBAzy+uARLjaCCLXDtVAeT8qmZ5e/UHsR+bHFIEdkGlccLJXkocBB03xQPOOcT1joTHvPhZGZW6rqte7Eina5HxysyGfcKDFBth65rrlHTEh12Zspa1uF6/gyHIMcI0740R+z0UmMZfona/U4EQ+uwC78p0+iFji1uj/zit+riWwgS9waAFo2tuwvVgWoo5pQYFW7+M00NxqTJfkhgRlW5MfapZtG7aEzN3/3odmYhHNuKIm7k7xSyqPITZ2fcik8BLB5I101G+cXNmvxmKKnrWYvw0HWeCVECBb9wZZJcBaYnUS3LSjAy4PaDVIiTZsKsimnSXRdc4ajqhc7cU1r0wZRUh79dcF9VePIM6h5BXerME/2Jl6pm/GAlm9fYEIPtXD3EhuC9a/oSqZCqMiQDnhASPliGJCfTfFqKbzpFeVnHx9FFOGXp7qA49qmCFP9RlYbJEaUJIfNsN3aHKhH3F3HyMCKEP1ZkenMd4AwxEpks8lbJPam/zq7Y/Cdls/mrcuCacVVldcovAdC0YzuwEKkR2g= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7901.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(52116014)(1800799024)(366016)(38350700014)(56012099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4nQ9okX6796nCGJp+Cv5Jv86uoqBjNfI3CfCmCQD130gAecmHm18YV84u6sh?= =?us-ascii?Q?BtpfPu6pc9lMKhf9VDJ/ZE5k+B8eNk2oJPjmvJ+ec8pztyJEsNncibdxRvWP?= =?us-ascii?Q?HCNzPwqbuZF4X4WVFIYRnbj1tScx32HW2+YfdM1OCs8EmvpHnY88WnELOJVC?= =?us-ascii?Q?nKRmrRVhbxOyr3KOPD2eGgOKC20aMR60hcqPLWdISUsjWrst/UQmQ+4xILNQ?= =?us-ascii?Q?UEtJMh4f3z7KEG7ZUYsoiyX1GChqzOLvh2mvCW77A8x0q4ScukSqu/4HEOYt?= =?us-ascii?Q?Xk3JNIzqXk4LlxVFJHlyZqtRMxVR6H38w3e1sSyhK88fqfmRXsLo83EPMOWa?= =?us-ascii?Q?TdpEsiLSBo8cMl9/Qxto6OlPhMw/VbYC8TT1sXPFIWq93+ordCEsP+qoYubD?= =?us-ascii?Q?mIQeewAqDKGg/Uxynsnp/gb5dOjPB587C/D66bD9v4wNwlKH6n4I+ByEk8kH?= =?us-ascii?Q?fVIzbLDgVcV6xn9xdyoox8FZqU3CpxH+vv0KypKuqKfbNydFO/ObyWwlRH2b?= =?us-ascii?Q?h6syfrLxGYoyU2sU/oj1DpaHUDCfRWLjJ8shYjVjK9xYbBtC6wF8ck3vv8ct?= =?us-ascii?Q?mdHxjhUDANDskMLUVVfoKTGEJb7DgIgf7J+3CoAqG1pPkNWQCJ8jGzkYMgIL?= =?us-ascii?Q?5QjenDtS6oJw9ItCThTAuuiaj0dEcVVEn9NXELPRrCYgLJMkOlvaVXUDukti?= =?us-ascii?Q?KnYUuA/uSnYYH9mHu58RGlvBeAtoK36L3QiGPlEdImeKxaeOHduBkAL7Fi0K?= =?us-ascii?Q?q4WBch3yvA1JaJ04LuuyDjr2cSuxVry5NDmZIJwPI3u1wSMMvgo1qOFgxuC0?= =?us-ascii?Q?sSNrptbKQiBbLIGN1Ejuu9uW5DGxzW66KRg+F4lzOhL+gEqBpb/esWuOd6CI?= =?us-ascii?Q?+mZqeNB5oyLLJh4K8iEoKopPvGBocfYRPTf3qoQ5KGi7OnyAQGo1C40QeYZK?= =?us-ascii?Q?neRtdm8+SPEI5q1+6Rt1bpNNFoFiRfLBAvSBOgs3zhF2bBFhzPfxq3Sxdauv?= =?us-ascii?Q?QNHTJpUHYdeLc1HLzyxGzUzPcYd1S2PyvxvIKFx4QRd2do9GuNK1qaGeHEst?= =?us-ascii?Q?kR2YF1Ei9FFFgw/3t/qhaZjJW4PfagFwlh1CMxX9jnSzCVYWr0438Z0wXx3c?= =?us-ascii?Q?rbEfy4ZA55v8Dpv7T++XtFV6LdIoMRAj6UPJlBv9DHVcmsFYt3o6qwbqGzpG?= =?us-ascii?Q?UFg71pt7JDeM0FEW7S7A8eGCZwNATovuG94sgnj6qX8FJV6mKSMyyptsupUD?= =?us-ascii?Q?ToBSetRHd+csb2xVjtCIgUWTQ7qrWzyGm+FfMV6dYgwvlRhtU/oVdaAsKlrs?= =?us-ascii?Q?X4G+X5ZcAPOrO4mYcC2tQ/5IpoSa7DU1lbnJnLpte6xkP3N2kWUfGxKOP0xT?= =?us-ascii?Q?wV8SOZA3ghUOxe4HYClJAi/3Cu9quoVjChMMd7nsmD2BNjPQDdbB5g/qUHeE?= =?us-ascii?Q?YYd3rDm5DHsEVXDPUNyC7cqgcwwk/VQ4BL8hrLIycWAWGxVlt1vwwRIVxgx0?= =?us-ascii?Q?/Je6ct65ZcehbV7cMIywIn4mjRNLLQCf2UfWUD845jqDUO1RK+DBKYiVIte6?= =?us-ascii?Q?CSyhtPX1oYJG+IcCBMQn77WsmJpjdq+adeiAaeSIUEQLM3KQrBj7bc6FRrZZ?= =?us-ascii?Q?/NZ40AK95cCUMonAGsgk0hrSpuNkZrCVFVB2qEj53POoG6hwZnTygSrvXuXS?= =?us-ascii?Q?rkXgxpaSgR85dOm3dckMUrUTgxUEh7C1+K/+F4mMAvRfbWbnuHKoLgGLKkM0?= =?us-ascii?Q?m4u0lG/1HZ4GV+NJqXAuAis3xw0tDW8=3D?= X-Exchange-RoutingPolicyChecked: rhUnXTuVaHOqBNuMxu1GG/E+qwdal/81RLqvxSSjVCzVEXhzUiBdqSMiwrHFL+06RN4UqBnKlhmJOKzk/z5GqUFt/EE0D5NOtacattPvc6IjsL87dGzupoQx2JnIBZBs4Z3BgjS87fGKmqlTEZPWD8LSs9vJ29OqdVqf9VYGlJhqJfaT32xkM2qA/QbLt89gGfZDoH7IXLLyH3UwKTK1mGnEcaRM6+Q9mfHpZJO9DrxsSgL+Hh9+hQeY5/b3SeBLcH2iILnB4+HIMfpWeaSPDhh3452Kf6SwWjUN90/3l7Y3YeKwlHGjjAB8XMiYAiIUFuWha5bzmZt6BaFNyzAyoQ== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: f31ac786-2578-4cfe-2d0c-08de88cf42d3 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7901.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2026 11:28:09.6232 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MnahLDaAH/g3Jr2MMzUa2v0WQTCIUsZvxqGqu/9lCggejXbC4u8UGmMPdxY21NMKPAw4UgsbrS4OEaw9yBIJ+J0zV6hU39TiB4A7lxUxZBY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PPF027BB0053 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDA4OSBTYWx0ZWRfX88rFwtidSFZo RTb1c7iiHA5PLUgbYN8IX4HL9qMf+O8nYBbf7DIzaJQIVZt38yV4yhtzHiKYRI5FT2NvGaJAfwV cDSN/b39RA9PZ1SdcT/7d8OeZaGF6WwEunfrrNp6EyID1mGIU0K3NygJgVyXVTSQd4U1k8dxzpw /YB6ovNq71+pyEci8hhWXfLp5PpVrqI8zVbxMbk1lSvSEAlU4fWGsuavC3XLLCEoTFSY/9c1Y7l 8V/5766LXeibRbyX8+aWqQLSNxll5IBiyYSRXJdncOb1OxXL90415jUD5V0OESu77lPtRzYbDCT 3XL0fHfFz0hHolLYMefrlp5a4sCPK/5vRHtvur+pofEZdLLtlwAA/ZrILZeE3xmxKkOdwDInqHS 2XADPHwSyHIX79bvnrRb0OB6rQJLIAPYzGSKNpxeq5N8yj1MPk9aRwE9ti7QM7xpYDbuNmssvf6 9GfsnFe254KfpZXdKMw== X-Authority-Analysis: v=2.4 cv=Q5vfIo2a c=1 sm=1 tr=0 ts=69c123cc cx=c_pps a=zLPr+aUDpHWP/LWwllnpHg==:117 a=6eWqkTHjU83fiwn7nKZWdM+Sl24=:19 a=z/mQ4Ysz8XfWz/Q5cLBRGdckG28=:19 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=xqWC_Br6kY4A:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=bi6dqmuHe4P4UrxVR6um:22 a=fTW__CHxibyLmBMfj2wP:22 a=t7CeM3EgAAAA:8 a=20KFwNOVAAAA:8 a=BcPKCTjPAAAA:8 a=fQQHQRxZRoAk7G4E3NkA:9 a=FdTzh2GWekK77mhwV6Dw:22 a=MNXww67FyIVnWKX2fotq:22 X-Proofpoint-ORIG-GUID: mXJroS7Lw2J_X0Jlp2PbqI7hCIHpiZqa X-Proofpoint-GUID: mXJroS7Lw2J_X0Jlp2PbqI7hCIHpiZqa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-23_03,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 bulkscore=0 clxscore=1015 phishscore=0 adultscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230089 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Sunil Dora On musl-based systems, may expose BOTHER even though struct termios does not define c_ispeed/c_ospeed. This causes the Linux-specific custom baud rate path to be compiled and fail to build. Fix this at the macro level by requiring HAVE_STRUCT_TERMIOS_C_OSPEED alongside BOTHER in the HAVE_CUSTOM_BAUDRATE_SUPPORT guard. This prevents the Linux-specific path from being compiled on systems where the required fields are unavailable, leaving set_custom_baudrate_linux() unchanged. Introduce a platform-agnostic implementation using the POSIX cfsetispeed/cfsetospeed interface, guarded by HAVE_CFSETSPEED_ARBITRARY. This interface is supported by glibc 2.42 and later and is expected to be standardized by a future POSIX revision. It also covers systems such as GNU Hurd that do not provide BOTHER. Return values from cfsetispeed() and cfsetospeed() are checked, and errors are reported via perror_with_name(). Update the dispatcher to prefer the POSIX implementation when available, falling back to Linux-specific (BOTHER) or Darwin-specific (IOSSIOSPEED) mechanisms otherwise. Suggested-by: Kevin Buettner Suggested-by: Maciej W. Rozycki Signed-off-by: Sunil Dora --- Changes since V3: - Moved the fix to the macro level, requiring HAVE_STRUCT_TERMIOS_C_OSPEED alongside BOTHER. - Left set_custom_baudrate_linux() completely unchanged. - Introduced set_custom_baudrate_posix(), guarded by HAVE_CFSETSPEED_ARBITRARY. - Added return value checks for cfsetispeed() and cfsetospeed(). - Extended HAVE_CUSTOM_BAUDRATE_SUPPORT for systems with HAVE_CFSETSPEED_ARBITRARY. - Removed the #else error() fallback. - Updated comments to reflect the new behaviour. gdb/NEWS | 7 +++++++ gdb/config.in | 6 ++++++ gdb/configure | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ gdb/configure.ac | 22 ++++++++++++++++++++ gdb/ser-unix.c | 43 ++++++++++++++++++++++++++++++++++----- 5 files changed, 125 insertions(+), 5 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index e46a5108272..967787783e2 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -36,6 +36,13 @@ subsequent runs of the inferior will use the same arguments as the first run. +* GDB now supports arbitrary baud rates on systems where the host libc + accepts them via cfsetispeed/cfsetospeed (such as glibc 2.42+). + On Linux systems where this is not available, GDB falls back to the + termios2 (BOTHER) interface. The legacy termios fallback is now + only compiled on systems where struct termios exposes c_ispeed + and c_ospeed. + * Support for stabs debug information has been removed. * Support for mdebug debug information has been removed. diff --git a/gdb/config.in b/gdb/config.in index b11fcf18372..b7aacab898a 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -110,6 +110,9 @@ the CoreFoundation framework. */ #undef HAVE_CFPREFERENCESCOPYAPPVALUE +/* Define if cfsetispeed/cfsetospeed accept arbitrary baud rates */ +#undef HAVE_CFSETSPEED_ARBITRARY + /* Define to 1 if you have the `clearenv' function. */ #undef HAVE_CLEARENV @@ -517,6 +520,9 @@ /* Define to 1 if `st_blocks' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_BLOCKS +/* Define to 1 if `c_ospeed' is a member of `struct termios'. */ +#undef HAVE_STRUCT_TERMIOS_C_OSPEED + /* Define to 1 if `td_pcb' is a member of `struct thread'. */ #undef HAVE_STRUCT_THREAD_TD_PCB diff --git a/gdb/configure b/gdb/configure index 12c54521682..ef2ee9f72ec 100755 --- a/gdb/configure +++ b/gdb/configure @@ -27728,6 +27728,58 @@ if test "$ac_res" != no; then : fi +# Check whether cfsetispeed/cfsetospeed accept arbitrary baud rates. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cfsetispeed/cfsetospeed accept arbitrary baud rates" >&5 +$as_echo_n "checking whether cfsetispeed/cfsetospeed accept arbitrary baud rates... " >&6; } +if ${gdb_cv_cfsetspeed_arbitrary+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + #if B9600 != 9600 + #error B-constants are not numeric symbols + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gdb_cv_cfsetspeed_arbitrary=yes +else + gdb_cv_cfsetspeed_arbitrary=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_cfsetspeed_arbitrary" >&5 +$as_echo "$gdb_cv_cfsetspeed_arbitrary" >&6; } + +if test "$gdb_cv_cfsetspeed_arbitrary" = yes; then + +$as_echo "#define HAVE_CFSETSPEED_ARBITRARY 1" >>confdefs.h + +fi + +# Check for members required by the legacy Linux custom baud rate path. +ac_fn_c_check_member "$LINENO" "struct termios" "c_ospeed" "ac_cv_member_struct_termios_c_ospeed" "#include +" +if test "x$ac_cv_member_struct_termios_c_ospeed" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TERMIOS_C_OSPEED 1 +_ACEOF + + +fi + + # Check whether --with-jit-reader-dir was given. diff --git a/gdb/configure.ac b/gdb/configure.ac index cf8078e1d89..e558cf44703 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -725,6 +725,28 @@ AC_CONFIG_FILES([jit-reader.h:jit-reader.in]) AC_SEARCH_LIBS(dlopen, dl) +# Check whether cfsetispeed/cfsetospeed accept arbitrary baud rates. +AC_CACHE_CHECK([whether cfsetispeed/cfsetospeed accept arbitrary baud rates], + [gdb_cv_cfsetspeed_arbitrary], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[ + #if B9600 != 9600 + #error B-constants are not numeric symbols + #endif + ]])], + [gdb_cv_cfsetspeed_arbitrary=yes], + [gdb_cv_cfsetspeed_arbitrary=no]) +]) + +if test "$gdb_cv_cfsetspeed_arbitrary" = yes; then + AC_DEFINE([HAVE_CFSETSPEED_ARBITRARY], [1], + [Define if cfsetispeed/cfsetospeed accept arbitrary baud rates]) +fi + +# Check for members required by the legacy Linux custom baud rate path. +AC_CHECK_MEMBERS([struct termios.c_ospeed], [], [], [[#include ]]) + GDB_AC_WITH_DIR([JIT_READER_DIR], [jit-reader-dir], [directory to load the JIT readers from], [${libdir}/gdb]) diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index c295a9c5ba1..0a6cdf0f630 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -55,7 +55,10 @@ #include "gdbsupport/scoped_ignore_sigttou.h" -#if defined(HAVE_SYS_IOCTL_H) && (defined(BOTHER) || defined(IOSSIOSPEED)) +#if defined(HAVE_CFSETSPEED_ARBITRARY) || \ + (defined(HAVE_SYS_IOCTL_H) && \ + ((defined(BOTHER) && defined(HAVE_STRUCT_TERMIOS_C_OSPEED)) || \ + defined(IOSSIOSPEED))) # define HAVE_CUSTOM_BAUDRATE_SUPPORT 1 #endif @@ -508,6 +511,33 @@ set_baudcode_baudrate (struct serial *scb, int baud_code) perror_with_name (_("could not set tty state")); } +#if defined(HAVE_CFSETSPEED_ARBITRARY) + +/* Set a custom baud rate using the POSIX cfsetispeed/cfsetospeed + interface. Supported in glibc 2.42+ and expected to be + standardized in a future POSIX revision. It is platform-agnostic + and also covers systems like GNU Hurd that do not provide BOTHER. */ + +static void +set_custom_baudrate_posix (int fd, int rate) +{ + struct termios tio; + + if (tcgetattr (fd, &tio) < 0) + perror_with_name (_("Can not get current baud rate")); + + if (cfsetispeed (&tio, rate) < 0) + perror_with_name (_("Can not set custom input baud rate")); + + if (cfsetospeed (&tio, rate) < 0) + perror_with_name (_("Can not set custom output baud rate")); + + if (tcsetattr (fd, TCSANOW, &tio) < 0) + perror_with_name (_("Can not set custom baud rate")); +} + +#endif /* HAVE_CFSETSPEED_ARBITRARY */ + #if HAVE_CUSTOM_BAUDRATE_SUPPORT && defined(BOTHER) /* Set a custom baud rate using the termios BOTHER. */ @@ -560,14 +590,17 @@ set_custom_baudrate_darwin (int fd, int rate) #if HAVE_CUSTOM_BAUDRATE_SUPPORT /* Set a baud rate that differs from the OS B_codes. - This is possible if one of the following macros is available: - - BOTHER (Linux). - - IOSSIOSPEED (Darwin). */ + Prefer the POSIX cfsetispeed/cfsetospeed interface when the host + libc accepts arbitrary baud rates. Otherwise fall back to + Linux-specific (BOTHER) or Darwin-specific (IOSSIOSPEED) + interfaces. */ static void set_custom_baudrate (int fd, int rate) { -#if defined(BOTHER) +#if defined(HAVE_CFSETSPEED_ARBITRARY) + set_custom_baudrate_posix (fd, rate); +#elif defined(BOTHER) set_custom_baudrate_linux (fd, rate); #elif defined(IOSSIOSPEED) set_custom_baudrate_darwin (fd, rate); -- 2.49.0