From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yaRMBfShvGli5TAAWB0awg (envelope-from ) for ; Thu, 19 Mar 2026 21:25:08 -0400 Received: by simark.ca (Postfix, from userid 112) id 0FB511E0BC; Thu, 19 Mar 2026 21:25:08 -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.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 86F0D1E04F for ; Thu, 19 Mar 2026 21:25:07 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 28CAD4C3180C for ; Fri, 20 Mar 2026 01:25:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28CAD4C3180C Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by sourceware.org (Postfix) with ESMTP id ADAC04BBC098; Fri, 20 Mar 2026 01:24:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ADAC04BBC098 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ADAC04BBC098 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=78.133.224.34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773969881; cv=none; b=wDiam+u9O9ezlTrl8UQiJ7qSheq/3NSOGRQQktnz6rxhCEFdWBkpCHC6PLXf9e0dFAotP/OlxTqtZ1ztUufUgokgNNDWWEH3Kw+9xH9rhLfCGo6d9Mzn4k6YVL959GlmBTALYijRkl/ALGGHBUXIcHtG+gHUgyNaH+2WkpbJ5VY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773969881; c=relaxed/simple; bh=dZCqCf8joxtx7CUMCX4vIFOB4CMpbRz7r9MQPSEpSkA=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=wKjpyMbjQQ5gLt0GidcQe3c0Atj66oeNv2Hv4Z8yapbKfB7bweZ+2WaKtuD/luJbFeO/PyecFkV5olzclPrQBdotD0AMjHPzZw1uwm59NYXg6cjRUlkIL40E5E5iINqaRCaiz3TKmh4EnsI9Pfi8mc+cq/Cz6FwS1J2MRXv2kkQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADAC04BBC098 Received: by angie.orcam.me.uk (Postfix, from userid 500) id B93C192009C; Fri, 20 Mar 2026 02:24:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id B2DDA92009B; Fri, 20 Mar 2026 01:24:40 +0000 (GMT) Date: Fri, 20 Mar 2026 01:24:40 +0000 (GMT) From: "Maciej W. Rozycki" To: sunilkumar.dora@windriver.com cc: gdb-patches@sourceware.org, Kevin Buettner , Randy.MacLeod@windriver.com, Sundeep.Kokkonda@windriver.com, schwab@linux-m68k.org, tromey@sourceware.org, Simon Marchi Subject: Re: [PATCH V3] PR gdb/33747: gdb/ser-unix: modernize Linux custom baud rate support In-Reply-To: <20260312210106.880833-1-sunilkumar.dora@windriver.com> Message-ID: References: <20260312210106.880833-1-sunilkumar.dora@windriver.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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, 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) > 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); > + > + if (tcsetattr (fd, TCSANOW, &tio) < 0) > + perror_with_name (_("Cannot set custom baud rate")); It doesn't appear to me this code should be wrapped in: #if ... && defined(BOTHER) or for that matter be a part of `set_custom_baudrate_linux' (which AFAICT should be left alone, or please point me at what actually you have changed there that is not pure code massaging) as this is now platform-agnostic (and I believe GNU Hurd has always supported arbitrary baud rates using this interface). I'm leaving it up to you to come up with a name for this new variant of the function. Also ISTM that HAVE_CUSTOM_BAUDRATE_SUPPORT now also needs to be set if HAVE_CFSETSPEED_ARBITRARY rather than relying on BOTHER to be defined as well, which may not necessarily be the case (cf. GNU Hurd again). > +#else > + error (_("Custom baud rate not supported on this platform")); > +#endif This shouldn't be needed as this code is not supposed to be ever compiled if !HAVE_CUSTOM_BAUDRATE_SUPPORT (IOW don't set the macro instead if the conditions required are not met). Maciej