From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id g0GpNYpH0mnfgAgAWB0awg (envelope-from ) for ; Sun, 05 Apr 2026 07:29:14 -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=i4CTKX2W; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BD8201E0BC; Sun, 05 Apr 2026 07:29:14 -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 11A951E04F for ; Sun, 05 Apr 2026 07:29:13 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 5F1874BA2E28 for ; Sun, 5 Apr 2026 11:29:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F1874BA2E28 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=i4CTKX2W Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 516CB4BA2E24 for ; Sun, 5 Apr 2026 11:28:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 516CB4BA2E24 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 516CB4BA2E24 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775388520; cv=none; b=MLPacrjnmK+f+QeeSTOpfHo1aswf4DO1hzaeDTLfOxIspNDy7OP5k883FIgP0A8Vegslk384XwQ14zqmCpjYNmxQJ3B528Z2VFSduyheQCVDVyQFcGycV61sYgRj106wZ9+SFvWQQYGkFmaadx1uyJ0S41BmW5Y1/6avaiuKAmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775388520; c=relaxed/simple; bh=rkWB1VHkDkoKooGGx1MD1U35PuLfU0RQR/7GZSO/Vyk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=KYiNkfKXWvQNXQO+mkim9mNGrQd/+BBRl2AvVU9z2fdusNo43prKrSlvGENLFkbfaqkOR69w41q7siaH3JKcbdzZnAmcyKhyTQr2T2QoSM5wb2tACoB35cPPLlpBn2QpZc48UvuT2XXwzCNs9ItCz78oymbDgfa73QpfYxgFKbo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 516CB4BA2E24 Received: from eig-obgw-5004b.ext.cloudfilter.net ([10.0.29.208]) by cmsmtp with ESMTPS id 9EeZwySAt4Rkp9Leiw1Ih5; Sun, 05 Apr 2026 11:28:40 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 9Legwc68Mraqe9LehwPuEv; Sun, 05 Apr 2026 11:28:39 +0000 X-Authority-Analysis: v=2.4 cv=UNPdHDfy c=1 sm=1 tr=0 ts=69d24767 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=ItBw4LHWJt0A:10 a=6t6z0mQRakQw59w5_ykA:9 a=QEXdDO2ut3YA:10 a=O8hF6Hzn-FEA: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=MPt1+8Dp/JE2jH+pIYuBjf0E0JQNhoHqR4pyUOr6qKo=; b=i4CTKX2WjPalKD6PSw4sjylV6b K2i8ANH20pKBQqnFMReGgfeUgIjZ5LTZgC/Qp0SNM/evOKnBTauOP3B/YtODYUkuxnq3kyKFvyTEY 4so00RWV2Nk4MFrCFQ0Uf12L4; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:42722 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 1w9Leg-00000001QMu-2rDq; Sun, 05 Apr 2026 05:28:38 -0600 From: Tom Tromey Date: Sun, 05 Apr 2026 05:28:41 -0600 Subject: [PATCH 4/4] Add function styling to error messages MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260405-more-error-style-v1-4-6c04da718875@tromey.com> References: <20260405-more-error-style-v1-0-6c04da718875@tromey.com> In-Reply-To: <20260405-more-error-style-v1-0-6c04da718875@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: 1w9Leg-00000001QMu-2rDq 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]:42722 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGCJMYIiYStkz9i1JFdKObCezbvjMe3ELYD0pV5JeHRAhbJpY1bCGdr6mVvPnrH0eiihuOSSCPUjLPfEIRM6l6mRiIEYc+mwBNRMOu2YQrwT6yt8e//h 9c1cmfi/qAwuVTpMYsTNy/I9kw1ekjiFHHZ9RIQRDmj2N7SEO1hX4Muh76EIu9VPaAArT33q1e93Isr48yZGQwC6W1gQCsGT4dY= 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 a number of error messages in gdb to use function_name_style. --- gdb/c-exp.y | 5 ++-- gdb/dwarf2/ada-imported.c | 6 +++-- gdb/eval.c | 5 ++-- gdb/infcall.c | 58 +++++++++++++++++++++++++++-------------------- gdb/rust-lang.c | 6 +++-- gdb/valops.c | 23 +++++++++++-------- 6 files changed, 61 insertions(+), 42 deletions(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index b036e13d188..2829d8bccba 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1079,8 +1079,9 @@ block : block COLONCOLON name nullptr).symbol; if (tem == nullptr) - error (_("No function \"%s\" in specified context."), - copy.c_str ()); + error (_("No function \"%ps\" in specified context."), + styled_string (function_name_style.style (), + copy.c_str ())); $$ = tem->value_block (); } ; diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c index 0511c9a34b7..7cdaffef886 100644 --- a/gdb/dwarf2/ada-imported.c +++ b/gdb/dwarf2/ada-imported.c @@ -21,6 +21,7 @@ #include "value.h" #include "dwarf2/loc.h" #include "objfiles.h" +#include "cli/cli-style.h" /* Helper to get the imported symbol's real name. */ static const char * @@ -107,8 +108,9 @@ ada_alias_get_block_value (const struct symbol *sym) block_symbol real_symbol = lookup_global_symbol (name, nullptr, SEARCH_FUNCTION_DOMAIN); if (real_symbol.symbol == nullptr) - error (_("could not find alias '%s' for function '%s'"), - name, sym->print_name ()); + error (_("could not find alias '%s' for function '%ps'"), + name, + styled_string (function_name_style.style (), sym->print_name ())); if (real_symbol.symbol->loc_class () != LOC_BLOCK) error (_("alias '%s' for function '%s' is not a function"), name, sym->print_name ()); diff --git a/gdb/eval.c b/gdb/eval.c index 1ea7b4d17b4..a00774bda3d 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -784,9 +784,10 @@ scope_operation::evaluate_funcall (struct type *expect_type, if (!static_memfuncp) { /* For the time being, we don't handle this. */ - error (_("Call to overloaded function %s requires " + error (_("Call to overloaded function %ps requires " "`this' pointer"), - function_name); + styled_string (function_name_style.style (), + function_name)); } arg_view = arg_view.slice (1); diff --git a/gdb/infcall.c b/gdb/infcall.c index 941b0a95c5b..9af605d721a 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -43,6 +43,7 @@ #include #include "gdbsupport/scope-exit.h" #include +#include "cli/cli-style.h" /* True if we are debugging inferior calls. */ @@ -1100,9 +1101,11 @@ call_function_by_hand_dummy (struct value *function, CORE_ADDR funaddr = find_function_addr (function, &values_type, &ftype); if (is_nocall_function (ftype)) - error (_("Cannot call the function '%s' which does not follow the " + error (_("Cannot call the function '%ps' which does not follow the " "target calling convention."), - get_function_name (funaddr, name_buf, sizeof (name_buf))); + styled_string (function_name_style.style (), + get_function_name (funaddr, name_buf, + sizeof (name_buf)))); if (values_type == NULL || values_type->is_stub ()) values_type = default_return_type; @@ -1110,9 +1113,9 @@ call_function_by_hand_dummy (struct value *function, { const char *name = get_function_name (funaddr, name_buf, sizeof (name_buf)); - error (_("'%s' has unknown return type; " + error (_("'%ps' has unknown return type; " "cast the call to its declared return type"), - name); + styled_string (function_name_style.style (), name)); } values_type = check_typedef (values_type); @@ -1675,9 +1678,10 @@ call_function_by_hand_dummy (struct value *function, throw_error (e.error, _("%s\n\ An error occurred while in a function called from GDB.\n\ Evaluation of the expression containing the function\n\ -(%s) will be abandoned.\n\ +(%ps) will be abandoned.\n\ When the function is done executing, GDB will silently stop."), - e.what (), name); + e.what (), + styled_string (function_name_style.style (), name)); case RETURN_QUIT: default: throw_exception (std::move (e)); @@ -1703,8 +1707,8 @@ When the function is done executing, GDB will silently stop."), error (_("The program being debugged exited while in a function " "called from GDB.\n" "Evaluation of the expression containing the function\n" - "(%s) will be abandoned."), - name); + "(%ps) will be abandoned."), + styled_string (function_name_style.style (), name)); } if (call_thread_ptid != inferior_ptid) @@ -1724,16 +1728,16 @@ When the function is done executing, GDB will silently stop."), The program received a signal in another thread while\n\ making a function call from GDB.\n\ Evaluation of the expression containing the function\n\ -(%s) will be abandoned.\n\ +(%ps) will be abandoned.\n\ When the function is done executing, GDB will silently stop."), - name); + styled_string (function_name_style.style (), name)); else error (_("\ The program stopped in another thread while making a function call from GDB.\n\ Evaluation of the expression containing the function\n\ -(%s) will be abandoned.\n\ +(%ps) will be abandoned.\n\ When the function is done executing, GDB will silently stop."), - name); + styled_string (function_name_style.style (), name)); } { @@ -1774,10 +1778,11 @@ The program being debugged received signal %s, %s\n\ while in a function called from GDB. GDB has restored the context\n\ to what it was before the call. To change this behavior use\n\ \"set unwind-on-signal off\". Evaluation of the expression containing\n\ -the function (%s) will be abandoned."), +the function (%ps) will be abandoned."), gdb_signal_to_name (stop_signal), gdb_signal_to_string (stop_signal), - name.c_str ()); + styled_string (function_name_style.style (), + name.c_str ())); } else { @@ -1794,9 +1799,10 @@ The program being debugged was signaled while in a function called from GDB.\n\ GDB remains in the frame where the signal was received.\n\ To change this behavior use \"set unwind-on-signal on\".\n\ Evaluation of the expression containing the function\n\ -(%s) will be abandoned.\n\ +(%ps) will be abandoned.\n\ When the function is done executing, GDB will silently stop."), - name.c_str ()); + styled_string (function_name_style.style (), + name.c_str ())); } } @@ -1822,8 +1828,9 @@ The program being debugged timed out while in a function called from GDB.\n\ GDB has restored the context to what it was before the call.\n\ To change this behavior use \"set unwind-on-timeout off\".\n\ Evaluation of the expression containing the function\n\ -(%s) will be abandoned."), - name.c_str ()); +(%ps) will be abandoned."), + styled_string (function_name_style.style (), + name.c_str ())); } else { @@ -1837,9 +1844,10 @@ The program being debugged timed out while in a function called from GDB.\n\ GDB remains in the frame where the timeout occurred.\n\ To change this behavior use \"set unwind-on-timeout on\".\n\ Evaluation of the expression containing the function\n\ -(%s) will be abandoned.\n\ +(%ps) will be abandoned.\n\ When the function is done executing, GDB will silently stop."), - name.c_str ()); + styled_string (function_name_style.style (), + name.c_str ())); } } @@ -1859,9 +1867,10 @@ caused by an unhandled C++ exception. GDB blocked this call in order\n\ to prevent the program from being terminated, and has restored the\n\ context to its original state before the call.\n\ To change this behavior use \"set unwind-on-terminating-exception off\".\n\ -Evaluation of the expression containing the function (%s)\n\ +Evaluation of the expression containing the function (%ps)\n\ will be abandoned."), - name.c_str ()); + styled_string (function_name_style.style (), + name.c_str ())); } else if (stop_stack_dummy == STOP_NONE) { @@ -1883,9 +1892,10 @@ will be abandoned."), error (_("\ The program being debugged stopped while in a function called from GDB.\n\ Evaluation of the expression containing the function\n\ -(%s) will be abandoned.\n\ +(%ps) will be abandoned.\n\ When the function is done executing, GDB will silently stop."), - name.c_str ()); + styled_string (function_name_style.style (), + name.c_str ())); } } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 522b20c97ff..517d6333d12 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1751,11 +1751,13 @@ rust_structop::evaluate_funcall (struct type *expect_type, SEARCH_FUNCTION_DOMAIN, nullptr); if (sym.symbol == NULL) - error (_("Could not find function named '%s'"), name.c_str ()); + error (_("Could not find function named '%ps'"), + styled_string (function_name_style.style (), name.c_str ())); struct type *fn_type = sym.symbol->type (); if (fn_type->num_fields () == 0) - error (_("Function '%s' takes no arguments"), name.c_str ()); + error (_("Function '%ps' takes no arguments"), + styled_string (function_name_style.style (), name.c_str ())); if (fn_type->field (0).type ()->code () == TYPE_CODE_PTR) args[0] = value_addr (args[0]); diff --git a/gdb/valops.c b/gdb/valops.c index 207f7d878ef..515e43ccdfa 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -2963,26 +2963,29 @@ find_overload_match (gdb::array_view args, { std::string hint = incomplete_type_hint (args); if (method == METHOD) - error (_("Cannot resolve method %s%s%s to any overloaded instance%s"), + error (_("Cannot resolve method %p[%s%s%s%p] to any overloaded instance%s"), + function_name_style.style ().ptr (), obj_type_name, (obj_type_name && *obj_type_name) ? "::" : "", - name, hint.c_str ()); + name, nullptr, hint.c_str ()); else - error (_("Cannot resolve function %s to any overloaded instance%s"), - func_name, hint.c_str ()); + error (_("Cannot resolve function %ps to any overloaded instance%s"), + styled_string (function_name_style.style (), func_name), + hint.c_str ()); } else if (match_quality == NON_STANDARD) { if (method == METHOD) warning (_("Using non-standard conversion to match " - "method %s%s%s to supplied arguments"), + "method %p[%s%s%s%p] to supplied arguments"), + function_name_style.style ().ptr (), obj_type_name, (obj_type_name && *obj_type_name) ? "::" : "", - name); + name, nullptr); else warning (_("Using non-standard conversion to match " - "function %s to supplied arguments"), - func_name); + "function %ps to supplied arguments"), + styled_string (function_name_style.style (), func_name)); } if (staticp != NULL) @@ -3726,8 +3729,8 @@ value_struct_elt_for_reference (struct type *domain, int offset, else if (noside == EVAL_AVOID_SIDE_EFFECTS) return value::allocate (TYPE_FN_FIELD_TYPE (f, j)); else - error (_("Cannot reference virtual member function \"%s\""), - name); + error (_("Cannot reference virtual member function \"%ps\""), + styled_string (function_name_style.style (), name)); } else { -- 2.49.0