The "set style" commands which set colors are broken on MS-Windows (was: [ANNOUNCEMENT] GDB 17.1 released!)
| Message ID | 86h5t1gsp9.fsf@gnu.org |
|---|---|
| State | New |
| Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id CD9924BA2E04 for <patchwork@sourceware.org>; Sun, 4 Jan 2026 18:05:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD9924BA2E04 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=fpUplywC X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from eggs.gnu.org (eggs.gnu.org [209.51.188.92]) by sourceware.org (Postfix) with ESMTPS id D5E614BA2E04 for <gdb-patches@sourceware.org>; Sun, 4 Jan 2026 18:05:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5E614BA2E04 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D5E614BA2E04 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.51.188.92 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767549909; cv=none; b=JupU6m2RUMpU19O8ccJx/FFFn6d5/eupyqBC+dp8a3tezoH5MBv9HFq+GGgFu6EmYsVIx/oYGCHPM/vrGeXEHakxv3bO34d372ALm/9hKVyP5G0N/DrQSauLxqen2e8rc94S6Lem1J/8+P/t/X4aX3gYpDMjiTJTm4izWsUjoxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767549909; c=relaxed/simple; bh=LPvLywG7KmOqntRbjSLWkGLggJ+OlNCGQQxzcLGwy9Q=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=Z9lAD3ezAPffirhSVkYmGcVCaR2i4yfXAHE1p3a8swHIVwpYNkNdqNxTvMXlzpxbILNKyQss3tAyclbqcAM7pch6IAqB1rrZFMjmWeXPyV9MTPr/5jXFo8Mva60+j8fsfa7Gyt2//V8FcH4NmsYYNqJ5QXNTzJsQaVI8hMzFRyw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5E614BA2E04 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@gnu.org>) id 1vcSTU-0007HH-Pk for gdb-patches@sourceware.org; Sun, 04 Jan 2026 13:05:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=OOLe5xvmah2RMZGvmWuenRa6KjuijHeUgxpPyzVXjTs=; b=fpUplywCHhip qbRAH6gFG/Fptkdq6s91iVGDpqRPKSxsn6KDpdLDnZmpCBPplOaRICYHq4qcfiQ57XujZsuiXPThU ZRUkstheyUErW8WG4VSoSEu30ncV62N9qxyPe+dGtpsQuRRB8TtsL0hfSOB/+SNj7Z0pfQzuL0UBp TCE2hvf81T9M7k+3FrCDjXXBp+DMDAXaXv9fyndriNLpLwi2ZERW4RVPQ8l6zlAo7Xf2qjcs3MMJ/ 6XPm3bCGg++Fw8SaXwJlPzTOSdW/0+BENvRCJn3C0b9BeRIas0A31OeebUN45mp9MYIoqj63xObG6 JDMVEzRYUwlne4IjRg5YgQ==; Date: Sun, 04 Jan 2026 20:04:34 +0200 Message-Id: <86h5t1gsp9.fsf@gnu.org> From: Eli Zaretskii <eliz@gnu.org> To: gdb-patches@sourceware.org In-Reply-To: <announce.20251220053009.F3797804ED@takamaka.gnat.com> (message from Joel Brobecker via Gdb-announce via Gdb on Sat, 20 Dec 2025 09:30:09 +0400 (+04)) Subject: The "set style" commands which set colors are broken on MS-Windows (was: [ANNOUNCEMENT] GDB 17.1 released!) References: <announce.20251220053009.F3797804ED@takamaka.gnat.com> X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
The "set style" commands which set colors are broken on MS-Windows (was: [ANNOUNCEMENT] GDB 17.1 released!)
|
|
Commit Message
Eli Zaretskii
Jan. 4, 2026, 6:04 p.m. UTC
> Date: Sat, 20 Dec 2025 09:30:09 +0400 (+04) > From: Joel Brobecker via Gdb-announce via Gdb <gdb@sourceware.org> > Cc: Joel Brobecker via Gdb-announce <gdb-announce@sourceware.org> > > > GDB 17.1 released! > > Release 17.1 of GDB, the GNU Debugger, is now available. GDB is > a source-level debugger for Ada, C, C++, Fortran, Go, Rust, and many > other languages. GDB can target (i.e., debug programs running on) > more than a dozen different processor architectures, and GDB itself > can run on most popular GNU/Linux, Unix and Microsoft Windows variants. > GDB is free (libre) software. > > You can download GDB from the GNU HTTPS server in the directory: > > https://ftp.gnu.org/gnu/gdb/?C=M;O=D I've built GDB 17.1 today on MS-Windows with MinGW, and found that the commands which set colors of styling are broken. Specifically, the default colors do work, and are displayed as expected, but as soon as one types a "set style SOMETHING foreground COLOR" command, the specified color is reset to "none". The reason is this code in ui-style.c: const std::vector<color_space> & colorsupport () { static const std::vector<color_space> value = [] { std::vector<color_space> result = {color_space::MONOCHROME}; int colors = tgetnum ("Co"); if (colors >= 8) result.push_back (color_space::ANSI_8COLOR); if (colors >= 16) result.push_back (color_space::AIXTERM_16COLOR); if (colors >= 256) result.push_back (color_space::XTERM_256COLOR); This relies on the terminfo's "Co" capability for determining the number of colors supported by the terminal. However, Windows terminals usually lack terminfo entries, so the above code decides that the terminal doesn't support colors at all. The simplest fix is below. I filed a Bugzilla bug 33761 due to this. I think this should be fixed both on master and on the branch. Here's the proposed patch:
Comments
> Date: Sun, 04 Jan 2026 20:04:34 +0200 > From: Eli Zaretskii <eliz@gnu.org> > > > Date: Sat, 20 Dec 2025 09:30:09 +0400 (+04) > > From: Joel Brobecker via Gdb-announce via Gdb <gdb@sourceware.org> > > Cc: Joel Brobecker via Gdb-announce <gdb-announce@sourceware.org> > > > > > > GDB 17.1 released! > > > > Release 17.1 of GDB, the GNU Debugger, is now available. GDB is > > a source-level debugger for Ada, C, C++, Fortran, Go, Rust, and many > > other languages. GDB can target (i.e., debug programs running on) > > more than a dozen different processor architectures, and GDB itself > > can run on most popular GNU/Linux, Unix and Microsoft Windows variants. > > GDB is free (libre) software. > > > > You can download GDB from the GNU HTTPS server in the directory: > > > > https://ftp.gnu.org/gnu/gdb/?C=M;O=D > > I've built GDB 17.1 today on MS-Windows with MinGW, and found that the > commands which set colors of styling are broken. Specifically, the > default colors do work, and are displayed as expected, but as soon as > one types a "set style SOMETHING foreground COLOR" command, the > specified color is reset to "none". > > The reason is this code in ui-style.c: > > const std::vector<color_space> & > colorsupport () > { > static const std::vector<color_space> value = [] > { > std::vector<color_space> result = {color_space::MONOCHROME}; > > int colors = tgetnum ("Co"); > if (colors >= 8) > result.push_back (color_space::ANSI_8COLOR); > if (colors >= 16) > result.push_back (color_space::AIXTERM_16COLOR); > if (colors >= 256) > result.push_back (color_space::XTERM_256COLOR); > > This relies on the terminfo's "Co" capability for determining the > number of colors supported by the terminal. However, Windows > terminals usually lack terminfo entries, so the above code decides > that the terminal doesn't support colors at all. > > The simplest fix is below. I filed a Bugzilla bug 33761 due to this. > I think this should be fixed both on master and on the branch. > > Here's the proposed patch: Ping! Any objections to installing this patch, both on master and on the branch?
Eli Zaretskii <eliz@gnu.org> writes: >> Date: Sun, 04 Jan 2026 20:04:34 +0200 >> From: Eli Zaretskii <eliz@gnu.org> >> >> > Date: Sat, 20 Dec 2025 09:30:09 +0400 (+04) >> > From: Joel Brobecker via Gdb-announce via Gdb <gdb@sourceware.org> >> > Cc: Joel Brobecker via Gdb-announce <gdb-announce@sourceware.org> >> > >> > >> > GDB 17.1 released! >> > >> > Release 17.1 of GDB, the GNU Debugger, is now available. GDB is >> > a source-level debugger for Ada, C, C++, Fortran, Go, Rust, and many >> > other languages. GDB can target (i.e., debug programs running on) >> > more than a dozen different processor architectures, and GDB itself >> > can run on most popular GNU/Linux, Unix and Microsoft Windows variants. >> > GDB is free (libre) software. >> > >> > You can download GDB from the GNU HTTPS server in the directory: >> > >> > https://ftp.gnu.org/gnu/gdb/?C=M;O=D >> >> I've built GDB 17.1 today on MS-Windows with MinGW, and found that the >> commands which set colors of styling are broken. Specifically, the >> default colors do work, and are displayed as expected, but as soon as >> one types a "set style SOMETHING foreground COLOR" command, the >> specified color is reset to "none". >> >> The reason is this code in ui-style.c: >> >> const std::vector<color_space> & >> colorsupport () >> { >> static const std::vector<color_space> value = [] >> { >> std::vector<color_space> result = {color_space::MONOCHROME}; >> >> int colors = tgetnum ("Co"); >> if (colors >= 8) >> result.push_back (color_space::ANSI_8COLOR); >> if (colors >= 16) >> result.push_back (color_space::AIXTERM_16COLOR); >> if (colors >= 256) >> result.push_back (color_space::XTERM_256COLOR); >> >> This relies on the terminfo's "Co" capability for determining the >> number of colors supported by the terminal. However, Windows >> terminals usually lack terminfo entries, so the above code decides >> that the terminal doesn't support colors at all. >> >> The simplest fix is below. I filed a Bugzilla bug 33761 due to this. >> I think this should be fixed both on master and on the branch. >> >> Here's the proposed patch: > > Ping! Any objections to installing this patch, both on master and on > the branch? Sorry, I meant to get back to you on this. I've got no objections. Thanks, Andrew
> From: Andrew Burgess <aburgess@redhat.com> > Date: Sat, 17 Jan 2026 13:02:11 +0000 > > Eli Zaretskii <eliz@gnu.org> writes: > > >> const std::vector<color_space> & > >> colorsupport () > >> { > >> static const std::vector<color_space> value = [] > >> { > >> std::vector<color_space> result = {color_space::MONOCHROME}; > >> > >> int colors = tgetnum ("Co"); > >> if (colors >= 8) > >> result.push_back (color_space::ANSI_8COLOR); > >> if (colors >= 16) > >> result.push_back (color_space::AIXTERM_16COLOR); > >> if (colors >= 256) > >> result.push_back (color_space::XTERM_256COLOR); > >> > >> This relies on the terminfo's "Co" capability for determining the > >> number of colors supported by the terminal. However, Windows > >> terminals usually lack terminfo entries, so the above code decides > >> that the terminal doesn't support colors at all. > >> > >> The simplest fix is below. I filed a Bugzilla bug 33761 due to this. > >> I think this should be fixed both on master and on the branch. > >> > >> Here's the proposed patch: > > > > Ping! Any objections to installing this patch, both on master and on > > the branch? > > Sorry, I meant to get back to you on this. I've got no objections. Thanks, now installed on master and on the branch.
--- gdb/ui-style.c~ 2025-12-20 04:53:21.000000000 +0200 +++ gdb/ui-style.c 2026-01-04 19:13:51.707357200 +0200 @@ -595,6 +595,12 @@ colorsupport () std::vector<color_space> result = {color_space::MONOCHROME}; int colors = tgetnum ("Co"); +#ifdef __MINGW32__ + /* MS-Windows terminal generally doesn't have "Co" in its + terminfo, but always supports 8 colors. */ + if (colors <= 0) + colors = 8; +#endif if (colors >= 8) result.push_back (color_space::ANSI_8COLOR); if (colors >= 16)