From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eyLKAAeB2WmaTBEAWB0awg (envelope-from ) for ; Fri, 10 Apr 2026 19:00:23 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=nJIIoA1u; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D19DA1E0BC; Fri, 10 Apr 2026 19:00:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED 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 CFB9F1E0B1 for ; Fri, 10 Apr 2026 19:00:20 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E4EF54BA2E2A for ; Fri, 10 Apr 2026 23:00:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4EF54BA2E2A Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=nJIIoA1u Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 2903F4BA2E27 for ; Fri, 10 Apr 2026 22:59:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2903F4BA2E27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2903F4BA2E27 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775861983; cv=none; b=PVm6BEWoQNETFr1n71GaCd/+H2hytYXYKPfzRJmv3EPoo3LCbePEZHeGgGevdqD3R5k4FTdo1pTJE++HO7iDGi0vr/YeTnp57t2kmaXFsX4g8X+YueBvaBKHreaKHq3vvNrgbo4YBxVOe8FM13uT34Q1qO160N+aO4f2IsR/w8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775861983; c=relaxed/simple; bh=eFi+4pPsaGy6lS42VDMci3ztv6Z9hetPa4eIyyIMs9o=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=FUrNAzQbejT7n7Lu/IV2BcwbV4rZ1fZMeOQsief4QN+p/r5wcnuj5hq2ZiAKoR65zcvRpHFA3uRrNzO3XjNCFPXjY3yuXgNJ+CYwbKZvyUJsyDTebX77pnc0lRR+gTvZzqwJbpcJs1wmgro95uz0zC64lsFQnkykLjMN9THOPJI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2903F4BA2E27 Received: from eig-obgw-6005b.ext.cloudfilter.net ([10.0.30.162]) by cmsmtp with ESMTPS id BIyewjTVznwj2BKpBwwV6X; Fri, 10 Apr 2026 22:59:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id BKpBwz6MlFeDMBKpBw3BeM; Fri, 10 Apr 2026 22:59:41 +0000 X-Authority-Analysis: v=2.4 cv=aq2yCTZV c=1 sm=1 tr=0 ts=69d980dd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=ItBw4LHWJt0A:10 a=APGXlkWM4nUoJUI5c1UA:9 a=QEXdDO2ut3YA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8yPM7Pa8YZA4OA9yQvKw7zsFdQQ+Z0thAURJjEPwMXw=; b=nJIIoA1uhcTuhIozJk80rPSmSc nPJK/ECylLYcPKMb1+N+0LMw7CG2Ynj1GeZSSv8ZdVIXwGExc7ancD9okqXTNKB/CZ6eGu8/Xc9dH Nz5bsxCSInjaOiZ1g63tgvBuv; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:49954 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wBKpA-00000001tnB-2Y5B; Fri, 10 Apr 2026 16:59:41 -0600 From: Tom Tromey Date: Fri, 10 Apr 2026 16:59:42 -0600 Subject: [PATCH 2/5] Use file- and line-styling with throw_error MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260410-unify-exceptions-v1-2-ea64dae971a8@tromey.com> References: <20260410-unify-exceptions-v1-0-ea64dae971a8@tromey.com> In-Reply-To: <20260410-unify-exceptions-v1-0-ea64dae971a8@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.225.82 X-Source-L: No X-Exim-ID: 1wBKpA-00000001tnB-2Y5B X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net ([192.168.122.1]) [75.166.225.82]:49954 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCs7tapzlp/EjlUGmdb/CC9CrR7aIKbheYr/779FCdoeeChNQtia2/eqgr9DtdMBcILYDVFmGLLk09bJcTUHn6Llpgp1IYbexBfL2bUcVCEeBxuyKtYt RTFfdi3Y6YD7psC4xNSLaqPFZKV+6X9pPsQ/AoqOopD8jysyCoz1Ajaz+P8lUf8x0FSOePy9dI3otqgaWtvWQ+3npLV3y8taWww= 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 This changes some throw_error calls to apply file_name_style and line_number_style. This patch does both at the same time because the two styles often appear in the same message. --- gdb/cli/cli-script.c | 7 +++++-- gdb/linespec.c | 24 ++++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 13ef2fb03ce..e081f0454b3 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1718,8 +1718,11 @@ script_from_file (FILE *stream, const char *file) /* Re-throw the error, but with the file name information prepended. */ throw_error (e.error, - _("%s:%d: Error in sourced command file:\n%s"), - source_file_name.c_str (), source_line_number, + _("%ps:%ps: Error in sourced command file:\n%s"), + styled_string (file_name_style.style (), + source_file_name.c_str ()), + styled_string (line_number_style.style (), + plongest (source_line_number)), e.what ()); } } diff --git a/gdb/linespec.c b/gdb/linespec.c index 981bd5faa4f..435b4fbcd2f 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -35,6 +35,7 @@ #include "interps.h" #include "target.h" #include "arch-utils.h" +#include "cli/cli-style.h" #include "cli/cli-utils.h" #include "filenames.h" #include "ada-lang.h" @@ -1540,7 +1541,8 @@ symbol_not_found_error (const char *symbol, const char *filename) if (filename) throw_error (NOT_FOUND_ERROR, _("Undefined convenience variable or function \"%s\" " - "not defined in \"%s\"."), symbol, filename); + "not defined in \"%ps\"."), symbol, + styled_string (file_name_style.style (), filename)); else throw_error (NOT_FOUND_ERROR, _("Undefined convenience variable or function \"%s\" " @@ -1550,8 +1552,9 @@ symbol_not_found_error (const char *symbol, const char *filename) { if (filename) throw_error (NOT_FOUND_ERROR, - _("Function \"%s\" not defined in \"%s\"."), - symbol, filename); + _("Function \"%s\" not defined in \"%ps\"."), + symbol, + styled_string (file_name_style.style (), filename)); else throw_error (NOT_FOUND_ERROR, _("Function \"%s\" not defined."), symbol); @@ -1606,7 +1609,8 @@ undefined_label_error (const char *function, const char *label) [[noreturn]] static void source_file_not_found_error (const char *name) { - throw_error (NOT_FOUND_ERROR, _("No source file named %s."), name); + throw_error (NOT_FOUND_ERROR, _("No source file named %ps."), + styled_string (file_name_style.style (), name)); } /* Unless at EIO, save the current stream position as completion word @@ -2145,12 +2149,16 @@ create_sals_line_offset (struct linespec_state *self, { if (ls->explicit_loc.source_filename) throw_error (NOT_FOUND_ERROR, - _("No compiled code for line %d in file \"%s\"."), - line, ls->explicit_loc.source_filename.get ()); + _("No compiled code for line %ps in file \"%ps\"."), + styled_string (line_number_style.style (), + plongest (line)), + styled_string (file_name_style.style (), + ls->explicit_loc.source_filename.get ())); else throw_error (NOT_FOUND_ERROR, - _("No compiled code for line %d in the current file."), - line); + _("No compiled code for line %ps in the current file."), + styled_string (line_number_style.style (), + plongest (line))); } return values; -- 2.49.0