From 3cb63a7d2a2ef6d01dddeb543580c49f96ea0b4b Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 25 Aug 2026 05:03:03 +0100 Subject: [PATCH] dev-debug/gdb: backport 2 fixes to 17.2 * Fix build on sparc * Don't enable emoji in MI output, which breaks e.g. kdevelop Closes: https://bugs.gentoo.org/981378 Signed-off-by: Sam James --- ...17.2-gdb-cli-Don-t-emit-emojis-in-MI.patch | 156 ++++++++ .../gdb/files/gdb-17.2-sparc-termios.patch | 75 ++++ dev-debug/gdb/gdb-17.2-r1.ebuild | 356 ++++++++++++++++++ 3 files changed, 587 insertions(+) create mode 100644 dev-debug/gdb/files/gdb-17.2-gdb-cli-Don-t-emit-emojis-in-MI.patch create mode 100644 dev-debug/gdb/files/gdb-17.2-sparc-termios.patch create mode 100644 dev-debug/gdb/gdb-17.2-r1.ebuild diff --git a/dev-debug/gdb/files/gdb-17.2-gdb-cli-Don-t-emit-emojis-in-MI.patch b/dev-debug/gdb/files/gdb-17.2-gdb-cli-Don-t-emit-emojis-in-MI.patch new file mode 100644 index 0000000000000..ff575669cfb61 --- /dev/null +++ b/dev-debug/gdb/files/gdb-17.2-gdb-cli-Don-t-emit-emojis-in-MI.patch @@ -0,0 +1,156 @@ +https://sourceware.org/PR34501 +https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/915 + +From 615449b7e8d92ed8b9025b3591853b2517b79fa5 Mon Sep 17 00:00:00 2001 +Message-ID: <615449b7e8d92ed8b9025b3591853b2517b79fa5.1787629806.git.sam@gentoo.org> +From: Tom de Vries +Date: Thu, 13 Aug 2026 03:59:17 +0200 +Subject: [PATCH] [gdb/cli] Don't emit emojis in MI +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +PR mi/34501 reports the following: +... +$ gdb -q \ + -ex 'set charset UTF-8' \ + -ex 'interpreter-exec mi2 "-break-insert -f foo' \ + -ex quit +&"�\235\214�\217 No symbol table is loaded. Use the \"file\" command.\n" + ... +$ +... + +The output is a bit odd, but that gets better if we use +'set print sevenbit-strings on': +... +&"\342\235\214\357\270\217 No symbol table is loaded. Use the \"file\" command.\n" +... + +The output we see there is the error emoji: +... +$ gdb +(gdb) b foo +❌️ No symbol table is loaded. Use the "file" command. +... + +More specifically, two utf-8 encoded unicode characters: +- Cross Mark [1]: 0xE2 0x9D 0x8C +- Variation Selector-16 (VS16) [2]: 0xEF 0xB8 0x8F + +Now the question: is GDB doing something wrong? + +I think we probably should encode unicode characters in MI error strings as +octal escapes, independent of the sevenbit-strings setting. This patch does +not address this part. + +Then there's the question whether we should emit emojis in MI error strings in +the first place [3]. In principle they're unicode characters encoded in UTF-8, +and we can expect other such unicode characters in translated error strings. + +But, given that MI has can_emit_style_escape () == false, and already filters +out ANSI escape sequences, I think it's reasonable to also disable emojis. + +As for implementation, I introduced a function emoji_allowed alongside +can_emit_style_escape, which defaults to the value of can_emit_style_escape. + +Tested on x86_64-linux. + +Approved-By: Tom Tromey + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34501 + +[1] https://www.compart.com/en/unicode/U+274C +[2] https://www.compart.com/en/unicode/U+FE0F +[3] https://sourceware.org/bugzilla/show_bug.cgi?id=33920#c1 + +(cherry picked from commit dbf19e0f878eb592011c25c1dbbfc35eee330ec2) +--- + gdb/cli/cli-style.c | 4 +-- + gdb/testsuite/gdb.base/style-mi-no-emoji.exp | 30 ++++++++++++++++++++ + gdb/ui-file.h | 8 ++++++ + 3 files changed, 40 insertions(+), 2 deletions(-) + create mode 100644 gdb/testsuite/gdb.base/style-mi-no-emoji.exp + +diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c +index d6829f01095..7379f9a55bc 100644 +--- a/gdb/cli/cli-style.c ++++ b/gdb/cli/cli-style.c +@@ -468,7 +468,7 @@ show_warning_prefix (struct ui_file *file, int from_tty, + void + print_warning_prefix (ui_file *file) + { +- if (emojis_ok ()) ++ if (file->emoji_allowed () && emojis_ok ()) + gdb_puts (warning_prefix.c_str (), file); + } + +@@ -490,7 +490,7 @@ show_error_prefix (struct ui_file *file, int from_tty, + void + print_error_prefix (ui_file *file) + { +- if (emojis_ok ()) ++ if (file->emoji_allowed () && emojis_ok ()) + gdb_puts (error_prefix.c_str (), file); + } + +diff --git a/gdb/testsuite/gdb.base/style-mi-no-emoji.exp b/gdb/testsuite/gdb.base/style-mi-no-emoji.exp +new file mode 100644 +index 00000000000..c46c35b04a6 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/style-mi-no-emoji.exp +@@ -0,0 +1,30 @@ ++# Copyright (C) 2026 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Check that emojis are not printed in MI error messages. ++ ++with_ansi_styling_terminal { ++ clean_restart ++ ++ gdb_test "set style emoji on" ++ ++ # Check that there is no emoji printed before the error. Regression test ++ # for PR34501. ++ set re_line \ ++ [string_to_regexp \ ++ {&"No symbol table is loaded. Use the \"file\" command.\n"}] ++ gdb_test {interpreter-exec mi2 "-break-insert -f foo"} \ ++ "\r\n${re_line}(?=\r\n).*" ++} +diff --git a/gdb/ui-file.h b/gdb/ui-file.h +index 1219bde0a75..bf44389d652 100644 +--- a/gdb/ui-file.h ++++ b/gdb/ui-file.h +@@ -93,6 +93,14 @@ class ui_file + virtual bool can_emit_style_escape () + { return false; } + ++ /* True if emojis are allowed on STREAM. */ ++ bool emoji_allowed () ++ { ++ /* By default, assume that emojis are not allowed on streams that don't ++ support ANSI escapes. */ ++ return can_emit_style_escape (); ++ } ++ + virtual void flush () + {} + + +base-commit: 2636da31af44fab38c22cee0fe771761173ea64b +-- +2.55.0 + diff --git a/dev-debug/gdb/files/gdb-17.2-sparc-termios.patch b/dev-debug/gdb/files/gdb-17.2-sparc-termios.patch new file mode 100644 index 0000000000000..dee6800b4cacf --- /dev/null +++ b/dev-debug/gdb/files/gdb-17.2-sparc-termios.patch @@ -0,0 +1,75 @@ +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=2636da31af44fab38c22cee0fe771761173ea64b + +From 2636da31af44fab38c22cee0fe771761173ea64b Mon Sep 17 00:00:00 2001 +From: Simon Marchi +Date: Mon, 17 Nov 2025 16:25:18 -0500 +Subject: [PATCH] gdb/ser-unix: work around conflicting types for tcflag_t +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf8 +Content-Transfer-Encoding: 8bit + +When trying to cross-compile GDB to sparc-buildroot-linux-uclibc, I get: + + CXX ser-unix.o + In file included from /data1/smarchi/many-buildroots/toolchains/sparc/sparc-buildroot-linux-uclibc/sysroot/usr/include/termios.h:39, + from /home/smarchi/src/binutils-gdb/gdb/ser-unix.c:51: + /data1/smarchi/many-buildroots/toolchains/sparc/sparc-buildroot-linux-uclibc/sysroot/usr/include/bits/termios.h:26:22: error: conflicting declaration ‘typedef unsigned int tcflag_t’ + 26 | typedef unsigned int tcflag_t; + | ^~~~~~~~ + In file included from /home/smarchi/src/binutils-gdb/gdb/ser-unix.c:46: + /data1/smarchi/many-buildroots/toolchains/sparc/sparc-buildroot-linux-uclibc/sysroot/usr/include/asm/termbits.h:13:25: note: previous declaration as ‘typedef long unsigned int tcflag_t’ + 13 | typedef unsigned long tcflag_t; + | ^~~~~~~~ + +uClibc and the kernel don't agree on the definition of tcflag_t for this +architecture. Here' uClibc [1]: + + typedef unsigned int tcflag_t; + +And here's the kernel [2]: + + #if defined(__sparc__) && defined(__arch64__) + typedef unsigned int tcflag_t; + #else + typedef unsigned long tcflag_t; <--- that branch is take + #endif + +glibc [3] has the same definition as uClibc, so we would get the same +problem. + +I propose to work around this the same way as we handle differences in +the termios structure, by renaming the version from the kernel. + +I opened a bug on the glibc bugzilla [4] to ask if this is something +that would need to be fixed on the libc side, but in the mean time we +need to work around it. + +[1] https://github.com/kraj/uClibc/blob/ca1c74d67dd115d059a875150e10b8560a9c35a8/libc/sysdeps/linux/sparc/bits/termios.h#L26 +[2] https://github.com/torvalds/linux/blob/e7c375b181600caf135cfd03eadbc45eb530f2cb/arch/sparc/include/uapi/asm/termbits.h#L7-L11 +[3] https://gitlab.com/gnutools/glibc/-/blob/efc8642051e6c4fe5165e8986c1338ba2c180de6/bits/termios.h#L104 +[4] https://sourceware.org/bugzilla/show_bug.cgi?id=33643 + +Change-Id: I71c6e0df5ac8e2ff3db3233a2220faaf70c3df6d +Approved-By: Tom Tromey +(cherry picked from commit 6b84377e146794446f21371f8455b870a029cc8e) +--- + gdb/ser-unix.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c +index 5ec664df1f3..50c0fdddf6d 100644 +--- a/gdb/ser-unix.c ++++ b/gdb/ser-unix.c +@@ -43,8 +43,10 @@ + /* Workaround to resolve conflicting declarations of termios + in and . */ + # define termios asmtermios ++# define tcflag_t asmtcflag_t + # include + # undef termios ++# undef tcflag_t + #endif + + #ifdef HAVE_TERMIOS_H +-- +2.43.7 diff --git a/dev-debug/gdb/gdb-17.2-r1.ebuild b/dev-debug/gdb/gdb-17.2-r1.ebuild new file mode 100644 index 0000000000000..b53f8400ec2c6 --- /dev/null +++ b/dev-debug/gdb/gdb-17.2-r1.ebuild @@ -0,0 +1,356 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +# See https://sourceware.org/gdb/wiki/DistroAdvice for general packaging +# tips & notes. + +GUILE_COMPAT=( 2-2 3-0 ) +PYTHON_COMPAT=( python3_{11..14} ) +inherit flag-o-matic guile-single linux-info python-single-r1 strip-linguas toolchain-funcs + +export CTARGET=${CTARGET:-${CHOST}} + +if [[ ${CTARGET} == ${CHOST} ]] ; then + if [[ ${CATEGORY} == cross-* ]] ; then + export CTARGET=${CATEGORY#cross-} + fi +fi + +is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; } + +case ${PV} in + 9999*) + # live git tree + EGIT_REPO_URI=" + https://sourceware.org/git/binutils-gdb.git + https://git.sr.ht/~sourceware/binutils-gdb + https://gitlab.com/x86-binutils/binutils-gdb.git + " + inherit git-r3 + SRC_URI="" + ;; + *.*.50_p2???????|*.*.90_p2???????) + # Weekly snapshots + MY_PV="${PV/_p/.}" + SRC_URI=" + https://sourceware.org/pub/gdb/snapshots/branch/gdb-weekly-${MY_PV}.tar.xz + https://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-${MY_PV}.tar.xz + https://distfiles.gentoo.org/pub/proj/toolchain/gdb/snapshots/gdb-weekly-${MY_PV}.tar.xz + " + S="${WORKDIR}/${PN}-${MY_PV}" + + # e.g. 13.1.90_p20230325 is a snapshot on the stable branch, so it's fine + if [[ ${PV} == *.[123456789].9?_p2??????? ]] ; then + REGULAR_RELEASE=1 + fi + ;; + *.*.9?) + # Prereleases + MY_PV="${PV/_p/.}" + SRC_URI=" + https://sourceware.org/pub/gdb/snapshots/branch/gdb-${MY_PV}.tar.xz + https://distfiles.gentoo.org/pub/proj/toolchain/gdb/snapshots/gdb-${MY_PV}.tar.xz + " + S="${WORKDIR}/${PN}-${MY_PV}" + ;; + *) + # Normal upstream release + SRC_URI=" + mirror://gnu/gdb/${P}.tar.xz + https://sourceware.org/pub/gdb/releases/${P}.tar.xz + " + + REGULAR_RELEASE=1 +esac + +PATCH_DEV="" +PATCH_VER="" +DESCRIPTION="GNU debugger" +HOMEPAGE="https://sourceware.org/gdb/" +SRC_URI=" + ${SRC_URI} + ${PATCH_DEV:+https://distfiles.gentoo.org/pub/proj/toolchain/gdb/patches/${P}-patches-${PATCH_VER}.tar.xz} +" + +LICENSE="GPL-3+ LGPL-2.1+" +SLOT="0" +IUSE="babeltrace cet +debuginfod guile lzma multitarget nls +python rocm +server sim source-highlight test vanilla +xml xxhash zstd" +if [[ -n ${REGULAR_RELEASE} ]] ; then + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-macos ~x64-solaris" +fi +REQUIRED_USE=" + guile? ( ${GUILE_REQUIRED_USE} ) + python? ( ${PYTHON_REQUIRED_USE} ) + rocm? ( multitarget ) +" +RESTRICT="!test? ( test )" + +#