From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 3/4] Add variable styling to error messages
Date: Sun, 05 Apr 2026 05:28:40 -0600 [thread overview]
Message-ID: <20260405-more-error-style-v1-3-6c04da718875@tromey.com> (raw)
In-Reply-To: <20260405-more-error-style-v1-0-6c04da718875@tromey.com>
This changes some error messages in gdb to use variable_name_style.
---
gdb/ada-exp.y | 4 +++-
gdb/cli/cli-utils.c | 5 +++--
gdb/eval.c | 4 +++-
gdb/findvar.c | 4 +++-
gdb/valops.c | 6 ++++--
5 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 0262ce74c85..5c5d4675eb6 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -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. */
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index 18f112c1aad..856768f38f4 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -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
diff --git a/gdb/eval.c b/gdb/eval.c
index 7beff554ed4..1ea7b4d17b4 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -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);
}
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 99b0d31d9d4..98351143e79 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -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);
diff --git a/gdb/valops.c b/gdb/valops.c
index a5f16dc88f0..207f7d878ef 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -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);
}
--
2.49.0
next prev parent reply other threads:[~2026-04-05 11:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-05 11:28 [PATCH 0/4] Add more styling of " Tom Tromey
2026-04-05 11:28 ` [PATCH 1/4] Add command styling to " Tom Tromey
2026-04-05 11:28 ` [PATCH 2/4] Add filename " Tom Tromey
2026-04-05 11:28 ` Tom Tromey [this message]
2026-04-05 11:28 ` [PATCH 4/4] Add function " Tom Tromey
2026-04-05 12:55 ` [PATCH 0/4] Add more styling of " Andrew Burgess
2026-04-09 1:10 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260405-more-error-style-v1-3-6c04da718875@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox