From: Kevin Buettner <kevinb@redhat.com>
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
Date: Thu, 19 Mar 2026 15:44:07 -0700 [thread overview]
Message-ID: <20260319154254.643d8e82@f42-zbm-amd> (raw)
In-Reply-To: <20260312210106.880833-1-sunilkumar.dora@windriver.com>
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
next prev parent reply other threads:[~2026-03-19 22:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 21:01 sunilkumar.dora
2026-03-19 22:44 ` Kevin Buettner [this message]
2026-03-22 19:49 ` Sunil Kumar Dora
2026-03-20 1:24 ` Maciej W. Rozycki
2026-03-22 19:55 ` Sunil Kumar Dora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260319154254.643d8e82@f42-zbm-amd \
--to=kevinb@redhat.com \
--cc=Randy.MacLeod@windriver.com \
--cc=Sundeep.Kokkonda@windriver.com \
--cc=gdb-patches@sourceware.org \
--cc=macro@orcam.me.uk \
--cc=schwab@linux-m68k.org \
--cc=simark@simark.ca \
--cc=sunilkumar.dora@windriver.com \
--cc=tromey@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox