]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add variable styling to error messages
authorTom Tromey <tom@tromey.com>
Wed, 1 Apr 2026 22:17:33 +0000 (16:17 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 9 Apr 2026 01:12:45 +0000 (19:12 -0600)
This changes some error messages in gdb to use variable_name_style.

Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/ada-exp.y
gdb/cli/cli-utils.c
gdb/eval.c
gdb/findvar.c
gdb/valops.c

index 0262ce74c855f77c3c68a52097469dd1ac1d1701..5c5d4675eb6caf8d6264ee5976cdeea66d1aceac 100644 (file)
@@ -1349,7 +1349,9 @@ write_object_renaming (struct parser_state *par_state,
   block_symbol sym_info = ada_lookup_encoded_symbol (name, orig_left_context,
                                                     SEARCH_VFT);
   if (sym_info.symbol == NULL)
-    error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ());
+    error (_("Could not find renamed variable: %ps"),
+          styled_string (variable_name_style.style (),
+                         ada_decode (name).c_str ()));
   else if (sym_info.symbol->loc_class () == LOC_TYPEDEF)
     /* We have a renaming of an old-style renaming symbol.  Don't
        trust the block information.  */
index 18f112c1aadd79321136609f5fcbc9cc738bae83..856768f38f4723d8b82fc43ab1bbfe7b48fc8990 100644 (file)
@@ -52,8 +52,9 @@ get_ulongest (const char **pp, int trailer)
          std::string varname (start, p - start);
          if (!get_internalvar_integer (lookup_internalvar (varname.c_str ()),
                                       &retval))
-           error (_("Convenience variable $%s does not have integer value."),
-                  varname.c_str ());
+           error (_("Convenience variable %p[$%s%p] does not have integer value."),
+                  variable_name_style.style ().ptr (),
+                  varname.c_str (), nullptr);
        }
     }
   else
index 7beff554ed420cab2a2d15ae69827502a39c3328..1ea7b4d17b4dcd45b97bda0e029aa6c63adfe3c7 100644 (file)
@@ -41,6 +41,7 @@
 #include "expop.h"
 #include "c-exp.h"
 #include "inferior.h"
+#include "cli/cli-style.h"
 
 \f
 /* Parse the string EXP as a C expression, evaluate it,
@@ -1119,7 +1120,8 @@ eval_op_func_static_var (struct type *expect_type, struct expression *exp,
   struct block_symbol sym = lookup_symbol (var, blk, SEARCH_VAR_DOMAIN,
                                           nullptr);
   if (sym.symbol == NULL)
-    error (_("No symbol \"%s\" in specified context."), var);
+    error (_("No symbol \"%ps\" in specified context."),
+          styled_string (variable_name_style.style (), var));
   return evaluate_var_value (noside, sym.block, sym.symbol);
 }
 
index 99b0d31d9d41fb8275d831cbd41f44fe1d9623b7..98351143e7979fcf8088f176280f5baa166a2c55 100644 (file)
@@ -32,6 +32,7 @@
 #include "block.h"
 #include "objfiles.h"
 #include "language.h"
+#include "cli/cli-style.h"
 
 /* Basic byte-swapping routines.  All 'extract' functions return a
    host-format integer from a target-format integer at ADDR which is
@@ -299,7 +300,8 @@ language_defn::read_var_value (struct symbol *var,
   if (sym_need == SYMBOL_NEEDS_FRAME)
     gdb_assert (frame != NULL);
   else if (sym_need == SYMBOL_NEEDS_REGISTERS && !target_has_registers ())
-    error (_("Cannot read `%s' without registers"), var->print_name ());
+    error (_("Cannot read `%ps' without registers"),
+          styled_string (variable_name_style.style (), var->print_name ()));
 
   if (frame != NULL)
     frame = get_hosting_frame (var, var_block, frame);
index a5f16dc88f0ab813760a552b3a4e5f79194269ba..207f7d878efe87a8a4788f01cc68774c08d25151 100644 (file)
@@ -40,6 +40,7 @@
 #include "extension.h"
 #include "gdbsupport/byte-vector.h"
 #include "typeprint.h"
+#include "cli/cli-style.h"
 
 /* Local functions.  */
 
@@ -3985,8 +3986,9 @@ value_of_this (const struct language_defn *lang)
 
   sym = lookup_language_this (lang, b);
   if (sym.symbol == NULL)
-    error (_("current stack frame does not contain a variable named `%s'"),
-          lang->name_of_this ());
+    error (_("current stack frame does not contain a variable named `%ps'"),
+          styled_string (variable_name_style.style (),
+                         lang->name_of_this ()));
 
   return read_var_value (sym.symbol, sym.block, frame);
 }