[binutils-gdb] Use function style with throw_error

Tom Tromey via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2341567461e68b6b6e6d609eaee80ca15af06695

commit 2341567461e68b6b6e6d609eaee80ca15af06695
Author: Tom Tromey <[email protected]>
Date:   Tue Apr 7 18:22:42 2026 -0600

    Use function style with throw_error
    
    This changes some calls to throw_error to use function_name_style.

Diff:
---
 gdb/infcall.c  |  1 +
 gdb/linespec.c | 12 +++++++-----
 gdb/valarith.c |  7 +++++--
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/gdb/infcall.c b/gdb/infcall.c
index a1328479d0a..8b26f541de6 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -29,6 +29,7 @@
 #include "language.h"
 #include "objfiles.h"
 #include "cli/cli-cmds.h"
+#include "cli/cli-style.h"
 #include "command.h"
 #include "dummy-frame.h"
 #include "ada-lang.h"
diff --git a/gdb/linespec.c b/gdb/linespec.c
index c9c442ad125..5371d8426ae 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1549,12 +1549,13 @@ symbol_not_found_error (const char *symbol, const char *filename)
     {
       if (filename)
 	throw_error (NOT_FOUND_ERROR,
-		     _("Function \"%s\" not defined in \"%ps\"."),
-		     symbol,
+		     _("Function \"%ps\" not defined in \"%ps\"."),
+		     styled_string (function_name_style.style (), symbol),
 		     styled_string (file_name_style.style (), filename));
       else
 	throw_error (NOT_FOUND_ERROR,
-		     _("Function \"%s\" not defined."), symbol);
+		     _("Function \"%ps\" not defined."),
+		     styled_string (function_name_style.style (), symbol));
     }
 }
 
@@ -1593,8 +1594,9 @@ undefined_label_error (const char *function, const char *label)
 {
   if (function != NULL)
     throw_error (NOT_FOUND_ERROR,
-		_("No label \"%s\" defined in function \"%s\"."),
-		label, function);
+		 _("No label \"%s\" defined in function \"%ps\"."),
+		 label,
+		 styled_string (function_name_style.style (), function));
   else
     throw_error (NOT_FOUND_ERROR,
 		_("No label \"%s\" defined in current function."),
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 673bdee2d11..ed5b5d8adf9 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -30,6 +30,7 @@
 #include "gdbarch.h"
 #include "rust-lang.h"
 #include "ada-lang.h"
+#include "cli/cli-style.h"
 
 /* Forward declarations.  */
 static struct value *value_subscripted_rvalue (struct value *array,
@@ -559,7 +560,8 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
 				    argvec.slice (1, 2 - static_memfuncp));
     }
   throw_error (NOT_FOUND_ERROR,
-	       _("member function %s not found"), tstr);
+	       _("member function %ps not found"),
+	       styled_string (function_name_style.style (), tstr));
 }
 
 /* We know that arg1 is a structure, so try to find a unary user
@@ -672,7 +674,8 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
 				    argvec.slice (1, nargs));
     }
   throw_error (NOT_FOUND_ERROR,
-	       _("member function %s not found"), tstr);
+	       _("member function %ps not found"),
+	       styled_string (function_name_style.style (), tstr));
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.