]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use file- and line-styling with throw_error
authorTom Tromey <tom@tromey.com>
Wed, 8 Apr 2026 00:23:57 +0000 (18:23 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 8 May 2026 19:02:32 +0000 (13:02 -0600)
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
gdb/linespec.c

index 13ef2fb03ce1c55bba016ce06b9e3e954d51c43a..e081f0454b3be106fcf136ffaa0823efab1cd072 100644 (file)
@@ -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 ());
     }
 }
index 45e12e0927252ac03015ed93d9d8cdafe228365e..daa6a1abb5c7454883fe4e407aac9462144f899d 100644 (file)
@@ -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"
@@ -1536,7 +1537,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\" "
@@ -1546,8 +1548,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);
@@ -1602,7 +1605,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
@@ -2141,12 +2145,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;