]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/tui: fix unexpected reuse of color pairs master
authorJakob Schäffeler <jakob.schaeffeler@tum.de>
Sat, 9 May 2026 21:27:43 +0000 (23:27 +0200)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 21 Jul 2026 11:05:56 +0000 (12:05 +0100)
commitfbe7f20a0f098ca03913452b29f50f0dc8568f77
treeee185239418adad9009e95934030a5231ca99df8
parentce860baa0745ee7a1ad942ef1dc89b713bbb7a3c
gdb/tui: fix unexpected reuse of color pairs

TUI translates ANSI styling sequences to curses color pairs.
Currently, this process uses COLOR_PAIR, which only returns values
from 0 to 255 which results in unexpected reuse of color pairs.

Replacing wattron/wattroff with wcolor_set avoids the 256 color pair
limit imposed by the COLOR_PAIR macro.  However, wcolor_set takes a
short for the pair index, limiting pairs to SHRT_MAX.

To support the full range of COLOR_PAIRS (up to 65536 with ncurses
6.1+), init_pair is replaced with init_extended_pair, and the pair
index is passed to wcolor_set via the opts parameter as an extended
color pair, a documented ncurses extension.

This also results in last_color_pair no longer being needed, and so it
is removed.

The extended color pair extension requires ncurses 6.1+, so a
configure check has been added.  The fallback path uses the older
color pair API which limits GDB to SHRT_MAX (32767) color pairs.

This patch was tested with make check-gdb TESTS="gdb.tui/*.exp"
Additionally, I tested this with the python extension from the bug
report.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34134

Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/config.in
gdb/configure
gdb/configure.ac
gdb/tui/tui-io.c