From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qQLnLGF8vGlayjAAWB0awg (envelope-from ) for ; Thu, 19 Mar 2026 18:44:49 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZAelqTIU; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B05591E0BC; Thu, 19 Mar 2026 18:44:49 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,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 419671E08C for ; Thu, 19 Mar 2026 18:44:49 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 8A9554BAE7E5 for ; Thu, 19 Mar 2026 22:44:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A9554BAE7E5 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZAelqTIU Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id D477D4BAE7F1 for ; Thu, 19 Mar 2026 22:44:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D477D4BAE7F1 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D477D4BAE7F1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773960261; cv=none; b=KzWl2hjlxnwfZoqARWt9P6ikTSgrHXKaW12BYKeT5foPugukjszvJamcs7Ivll8QIhBVKOnusoxZsZfJrWxe4FbrJi8zAYbVwN34ncbI0GPzu2R7iLHGGuiYdPYQU6goVUD09FGLBUCaCmE/SB70yUEm+NtMvCCkSeBUnHD8So8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773960261; c=relaxed/simple; bh=bhCerFtk/r7Zsxw+KR8rhTommf4PV59capk38AatynA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=SS4aPeDPMM9VRxdlhnRLobqmua9Uw2mTtl3fsAGInZcOWBc3euFxWbagaSWvsUgAm5XkzsaIjcCoEyFeMcR5BLT7bMMurmdrKW5J1hpo/xOmPVvxlT1RNqJYxFExdwwit0hThSmoow94n+KuCgLNCTZj641Enbfbm38KPsBzeV0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D477D4BAE7F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773960260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H25ofQsYBtmzLJASrTSaskijO1sebhVqqKeV+Wwj33w=; b=ZAelqTIUnfRU1lCT9g2SuxY7V3MVFBAQTtMoqvnwucnsxZMWr84CfWhvX8XSa6PTB3x9XT F5LxX0bAIFugApkHBnxzCW3ZK6MZF6D6XfhBFfet0mmyQrMAn1y4QzSvgpAjYXq2CiLyWX /Q57eG4jitf36uyouSVLij/1bJow+/A= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-381-JEsr590kPj-nzovB_A67UQ-1; Thu, 19 Mar 2026 18:44:14 -0400 X-MC-Unique: JEsr590kPj-nzovB_A67UQ-1 X-Mimecast-MFC-AGG-ID: JEsr590kPj-nzovB_A67UQ_1773960253 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A01751800561; Thu, 19 Mar 2026 22:44:12 +0000 (UTC) Received: from f42-zbm-amd (unknown [10.22.88.12]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A9FB21800107; Thu, 19 Mar 2026 22:44:09 +0000 (UTC) Date: Thu, 19 Mar 2026 15:44:07 -0700 From: Kevin Buettner To: sunilkumar.dora@windriver.com Cc: gdb-patches@sourceware.org, macro@orcam.me.uk, Randy.MacLeod@windriver.com, Sundeep.Kokkonda@windriver.com, schwab@linux-m68k.org, tromey@sourceware.org, simark@simark.ca Subject: Re: [PATCH V3] PR gdb/33747: gdb/ser-unix: modernize Linux custom baud rate support Message-ID: <20260319154254.643d8e82@f42-zbm-amd> In-Reply-To: <20260312210106.880833-1-sunilkumar.dora@windriver.com> References: <20260312210106.880833-1-sunilkumar.dora@windriver.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: IiIpvdtBY85Gx1NWo1aqcjoEZw1Ozyz_gH-AqLfd5Co_1773960253 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Thu, 12 Mar 2026 14:01:06 -0700 sunilkumar.dora@windriver.com wrote: > diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c > index c295a9c5ba1..a15f4cc2162 100644 > --- a/gdb/ser-unix.c > +++ b/gdb/ser-unix.c > @@ -510,36 +510,59 @@ set_baudcode_baudrate (struct serial *scb, int > baud_code) > #if HAVE_CUSTOM_BAUDRATE_SUPPORT && defined(BOTHER) > > -/* Set a custom baud rate using the termios BOTHER. */ > +/* Set a custom baud rate. > + > + Prefer the POSIX cfsetispeed/cfsetospeed interface when it accepts > + arbitrary baud rates. Otherwise fall back to Linux-specific termios2 > + (BOTHER) or legacy termios interfaces. */ > > static void > set_custom_baudrate_linux (int fd, int rate) > { > -#ifdef TCGETS2 > - struct termios2 tio; > - const unsigned long req_get = TCGETS2; > - const unsigned long req_set = TCSETS2; > -#else > +#if defined(HAVE_CFSETSPEED_ARBITRARY) Can you add a comment about how this code path is supported by glibc 2.42+ ? You could also mention that this behavior is expected to be standardized by a future POSIX revision. > struct termios tio; > - const unsigned long req_get = TCGETS; > - const unsigned long req_set = TCSETS; > -#endif > + if (tcgetattr (fd, &tio) < 0) > + perror_with_name (_("Cannot get current baud rate")); > + > + cfsetispeed (&tio, rate); > + cfsetospeed (&tio, rate); Return values for cfsetispeed and cfsetospeed should be checked. If either call fails, it should either error out or try another way of setting the speed. Kevin