From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id U4eKORBcfGoJcSAAWB0awg (envelope-from ) for ; Wed, 12 Aug 2026 07:42:08 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Dt1DJpcC; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=RuCRLsLe; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=tztTAqaz; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Iu8zq9SB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D99F61E166; Wed, 12 Aug 2026 07:42: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=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 4D2751E033 for ; Wed, 12 Aug 2026 07:42:07 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11E3A4B99F53 for ; Wed, 12 Aug 2026 11:41:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11E3A4B99F53 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Dt1DJpcC; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=RuCRLsLe; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=tztTAqaz; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Iu8zq9SB Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 69E5A4B9DB70 for ; Wed, 12 Aug 2026 11:41:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69E5A4B9DB70 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 69E5A4B9DB70 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786534892; cv=none; b=XGfrp+9Qt3qTOtFyaG23JI/VaA6cUxqky9kqY2ht5n/GrHreEZEW8n9qJxK8oa161lIvEg1EwteMrR+sNWOdpm/+cDDG3xFVYLpFcVGCSzKnaoBNsl5vD7Pjn1UUnSXr3mW4Uug/u0AfZKrhE+G6tdusWEdW6NeczOk/zq0kkO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786534892; c=relaxed/simple; bh=X2pSX8z9mXnan9w0qxeyJQkRMrhQsNYuN0jTTSeHJI4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=D9eqTC9zMLFSR7z79715zdlWo3roSN832S2It/Z0hw7fnGpzjfUz7rizPzAT8u87C4vOpl5eBKsQ2X3xdRdb0InBbCiqKrb9GSxvRKF91XlEZ9f17xB9wtP9ivfxkK40wAY+nbTCH3+NBgTdw4OWIN5x+WNmlOAgHFpQzulKceE= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Dt1DJpcC; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=RuCRLsLe; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=tztTAqaz; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Iu8zq9SB DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69E5A4B9DB70 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EE0DF82297 for ; Wed, 12 Aug 2026 11:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1786534887; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DTq/TCWG4Ck4xCI5tFeZnMx0BAxUxFFzv9seIafVtOE=; b=Dt1DJpcCmM1Wpz68Nv90BtvYS1rmJeKtC8GWneGSiBYYmy0/dWK04X3JwSQsHVpxPpkIbJ fTyiWQuQq6za/OVqf5vLQ7On7kF7tjffNYv7nEpiRMZ7mMWqdBSa8grJq7+6HTmC+B0QEz D4mQMcipqPf1QlMWwMNfev7VtVl254A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1786534887; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DTq/TCWG4Ck4xCI5tFeZnMx0BAxUxFFzv9seIafVtOE=; b=RuCRLsLeC3/HpLFVELX/x67CldDMLj9gUU5c7KyZ1C43oje1MJuuvbYT0ZCmEVY/42+rKp TSLsjIf+5PxkqnCA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=tztTAqaz; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Iu8zq9SB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1786534882; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DTq/TCWG4Ck4xCI5tFeZnMx0BAxUxFFzv9seIafVtOE=; b=tztTAqazxigVav/kBKwm6Jvp0q6yNnaKiusLGHqDn6yAIkSI+h3lX8LRe02tt5pT2JwPOk avChH72AoOUwGYQgwQEifPqjXaI0YcbEmJdIrsK85+wnkKdGI/pl4LJfigPPpalvde0Czw Yf7ZzelULT8WHTFLEa/LpcztQT3lv10= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1786534882; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DTq/TCWG4Ck4xCI5tFeZnMx0BAxUxFFzv9seIafVtOE=; b=Iu8zq9SBBsgWNPRFwLXrUJUJ4FCsTgSr4oF7FH0IlawS0DXU8fdE7ToYkdPEXnItRXwYaO i3B1ZoeL/lPVgRBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D435A779B1 for ; Wed, 12 Aug 2026 11:41:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IleUMeJbfGolegAAD6G6ig (envelope-from ) for ; Wed, 12 Aug 2026 11:41:22 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/cli] Don't emit emojis in MI Date: Wed, 12 Aug 2026 13:41:22 +0200 Message-ID: <20260812114122.671945-1-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Queue-Id: EE0DF82297 X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[gnu.org:url,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,sourceware.org:url,compart.com:url,suse.de:mid,suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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 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 [1]. 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. 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 --- 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 03a887232c7..cd67a6f382c 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -467,7 +467,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); } @@ -489,7 +489,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 76185bbedf0..62671c2af81 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. */ + virtual 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: 4e8ba93fdb24f9bcf31f706e62e67c57ae91168f -- 2.51.0